38 #include "svnversion.h" 52 if (!strcmp(name,
"north"))
54 if (!strcmp(name,
"north_east"))
56 if (!strcmp(name,
"east"))
58 if (!strcmp(name,
"south_east"))
60 if (!strcmp(name,
"south"))
62 if (!strcmp(name,
"south_west"))
64 if (!strcmp(name,
"west"))
66 if (!strcmp(name,
"north_west"))
80 object *op = animation->
victim;
116 object *op = animation->
victim;
153 cf_log(
llevError,
"CFAnim: Error in animation - possible values for 'invisible' are 'yes' and 'no'\n");
169 cf_log(
llevError,
"CFAnim: Error in animation - possible values for 'wizard' are 'yes' and 'no'\n");
186 cf_log(
llevDebug,
"CFAnim: init say: parameters: %s\n", parameters ? parameters :
"null");
195 cf_log(
llevError,
"CFAnim: Error in animation: nothing to say with say function\n");
204 object *current_container;
228 if (current->
name == parameters)
283 if (current->name == parameters) {
297 cf_log(
llevError,
"CFAnim: Error in animation: possible values for 'ghosted' are 'yes' and 'no'\n");
305 || (!
id && !animation->
ghosted))
313 corpse->
contr = NULL;
317 animation->
corpse = corpse;
349 mapname = strstr(parameters,
" ");
354 mapx = atoi(parameters);
356 parameters = mapname;
357 assert(parameters != NULL);
359 mapname = strstr(parameters,
" ");
364 mapy = atoi(parameters);
366 if (mapname[0] ==
'\0')
370 teleport->
mapx = mapx;
371 teleport->
mapy = mapy;
419 if (sscanf(parameters,
"%d %d", &x, &y) != 2)
459 if (parameters && animation->
victim->
map) {
471 if (sscanf(parameters,
"%ld", &connection) != 1 || connection <= 0) {
496 if (olp->
value ==
id) {
522 {
"fire_north_east",
initfire, runfire },
524 {
"fire_south_east",
initfire, runfire },
525 {
"fire_south",
initfire, runfire },
526 {
"fire_south_west",
initfire, runfire },
528 {
"fire_north_west",
initfire, runfire },
530 {
"turn_north_east",
initturn, runturn },
532 {
"turn_south_east",
initturn, runturn },
533 {
"turn_south",
initturn, runturn },
534 {
"turn_south_west",
initturn, runturn },
536 {
"turn_north_west",
initturn, runturn },
538 {
"camera_north_east",
initcamera, runcamera },
540 {
"camera_south_east",
initcamera, runcamera },
542 {
"camera_south_west",
initcamera, runcamera },
544 {
"camera_north_west",
initcamera, runcamera },
572 ordered_commands = 1;
578 dummy.
name = command;
579 if (!ordered_commands)
604 while (fgets(buffer, buffer_size, fichier)) {
605 if (buffer[0] ==
'[')
607 if (buffer[0] ==
'#')
609 buffer[strlen(buffer)-strlen(
"\n")] =
'\0';
610 while (buffer[strlen(buffer)-1] ==
' ')
611 buffer[strlen(buffer)-1] =
'\0';
612 if (strlen(buffer) <= 0)
616 name = strstr(buffer,
" ");
628 parameters = strstr(name,
" ");
632 while (*parameters ==
' ')
634 if (*parameters ==
'\0')
643 if (!animationhook) {
656 next->
id = animationhook->
funcinit(name, parameters, next);
659 current->
next = next;
678 if (!strcmp(&buffer[strlen(buffer)-strlen(
"\n")],
"\n"))
679 buffer[strlen(buffer)-strlen(
"\n")] =
'\0';
680 *value = strstr(buffer,
"=");
686 while ((strlen(*variable) > 0) && ((*variable)[strlen(*variable)-1] ==
' '))
687 (*variable)[strlen(*variable)-1] =
'\0';
688 while ((strlen(*value) > 0) && ((*value)[strlen(*value)-1] ==
' '))
689 (*value)[strlen(*value)-1] =
'\0';
690 while (**value ==
' ')
692 if ((**variable ==
'\0') || (**value ==
'\0'))
719 else if (*strg ==
'n')
721 else if (*strg ==
'Y')
723 else if (*strg ==
'N')
725 else if (*strg ==
'1')
727 else if (*strg ==
'0')
742 for (current = first_animation; current; current = current->
nextanimation)
743 if (current->
victim == ob) {
763 new->nextmovement = NULL;
764 new->nextanimation = NULL;
769 first_animation =
new;
784 while (origin && !origin->
map)
785 origin = origin->
env;
787 if (!origin || !origin->
map)
795 for (x = 0; x < w; x++) {
796 for (y = 0; y < h; y++) {
798 if (ob->name == sname)
818 static int start_animation(
object *who,
object *activator,
object *event,
const char *file,
const char *message) {
822 object *victim = NULL;
824 int always_delete = 0;
831 int errors_allowed = 0;
833 const char *animationitem = NULL;
837 int errors_found = 0;
840 fichier = fopen(file,
"r");
841 if (fichier == NULL) {
845 while (fgets(buffer,
HUGE_BUF, fichier)) {
846 if (buffer[0] ==
'[')
848 if (buffer[0] ==
'#')
850 if (!strcmp(buffer,
"\n"))
859 if (strncmp(buffer,
"[Config]", 8)) {
860 cf_log(
llevError,
"CFAnim: Fatal error in %s: [Config] must be the first group defined.\n", file);
864 while (fgets(buffer,
HUGE_BUF, fichier)) {
865 if (buffer[0] ==
'[')
867 if (buffer[0] ==
'#')
869 if (!strcmp(buffer,
"\n"))
874 if (!strcmp(variable,
"name")) {
877 if (value[strlen(value)-1] ==
'"')
878 value[strlen(value)-1] =
'\0';
880 }
else if (!strcmp(variable,
"victimtype")) {
881 if (!strcmp(value,
"player"))
883 else if (!strcmp(value,
"object"))
885 else if (!strcmp(value,
"any"))
887 else if (!strcmp(value,
"byname"))
891 }
else if (!strcmp(variable,
"victim")) {
893 if (!strcmp(value,
"who"))
895 else if (!strcmp(value,
"activator"))
897 else if (!strcmp(value,
"who_owner"))
900 cf_log(
llevError,
"CFAnim: Warning: object \"who\" doesn't exist and you're victimized it's owner\n");
903 else if (!strcmp(value,
"activator_owner"))
906 cf_log(
llevError,
"CFAnim: Warning: object \"activator\" doesn't exist and you're victimized it's owner\n");
908 victim = activator->
env;
909 else if (victimtype == 3) {
913 }
else if (!strcmp(variable,
"unique")) {
916 }
else if (!strcmp(variable,
"always_delete")) {
919 }
else if (!strcmp(variable,
"delete_event_end")) {
922 }
else if (!strcmp(variable,
"parallel")) {
925 }
else if (!strcmp(variable,
"paralyzed")) {
928 }
else if (!strcmp(variable,
"invisible")) {
931 }
else if (!strcmp(variable,
"wizard")) {
934 }
else if (!strcmp(variable,
"errors_allowed")) {
937 }
else if (!strcmp(variable,
"verbose")) {
940 }
else if (!strcmp(variable,
"time_representation")) {
941 if (!strcmp(value,
"second"))
943 else if (!strcmp(value,
"tick"))
947 }
else if (!strcmp(variable,
"animation")) {
954 if (message && message[0] !=
'\0') {
959 if (buffer[0] ==
'\0') {
962 cf_log(
llevError,
"CFAnim: Errors occurred during the parsing of %s\n", file);
966 if (!animationitem) {
967 cf_log(
llevError,
"CFAnim: no animation specified when using %s\n", file);
990 if (((victim->
type ==
PLAYER) && (victimtype == 1))
991 || ((victim->
type !=
PLAYER) && (victimtype == 0))
992 || (errors_found && !errors_allowed)) {
994 cf_log(
llevError,
"CFAnim: No correct victim found or errors found, aborting.\n");
1001 if (unique && !always_delete) {
1006 current_anim->
name = name;
1007 current_anim->
victim = victim;
1008 current_anim->
event = event;
1009 current_anim->
paralyze = paralyzed;
1011 current_anim->
wizard = wizard;
1012 current_anim->
unique = unique;
1015 current_anim->
corpse = NULL;
1017 current_anim->
verbose = verbose;
1021 while (buffer[0] ==
'[') {
1022 while (strncmp(&buffer[1], animationitem, strlen(animationitem))) {
1023 while ((value = fgets(buffer,
HUGE_BUF, fichier)) != NULL)
1024 if (buffer[0] ==
'[')
1026 if (value == NULL) {
1027 cf_log(
llevError,
"CFAnim: no matching animation %s in file.\n", animationitem);
1100 time_t sec_elapsed = second.tv_sec - first.tv_sec;
1101 long nsec_elapsed = second.tv_nsec - first.tv_nsec;
1102 return (sec_elapsed * 1e6) + (nsec_elapsed / 1e3);
1112 struct timespec now;
1113 static struct timespec yesterday;
1114 static int already_passed = 0;
1115 long int delta_milli;
1117 clock_gettime(CLOCK_MONOTONIC, &now);
1118 if (!already_passed) {
1126 for (current = first_animation; current; current = current->
nextanimation)
1134 if (first_animation == current)
1135 first_animation = next;
1141 free(current->
name);
1145 previous_anim = current;
1167 const char *propname;
1171 va_start(args, type);
1172 propname = va_arg(args,
const char *);
1174 if (!strcmp(propname,
"Identification")) {
1175 buf = va_arg(args,
char *);
1176 size = va_arg(args,
int);
1180 }
else if (!strcmp(propname,
"FullName")) {
1181 buf = va_arg(args,
char *);
1182 size = va_arg(args,
int);
1207 va_start(args, type);
1208 event_code = va_arg(args,
int);
1222 object *who, *activator, *event;
1225 va_start(args, type);
1227 who = va_arg(args,
object *);
1228 activator = va_arg(args,
object *);
1229 va_arg(args,
object *);
1230 buf = va_arg(args,
char *);
1233 snprintf(message,
sizeof(message),
"%s", buf);
1238 query = va_arg(args,
int);
1239 event = va_arg(args,
object *);
1241 if (query == 1 && strcmp(message,
"query_object_is_animated") == 0) {
1252 if (activator != NULL) {
1254 }
else if (who != NULL) {
static long int initteleport(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static int get_dir_from_name(const char *name)
void cf_object_free_drop_inventory(object *ob)
CF_PLUGIN int initPlugin(const char *iversion, f_plug_api gethooksptr)
void cf_map_message(mapstruct *m, const char *msg, int color)
static CFmovement * parse_animation_block(char *buffer, size_t buffer_size, FILE *fichier, CFanimation *parent)
static long int initnotice(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static long int initmovement(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void cf_free_string(sstring str)
static int start_animation(object *who, object *activator, object *event, const char *file, const char *message)
CF_PLUGIN anim_move_result cfanim_runPluginCommand(object *op, char *params)
static int get_boolean(const char *strg, int *bl)
static object * find_by_name(object *origin, const char *name)
CF_PLUGIN int postInitPlugin(void)
void cf_object_set_flag(object *ob, int flag, int value)
static long int initapply(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static long int initfire(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static anim_move_result runtrigger(struct CFanimation_struct *animation, long int id, void *parameters)
static void animate(void)
static long int initmoveto(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static void animate_one(CFanimation *animation, long int milliseconds)
static long int initturn(const char *name, char *parameters, struct CFmovement_struct *move_entity)
int cf_map_get_height(mapstruct *map)
static anim_move_result runturn(struct CFanimation_struct *animation, long int id, void *parameters)
void cf_object_apply_below(object *pl)
void cf_object_update(object *op, int flags)
int cf_player_move(player *pl, int dir)
static int ordered_commands
static anim_move_result runghosted(struct CFanimation_struct *animation, long int id, void *parameters)
static anim_move_result runstop(struct CFanimation_struct *animation, long int id, void *parameters)
sstring cf_add_string(const char *str)
enum time_enum time_representation
static anim_move_result runmessage(struct CFanimation_struct *animation, long int id, void *parameters)
CF_PLUGIN int eventListener(int *type,...)
static CFanimationHook * get_command(char *command)
#define FOR_OB_AND_BELOW_FINISH()
void cf_log(LogLevel logLevel, const char *format,...)
static long int initcamera(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static anim_move_result runvisible(struct CFanimation_struct *animation, long int id, void *parameters)
char * cf_strdup_local(const char *str)
int cf_init_plugin(f_plug_api getHooks)
object * cf_object_find_by_name(const object *who, const char *name)
struct CFanimation_struct * parent
object * cf_object_clone(object *op, int clonetype)
static long int initghosted(const char *name, char *parameters, struct CFmovement_struct *move_entity)
CF_PLUGIN void * getPluginProperty(int *type,...)
static anim_move_result runmovement(struct CFanimation_struct *animation, long int id, void *parameters)
mapstruct * cf_map_get_map(const char *name, int flags)
static int is_animated_object(const object *ob)
sstring cf_find_string(const char *str)
static long int initpickup(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void cf_system_register_global_event(int event, const char *name, f_plug_event hook)
int teleport(object *teleporter, uint8_t tele_type, object *user)
void cf_object_say(object *op, char *msg)
static int equality_split(char *buffer, char **variable, char **value)
static anim_move_result runnotice(struct CFanimation_struct *animation, long int id, void *parameters)
static anim_move_result runteleport(struct CFanimation_struct *animation, long int id, void *parameters)
struct CFanimation_struct * nextanimation
static anim_move_result runwizard(struct CFanimation_struct *animation, long int id, void *parameters)
static anim_move_result runsay(struct CFanimation_struct *animation, long int id, void *parameters)
char * cf_get_maps_directory(const char *name, char *buf, int size)
static CFanimation * create_animation(void)
#define CLEAR_FLAG(xyz, p)
CF_PLUGIN int cfanim_globalEventListener(int *type,...)
static anim_move_result runfire(struct CFanimation_struct *animation, long int id, void *parameters)
long usec_elapsed(struct timespec first, struct timespec second)
CF_PLUGIN char SvnRevPlugin[]
static anim_move_result rundropobject(struct CFanimation_struct *animation, long int id, void *parameters)
void cf_object_remove(object *op)
static long int initvisible(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static long int initmessage(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void cf_map_trigger_connected(objectlink *ol, object *cause, int state)
int cf_object_apply(object *op, object *author, int flags)
struct CFmovement_struct * nextmovement
void cf_player_message(object *op, char *txt, int flags)
static int compareAnims(const void *a, const void *b)
int cf_object_move(object *op, int dir, object *originator)
#define CFAPI_MAP_PROP_PATH
static long int initpickupobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void cf_object_pickup(object *op, object *what)
void cf_object_drop(object *op, object *author)
static CFanimation * first_animation
CF_PLUGIN int closePlugin(void)
static anim_move_result runapplyobject(struct CFanimation_struct *animation, long int id, void *parameters)
sstring cf_map_get_sstring_property(mapstruct *map, int propcode)
static long int initwizard(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static long int initapplyobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)
#define FOR_OB_AND_BELOW_PREPARE(op_)
CFanimationHook animationbox[]
static anim_move_result runapply(struct CFanimation_struct *animation, long int id, void *parameters)
char * strdup(const char *str)
static anim_move_result runpickup(struct CFanimation_struct *animation, long int id, void *parameters)
int cf_object_teleport(object *ob, mapstruct *map, int x, int y)
static long int inittrigger(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static void prepare_commands(void)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
static anim_move_result runcamera(struct CFanimation_struct *animation, long int id, void *parameters)
struct CFmovement_struct * next
static long int initsay(const char *name, char *parameters, struct CFmovement_struct *move_entity)
#define FOR_BELOW_PREPARE(op_, it_)
static anim_move_result runmoveto(struct CFanimation_struct *animation, long int id, void *parameters)
static long int initstop(const char *name, char *parameters, struct CFmovement_struct *move_entity)
object * cf_map_insert_object_there(object *op, mapstruct *m, object *originator, int flag)
int cf_map_get_width(mapstruct *map)
int cf_object_move_to(object *op, int x, int y)
#define FOR_BELOW_FINISH()
void(* f_plug_api)(int *type,...)
static anim_move_result runpickupobject(struct CFanimation_struct *animation, long int id, void *parameters)
static long int initdropobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)