Crossfire Server, Trunk  R20513
cfanim.c
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* Crossfire Animator v2.0a */
3 /* Contacts: yann.chachkoff@myrealbox.com, tchize@myrealbox.com */
4 /*****************************************************************************/
5 /* That code is placed under the GNU General Public Licence (GPL) */
6 /* */
7 /* (C) 2001 David Delbecq for the original code version. */
8 /*****************************************************************************/
9 /* CrossFire, A Multiplayer game for X-windows */
10 /* */
11 /* Copyright (C) 2000 Mark Wedel */
12 /* Copyright (C) 1992 Frank Tore Johansen */
13 /* */
14 /* This program is free software; you can redistribute it and/or modify */
15 /* it under the terms of the GNU General Public License as published by */
16 /* the Free Software Foundation; either version 2 of the License, or */
17 /* (at your option) any later version. */
18 /* */
19 /* This program is distributed in the hope that it will be useful, */
20 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
21 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
22 /* GNU General Public License for more details. */
23 /* */
24 /* You should have received a copy of the GNU General Public License */
25 /* along with this program; if not, write to the Free Software */
26 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
27 /* */
28 /*****************************************************************************/
29 
30 /* First let's include the header file needed */
31 
32 #include <assert.h>
33 #include <stdarg.h>
34 #include <stdlib.h>
35 #include <string.h>
36 
37 #include "cfanim.h"
38 #include "svnversion.h"
39 
40 CF_PLUGIN char SvnRevPlugin[] = SVN_REV;
41 
42 static CFanimation *first_animation = NULL;
44 static int get_boolean(const char *strg, int *bl);
45 
51 static int get_dir_from_name(const char *name) {
52  if (!strcmp(name, "north"))
53  return 1;
54  if (!strcmp(name, "north_east"))
55  return 2;
56  if (!strcmp(name, "east"))
57  return 3;
58  if (!strcmp(name, "south_east"))
59  return 4;
60  if (!strcmp(name, "south"))
61  return 5;
62  if (!strcmp(name, "south_west"))
63  return 6;
64  if (!strcmp(name, "west"))
65  return 7;
66  if (!strcmp(name, "north_west"))
67  return 8;
68  return -1;
69 }
70 
71 static long int initmovement(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
72  int dir;
73 
74  dir = get_dir_from_name(name);
75  move_entity->parameters = NULL;
76  return dir;
77 }
78 
79 static anim_move_result runmovement(struct CFanimation_struct *animation, long int id, void *parameters) {
80  object *op = animation->victim;
81  int dir = id;
82 
83  if (animation->verbose)
84  cf_log(llevDebug, "CFAnim: Moving in direction %ld\n", id);
85  if (op->type == PLAYER)
86  cf_player_move(op->contr, dir);
87  else
88  cf_object_move(op, dir, op);
89  return mr_finished;
90 }
91 
92 static long int initfire(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
93  int dir;
94 
95  dir = get_dir_from_name(&(name[5]));
96  move_entity->parameters = NULL;
97  return dir;
98 }
99 
101 static anim_move_result runfire(struct CFanimation_struct *animation, long int id, void *parameters) {
102  if (animation->verbose)
103  cf_log(llevDebug, "CFAnim: Firing in direction %ld\n", id);
104  return mr_finished;
105 }
106 
107 static long int initturn(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
108  int dir;
109 
110  dir = get_dir_from_name(&(name[5]));
111  move_entity->parameters = NULL;
112  return dir;
113 }
114 
115 static anim_move_result runturn(struct CFanimation_struct *animation, long int id, void *parameters) {
116  object *op = animation->victim;
117  int dir = id;
118  /*int face;*/
119 
120  if (animation->verbose)
121  cf_log(llevDebug, "CFAnim: Turning in direction %ld\n", id);
122  op->facing = dir;
124 /* cf_object_set_int_property(op, CFAPI_OBJECT_PROP_ANIMATION, face);*/
125  return mr_finished;
126 }
127 
128 static long int initcamera(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
129  int dir;
130 
131  dir = get_dir_from_name(&(name[7]));
132  move_entity->parameters = NULL;
133  return dir;
134 }
135 
137 static anim_move_result runcamera(struct CFanimation_struct *animation, long int id, void *parameters) {
138  if (animation->verbose)
139  cf_log(llevDebug, "CFAnim: Moving the camera in direction %ld\n", id);
140  return mr_finished;
141  /*if (animation->victim->type == PLAYER)
142  hook_scroll_map(animation->victim, id);
143  else
144  printf("CFAnim: Not a player\n");
145  return 1;*/
146 }
147 
148 static long int initvisible(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
149  int result;
150 
151  if (get_boolean(parameters, &result))
152  return result;
153  cf_log(llevError, "CFAnim: Error in animation - possible values for 'invisible' are 'yes' and 'no'\n");
154  return -1;
155 }
156 
157 static anim_move_result runvisible(struct CFanimation_struct *animation, long int id, void *parameters) {
158  if (id == -1)
159  return mr_finished;
160  animation->invisible = id;
161  return mr_finished;
162 }
163 
164 static long int initwizard(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
165  int result;
166 
167  if (get_boolean(parameters, &result))
168  return result;
169  cf_log(llevError, "CFAnim: Error in animation - possible values for 'wizard' are 'yes' and 'no'\n");
170  return -1;
171 }
172 
173 static anim_move_result runwizard(struct CFanimation_struct *animation, long int id, void *parameters) {
174  if (id == -1)
175  return 1;
176  animation->wizard = id;
177  return mr_finished;
178 }
179 
180 static long int initsay(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
181  if (parameters)
182  move_entity->parameters = cf_strdup_local(parameters);
183  else
184  move_entity->parameters = NULL;
185  if (move_entity->parent->verbose)
186  cf_log(llevDebug, "CFAnim: init say: parameters: %s\n", parameters ? parameters : "null");
187  return 1;
188 }
189 
190 static anim_move_result runsay(struct CFanimation_struct *animation, long int id, void *parameters) {
191  if (parameters) {
192  cf_object_say(animation->victim, parameters);
193  free(parameters);
194  } else
195  cf_log(llevError, "CFAnim: Error in animation: nothing to say with say function\n");
196  return mr_finished;
197 }
198 
199 static long int initapply(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
200  return 1;
201 }
202 
203 static anim_move_result runapply(struct CFanimation_struct *animation, long int id, void *parameters) {
204  object *current_container;
205 
206  if (animation->victim->type != PLAYER)
207  return mr_finished;
208  current_container = animation->victim->container;
209  animation->victim->container = NULL;
210  cf_object_apply_below(animation->victim);
211  animation->victim->container = current_container;
212  return mr_finished;
213 }
214 
215 static long int initapplyobject(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
216  move_entity->parameters = parameters ? (void*)cf_add_string(parameters) : NULL;
217  return 1;
218 }
219 
220 static anim_move_result runapplyobject(struct CFanimation_struct *animation, long int id, void *parameters) {
221  object *current;
222  int aflag;
223 
224  if (!parameters)
225  return mr_finished;
226  current = animation->victim->below;
227  FOR_OB_AND_BELOW_PREPARE(current)
228  if (current->name == parameters)
229  break;
231  if (!current)
232  current = cf_object_find_by_name(animation->victim, parameters);
233  if (!current) {
234  cf_free_string(parameters);
235  return mr_finished;
236  }
237  aflag = AP_APPLY;
238  cf_object_apply(animation->victim, current, aflag);
239  cf_free_string(parameters);
240  return mr_finished;
241 }
242 
243 static long int initdropobject(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
244  move_entity->parameters = parameters ?
245  (void *)cf_add_string(parameters) : NULL;
246  return 1;
247 }
248 
249 static anim_move_result rundropobject(struct CFanimation_struct *animation, long int id, void *parameters) {
250  object *what;
251  if (!parameters)
252  return mr_finished;
253  what = cf_object_find_by_name(animation->victim, parameters);
254  if (what != NULL)
255  cf_object_drop(what, animation->victim);
256  cf_free_string(parameters);
257  return mr_finished;
258 }
259 
260 static long int initpickup(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
261  return 1;
262 }
263 
264 static anim_move_result runpickup(struct CFanimation_struct *animation, long int id, void *parameters) {
265  object *current;
266 
267  current = animation->victim->below;
268  if (!current)
269  return mr_finished;
270  cf_object_pickup(animation->victim, current);
271  return mr_finished;
272 }
273 
274 static long int initpickupobject(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
275  move_entity->parameters = parameters ? (void*)cf_add_string(parameters) : NULL;
276  return 1;
277 }
278 
279 static anim_move_result runpickupobject(struct CFanimation_struct *animation, long int id, void *parameters) {
280  if (!parameters)
281  return mr_finished;
282  FOR_BELOW_PREPARE(animation->victim, current)
283  if (current->name == parameters) {
284  cf_object_pickup(animation->victim, current);
285  break;
286  }
288  cf_free_string(parameters);
289  return mr_finished;
290 }
291 
292 static long int initghosted(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
293  int result;
294 
295  if (get_boolean(parameters, &result))
296  return result;
297  cf_log(llevError, "CFAnim: Error in animation: possible values for 'ghosted' are 'yes' and 'no'\n");
298  return -1;
299 }
300 
301 static anim_move_result runghosted(struct CFanimation_struct *animation, long int id, void *parameters) {
302  object *corpse;
303 
304  if ((id && animation->ghosted)
305  || (!id && !animation->ghosted))
306  runghosted(animation, !id, parameters);
307  if (id) { /*Create a ghost/corpse pair*/
308  corpse = cf_object_clone(animation->victim, 1);
309  corpse->x = animation->victim->x;
310  corpse->y = animation->victim->y;
311  corpse->type = 0;
312  CLEAR_FLAG(corpse, FLAG_WIZ);
313  corpse->contr = NULL;
314  cf_map_insert_object_there(corpse, animation->victim->map, NULL, 0);
315  animation->wizard = 1;
316  animation->invisible = 1;
317  animation->corpse = corpse;
318  } else { /*Remove a corpse, make current player visible*/
319  animation->wizard = 0;
320  animation->invisible = 0;
321  cf_object_remove(animation->corpse);
323  animation->corpse = NULL;
324  animation->victim->invisible = 0;
325  cf_player_move(animation->victim->contr, 0);
326  }
327  animation->ghosted = id;
328  return mr_finished;
329 }
330 
331 typedef struct {
332  char *mapname;
333  int mapx;
334  int mapy;
336 
337 static long int initteleport(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
338  char *mapname;
339  int mapx;
340  int mapy;
342 
343  move_entity->parameters = NULL;
344  cf_log(llevDebug, ".(%s)\n", parameters);
345  if (!parameters) {
346  cf_log(llevError, "CFAnim: Error - no parameters for teleport\n");
347  return 0;
348  }
349  mapname = strstr(parameters, " ");
350  cf_log(llevDebug, ".(%s)\n", parameters);
351  if (!mapname)
352  return 0;
353  *mapname = '\0';
354  mapx = atoi(parameters);
355  mapname++;
356  parameters = mapname;
357  assert(parameters != NULL);
358  cf_log(llevDebug, ".(%s)\n", parameters);
359  mapname = strstr(parameters, " ");
360  cf_log(llevDebug, ".\n");
361  if (!mapname)
362  return 0;
363  *mapname = '\0';
364  mapy = atoi(parameters);
365  mapname++;
366  if (mapname[0] == '\0')
367  return 0;
368  teleport = (teleport_params *)malloc(sizeof(teleport_params));
369  teleport->mapname = cf_strdup_local(mapname);
370  teleport->mapx = mapx;
371  teleport->mapy = mapy;
372  move_entity->parameters = teleport;
373  return 1;
374 }
375 
376 static anim_move_result runteleport(struct CFanimation_struct *animation, long int id, void *parameters) {
377  teleport_params *teleport = (teleport_params *)parameters;
378 
379  if (!parameters)
380  return mr_finished;
381  cf_object_teleport(animation->victim, cf_map_get_map(teleport->mapname, 0), teleport->mapx, teleport->mapy);
382  free(parameters);
383  return mr_finished;
384 }
385 
386 static long int initnotice(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
387  move_entity->parameters = parameters ? cf_strdup_local(parameters) : NULL;
388  return 1;
389 }
390 static anim_move_result runnotice(struct CFanimation_struct *animation, long int id, void *parameters) {
391  int val;
392 
393  val = NDI_NAVY|NDI_UNIQUE;
394 
395  cf_player_message(animation->victim, parameters, val);
396  return mr_finished;
397 }
398 
399 static long int initstop(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
400  return 1;
401 }
402 
404 static anim_move_result runstop(struct CFanimation_struct *animation, long int id, void *parameters) {
405  if (animation->verbose)
406  cf_log(llevDebug, "CFAnim: stop encountered\n");
407  return mr_finished;
408 }
409 
411 typedef struct {
412  int x, y;
413 } param_moveto;
414 
415 static long int initmoveto(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
416  param_moveto *moveto;
417  int x, y;
418 
419  if (sscanf(parameters, "%d %d", &x, &y) != 2)
420  return 0;
421 
422  moveto = (param_moveto *)calloc(1, sizeof(param_moveto));
423  moveto->x = x;
424  moveto->y = y;
425  move_entity->parameters = moveto;
426 
427  return 1;
428 }
429 
430 static anim_move_result runmoveto(struct CFanimation_struct *animation, long int id, void *parameters) {
431  int move;
432  param_moveto *dest = (param_moveto *)parameters;
433 
434  if (!dest)
435  return mr_finished;
436 
437  move = cf_object_move_to(animation->victim, dest->x, dest->y);
438 
439  if (animation->victim->x == dest->x && animation->victim->y == dest->y) {
440  free(parameters);
441  return mr_finished;
442  }
443 
444  if (move == 1)
445  return mr_again;
446 
447  return mr_finished;
448 }
449 
450 static long int initmessage(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
451  if (parameters)
452  move_entity->parameters = strdup(parameters);
453  else
454  move_entity->parameters = NULL;
455  return 1;
456 }
457 
458 static anim_move_result runmessage(struct CFanimation_struct *animation, long int id, void *parameters) {
459  if (parameters && animation->victim->map) {
460  cf_map_message(animation->victim->map, (const char *)parameters, NDI_UNIQUE|NDI_GREEN);
461  free(parameters);
462  }
463 
464  return mr_finished;
465 }
466 
467 static long int inittrigger(const char *name, char *parameters, struct CFmovement_struct *move_entity) {
468  long int connection;
469 
470  move_entity->parameters = NULL;
471  if (sscanf(parameters, "%ld", &connection) != 1 || connection <= 0) {
472  cf_log(llevError, "CFAnim: invalid connection %s\n", parameters);
473  return 0;
474  }
475  return connection;
476 }
477 
478 static anim_move_result runtrigger(struct CFanimation_struct *animation, long int id, void *parameters) {
479  oblinkpt *olp;
480  mapstruct *map;
481  objectlink *ol = NULL;
482 
483  if (animation->victim == NULL || animation->victim->map == NULL) {
484  cf_log(llevError, "CFAnim: trigger for victim not on map or NULL.\n");
485  return mr_finished;
486  }
487 
488  map = animation->victim->map;
489 
490  /* locate objectlink for this connected value */
491  if (!map->buttons) {
492  cf_log(llevError, "Map %s called for trigger on connected %d but there ain't any button list for that map!\n", cf_map_get_sstring_property(map, CFAPI_MAP_PROP_PATH), id);
493  return mr_finished;
494  }
495  for (olp = map->buttons; olp; olp = olp->next) {
496  if (olp->value == id) {
497  ol = olp->link;
498  break;
499  }
500  }
501  if (ol == NULL) {
502  cf_log(llevError, "Map %s called for trigger on connected %d but there ain't any button list for that map!\n", cf_map_get_sstring_property(map, CFAPI_MAP_PROP_PATH), id);
503  return mr_finished;
504  }
505  /* run the object link */
506  cf_map_trigger_connected(ol, NULL, 1);
507 
508  return mr_finished;
509 }
510 
513  { "north", initmovement, runmovement },
514  { "north_east", initmovement, runmovement },
515  { "east", initmovement, runmovement },
516  { "south_east", initmovement, runmovement },
517  { "south", initmovement, runmovement },
518  { "south_west", initmovement, runmovement },
519  { "west", initmovement, runmovement },
520  { "north_west", initmovement, runmovement },
521  { "fire_north", initfire, runfire },
522  { "fire_north_east", initfire, runfire },
523  { "fire_east", initfire, runfire },
524  { "fire_south_east", initfire, runfire },
525  { "fire_south", initfire, runfire },
526  { "fire_south_west", initfire, runfire },
527  { "fire_west", initfire, runfire },
528  { "fire_north_west", initfire, runfire },
529  { "turn_north", initturn, runturn },
530  { "turn_north_east", initturn, runturn },
531  { "turn_east", initturn, runturn },
532  { "turn_south_east", initturn, runturn },
533  { "turn_south", initturn, runturn },
534  { "turn_south_west", initturn, runturn },
535  { "turn_west", initturn, runturn },
536  { "turn_north_west", initturn, runturn },
537  { "camera_north", initcamera, runcamera },
538  { "camera_north_east", initcamera, runcamera },
539  { "camera_east", initcamera, runcamera },
540  { "camera_south_east", initcamera, runcamera },
541  { "camera_south", initcamera, runcamera },
542  { "camera_south_west", initcamera, runcamera },
543  { "camera_west", initcamera, runcamera },
544  { "camera_north_west", initcamera, runcamera },
545  { "invisible", initvisible, runvisible },
546  { "wizard", initwizard, runwizard },
547  { "say", initsay, runsay },
548  { "apply", initapply, runapply },
549  { "apply_object", initapplyobject, runapplyobject },
550  { "drop_object", initdropobject, rundropobject },
551  { "pickup", initpickup, runpickup },
552  { "pickup_object", initpickupobject, runpickupobject },
553  { "ghosted", initghosted, runghosted },
554  { "teleport", initteleport, runteleport },
555  { "notice", initnotice, runnotice },
556  { "stop", initstop, runstop },
557  { "moveto", initmoveto, runmoveto },
558  { "message", initmessage, runmessage },
559  { "trigger", inittrigger, runtrigger }
560 };
561 
563 
564 static int ordered_commands = 0;
565 
566 static int compareAnims(const void *a, const void *b) {
567  return strcmp(((const CFanimationHook *)a)->name, ((const CFanimationHook *)b)->name);
568 }
569 
570 static void prepare_commands(void) {
571  qsort(animationbox, animationcount, sizeof(CFanimationHook), compareAnims);
572  ordered_commands = 1;
573 }
574 
575 static CFanimationHook *get_command(char *command) {
576  CFanimationHook dummy;
577 
578  dummy.name = command;
579  if (!ordered_commands)
581  return (CFanimationHook *)bsearch(&dummy, animationbox, animationcount, sizeof(CFanimationHook), compareAnims);
582 }
583 
592 static CFmovement *parse_animation_block(char *buffer, size_t buffer_size, FILE *fichier, CFanimation *parent) {
593  CFmovement *first = NULL;
594  CFmovement *current = NULL;
595  CFmovement *next;
596  char *time;
597  char *name;
598  char *parameters;
599  int tick;
600  CFanimationHook *animationhook;
601 
602  if (parent->verbose)
603  cf_log(llevDebug, "CFAnim: In parse block for %s\n", buffer);
604  while (fgets(buffer, buffer_size, fichier)) {
605  if (buffer[0] == '[')
606  break;
607  if (buffer[0] == '#')
608  continue;
609  buffer[strlen(buffer)-strlen("\n")] = '\0';
610  while (buffer[strlen(buffer)-1] == ' ')
611  buffer[strlen(buffer)-1] = '\0';
612  if (strlen(buffer) <= 0)
613  continue;
614  time = buffer;
615 
616  name = strstr(buffer, " ");
617  if (!name)
618  continue;
619  *name = '\0';
620  name++;
621  while (*name == ' ')
622  name++;
623 
624  tick = atoi(time);
625  if (tick < 0)
626  continue;
627 
628  parameters = strstr(name, " ");
629  if (parameters) { /*Parameters may be nul*/
630  *parameters = '\0';
631  parameters++;
632  while (*parameters == ' ')
633  parameters++;
634  if (*parameters == '\0')
635  parameters = NULL;
636  }
637  animationhook = get_command(name);
638  if (!animationhook)
639  cf_log(llevError, "CFAnim: %s - Unknown animation command\n", name);
640  else if (parent->verbose) {
641  cf_log(llevDebug, "CFAnim: Parsed %s -> %p\n", name, animationhook);
642  }
643  if (!animationhook) {
644  if (parent->errors_allowed)
645  continue;
646  else
647  break;
648  }
649  next = (CFmovement *)malloc(sizeof(CFmovement));
650  if (!next)
651  continue;
652  next->parent = parent;
653  next->tick = tick;
654  next->next = NULL;
655  if (animationhook->funcinit)
656  next->id = animationhook->funcinit(name, parameters, next);
657  next->func = animationhook->funcrun;
658  if (current)
659  current->next = next;
660  else
661  first = next;
662  current = next;
663  }
664  return first;
665 }
666 
677 static int equality_split(char *buffer, char **variable, char **value) {
678  if (!strcmp(&buffer[strlen(buffer)-strlen("\n")], "\n"))
679  buffer[strlen(buffer)-strlen("\n")] = '\0';
680  *value = strstr(buffer, "=");
681  if (!*value)
682  return 0;
683  **value = '\0';
684  *variable = buffer;
685  (*value)++;
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 == ' ')
691  (*value)++;
692  if ((**variable == '\0') || (**value == '\0'))
693  return 0;
694  return 1;
695 }
696 
708 static int get_boolean(const char *strg, int *bl) {
709  /*
710  * We're only parsing the first character, so we
711  * really don't need to call strncmp().
712  * Should future checks need to check multiple characters,
713  * strncmp() would be a good choice. For that reason,
714  * I won't optimize this down to a switch statement.
715  * It makes it clearer how to handle multi-character checks.
716  */
717  if (*strg == 'y')
718  *bl = 1;
719  else if (*strg == 'n')
720  *bl = 0;
721  else if (*strg == 'Y')
722  *bl = 1;
723  else if (*strg == 'N')
724  *bl = 0;
725  else if (*strg == '1')
726  *bl = 1;
727  else if (*strg == '0')
728  *bl = 0;
729  else
730  return 0;
731  return 1;
732 }
733 
739 static int is_animated_object(const object *ob) {
740  CFanimation *current;
741 
742  for (current = first_animation; current; current = current->nextanimation)
743  if (current->victim == ob) {
744  return 1;
745  }
746  return 0;
747 }
748 
754  CFanimation *new;
755  CFanimation *current;
756 
757  new = (CFanimation *)malloc(sizeof(CFanimation));
758  if (!new)
759  return NULL;
760  new->name = NULL;
761  new->victim = NULL;
762  new->event = NULL;
763  new->nextmovement = NULL;
764  new->nextanimation = NULL;
765  new->delete_end = 0;
766  for (current = first_animation; (current && current->nextanimation); current = current->nextanimation)
767  ;
768  if (!current)
769  first_animation = new;
770  else
771  current->nextanimation = new;
772  return new;
773 }
774 
775 static object *find_by_name(object *origin, const char *name) {
776  int x, y, w, h;
777  mapstruct *map;
778  const char *sname;
779 
780  sname = cf_find_string(name);
781  if (!sname)
782  return NULL;
783 
784  while (origin && !origin->map)
785  origin = origin->env;
786 
787  if (!origin || !origin->map)
788  return NULL;
789 
790  map = origin->map;
791 
792  w = cf_map_get_width(map);
793  h = cf_map_get_height(map);
794 
795  for (x = 0; x < w; x++) {
796  for (y = 0; y < h; y++) {
797  FOR_MAP_PREPARE(map, x, y, ob) {
798  if (/*cf_object_get_sstring_property(ob, CFAPI_OBJECT_PROP_NAME)*/ob->name == sname)
799  return ob;
800  } FOR_MAP_FINISH();
801  }
802  }
803 
804  return NULL;
805 }
806 
818 static int start_animation(object *who, object *activator, object *event, const char *file, const char *message) {
819  FILE *fichier;
820  char *name = NULL;
821  int victimtype = 0;
822  object *victim = NULL;
823  int unique = 0;
824  int always_delete = 0;
825  int delete_end = 0;
826  int parallel = 0;
827  int paralyzed = 1;
828  int invisible = 0;
829  int wizard = 0;
830  enum time_enum timetype;
831  int errors_allowed = 0;
832  int verbose = 0;
833  const char *animationitem = NULL;
834  char buffer[HUGE_BUF];
835  char *variable;
836  char *value;
837  int errors_found = 0;
838  CFanimation *current_anim;
839 
840  fichier = fopen(file, "r");
841  if (fichier == NULL) {
842  cf_log(llevDebug, "CFAnim: Unable to open %s\n", file);
843  return 0;
844  }
845  while (fgets(buffer, HUGE_BUF, fichier)) {
846  if (buffer[0] == '[')
847  break;
848  if (buffer[0] == '#')
849  continue;
850  if (!strcmp(buffer, "\n"))
851  continue;
852  errors_found = 1;
853  cf_log(llevError, "CFAnim: '%s' has an invalid syntax.\n", buffer);
854  }
855  if (feof(fichier)) {
856  fclose(fichier);
857  return 0;
858  }
859  if (strncmp(buffer, "[Config]", 8)) {
860  cf_log(llevError, "CFAnim: Fatal error in %s: [Config] must be the first group defined.\n", file);
861  fclose(fichier);
862  return 0;
863  }
864  while (fgets(buffer, HUGE_BUF, fichier)) {
865  if (buffer[0] == '[')
866  break;
867  if (buffer[0] == '#')
868  continue;
869  if (!strcmp(buffer, "\n"))
870  continue;
871  if (!equality_split(buffer, &variable, &value))
872  errors_found = 1;
873  else {
874  if (!strcmp(variable, "name")) {
875  if (*value == '"')
876  value++;
877  if (value[strlen(value)-1] == '"')
878  value[strlen(value)-1] = '\0';
879  name = cf_strdup_local(value);
880  } else if (!strcmp(variable, "victimtype")) {
881  if (!strcmp(value, "player"))
882  victimtype = 0;
883  else if (!strcmp(value, "object"))
884  victimtype = 1;
885  else if (!strcmp(value, "any"))
886  victimtype = 2;
887  else if (!strcmp(value, "byname"))
888  victimtype = 3;
889  else
890  errors_found = 1;
891  } else if (!strcmp(variable, "victim")) {
892  cf_log(llevDebug, "CFAnim: Setting victim to %s\n", value);
893  if (!strcmp(value, "who"))
894  victim = who;
895  else if (!strcmp(value, "activator"))
896  victim = activator;
897  else if (!strcmp(value, "who_owner"))
898  if (!who) {
899  errors_found = 1;
900  cf_log(llevError, "CFAnim: Warning: object \"who\" doesn't exist and you're victimized it's owner\n");
901  } else
902  victim = who->env;
903  else if (!strcmp(value, "activator_owner"))
904  if (!activator) {
905  errors_found = 1;
906  cf_log(llevError, "CFAnim: Warning: object \"activator\" doesn't exist and you're victimized it's owner\n");
907  } else
908  victim = activator->env;
909  else if (victimtype == 3) {
910  victim = find_by_name(who, value);
911  } else
912  errors_found = 1;
913  } else if (!strcmp(variable, "unique")) {
914  if (!get_boolean(value, &unique))
915  errors_found = 1;
916  } else if (!strcmp(variable, "always_delete")) {
917  if (!get_boolean(value, &always_delete))
918  errors_found = 1;
919  } else if (!strcmp(variable, "delete_event_end")) {
920  if (!get_boolean(value, &delete_end))
921  errors_found = 1;
922  } else if (!strcmp(variable, "parallel")) {
923  if (!get_boolean(value, &parallel))
924  errors_found = 1;
925  } else if (!strcmp(variable, "paralyzed")) {
926  if (!get_boolean(value, &paralyzed))
927  errors_found = 1;
928  } else if (!strcmp(variable, "invisible")) {
929  if (!get_boolean(value, &invisible))
930  errors_found = 1;
931  } else if (!strcmp(variable, "wizard")) {
932  if (!get_boolean(value, &wizard))
933  errors_found = 1;
934  } else if (!strcmp(variable, "errors_allowed")) {
935  if (!get_boolean(value, &errors_allowed))
936  errors_found = 1;
937  } else if (!strcmp(variable, "verbose")) {
938  if (!get_boolean(value, &verbose))
939  errors_found = 1;
940  } else if (!strcmp(variable, "time_representation")) {
941  if (!strcmp(value, "second"))
942  timetype = time_second;
943  else if (!strcmp(value, "tick"))
944  timetype = time_tick;
945  else
946  errors_found = 1;
947  } else if (!strcmp(variable, "animation")) {
948  animationitem = cf_add_string(value);
949  } else
950  errors_found = 1;
951  }
952  }
953 
954  if (message && message[0] != '\0') {
955  cf_free_string(animationitem);
956  animationitem = cf_add_string(message);
957  }
958 
959  if (buffer[0] == '\0') {
960  if (animationitem)
961  cf_free_string(animationitem);
962  cf_log(llevError, "CFAnim: Errors occurred during the parsing of %s\n", file);
963  fclose(fichier);
964  return 0;
965  }
966  if (!animationitem) {
967  cf_log(llevError, "CFAnim: no animation specified when using %s\n", file);
968  fclose(fichier);
969  return 0;
970  }
971  if (!victim) {
972  if (animationitem)
973  cf_free_string(animationitem);
974  cf_log(llevError, "CFAnim: Fatal error - victim is NULL");
975  fclose(fichier);
976  return 0;
977  }
978  if (!(current_anim = create_animation())) {
979  if (animationitem)
980  cf_free_string(animationitem);
981  cf_log(llevError, "CFAnim: Fatal error - Not enough memory.\n");
982  fclose(fichier);
983  return 0;
984  }
985  if (always_delete) {
986  /*if (verbose) printf("CFAnim: Freeing event nr. %d for %s.\n", current_event, who->name);*/
987  cf_object_remove(event);
988  event = NULL;
989  }
990  if (((victim->type == PLAYER) && (victimtype == 1))
991  || ((victim->type != PLAYER) && (victimtype == 0))
992  || (errors_found && !errors_allowed)) {
993  if (verbose)
994  cf_log(llevError, "CFAnim: No correct victim found or errors found, aborting.\n");
995  if (animationitem)
996  cf_free_string(animationitem);
997  free(current_anim);
998  fclose(fichier);
999  return 0;
1000  }
1001  if (unique && !always_delete) {
1002  /*if (verbose) printf("CFAnim: Freeing event nr. %d for %s.\n", current_event, who->name);*/
1003  cf_object_remove(event);
1004  event = NULL;
1005  }
1006  current_anim->name = name;
1007  current_anim->victim = victim;
1008  current_anim->event = event;
1009  current_anim->paralyze = paralyzed;
1010  current_anim->invisible = invisible;
1011  current_anim->wizard = wizard;
1012  current_anim->unique = unique;
1013  current_anim->delete_end = delete_end;
1014  current_anim->ghosted = 0;
1015  current_anim->corpse = NULL;
1016  current_anim->time_representation = timetype;
1017  current_anim->verbose = verbose;
1018  current_anim->tick_left = 0;
1019  current_anim->errors_allowed = errors_allowed;
1020 
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] == '[')
1025  break;
1026  if (value == NULL) {
1027  cf_log(llevError, "CFAnim: no matching animation %s in file.\n", animationitem);
1028  cf_free_string(animationitem);
1029  fclose(fichier);
1030  return 0;
1031  }
1032  }
1033  current_anim->nextmovement = parse_animation_block(buffer, HUGE_BUF, fichier, current_anim);
1034  if (current_anim->nextmovement)
1035  break;
1036  }
1037  fclose(fichier);
1038  return 1;
1039 }
1040 
1046 static void animate_one(CFanimation *animation, long int milliseconds) {
1047  CFmovement *current;
1048  int mult = 1;
1049  anim_move_result result;
1050 
1051  if (animation->time_representation == time_second) {
1052  animation->tick_left += milliseconds;
1053  mult = 1000;
1054  } else
1055  animation->tick_left++;
1056 
1057  if (animation->verbose)
1058  cf_log(llevDebug, "CFAnim: Ticking %s for %s. Tickleft is %ld\n", animation->name, animation->victim->name, animation->tick_left);
1059  if (animation->invisible)
1060  animation->victim->invisible = 10;
1061  if (animation->wizard && animation->victim->type == PLAYER) {
1062  /* setting FLAG_WIZ *on non player leads to issues, as many functions expect contr to not be NULL in this case. */
1063  if (animation->verbose)
1064  cf_log(llevDebug, "CFAnim: Setting wizard flags\n");
1065  cf_object_set_flag(animation->victim, FLAG_WIZPASS, 1);
1066  cf_object_set_flag(animation->victim, FLAG_WIZCAST, 1);
1067  cf_object_set_flag(animation->victim, FLAG_WIZ, 1);
1068  if (animation->verbose)
1069  cf_log(llevDebug, "CFAnim: Setting wizard flags done\n");
1070 
1071  }
1072  if (animation->paralyze)
1073  animation->victim->speed_left = -99999;
1074 
1075  cf_object_update(animation->victim, UP_OBJ_CHANGE);
1076 
1077  if (animation->nextmovement)
1078  while (animation->tick_left > animation->nextmovement->tick*mult) {
1079  animation->tick_left -= animation->nextmovement->tick*mult;
1080  result = animation->nextmovement->func(animation, animation->nextmovement->id, animation->nextmovement->parameters);
1081  if (result == mr_again)
1082  continue;
1083 
1084  current = animation->nextmovement;
1085  animation->nextmovement = animation->nextmovement->next;
1086  free(current);
1087  if (!animation->nextmovement)
1088  break;
1089  }
1090  cf_object_set_flag(animation->victim, FLAG_WIZPASS, 0);
1091  cf_object_set_flag(animation->victim, FLAG_WIZCAST, 0);
1092  cf_object_set_flag(animation->victim, FLAG_WIZ, 0);
1093 }
1094 
1099 long usec_elapsed(struct timespec first, struct timespec second) {
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);
1103 }
1104 
1108 static void animate(void) {
1109  CFanimation *current;
1110  CFanimation *next;
1111  CFanimation *previous_anim = NULL;
1112  struct timespec now;
1113  static struct timespec yesterday;
1114  static int already_passed = 0;
1115  long int delta_milli;
1116 
1117  clock_gettime(CLOCK_MONOTONIC, &now);
1118  if (!already_passed) {
1119  already_passed = 1;
1120  yesterday = now;
1121  return;
1122  }
1123  delta_milli = usec_elapsed(yesterday, now) / 1e3;
1124  /*printf("Working for %ld milli seconds\n", delta_milli);*/
1125  yesterday = now;
1126  for (current = first_animation; current; current = current->nextanimation)
1127  animate_one(current, delta_milli);
1128  current = first_animation;
1129  while (current) {
1130  if (!current->nextmovement) {
1131  if (current->paralyze)
1132  current->victim->speed_left = current->victim->speed;
1133  next = current->nextanimation;
1134  if (first_animation == current)
1135  first_animation = next;
1136  else {
1137  previous_anim->nextanimation = next;
1138  }
1139  if (current->delete_end && current->event != NULL)
1140  cf_object_remove(current->event);
1141  free(current->name);
1142  free(current);
1143  current = next;
1144  } else {
1145  previous_anim = current;
1146  current = current->nextanimation;
1147  }
1148  }
1149 }
1150 
1157 CF_PLUGIN int initPlugin(const char *iversion, f_plug_api gethooksptr) {
1158  cf_init_plugin(gethooksptr);
1159  cf_log(llevDebug, "CFAnim 2.0a init\n");
1160 
1161  /* Place your initialization code here */
1162  return 0;
1163 }
1164 
1165 CF_PLUGIN void *getPluginProperty(int *type, ...) {
1166  va_list args;
1167  const char *propname;
1168  char *buf;
1169  int size;
1170 
1171  va_start(args, type);
1172  propname = va_arg(args, const char *);
1173 
1174  if (!strcmp(propname, "Identification")) {
1175  buf = va_arg(args, char *);
1176  size = va_arg(args, int);
1177  va_end(args);
1178  snprintf(buf, size, PLUGIN_NAME);
1179  return NULL;
1180  } else if (!strcmp(propname, "FullName")) {
1181  buf = va_arg(args, char *);
1182  size = va_arg(args, int);
1183  va_end(args);
1184  snprintf(buf, size, PLUGIN_VERSION);
1185  return NULL;
1186  }
1187  va_end(args);
1188  return NULL;
1189 }
1190 
1192  return -1;
1193 }
1194 
1196  cf_log(llevDebug, "CFAnim 2.0a post init\n");
1197  /* Pick the global events you want to monitor from this plugin */
1199  return 0;
1200 }
1201 
1203  va_list args;
1204  int rv = 0;
1205  int event_code;
1206 
1207  va_start(args, type);
1208  event_code = va_arg(args, int);
1209  assert(event_code == EVENT_CLOCK);
1210 
1211  animate();
1212 
1213  va_end(args);
1214 
1215  return rv;
1216 }
1217 
1218 CF_PLUGIN int eventListener(int *type, ...) {
1219  int rv = 0;
1220  va_list args;
1221  char *buf, message[MAX_BUF], script[MAX_BUF];
1222  object *who, *activator/*, *third*/, *event;
1223  int query;
1224 
1225  va_start(args, type);
1226 
1227  who = va_arg(args, object *);
1228  activator = va_arg(args, object *);
1229  /*third =*/ va_arg(args, object *);
1230  buf = va_arg(args, char *);
1231 
1232  if (buf != NULL) {
1233  snprintf(message, sizeof(message), "%s", buf);
1234  } else {
1235  message[0] = '\0';
1236  }
1237 
1238  query = va_arg(args, int); /* 'fix', ignored */
1239  event = va_arg(args, object *);
1240 
1241  if (query == 1 && strcmp(message, "query_object_is_animated") == 0) {
1242  rv = is_animated_object(who);
1243  va_end(args);
1244  return rv;
1245  }
1246 
1248  cf_get_maps_directory(event->slaying, script, sizeof(script));
1249  va_end(args);
1250 
1251  /* Put your plugin action(s) here */
1252  if (activator != NULL) {
1253  cf_log(llevDebug, "CFAnim: %s called animator script %s\n", activator->name, script);
1254  } else if (who != NULL) {
1255  activator = who;
1256  cf_log(llevDebug, "CFAnim: %s called animator script %s\n", who->name, script);
1257  }
1258 
1259  rv = start_animation(who, activator, event, script, message);
1260 
1261  return rv;
1262 }
1263 
1265  cf_log(llevDebug, "CFAnim 2.0a closing\n");
1266  return 0;
1267 }
static long int initteleport(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:337
static int get_dir_from_name(const char *name)
Returns the direction from its name.
Definition: cfanim.c:51
Error, serious thing.
Definition: logger.h:11
void * parameters
Parameters to the function.
Definition: cfanim.h:61
void cf_object_free_drop_inventory(object *ob)
Wrapper for object_free_drop_inventory().
CF_PLUGIN int initPlugin(const char *iversion, f_plug_api gethooksptr)
Plugin initialisation function.
Definition: cfanim.c:1157
void cf_map_message(mapstruct *m, const char *msg, int color)
Partial wrapper for ext_info_map().
static CFmovement * parse_animation_block(char *buffer, size_t buffer_size, FILE *fichier, CFanimation *parent)
Parse an animation block in the animation file.
Definition: cfanim.c:592
static long int initnotice(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:386
static long int initmovement(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:71
Used to link together several objects.
Definition: object.h:442
CFAnimInitFunc funcinit
Function to process the parameters of the move.
Definition: cfanim.h:90
int tick
Move duration, units depending on parent&#39;s time_representation.
Definition: cfanim.h:63
void cf_free_string(sstring str)
Wrapper for free_string().
static int start_animation(object *who, object *activator, object *event, const char *file, const char *message)
Create a new animation object according to file, option and activator (who)
Definition: cfanim.c:818
CF_PLUGIN anim_move_result cfanim_runPluginCommand(object *op, char *params)
Definition: cfanim.c:1191
static int get_boolean(const char *strg, int *bl)
This function gets a string containing [Y/y](es)/[N/n](o), 1/0 and set bl according to what&#39;s read if...
Definition: cfanim.c:708
static object * find_by_name(object *origin, const char *name)
Definition: cfanim.c:775
long int id
Identifier, used for various things.
Definition: cfanim.h:62
CF_PLUGIN int postInitPlugin(void)
Definition: cfanim.c:1195
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)
Definition: cfanim.c:199
struct obj * container
Current container being used.
Definition: object.h:291
static long int initfire(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:92
static anim_move_result runtrigger(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:478
One server tick.
Definition: cfanim.h:41
CFAnimRunFunc func
Function to run for this move.
Definition: cfanim.h:60
static void animate(void)
Animates all currently running animations.
Definition: cfanim.c:1108
static long int initmoveto(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:415
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
static void animate_one(CFanimation *animation, long int milliseconds)
Checks if an animation can execute one or more moves, and if so does them.
Definition: cfanim.c:1046
static long int initturn(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:107
int16_t invisible
How much longer the object will be invis.
Definition: object.h:360
const char * slaying
Which race to do double damage to.
Definition: object.h:319
int cf_map_get_height(mapstruct *map)
CFAnimRunFunc funcrun
Function to run the move.
Definition: cfanim.h:91
static anim_move_result runturn(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:115
void cf_object_apply_below(object *pl)
Wrapper for apply_by_living_below().
void cf_object_update(object *op, int flags)
int cf_player_move(player *pl, int dir)
static int ordered_commands
Definition: cfanim.c:564
static anim_move_result runghosted(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:301
static anim_move_result runstop(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:404
object * victim
Definition: cfanim.h:70
sstring cf_add_string(const char *str)
Wrapper for add_string().
enum time_enum time_representation
Definition: cfanim.h:82
#define AP_APPLY
Item is to be applied.
Definition: define.h:610
static anim_move_result runmessage(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:458
long value
Used as connected value in buttons/gates.
Definition: object.h:453
CF_PLUGIN int eventListener(int *type,...)
Definition: cfanim.c:1218
static CFanimationHook * get_command(char *command)
Definition: cfanim.c:575
#define FOR_OB_AND_BELOW_FINISH()
Finishes FOR_OB_AND_BELOW_PREPARE().
Definition: define.h:789
Used to link together several object links.
Definition: object.h:451
object * event
Definition: cfanim.h:71
struct oblnk * link
Items for this value.
Definition: object.h:452
void cf_log(LogLevel logLevel, const char *format,...)
Wrapper for LOG().
#define NDI_NAVY
Definition: newclient.h:223
static long int initcamera(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:128
static anim_move_result runvisible(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:157
int16_t y
Position in the map for this object.
Definition: object.h:326
char * cf_strdup_local(const char *str)
Wrapper for strdup_local().
struct oblinkpt * next
Next value in the list.
Definition: object.h:454
int cf_init_plugin(f_plug_api getHooks)
object * cf_object_find_by_name(const object *who, const char *name)
Wrapper for object_find_by_name().
struct CFanimation_struct * parent
Animation this move is linked to.
Definition: cfanim.h:59
float speed_left
How much speed is left to spend this round.
Definition: object.h:329
Move completed.
Definition: cfanim.h:46
object * cf_object_clone(object *op, int clonetype)
Clone an object.
int y
Coordinates.
Definition: cfanim.c:412
static long int initghosted(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:292
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
CF_PLUGIN void * getPluginProperty(int *type,...)
Definition: cfanim.c:1165
object * corpse
Definition: cfanim.h:80
#define snprintf
Definition: win32.h:46
static anim_move_result runmovement(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:79
mapstruct * cf_map_get_map(const char *name, int flags)
Wrapper for ready_map_name().
One move in an animation.
Definition: cfanim.h:58
static int is_animated_object(const object *ob)
Is specified object currently being animated?
Definition: cfanim.c:739
sstring cf_find_string(const char *str)
#define PLUGIN_NAME
Definition: cfanim.h:32
#define NDI_GREEN
SeaGreen.
Definition: newclient.h:228
const char * name
The name of the object, obviously...
Definition: object.h:311
struct obj * env
Pointer to the object which is the environment.
Definition: object.h:293
static long int initpickup(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:260
struct obj * below
Pointer to the object stacked below this one.
Definition: object.h:287
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)
Teleport an item around a nearby random teleporter of specified type.
Definition: move.c:188
void cf_object_say(object *op, char *msg)
anim_move_result
Result of one animation move.
Definition: cfanim.h:45
static int equality_split(char *buffer, char **variable, char **value)
This function take buffer with a value like "blabla= things" and extracts some things.
Definition: cfanim.c:677
struct pl * contr
Pointer to the player which control this object.
Definition: object.h:276
static anim_move_result runnotice(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:390
static anim_move_result runteleport(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:376
struct CFanimation_struct * nextanimation
Definition: cfanim.h:84
static anim_move_result runwizard(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:173
static anim_move_result runsay(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:190
char * cf_get_maps_directory(const char *name, char *buf, int size)
Wrapper for create_pathname().
static CFanimation * create_animation(void)
Create a new animation.
Definition: cfanim.c:753
float speed
The overall speed of this object.
Definition: object.h:328
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
#define FLAG_WIZ
Object has special privilegies.
Definition: define.h:231
CF_PLUGIN int cfanim_globalEventListener(int *type,...)
Definition: cfanim.c:1202
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
static anim_move_result runfire(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:101
long usec_elapsed(struct timespec first, struct timespec second)
Return the number of microseconds between two timespec structures.
Definition: cfanim.c:1099
CF_PLUGIN char SvnRevPlugin[]
Definition: cfanim.c:40
oblinkpt * buttons
Linked list of linked lists of buttons.
Definition: map.h:354
int16_t x
Definition: object.h:326
static anim_move_result rundropobject(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:249
void cf_object_remove(object *op)
Wrapper for object_remove().
static long int initvisible(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:148
static long int initmessage(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:450
void cf_map_trigger_connected(objectlink *ol, object *cause, int state)
Wrapper for trigger_connected().
One full animation.
Definition: cfanim.h:68
int cf_object_apply(object *op, object *author, int flags)
Wrapper for apply_manual().
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
Definition: define.h:765
struct CFmovement_struct * nextmovement
Definition: cfanim.h:83
#define EVENT_CLOCK
Global time event.
Definition: plugin.h:84
See Player.
Definition: object.h:107
void cf_player_message(object *op, char *txt, int flags)
static int compareAnims(const void *a, const void *b)
Definition: cfanim.c:566
#define UP_OBJ_CHANGE
Object changed.
Definition: object.h:518
#define CF_PLUGIN
Definition: plugin_common.h:38
int cf_object_move(object *op, int dir, object *originator)
Destination for moveto command.
Definition: cfanim.c:411
#define FLAG_WIZCAST
The wizard can cast spells in no-magic area.
Definition: define.h:290
Only for debugging purposes.
Definition: logger.h:13
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:338
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:297
static long int initpickupobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:274
void cf_object_pickup(object *op, object *what)
One second.
Definition: cfanim.h:40
void cf_object_drop(object *op, object *author)
static CFanimation * first_animation
Animations we&#39;re currently processing.
Definition: cfanim.c:42
CF_PLUGIN int closePlugin(void)
Definition: cfanim.c:1264
static anim_move_result runapplyobject(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:220
sstring cf_map_get_sstring_property(mapstruct *map, int propcode)
static long int initwizard(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:164
static long int initapplyobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:215
#define FOR_OB_AND_BELOW_PREPARE(op_)
Constructs a loop iterating over an object and all objects below it in the same pile.
Definition: define.h:785
CFanimationHook animationbox[]
Available animation commands.
Definition: cfanim.c:512
const char * name
Name as it appears in the animation file.
Definition: cfanim.h:89
static anim_move_result runapply(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:203
char * strdup(const char *str)
Portable implementation of strdup(3).
Definition: porting.c:200
static anim_move_result runpickup(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:264
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:245
Move should continue next time.
Definition: cfanim.h:47
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)
Definition: cfanim.c:467
long int tick_left
Definition: cfanim.h:81
static void prepare_commands(void)
Definition: cfanim.c:570
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
Definition: define.h:758
int animationcount
Definition: cfanim.c:562
static anim_move_result runcamera(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:137
struct CFmovement_struct * next
Next move in the animation.
Definition: cfanim.h:64
static long int initsay(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:180
#define FOR_BELOW_PREPARE(op_, it_)
Constructs a loop iterating over all objects below an object.
Definition: define.h:739
static anim_move_result runmoveto(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:430
This is a game-map.
Definition: map.h:325
static long int initstop(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:399
#define FLAG_WIZPASS
The wizard can go through walls.
Definition: define.h:315
int8_t facing
Object is oriented/facing that way.
Definition: object.h:335
char * mapname
Definition: cfanim.c:332
object * cf_map_insert_object_there(object *op, mapstruct *m, object *originator, int flag)
Wrapper for object_insert_in_map().
Available animation move.
Definition: cfanim.h:88
int cf_map_get_width(mapstruct *map)
int cf_object_move_to(object *op, int x, int y)
Wrapper for move_to().
int errors_allowed
Definition: cfanim.h:78
time_enum
Time units the animation can use.
Definition: cfanim.h:39
#define FOR_BELOW_FINISH()
Finishes FOR_BELOW_PREPARE().
Definition: define.h:746
void(* f_plug_api)(int *type,...)
General API function.
Definition: plugin.h:125
static anim_move_result runpickupobject(struct CFanimation_struct *animation, long int id, void *parameters)
Definition: cfanim.c:279
static long int initdropobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)
Definition: cfanim.c:243
#define PLUGIN_VERSION
Definition: cfanim.h:33