Crossfire Server, Trunk
cfanim.cpp
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 
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, CFmovement *move_entity) {
72  int dir;
74 
75  dir = get_dir_from_name(name);
76  move_entity->parameters = NULL;
77  return dir;
78 }
79 
80 static anim_move_result runmovement(CFanimation *animation, long int id, void *parameters) {
81  object *op = animation->victim;
82  int dir = id;
84 
85  if (animation->verbose)
86  cf_log(llevDebug, "CFAnim: Moving in direction %ld\n", id);
87  if (op->type == PLAYER)
88  cf_player_move(op->contr, dir);
89  else
90  cf_object_move(op, dir, op);
91  return mr_finished;
92 }
93 
94 static long int initfire(const char *name, char *parameters, CFmovement *move_entity) {
95  int dir;
97 
98  dir = get_dir_from_name(&(name[5]));
99  move_entity->parameters = NULL;
100  return dir;
101 }
102 
104 static anim_move_result runfire(CFanimation *animation, long int id, void *parameters) {
105  (void)parameters;
106  if (animation->verbose)
107  cf_log(llevDebug, "CFAnim: Firing in direction %ld\n", id);
108  return mr_finished;
109 }
110 
111 static long int initturn(const char *name, char *parameters, CFmovement *move_entity) {
112  int dir;
113  (void)parameters;
114 
115  dir = get_dir_from_name(&(name[5]));
116  move_entity->parameters = NULL;
117  return dir;
118 }
119 
120 static anim_move_result runturn(CFanimation *animation, long int id, void *parameters) {
121  object *op = animation->victim;
122  int dir = id;
123  (void)parameters;
124  /*int face;*/
125 
126  if (animation->verbose)
127  cf_log(llevDebug, "CFAnim: Turning in direction %ld\n", id);
128  op->facing = dir;
130 /* cf_object_set_int_property(op, CFAPI_OBJECT_PROP_ANIMATION, face);*/
131  return mr_finished;
132 }
133 
134 static long int initcamera(const char *name, char *parameters, CFmovement *move_entity) {
135  int dir;
136  (void)parameters;
137 
138  dir = get_dir_from_name(&(name[7]));
139  move_entity->parameters = NULL;
140  return dir;
141 }
142 
144 static anim_move_result runcamera(CFanimation *animation, long int id, void *parameters) {
145  (void)parameters;
146  if (animation->verbose)
147  cf_log(llevDebug, "CFAnim: Moving the camera in direction %ld\n", id);
148  return mr_finished;
149  /*if (animation->victim->type == PLAYER)
150  hook_scroll_map(animation->victim, id);
151  else
152  printf("CFAnim: Not a player\n");
153  return 1;*/
154 }
155 
156 static long int initvisible(const char *name, char *parameters, CFmovement *move_entity) {
157  int result;
158  (void)name;
159  (void)move_entity;
160 
162  return result;
163  cf_log(llevError, "CFAnim: Error in animation - possible values for 'invisible' are 'yes' and 'no'\n");
164  return -1;
165 }
166 
167 static anim_move_result runvisible(CFanimation *animation, long int id, void *parameters) {
168  (void)parameters;
169  if (id == -1)
170  return mr_finished;
171  animation->invisible = id;
172  return mr_finished;
173 }
174 
175 static long int initwizard(const char *name, char *parameters, CFmovement *move_entity) {
176  int result;
177  (void)name;
178  (void)move_entity;
179 
181  return result;
182  cf_log(llevError, "CFAnim: Error in animation - possible values for 'wizard' are 'yes' and 'no'\n");
183  return mr_finished;
184 }
185 
186 static anim_move_result runwizard(CFanimation *animation, long int id, void *parameters) {
187  (void)parameters;
188  if (id == -1)
189  return mr_finished;
190  animation->wizard = id;
191  return mr_finished;
192 }
193 
194 static long int initsay(const char *name, char *parameters, CFmovement *move_entity) {
195  (void)name;
196  if (parameters)
197  move_entity->parameters = cf_strdup_local(parameters);
198  else
199  move_entity->parameters = NULL;
200  if (move_entity->parent->verbose)
201  cf_log(llevDebug, "CFAnim: init say: parameters: %s\n", parameters ? parameters : "null");
202  return 1;
203 }
204 
205 static anim_move_result runsay(CFanimation *animation, long int id, void *parameters) {
206  (void)id;
207  if (parameters) {
208  cf_object_say(animation->victim, static_cast<const char *>(parameters));
209  free(parameters);
210  } else
211  cf_log(llevError, "CFAnim: Error in animation: nothing to say with say function\n");
212  return mr_finished;
213 }
214 
215 static long int initapply(const char *name, char *parameters, CFmovement *move_entity) {
216  (void)name;
217  (void)parameters;
218  (void)move_entity;
219  return 1;
220 }
221 
222 static anim_move_result runapply(CFanimation *animation, long int id, void *parameters) {
223  object *current_container;
224  (void)id;
225  (void)parameters;
226 
227  if (animation->victim->type != PLAYER)
228  return mr_finished;
229  current_container = animation->victim->container;
230  animation->victim->container = NULL;
231  cf_object_apply_below(animation->victim);
232  animation->victim->container = current_container;
233  return mr_finished;
234 }
235 
236 static long int initapplyobject(const char *name, char *parameters, CFmovement *move_entity) {
237  (void)name;
238  move_entity->parameters = parameters ? (void*)cf_add_string(static_cast<sstring>(parameters)) : NULL;
239  return 1;
240 }
241 
242 static anim_move_result runapplyobject(CFanimation *animation, long int id, void *parameters) {
243  object *current;
244  int aflag;
245  (void)id;
246 
247  if (!parameters)
248  return mr_finished;
249  current = animation->victim->below;
251  if (current->name == parameters)
252  break;
253  }
255  if (!current)
256  current = cf_object_find_by_name(animation->victim, static_cast<char *>(parameters));
257  if (!current) {
258  cf_free_string(static_cast<sstring>(parameters));
259  return mr_finished;
260  }
261  aflag = AP_APPLY;
262  cf_object_apply(animation->victim, current, aflag);
263  cf_free_string(static_cast<sstring>(parameters));
264  return mr_finished;
265 }
266 
267 static long int initdropobject(const char *name, char *parameters, CFmovement *move_entity) {
268  (void)name;
269  move_entity->parameters = parameters ?
270  (void *)cf_add_string(static_cast<sstring>(parameters)) : NULL;
271  return 1;
272 }
273 
274 static anim_move_result rundropobject(CFanimation *animation, long int id, void *parameters) {
275  object *what;
276  (void)id;
277  if (!parameters)
278  return mr_finished;
279  what = cf_object_find_by_name(animation->victim, static_cast<sstring>(parameters));
280  if (what != NULL)
281  cf_object_drop(what, animation->victim);
282  cf_free_string(static_cast<sstring>(parameters));
283  return mr_finished;
284 }
285 
286 static long int initpickup(const char *name, char *parameters, CFmovement *move_entity) {
287  (void)name;
288  (void)parameters;
289  (void)move_entity;
290  return 1;
291 }
292 
293 static anim_move_result runpickup(CFanimation *animation, long int id, void *parameters) {
294  object *current;
295  (void)id;
296  (void)parameters;
297 
298  current = animation->victim->below;
299  if (!current)
300  return mr_finished;
301  cf_object_pickup(animation->victim, current);
302  return mr_finished;
303 }
304 
305 static long int initpickupobject(const char *name, char *parameters, CFmovement *move_entity) {
306  (void)name;
307  move_entity->parameters = parameters ? (void*)cf_add_string(static_cast<sstring>(parameters)) : NULL;
308  return 1;
309 }
310 
311 static anim_move_result runpickupobject(CFanimation *animation, long int id, void *parameters) {
312  (void)id;
313  if (!parameters)
314  return mr_finished;
315  FOR_BELOW_PREPARE(animation->victim, current)
316  if (current->name == parameters) {
317  cf_object_pickup(animation->victim, current);
318  break;
319  }
321  cf_free_string(static_cast<sstring>(parameters));
322  return mr_finished;
323 }
324 
325 static long int initghosted(const char *name, char *parameters, CFmovement *move_entity) {
326  int result;
327  (void)name;
328  (void)move_entity;
329 
331  return result;
332  cf_log(llevError, "CFAnim: Error in animation: possible values for 'ghosted' are 'yes' and 'no'\n");
333  return -1;
334 }
335 
336 static anim_move_result runghosted(CFanimation *animation, long int id, void *parameters) {
337  object *corpse;
338 
339  if ((id && animation->ghosted)
340  || (!id && !animation->ghosted))
341  runghosted(animation, !id, parameters);
342  if (id) { /*Create a ghost/corpse pair*/
343  corpse = cf_object_clone(animation->victim, 1);
344  corpse->x = animation->victim->x;
345  corpse->y = animation->victim->y;
346  corpse->type = 0;
347  CLEAR_FLAG(corpse, FLAG_WIZ);
348  corpse->contr = NULL;
349  cf_map_insert_object_there(corpse, animation->victim->map, NULL, 0);
350  animation->wizard = 1;
351  animation->invisible = 1;
352  animation->corpse = corpse;
353  } else { /*Remove a corpse, make current player visible*/
354  animation->wizard = 0;
355  animation->invisible = 0;
356  cf_object_remove(animation->corpse);
358  animation->corpse = NULL;
359  animation->victim->invisible = 0;
360  cf_player_move(animation->victim->contr, 0);
361  }
362  animation->ghosted = id;
363  return mr_finished;
364 }
365 
367  char *mapname;
368  int mapx;
369  int mapy;
370 };
371 
372 static long int initteleport(const char *name, char *parameters, CFmovement *move_entity) {
373  char *mapname;
374  int mapx;
375  int mapy;
377  (void)name;
378 
379  move_entity->parameters = NULL;
380  cf_log(llevDebug, ".(%s)\n", parameters);
381  if (!parameters) {
382  cf_log(llevError, "CFAnim: Error - no parameters for teleport\n");
383  return 0;
384  }
385  mapname = strstr(parameters, " ");
386  cf_log(llevDebug, ".(%s)\n", parameters);
387  if (!mapname)
388  return 0;
389  *mapname = '\0';
390  mapx = atoi(parameters);
391  mapname++;
393  assert(parameters != NULL);
394  cf_log(llevDebug, ".(%s)\n", parameters);
395  mapname = strstr(parameters, " ");
396  cf_log(llevDebug, ".\n");
397  if (!mapname)
398  return 0;
399  *mapname = '\0';
400  mapy = atoi(parameters);
401  mapname++;
402  if (mapname[0] == '\0')
403  return 0;
404  teleport = (teleport_params *)malloc(sizeof(teleport_params));
405  teleport->mapname = cf_strdup_local(mapname);
406  teleport->mapx = mapx;
407  teleport->mapy = mapy;
408  move_entity->parameters = teleport;
409  return 1;
410 }
411 
412 static anim_move_result runteleport(CFanimation *animation, long int id, void *parameters) {
414  (void)id;
415 
416  if (!parameters)
417  return mr_finished;
418  cf_object_teleport(animation->victim, cf_map_get_map(teleport->mapname, 0), teleport->mapx, teleport->mapy);
419  free(parameters);
420  return mr_finished;
421 }
422 
423 static long int initnotice(const char *name, char *parameters, CFmovement *move_entity) {
424  (void)name;
425  move_entity->parameters = parameters ? cf_strdup_local(parameters) : NULL;
426  return 1;
427 }
428 static anim_move_result runnotice(CFanimation *animation, long int id, void *parameters) {
429  int val;
430  (void)id;
431 
432  val = NDI_NAVY|NDI_UNIQUE;
433 
434  cf_player_message(animation->victim, static_cast<char *>(parameters), val);
435  return mr_finished;
436 }
437 
438 static long int initstop(const char *name, char *parameters, CFmovement *move_entity) {
439  (void)name;
440  (void)parameters;
441  (void)move_entity;
442  return 1;
443 }
444 
446 static anim_move_result runstop(CFanimation *animation, long int id, void *parameters) {
447  (void)id;
448  (void)parameters;
449  if (animation->verbose)
450  cf_log(llevDebug, "CFAnim: stop encountered\n");
451  return mr_finished;
452 }
453 
455 struct param_moveto {
456  int x, y;
457 };
458 
459 static long int initmoveto(const char *name, char *parameters, CFmovement *move_entity) {
460  param_moveto *moveto;
461  int x, y;
462  (void)name;
463 
464  if (sscanf(parameters, "%d %d", &x, &y) != 2)
465  return 0;
466 
467  moveto = (param_moveto *)calloc(1, sizeof(param_moveto));
468  moveto->x = x;
469  moveto->y = y;
470  move_entity->parameters = moveto;
471 
472  return 1;
473 }
474 
475 static anim_move_result runmoveto(CFanimation *animation, long int id, void *parameters) {
476  int move;
478  (void)id;
479 
480  if (!dest)
481  return mr_finished;
482 
483  move = cf_object_move_to(animation->victim, dest->x, dest->y);
484 
485  if (animation->victim->x == dest->x && animation->victim->y == dest->y) {
486  free(parameters);
487  return mr_finished;
488  }
489 
490  if (move == 1)
491  return mr_again;
492 
493  return mr_finished;
494 }
495 
496 static long int initmessage(const char *name, char *parameters, CFmovement *move_entity) {
497  (void)name;
498  if (parameters)
499  move_entity->parameters = strdup(parameters);
500  else
501  move_entity->parameters = NULL;
502  return 1;
503 }
504 
505 static anim_move_result runmessage(CFanimation *animation, long int id, void *parameters) {
506  (void)id;
507  if (parameters && animation->victim->map) {
508  cf_map_message(animation->victim->map, (const char *)parameters, NDI_UNIQUE|NDI_GREEN);
509  free(parameters);
510  }
511 
512  return mr_finished;
513 }
514 
515 static long int inittrigger(const char *name, char *parameters, CFmovement *move_entity) {
516  long int connection;
517  (void)name;
518 
519  move_entity->parameters = NULL;
520  if (sscanf(parameters, "%ld", &connection) != 1 || connection <= 0) {
521  cf_log(llevError, "CFAnim: invalid connection %s\n", parameters);
522  return 0;
523  }
524  return connection;
525 }
526 
527 static anim_move_result runtrigger(CFanimation *animation, long int id, void *parameters) {
528  oblinkpt *olp;
529  mapstruct *map;
530  objectlink *ol = NULL;
531  (void)parameters;
532 
533  if (animation->victim == NULL || animation->victim->map == NULL) {
534  cf_log(llevError, "CFAnim: trigger for victim not on map or NULL.\n");
535  return mr_finished;
536  }
537 
538  map = animation->victim->map;
539 
540  /* locate objectlink for this connected value */
541  if (!map->buttons) {
542  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);
543  return mr_finished;
544  }
545  for (olp = map->buttons; olp; olp = olp->next) {
546  if (olp->value == id) {
547  ol = olp->link;
548  break;
549  }
550  }
551  if (ol == NULL) {
552  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);
553  return mr_finished;
554  }
555  /* run the object link */
556  cf_map_trigger_connected(ol, NULL, 1);
557 
558  return mr_finished;
559 }
560 
563  { "north", initmovement, runmovement },
564  { "north_east", initmovement, runmovement },
565  { "east", initmovement, runmovement },
566  { "south_east", initmovement, runmovement },
567  { "south", initmovement, runmovement },
568  { "south_west", initmovement, runmovement },
569  { "west", initmovement, runmovement },
570  { "north_west", initmovement, runmovement },
571  { "fire_north", initfire, runfire },
572  { "fire_north_east", initfire, runfire },
573  { "fire_east", initfire, runfire },
574  { "fire_south_east", initfire, runfire },
575  { "fire_south", initfire, runfire },
576  { "fire_south_west", initfire, runfire },
577  { "fire_west", initfire, runfire },
578  { "fire_north_west", initfire, runfire },
579  { "turn_north", initturn, runturn },
580  { "turn_north_east", initturn, runturn },
581  { "turn_east", initturn, runturn },
582  { "turn_south_east", initturn, runturn },
583  { "turn_south", initturn, runturn },
584  { "turn_south_west", initturn, runturn },
585  { "turn_west", initturn, runturn },
586  { "turn_north_west", initturn, runturn },
587  { "camera_north", initcamera, runcamera },
588  { "camera_north_east", initcamera, runcamera },
589  { "camera_east", initcamera, runcamera },
590  { "camera_south_east", initcamera, runcamera },
591  { "camera_south", initcamera, runcamera },
592  { "camera_south_west", initcamera, runcamera },
593  { "camera_west", initcamera, runcamera },
594  { "camera_north_west", initcamera, runcamera },
595  { "invisible", initvisible, runvisible },
596  { "wizard", initwizard, runwizard },
597  { "say", initsay, runsay },
598  { "apply", initapply, runapply },
599  { "apply_object", initapplyobject, runapplyobject },
600  { "drop_object", initdropobject, rundropobject },
601  { "pickup", initpickup, runpickup },
602  { "pickup_object", initpickupobject, runpickupobject },
603  { "ghosted", initghosted, runghosted },
604  { "teleport", initteleport, runteleport },
605  { "notice", initnotice, runnotice },
606  { "stop", initstop, runstop },
607  { "moveto", initmoveto, runmoveto },
608  { "message", initmessage, runmessage },
609  { "trigger", inittrigger, runtrigger }
610 };
611 
613 
614 static int ordered_commands = 0;
615 
616 static int compareAnims(const void *a, const void *b) {
617  return strcmp(((const CFanimationHook *)a)->name, ((const CFanimationHook *)b)->name);
618 }
619 
620 static void prepare_commands(void) {
622  ordered_commands = 1;
623 }
624 
626  CFanimationHook dummy;
627 
628  dummy.name = command;
629  if (!ordered_commands)
631  return (CFanimationHook *)bsearch(&dummy, animationbox, animationcount, sizeof(CFanimationHook), compareAnims);
632 }
633 
642 static CFmovement *parse_animation_block(char *buffer, size_t buffer_size, FILE *fichier, CFanimation *parent) {
643  CFmovement *first = NULL;
644  CFmovement *current = NULL;
645  CFmovement *next;
646  char *time;
647  char *name;
648  char *parameters;
649  int tick;
650  CFanimationHook *animationhook;
651 
652  if (parent->verbose)
653  cf_log(llevDebug, "CFAnim: In parse block for %s\n", buffer);
654  while (fgets(buffer, buffer_size, fichier)) {
655  if (buffer[0] == '[')
656  break;
657  if (buffer[0] == '#')
658  continue;
659  buffer[strlen(buffer)-strlen("\n")] = '\0';
660  while (buffer[strlen(buffer)-1] == ' ')
661  buffer[strlen(buffer)-1] = '\0';
662  if (strlen(buffer) <= 0)
663  continue;
664  time = buffer;
665 
666  name = strstr(buffer, " ");
667  if (!name)
668  continue;
669  *name = '\0';
670  name++;
671  while (*name == ' ')
672  name++;
673 
674  tick = atoi(time);
675  if (tick < 0)
676  continue;
677 
678  parameters = strstr(name, " ");
679  if (parameters) { /*Parameters may be nul*/
680  *parameters = '\0';
681  parameters++;
682  while (*parameters == ' ')
683  parameters++;
684  if (*parameters == '\0')
685  parameters = NULL;
686  }
687  animationhook = get_command(name);
688  if (!animationhook)
689  cf_log(llevError, "CFAnim: %s - Unknown animation command\n", name);
690  else if (parent->verbose) {
691  cf_log(llevDebug, "CFAnim: Parsed %s -> %p\n", name, animationhook);
692  }
693  if (!animationhook) {
694  if (parent->errors_allowed)
695  continue;
696  else
697  break;
698  }
699  next = (CFmovement *)malloc(sizeof(CFmovement));
700  if (!next)
701  continue;
702  next->parent = parent;
703  next->tick = tick;
704  next->next = NULL;
705  if (animationhook->funcinit)
706  next->id = animationhook->funcinit(name, parameters, next);
707  next->func = animationhook->funcrun;
708  if (current)
709  current->next = next;
710  else
711  first = next;
712  current = next;
713  }
714  return first;
715 }
716 
727 static int equality_split(char *buffer, char **variable, char **value) {
728  if (!strcmp(&buffer[strlen(buffer)-strlen("\n")], "\n"))
729  buffer[strlen(buffer)-strlen("\n")] = '\0';
730  *value = strstr(buffer, "=");
731  if (!*value)
732  return 0;
733  **value = '\0';
734  *variable = buffer;
735  (*value)++;
736  while ((strlen(*variable) > 0) && ((*variable)[strlen(*variable)-1] == ' '))
737  (*variable)[strlen(*variable)-1] = '\0';
738  while ((strlen(*value) > 0) && ((*value)[strlen(*value)-1] == ' '))
739  (*value)[strlen(*value)-1] = '\0';
740  while (**value == ' ')
741  (*value)++;
742  if ((**variable == '\0') || (**value == '\0'))
743  return 0;
744  return 1;
745 }
746 
758 static int get_boolean(const char *strg, int *bl) {
759  /*
760  * We're only parsing the first character, so we
761  * really don't need to call strncmp().
762  * Should future checks need to check multiple characters,
763  * strncmp() would be a good choice. For that reason,
764  * I won't optimize this down to a switch statement.
765  * It makes it clearer how to handle multi-character checks.
766  */
767  if (*strg == 'y')
768  *bl = 1;
769  else if (*strg == 'n')
770  *bl = 0;
771  else if (*strg == 'Y')
772  *bl = 1;
773  else if (*strg == 'N')
774  *bl = 0;
775  else if (*strg == '1')
776  *bl = 1;
777  else if (*strg == '0')
778  *bl = 0;
779  else
780  return 0;
781  return 1;
782 }
783 
789 static int is_animated_object(const object *ob) {
791 
792  for (current = first_animation; current; current = current->nextanimation)
793  if (current->victim == ob) {
794  return 1;
795  }
796  return 0;
797 }
798 
804  CFanimation *anim;
806 
807  anim = (CFanimation *)malloc(sizeof(CFanimation));
808  if (!anim)
809  return NULL;
810  anim->name = NULL;
811  anim->victim = NULL;
812  anim->event = NULL;
813  anim->nextmovement = NULL;
814  anim->nextanimation = NULL;
815  anim->delete_end = 0;
816  for (current = first_animation; (current && current->nextanimation); current = current->nextanimation)
817  ;
818  if (!current)
820  else
821  current->nextanimation = anim;
822  return anim;
823 }
824 
825 static object *find_by_name(object *origin, const char *name) {
826  int x, y, w, h;
827  mapstruct *map;
828  const char *sname;
829 
830  sname = cf_find_string(name);
831  if (!sname)
832  return NULL;
833 
834  while (origin && !origin->map)
835  origin = origin->env;
836 
837  if (!origin || !origin->map)
838  return NULL;
839 
840  map = origin->map;
841 
842  w = cf_map_get_width(map);
843  h = cf_map_get_height(map);
844 
845  for (x = 0; x < w; x++) {
846  for (y = 0; y < h; y++) {
847  FOR_MAP_PREPARE(map, x, y, ob) {
848  if (/*cf_object_get_sstring_property(ob, CFAPI_OBJECT_PROP_NAME)*/ob->name == sname)
849  return ob;
850  } FOR_MAP_FINISH();
851  }
852  }
853 
854  return NULL;
855 }
856 
868 static int start_animation(object *who, object *activator, object *event, const char *file, const char *message) {
869  FILE *fichier;
870  char *name = NULL;
871  int victimtype = 0;
872  object *victim = NULL;
873  int unique = 0;
874  int always_delete = 0;
875  int delete_end = 0;
876  int parallel = 0;
877  int paralyzed = 1;
878  int invisible = 0;
879  int wizard = 0;
880  enum time_enum timetype = time_second;
881  int errors_allowed = 0;
882  int verbose = 0;
883  const char *animationitem = NULL;
884  char buffer[HUGE_BUF];
885  char *variable;
886  char *value;
887  int errors_found = 0;
888  CFanimation *current_anim;
889 
890  fichier = fopen(file, "r");
891  if (fichier == NULL) {
892  cf_log(llevDebug, "CFAnim: Unable to open %s\n", file);
893  return 0;
894  }
895  while (fgets(buffer, HUGE_BUF, fichier)) {
896  if (buffer[0] == '[')
897  break;
898  if (buffer[0] == '#')
899  continue;
900  if (!strcmp(buffer, "\n"))
901  continue;
902  errors_found = 1;
903  cf_log(llevError, "CFAnim: '%s' has an invalid syntax.\n", buffer);
904  }
905  if (feof(fichier)) {
906  fclose(fichier);
907  return 0;
908  }
909  if (strncmp(buffer, "[Config]", 8)) {
910  cf_log(llevError, "CFAnim: Fatal error in %s: [Config] must be the first group defined.\n", file);
911  fclose(fichier);
912  return 0;
913  }
914  while (fgets(buffer, HUGE_BUF, fichier)) {
915  if (buffer[0] == '[')
916  break;
917  if (buffer[0] == '#')
918  continue;
919  if (!strcmp(buffer, "\n"))
920  continue;
921  if (!equality_split(buffer, &variable, &value))
922  errors_found = 1;
923  else {
924  if (!strcmp(variable, "name")) {
925  if (*value == '"')
926  value++;
927  if (value[strlen(value)-1] == '"')
928  value[strlen(value)-1] = '\0';
930  } else if (!strcmp(variable, "victimtype")) {
931  if (!strcmp(value, "player"))
932  victimtype = 0;
933  else if (!strcmp(value, "object"))
934  victimtype = 1;
935  else if (!strcmp(value, "any"))
936  victimtype = 2;
937  else if (!strcmp(value, "byname"))
938  victimtype = 3;
939  else
940  errors_found = 1;
941  } else if (!strcmp(variable, "victim")) {
942  cf_log(llevDebug, "CFAnim: Setting victim to %s\n", value);
943  if (!strcmp(value, "who"))
944  victim = who;
945  else if (!strcmp(value, "activator"))
946  victim = activator;
947  else if (!strcmp(value, "who_owner"))
948  if (!who) {
949  errors_found = 1;
950  cf_log(llevError, "CFAnim: Warning: object \"who\" doesn't exist and you're victimized it's owner\n");
951  } else
952  victim = who->env;
953  else if (!strcmp(value, "activator_owner"))
954  if (!activator) {
955  errors_found = 1;
956  cf_log(llevError, "CFAnim: Warning: object \"activator\" doesn't exist and you're victimized it's owner\n");
957  } else
958  victim = activator->env;
959  else if (victimtype == 3) {
961  } else
962  errors_found = 1;
963  } else if (!strcmp(variable, "unique")) {
964  if (!get_boolean(value, &unique))
965  errors_found = 1;
966  } else if (!strcmp(variable, "always_delete")) {
967  if (!get_boolean(value, &always_delete))
968  errors_found = 1;
969  } else if (!strcmp(variable, "delete_event_end")) {
970  if (!get_boolean(value, &delete_end))
971  errors_found = 1;
972  } else if (!strcmp(variable, "parallel")) {
973  if (!get_boolean(value, &parallel))
974  errors_found = 1;
975  } else if (!strcmp(variable, "paralyzed")) {
976  if (!get_boolean(value, &paralyzed))
977  errors_found = 1;
978  } else if (!strcmp(variable, "invisible")) {
979  if (!get_boolean(value, &invisible))
980  errors_found = 1;
981  } else if (!strcmp(variable, "wizard")) {
982  if (!get_boolean(value, &wizard))
983  errors_found = 1;
984  } else if (!strcmp(variable, "errors_allowed")) {
985  if (!get_boolean(value, &errors_allowed))
986  errors_found = 1;
987  } else if (!strcmp(variable, "verbose")) {
988  if (!get_boolean(value, &verbose))
989  errors_found = 1;
990  } else if (!strcmp(variable, "time_representation")) {
991  if (!strcmp(value, "second"))
992  timetype = time_second;
993  else if (!strcmp(value, "tick"))
994  timetype = time_tick;
995  else
996  errors_found = 1;
997  } else if (!strcmp(variable, "animation")) {
998  animationitem = cf_add_string(value);
999  } else
1000  errors_found = 1;
1001  }
1002  }
1003 
1004  if (message && message[0] != '\0') {
1005  cf_free_string(animationitem);
1006  animationitem = cf_add_string(message);
1007  }
1008 
1009  if (buffer[0] == '\0') {
1010  if (animationitem)
1011  cf_free_string(animationitem);
1012  cf_log(llevError, "CFAnim: Errors occurred during the parsing of %s\n", file);
1013  fclose(fichier);
1014  return 0;
1015  }
1016  if (!animationitem) {
1017  cf_log(llevError, "CFAnim: no animation specified when using %s\n", file);
1018  fclose(fichier);
1019  return 0;
1020  }
1021  if (!victim) {
1022  if (animationitem)
1023  cf_free_string(animationitem);
1024  cf_log(llevError, "CFAnim: Fatal error - victim is NULL");
1025  fclose(fichier);
1026  return 0;
1027  }
1028  if (!(current_anim = create_animation())) {
1029  if (animationitem)
1030  cf_free_string(animationitem);
1031  cf_log(llevError, "CFAnim: Fatal error - Not enough memory.\n");
1032  fclose(fichier);
1033  return 0;
1034  }
1035  if (always_delete) {
1036  /*if (verbose) printf("CFAnim: Freeing event nr. %d for %s.\n", current_event, who->name);*/
1038  event = NULL;
1039  }
1040  if (((victim->type == PLAYER) && (victimtype == 1))
1041  || ((victim->type != PLAYER) && (victimtype == 0))
1042  || (errors_found && !errors_allowed)) {
1043  if (verbose)
1044  cf_log(llevError, "CFAnim: No correct victim found or errors found, aborting.\n");
1045  if (animationitem)
1046  cf_free_string(animationitem);
1047  free(current_anim);
1048  fclose(fichier);
1049  return 0;
1050  }
1051  if (unique && !always_delete) {
1052  /*if (verbose) printf("CFAnim: Freeing event nr. %d for %s.\n", current_event, who->name);*/
1054  event = NULL;
1055  }
1056  current_anim->name = name;
1057  current_anim->victim = victim;
1058  current_anim->event = event;
1059  current_anim->paralyze = paralyzed;
1060  current_anim->invisible = invisible;
1061  current_anim->wizard = wizard;
1062  current_anim->unique = unique;
1063  current_anim->delete_end = delete_end;
1064  current_anim->ghosted = 0;
1065  current_anim->corpse = NULL;
1066  current_anim->time_representation = timetype;
1067  current_anim->verbose = verbose;
1068  current_anim->tick_left = 0;
1069  current_anim->errors_allowed = errors_allowed;
1070 
1071  while (buffer[0] == '[') {
1072  while (strncmp(&buffer[1], animationitem, strlen(animationitem))) {
1073  while ((value = fgets(buffer, HUGE_BUF, fichier)) != NULL)
1074  if (buffer[0] == '[')
1075  break;
1076  if (value == NULL) {
1077  cf_log(llevError, "CFAnim: no matching animation %s in file.\n", animationitem);
1078  cf_free_string(animationitem);
1079  fclose(fichier);
1080  return 0;
1081  }
1082  }
1083  current_anim->nextmovement = parse_animation_block(buffer, HUGE_BUF, fichier, current_anim);
1084  if (current_anim->nextmovement)
1085  break;
1086  }
1087  fclose(fichier);
1088  return 1;
1089 }
1090 
1096 static void animate_one(CFanimation *animation, long int milliseconds) {
1098  int mult = 1;
1100 
1101  if (animation->time_representation == time_second) {
1102  animation->tick_left += milliseconds;
1103  mult = 1000;
1104  } else
1105  animation->tick_left++;
1106 
1107  if (animation->verbose)
1108  cf_log(llevDebug, "CFAnim: Ticking %s for %s. Tickleft is %ld\n", animation->name, animation->victim->name, animation->tick_left);
1109  if (animation->invisible)
1110  animation->victim->invisible = 10;
1111  if (animation->wizard && animation->victim->type == PLAYER) {
1112  /* setting FLAG_WIZ *on non player leads to issues, as many functions expect contr to not be NULL in this case. */
1113  if (animation->verbose)
1114  cf_log(llevDebug, "CFAnim: Setting wizard flags\n");
1115  cf_object_set_flag(animation->victim, FLAG_WIZPASS, 1);
1116  cf_object_set_flag(animation->victim, FLAG_WIZCAST, 1);
1117  cf_object_set_flag(animation->victim, FLAG_WIZ, 1);
1118  if (animation->verbose)
1119  cf_log(llevDebug, "CFAnim: Setting wizard flags done\n");
1120 
1121  }
1122  if (animation->paralyze)
1123  animation->victim->speed_left = -99999;
1124 
1125  cf_object_update(animation->victim, UP_OBJ_CHANGE);
1126 
1127  if (animation->nextmovement)
1128  while (animation->tick_left > animation->nextmovement->tick*mult) {
1129  animation->tick_left -= animation->nextmovement->tick*mult;
1130  result = animation->nextmovement->func(animation, animation->nextmovement->id, animation->nextmovement->parameters);
1131  if (result == mr_again)
1132  continue;
1133 
1134  current = animation->nextmovement;
1135  animation->nextmovement = animation->nextmovement->next;
1136  free(current);
1137  if (!animation->nextmovement)
1138  break;
1139  }
1140  cf_object_set_flag(animation->victim, FLAG_WIZPASS, 0);
1141  cf_object_set_flag(animation->victim, FLAG_WIZCAST, 0);
1142  cf_object_set_flag(animation->victim, FLAG_WIZ, 0);
1143 }
1144 
1149 long usec_elapsed(struct timespec first, struct timespec second) {
1150  time_t sec_elapsed = second.tv_sec - first.tv_sec;
1151  long nsec_elapsed = second.tv_nsec - first.tv_nsec;
1152  return (sec_elapsed * 1e6) + (nsec_elapsed / 1e3);
1153 }
1154 
1158 static void animate(void) {
1160  CFanimation *next;
1161  CFanimation *previous_anim = NULL;
1162  struct timespec now;
1163  static struct timespec yesterday;
1164  static int already_passed = 0;
1165  long int delta_milli;
1166 
1167  clock_gettime(CLOCK_MONOTONIC, &now);
1168  if (!already_passed) {
1169  already_passed = 1;
1170  yesterday = now;
1171  return;
1172  }
1173  delta_milli = usec_elapsed(yesterday, now) / 1e3;
1174  /*printf("Working for %ld milli seconds\n", delta_milli);*/
1175  yesterday = now;
1176  for (current = first_animation; current; current = current->nextanimation)
1177  animate_one(current, delta_milli);
1179  while (current) {
1180  if (!current->nextmovement) {
1181  if (current->paralyze)
1182  current->victim->speed_left = current->victim->speed;
1183  next = current->nextanimation;
1184  if (first_animation == current)
1186  else {
1187  previous_anim->nextanimation = next;
1188  }
1189  if (current->delete_end && current->event != NULL)
1190  cf_object_remove(current->event);
1191  free(current->name);
1192  free(current);
1193  current = next;
1194  } else {
1195  previous_anim = current;
1196  current = current->nextanimation;
1197  }
1198  }
1199 }
1200 
1207 extern "C"
1208 CF_PLUGIN int initPlugin(const char *iversion, f_plug_api gethooksptr) {
1209  (void)iversion;
1210  cf_init_plugin(gethooksptr);
1211  cf_log(llevDebug, "CFAnim 2.0a init\n");
1212 
1213  /* Place your initialization code here */
1214  return 0;
1215 }
1216 
1217 extern "C"
1219  va_list args;
1220  const char *propname;
1221  char *buf;
1222  int size;
1223 
1224  va_start(args, type);
1225  propname = va_arg(args, const char *);
1226 
1227  if (!strcmp(propname, "Identification")) {
1228  buf = va_arg(args, char *);
1229  size = va_arg(args, int);
1230  va_end(args);
1231  snprintf(buf, size, PLUGIN_NAME);
1232  return NULL;
1233  } else if (!strcmp(propname, "FullName")) {
1234  buf = va_arg(args, char *);
1235  size = va_arg(args, int);
1236  va_end(args);
1237  snprintf(buf, size, PLUGIN_VERSION);
1238  return NULL;
1239  }
1240  va_end(args);
1241  return NULL;
1242 }
1243 
1244 extern "C"
1246  (void)op;
1247  (void)params;
1248  return mr_finished;
1249 }
1250 
1251 extern "C"
1253  cf_log(llevDebug, "CFAnim 2.0a post init\n");
1254  /* Pick the global events you want to monitor from this plugin */
1256  return 0;
1257 }
1258 
1259 extern "C"
1261  va_list args;
1262  int rv = 0;
1263  int event_code;
1264 
1265  va_start(args, type);
1266  event_code = va_arg(args, int);
1267  assert(event_code == EVENT_CLOCK);
1268 
1269  animate();
1270 
1271  va_end(args);
1272 
1273  return rv;
1274 }
1275 
1276 extern "C"
1277 CF_PLUGIN int eventListener(int *type, ...) {
1278  int rv = 0;
1279  va_list args;
1280  char *buf, message[MAX_BUF], script[MAX_BUF];
1281  object *who, *activator/*, *third*/, *event;
1282  int query;
1283 
1284  va_start(args, type);
1285 
1286  who = va_arg(args, object *);
1287  activator = va_arg(args, object *);
1288  /*third =*/ va_arg(args, object *);
1289  buf = va_arg(args, char *);
1290 
1291  if (buf != NULL) {
1292  snprintf(message, sizeof(message), "%s", buf);
1293  } else {
1294  message[0] = '\0';
1295  }
1296 
1297  query = va_arg(args, int); /* 'fix', ignored */
1298  event = va_arg(args, object *);
1299 
1300  if (query == 1 && strcmp(message, "query_object_is_animated") == 0) {
1301  rv = is_animated_object(who);
1302  va_end(args);
1303  return rv;
1304  }
1305 
1307  cf_get_maps_directory(event->slaying, script, sizeof(script));
1308  va_end(args);
1309 
1310  /* Put your plugin action(s) here */
1311  if (activator != NULL) {
1312  cf_log(llevDebug, "CFAnim: %s called animator script %s\n", activator->name, script);
1313  } else if (who != NULL) {
1314  activator = who;
1315  cf_log(llevDebug, "CFAnim: %s called animator script %s\n", who->name, script);
1316  }
1317 
1318  rv = start_animation(who, activator, event, script, message);
1319 
1320  return rv;
1321 }
1322 
1323 extern "C"
1325  cf_log(llevDebug, "CFAnim 2.0a closing\n");
1326  return 0;
1327 }
CFanimationHook
Definition: cfanim.h:88
mr_again
@ mr_again
Definition: cfanim.h:47
give.next
def next
Definition: give.py:44
animate_one
static void animate_one(CFanimation *animation, long int milliseconds)
Definition: cfanim.cpp:1096
PLAYER
@ PLAYER
Definition: object.h:112
initsay
static long int initsay(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:194
cf_log
void cf_log(LogLevel logLevel, const char *format,...)
Definition: plugin_common.cpp:1522
cf_map_get_height
int cf_map_get_height(mapstruct *map)
Definition: plugin_common.cpp:1404
cf_add_string
sstring cf_add_string(const char *str)
Definition: plugin_common.cpp:1167
FOR_MAP_FINISH
#define FOR_MAP_FINISH()
Definition: define.h:730
cf_map_get_sstring_property
sstring cf_map_get_sstring_property(mapstruct *map, int propcode)
Definition: plugin_common.cpp:270
AP_APPLY
#define AP_APPLY
Definition: define.h:574
llevError
@ llevError
Definition: logger.h:11
CFanimation::corpse
object * corpse
Definition: cfanim.h:80
cf_object_teleport
int cf_object_teleport(object *ob, mapstruct *map, int x, int y)
Definition: plugin_common.cpp:1360
cf_object_apply_below
void cf_object_apply_below(object *pl)
Definition: plugin_common.cpp:553
runsay
static anim_move_result runsay(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:205
eventListener
CF_PLUGIN int eventListener(int *type,...)
Definition: cfanim.cpp:1277
diamondslots.x
x
Definition: diamondslots.py:15
time_enum
time_enum
Definition: cfanim.h:39
CFanimation::paralyze
int paralyze
Definition: cfanim.h:72
cfanim_runPluginCommand
CF_PLUGIN anim_move_result cfanim_runPluginCommand(object *op, char *params)
Definition: cfanim.cpp:1245
oblinkpt::next
oblinkpt * next
Definition: object.h:472
NDI_GREEN
#define NDI_GREEN
Definition: newclient.h:252
initapply
static long int initapply(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:215
prepare_commands
static void prepare_commands(void)
Definition: cfanim.cpp:620
ordered_commands
static int ordered_commands
Definition: cfanim.cpp:614
runmoveto
static anim_move_result runmoveto(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:475
initmoveto
static long int initmoveto(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:459
runghosted
static anim_move_result runghosted(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:336
cf_strdup_local
char * cf_strdup_local(const char *str)
Definition: plugin_common.cpp:1446
disinfect.a
a
Definition: disinfect.py:13
initwizard
static long int initwizard(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:175
FOR_BELOW_PREPARE
#define FOR_BELOW_PREPARE(op_, it_)
Definition: define.h:704
object::invisible
int16_t invisible
Definition: object.h:370
closePlugin
CF_PLUGIN int closePlugin(void)
Definition: cfanim.cpp:1324
object::x
int16_t x
Definition: object.h:335
object::speed_left
float speed_left
Definition: object.h:338
SVN_REV
#define SVN_REV
Definition: svnversion.h:2
runwizard
static anim_move_result runwizard(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:186
object::map
struct mapstruct * map
Definition: object.h:305
guildjoin.ob
ob
Definition: guildjoin.py:42
param_moveto
Definition: cfanim.cpp:455
cf_object_apply
int cf_object_apply(object *op, object *author, int flags)
Definition: plugin_common.cpp:542
mad_mage_user.file
file
Definition: mad_mage_user.py:15
CFmovement::tick
int tick
Definition: cfanim.h:63
cf_object_move_to
int cf_object_move_to(object *op, int x, int y)
Definition: plugin_common.cpp:630
cf_object_free_drop_inventory
void cf_object_free_drop_inventory(object *ob)
Definition: plugin_common.cpp:571
FLAG_WIZCAST
#define FLAG_WIZCAST
Definition: define.h:289
cf_find_string
sstring cf_find_string(const char *str)
Definition: plugin_common.cpp:1189
initnotice
static long int initnotice(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:423
NDI_NAVY
#define NDI_NAVY
Definition: newclient.h:247
oblinkpt
Definition: object.h:469
cf_player_move
int cf_player_move(player *pl, int dir)
Definition: plugin_common.cpp:524
runteleport
static anim_move_result runteleport(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:412
mr_finished
@ mr_finished
Definition: cfanim.h:46
initteleport
static long int initteleport(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:372
buf
StringBuffer * buf
Definition: readable.cpp:1565
get_boolean
static int get_boolean(const char *strg, int *bl)
Definition: cfanim.cpp:758
find_by_name
static object * find_by_name(object *origin, const char *name)
Definition: cfanim.cpp:825
HUGE_BUF
#define HUGE_BUF
Definition: define.h:37
initvisible
static long int initvisible(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:156
rundropobject
static anim_move_result rundropobject(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:274
CFanimation::tick_left
long int tick_left
Definition: cfanim.h:81
FOR_BELOW_FINISH
#define FOR_BELOW_FINISH()
Definition: define.h:711
CFmovement::id
long int id
Definition: cfanim.h:62
object::y
int16_t y
Definition: object.h:335
autojail.who
who
Definition: autojail.py:3
CFanimationHook::funcrun
CFAnimRunFunc funcrun
Definition: cfanim.h:91
runtrigger
static anim_move_result runtrigger(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:527
object::contr
struct player * contr
Definition: object.h:284
teleport
int teleport(object *teleporter, uint8_t tele_type, object *user)
Definition: move.cpp:204
start_animation
static int start_animation(object *who, object *activator, object *event, const char *file, const char *message)
Definition: cfanim.cpp:868
CFanimation::wizard
int wizard
Definition: cfanim.h:74
disinfect.map
map
Definition: disinfect.py:4
oblinkpt::link
objectlink * link
Definition: object.h:470
EVENT_CLOCK
#define EVENT_CLOCK
Definition: events.h:40
cf_object_say
void cf_object_say(object *op, const char *msg)
Definition: plugin_common.cpp:1049
diamondslots.activator
activator
Definition: diamondslots.py:10
make_face_from_files.args
args
Definition: make_face_from_files.py:37
rotate-tower.result
bool result
Definition: rotate-tower.py:13
CF_PLUGIN
#define CF_PLUGIN
Definition: plugin_common.h:38
initfire
static long int initfire(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:94
cf_map_insert_object_there
object * cf_map_insert_object_there(object *op, mapstruct *m, object *originator, int flag)
Definition: plugin_common.cpp:1315
f_plug_api
void(* f_plug_api)(int *type,...)
Definition: plugin.h:79
is_animated_object
static int is_animated_object(const object *ob)
Definition: cfanim.cpp:789
SvnRevPlugin
CF_PLUGIN char SvnRevPlugin[]
Definition: cfanim.cpp:40
sword_of_souls.victim
victim
Definition: sword_of_souls.py:12
CFmovement::parameters
void * parameters
Definition: cfanim.h:61
runpickup
static anim_move_result runpickup(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:293
FOR_OB_AND_BELOW_FINISH
#define FOR_OB_AND_BELOW_FINISH()
Definition: define.h:754
oblinkpt::value
long value
Definition: object.h:471
cf_init_plugin
int cf_init_plugin(f_plug_api getHooks)
Definition: plugin_common.cpp:146
object::below
object * below
Definition: object.h:295
first_animation
static CFanimation * first_animation
Definition: cfanim.cpp:42
PLUGIN_NAME
#define PLUGIN_NAME
Definition: cfanim.h:32
compareAnims
static int compareAnims(const void *a, const void *b)
Definition: cfanim.cpp:616
CFanimation::nextmovement
CFmovement * nextmovement
Definition: cfanim.h:83
CFanimation::errors_allowed
int errors_allowed
Definition: cfanim.h:78
get_dir_from_name
static int get_dir_from_name(const char *name)
Definition: cfanim.cpp:51
runpickupobject
static anim_move_result runpickupobject(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:311
time_tick
@ time_tick
Definition: cfanim.h:41
initmovement
static long int initmovement(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:71
equality_split
static int equality_split(char *buffer, char **variable, char **value)
Definition: cfanim.cpp:727
Ice.b
b
Definition: Ice.py:48
guild_questpoints_apply.mapname
mapname
Definition: guild_questpoints_apply.py:8
object::type
uint8_t type
Definition: object.h:348
cf_object_clone
object * cf_object_clone(object *op, int clonetype)
Definition: plugin_common.cpp:683
CFanimation::invisible
int invisible
Definition: cfanim.h:73
CFAPI_MAP_PROP_PATH
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:247
param_moveto::y
int y
Definition: cfanim.cpp:456
CFanimation::unique
int unique
Definition: cfanim.h:75
inittrigger
static long int inittrigger(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:515
FLAG_WIZPASS
#define FLAG_WIZPASS
Definition: define.h:314
CFanimation::verbose
int verbose
Definition: cfanim.h:76
initmessage
static long int initmessage(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:496
cf_map_message
void cf_map_message(mapstruct *m, const char *msg, int color)
Definition: plugin_common.cpp:667
animate.anim
string anim
Definition: animate.py:20
devourers.command
command
Definition: devourers.py:16
FOR_OB_AND_BELOW_PREPARE
#define FOR_OB_AND_BELOW_PREPARE(op_)
Definition: define.h:750
runnotice
static anim_move_result runnotice(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:428
cf_object_drop
void cf_object_drop(object *op, object *author)
Definition: plugin_common.cpp:1043
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
teleport_params
Definition: cfanim.cpp:366
CFmovement::next
CFmovement * next
Definition: cfanim.h:64
getPluginProperty
CF_PLUGIN void * getPluginProperty(int *type,...)
Definition: cfanim.cpp:1218
runmovement
static anim_move_result runmovement(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:80
cf_free_string
void cf_free_string(sstring str)
Definition: plugin_common.cpp:1182
anim_move_result
anim_move_result
Definition: cfanim.h:45
MAX_BUF
#define MAX_BUF
Definition: define.h:35
cf_object_find_by_name
object * cf_object_find_by_name(const object *who, const char *name)
Definition: plugin_common.cpp:605
cf_object_pickup
void cf_object_pickup(object *op, object *what)
Definition: plugin_common.cpp:1434
initdropobject
static long int initdropobject(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:267
initapplyobject
static long int initapplyobject(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:236
runapplyobject
static anim_move_result runapplyobject(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:242
FOR_MAP_PREPARE
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Definition: define.h:723
time_second
@ time_second
Definition: cfanim.h:40
CFanimation::time_representation
enum time_enum time_representation
Definition: cfanim.h:82
PLUGIN_VERSION
#define PLUGIN_VERSION
Definition: cfanim.h:33
cf_object_move
int cf_object_move(object *op, int dir, object *originator)
Definition: plugin_common.cpp:531
diamondslots.message
string message
Definition: diamondslots.py:57
CFmovement::func
CFAnimRunFunc func
Definition: cfanim.h:60
create_animation
static CFanimation * create_animation(void)
Definition: cfanim.cpp:803
cf_system_register_global_event
void cf_system_register_global_event(int event, const char *name, f_plug_event hook)
Definition: plugin_common.cpp:1102
FLAG_WIZ
#define FLAG_WIZ
Definition: define.h:231
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:265
object::name
sstring name
Definition: object.h:319
filter.parameters
parameters
Definition: filter.py:41
cf_map_trigger_connected
void cf_map_trigger_connected(objectlink *ol, object *cause, int state)
Definition: plugin_common.cpp:1028
CFanimation::ghosted
int ghosted
Definition: cfanim.h:77
runstop
static anim_move_result runstop(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:446
mapstruct
Definition: map.h:313
cf_object_set_flag
void cf_object_set_flag(object *ob, int flag, int value)
Definition: plugin_common.cpp:1288
CFmovement
Definition: cfanim.h:58
object::env
object * env
Definition: object.h:301
postInitPlugin
CF_PLUGIN int postInitPlugin(void)
Definition: cfanim.cpp:1252
sstring
const typedef char * sstring
Definition: sstring.h:2
give.op
op
Definition: give.py:33
autojail.value
value
Definition: autojail.py:6
CFmovement::parent
struct CFanimation * parent
Definition: cfanim.h:59
animationcount
int animationcount
Definition: cfanim.cpp:612
initpickup
static long int initpickup(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:286
convert.dest
dest
Definition: convert.py:25
teleport_params::mapy
int mapy
Definition: cfanim.cpp:369
cfanim.h
CFanimation::victim
object * victim
Definition: cfanim.h:70
roll-o-matic.params
params
Definition: roll-o-matic.py:193
get_command
static CFanimationHook * get_command(char *command)
Definition: cfanim.cpp:625
diamondslots.y
y
Definition: diamondslots.py:16
cf_get_maps_directory
char * cf_get_maps_directory(const char *name, char *buf, int size)
Definition: plugin_common.cpp:1069
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
CFanimation::nextanimation
CFanimation * nextanimation
Definition: cfanim.h:84
runturn
static anim_move_result runturn(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:120
teleport_params::mapx
int mapx
Definition: cfanim.cpp:368
runapply
static anim_move_result runapply(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:222
cfanim_globalEventListener
CF_PLUGIN int cfanim_globalEventListener(int *type,...)
Definition: cfanim.cpp:1260
initstop
static long int initstop(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:438
runfire
static anim_move_result runfire(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:104
runvisible
static anim_move_result runvisible(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:167
initturn
static long int initturn(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:111
CFanimationHook::funcinit
CFAnimInitFunc funcinit
Definition: cfanim.h:90
object::container
object * container
Definition: object.h:299
param_moveto::x
int x
Definition: cfanim.cpp:456
UP_OBJ_CHANGE
#define UP_OBJ_CHANGE
Definition: object.h:532
CFanimation::event
object * event
Definition: cfanim.h:71
animate.event
event
DIALOGCHECK MINARGS 1 MAXARGS 2
Definition: animate.py:17
cf_player_message
void cf_player_message(object *op, const char *txt, int flags)
Definition: plugin_common.cpp:787
initcamera
static long int initcamera(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:134
cf_map_get_map
mapstruct * cf_map_get_map(const char *name, int flags)
Definition: plugin_common.cpp:935
animate
static void animate(void)
Definition: cfanim.cpp:1158
initpickupobject
static long int initpickupobject(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:305
connection
Definition: connection.py:1
cf_object_update
void cf_object_update(object *op, int flags)
Definition: plugin_common.cpp:1428
teleport_params::mapname
char * mapname
Definition: cfanim.cpp:367
CFanimation
Definition: cfanim.h:68
svnversion.h
cf_object_remove
void cf_object_remove(object *op)
Definition: plugin_common.cpp:562
replace.current
current
Definition: replace.py:64
CFanimation::name
char * name
Definition: cfanim.h:69
parse_animation_block
static CFmovement * parse_animation_block(char *buffer, size_t buffer_size, FILE *fichier, CFanimation *parent)
Definition: cfanim.cpp:642
cf_map_get_width
int cf_map_get_width(mapstruct *map)
Definition: plugin_common.cpp:1400
initPlugin
CF_PLUGIN int initPlugin(const char *iversion, f_plug_api gethooksptr)
Definition: cfanim.cpp:1208
runcamera
static anim_move_result runcamera(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:144
animationbox
CFanimationHook animationbox[]
Definition: cfanim.cpp:562
llevDebug
@ llevDebug
Definition: logger.h:13
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
give.name
name
Definition: give.py:27
CFanimation::delete_end
int delete_end
Definition: cfanim.h:79
runmessage
static anim_move_result runmessage(CFanimation *animation, long int id, void *parameters)
Definition: cfanim.cpp:505
initghosted
static long int initghosted(const char *name, char *parameters, CFmovement *move_entity)
Definition: cfanim.cpp:325
CFanimationHook::name
const char * name
Definition: cfanim.h:89
usec_elapsed
long usec_elapsed(struct timespec first, struct timespec second)
Definition: cfanim.cpp:1149
diamondslots.id
id
Definition: diamondslots.py:53