Crossfire Server, Trunk  R20513
Data Structures | Functions | Variables
cfanim.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "cfanim.h"
#include "svnversion.h"
Include dependency graph for cfanim.c:

Go to the source code of this file.

Data Structures

struct  param_moveto
 Destination for moveto command. More...
 
struct  teleport_params
 

Functions

static void animate (void)
 Animates all currently running animations. More...
 
static void animate_one (CFanimation *animation, long int milliseconds)
 Checks if an animation can execute one or more moves, and if so does them. More...
 
CF_PLUGIN int cfanim_globalEventListener (int *type,...)
 
CF_PLUGIN anim_move_result cfanim_runPluginCommand (object *op, char *params)
 
CF_PLUGIN int closePlugin (void)
 
static int compareAnims (const void *a, const void *b)
 
static CFanimationcreate_animation (void)
 Create a new animation. More...
 
static int equality_split (char *buffer, char **variable, char **value)
 This function take buffer with a value like "blabla= things" and extracts some things. More...
 
CF_PLUGIN int eventListener (int *type,...)
 
static objectfind_by_name (object *origin, const char *name)
 
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's read if return value is true, strg was set successfully else, an error occured and bl was not touched. More...
 
static CFanimationHookget_command (char *command)
 
static int get_dir_from_name (const char *name)
 Returns the direction from its name. More...
 
CF_PLUGIN void * getPluginProperty (int *type,...)
 
static long int initapply (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initapplyobject (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initcamera (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initdropobject (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initfire (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initghosted (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initmessage (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initmovement (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initmoveto (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initnotice (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initpickup (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initpickupobject (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
CF_PLUGIN int initPlugin (const char *iversion, f_plug_api gethooksptr)
 Plugin initialisation function. More...
 
static long int initsay (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initstop (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initteleport (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int inittrigger (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initturn (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initvisible (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static long int initwizard (const char *name, char *parameters, struct CFmovement_struct *move_entity)
 
static int is_animated_object (const object *ob)
 Is specified object currently being animated? More...
 
static CFmovementparse_animation_block (char *buffer, size_t buffer_size, FILE *fichier, CFanimation *parent)
 Parse an animation block in the animation file. More...
 
CF_PLUGIN int postInitPlugin (void)
 
static void prepare_commands (void)
 
static anim_move_result runapply (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runapplyobject (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runcamera (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result rundropobject (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runfire (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runghosted (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runmessage (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runmovement (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runmoveto (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runnotice (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runpickup (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runpickupobject (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runsay (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runstop (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runteleport (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runtrigger (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runturn (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runvisible (struct CFanimation_struct *animation, long int id, void *parameters)
 
static anim_move_result runwizard (struct CFanimation_struct *animation, long int id, void *parameters)
 
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) More...
 
long usec_elapsed (struct timespec first, struct timespec second)
 Return the number of microseconds between two timespec structures. More...
 

Variables

CFanimationHook animationbox []
 Available animation commands. More...
 
int animationcount = sizeof(animationbox)/sizeof(CFanimationHook)
 
static CFanimationfirst_animation = NULL
 Animations we're currently processing. More...
 
static int ordered_commands = 0
 
CF_PLUGIN char SvnRevPlugin [] = SVN_REV
 

Function Documentation

static void animate ( void  )
static

Animates all currently running animations.

Definition at line 1108 of file cfanim.c.

References animate_one(), cf_object_remove(), CFanimation_struct::delete_end, CFanimation_struct::event, first_animation, CFanimation_struct::name, CFanimation_struct::nextanimation, CFanimation_struct::nextmovement, CFanimation_struct::paralyze, obj::speed, obj::speed_left, usec_elapsed(), and CFanimation_struct::victim.

Referenced by cfanim_globalEventListener().

Here is the call graph for this function:

Here is the caller graph for this function:

static void animate_one ( CFanimation animation,
long int  milliseconds 
)
static

Checks if an animation can execute one or more moves, and if so does them.

Parameters
animationanimation to check
millisecondstime elapsed since the last time this function was called.

Definition at line 1046 of file cfanim.c.

References cf_log(), cf_object_set_flag(), cf_object_update(), FLAG_WIZ, FLAG_WIZCAST, FLAG_WIZPASS, CFmovement_struct::func, CFmovement_struct::id, CFanimation_struct::invisible, obj::invisible, llevDebug, mr_again, CFanimation_struct::name, obj::name, CFmovement_struct::next, CFanimation_struct::nextmovement, CFanimation_struct::paralyze, CFmovement_struct::parameters, PLAYER, obj::speed_left, CFmovement_struct::tick, CFanimation_struct::tick_left, CFanimation_struct::time_representation, time_second, obj::type, UP_OBJ_CHANGE, CFanimation_struct::verbose, CFanimation_struct::victim, and CFanimation_struct::wizard.

Referenced by animate().

Here is the call graph for this function:

Here is the caller graph for this function:

CF_PLUGIN int cfanim_globalEventListener ( int *  type,
  ... 
)

Definition at line 1202 of file cfanim.c.

References animate(), and EVENT_CLOCK.

Referenced by postInitPlugin().

Here is the call graph for this function:

Here is the caller graph for this function:

CF_PLUGIN anim_move_result cfanim_runPluginCommand ( object op,
char *  params 
)

Definition at line 1191 of file cfanim.c.

CF_PLUGIN int closePlugin ( void  )

Definition at line 1264 of file cfanim.c.

static int compareAnims ( const void *  a,
const void *  b 
)
static

Definition at line 566 of file cfanim.c.

Referenced by get_command(), and prepare_commands().

Here is the caller graph for this function:

static CFanimation* create_animation ( void  )
static

Create a new animation.

Returns
new animation pointer inserted in the list of animations.

Definition at line 753 of file cfanim.c.

References CFanimation_struct::name, and CFanimation_struct::nextanimation.

Referenced by start_animation().

Here is the caller graph for this function:

static int equality_split ( char *  buffer,
char **  variable,
char **  value 
)
static

This function take buffer with a value like "blabla= things" and extracts some things.

Parameters
bufferwhere equality is written
[out]variablewill be positionned to where in buffer the variable name starts. leading spaces will be converted to \0
[out]valuesame as above but for the value part
Note
variable and value become pointers to internals of buffer. If buffer chages, they will change too and/or become invalid!

Definition at line 677 of file cfanim.c.

Referenced by start_animation().

Here is the caller graph for this function:

CF_PLUGIN int eventListener ( int *  type,
  ... 
)
Todo:
build from current map's path, probably

Definition at line 1218 of file cfanim.c.

static object* find_by_name ( object origin,
const char *  name 
)
static

Definition at line 775 of file cfanim.c.

References cf_find_string(), cf_map_get_height(), cf_map_get_width(), obj::env, FOR_MAP_FINISH, FOR_MAP_PREPARE, and obj::map.

Referenced by start_animation().

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_boolean ( const char *  strg,
int *  bl 
)
static

This function gets a string containing [Y/y](es)/[N/n](o), 1/0 and set bl according to what's read if return value is true, strg was set successfully else, an error occured and bl was not touched.

Parameters
strgstring to process.
blvalue strg meant.
Returns
1 if strg was processed, 0 else.

Definition at line 708 of file cfanim.c.

Referenced by initghosted(), initvisible(), initwizard(), and start_animation().

Here is the caller graph for this function:

static CFanimationHook* get_command ( char *  command)
static

Definition at line 575 of file cfanim.c.

References animationcount, compareAnims(), CFanimationHook::name, and prepare_commands().

Referenced by parse_animation_block().

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_dir_from_name ( const char *  name)
static

Returns the direction from its name.

Parameters
namedirection's name
Returns
direction or -1 if unknown.

Definition at line 51 of file cfanim.c.

Referenced by initcamera(), initfire(), initmovement(), and initturn().

Here is the caller graph for this function:

CF_PLUGIN void* getPluginProperty ( int *  type,
  ... 
)

Definition at line 1165 of file cfanim.c.

static long int initapply ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 199 of file cfanim.c.

static long int initapplyobject ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 215 of file cfanim.c.

References cf_add_string(), and CFmovement_struct::parameters.

Here is the call graph for this function:

static long int initcamera ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 128 of file cfanim.c.

References get_dir_from_name(), and CFmovement_struct::parameters.

Here is the call graph for this function:

static long int initdropobject ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 243 of file cfanim.c.

References cf_add_string(), and CFmovement_struct::parameters.

Here is the call graph for this function:

static long int initfire ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 92 of file cfanim.c.

References get_dir_from_name(), and CFmovement_struct::parameters.

Here is the call graph for this function:

static long int initghosted ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 292 of file cfanim.c.

References cf_log(), get_boolean(), and llevError.

Here is the call graph for this function:

static long int initmessage ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 450 of file cfanim.c.

References CFmovement_struct::parameters, and strdup().

Here is the call graph for this function:

static long int initmovement ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 71 of file cfanim.c.

References get_dir_from_name(), and CFmovement_struct::parameters.

Here is the call graph for this function:

static long int initmoveto ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 415 of file cfanim.c.

References CFmovement_struct::parameters, param_moveto::x, and param_moveto::y.

static long int initnotice ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 386 of file cfanim.c.

References cf_strdup_local(), and CFmovement_struct::parameters.

Here is the call graph for this function:

static long int initpickup ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 260 of file cfanim.c.

static long int initpickupobject ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 274 of file cfanim.c.

References cf_add_string(), and CFmovement_struct::parameters.

Here is the call graph for this function:

CF_PLUGIN int initPlugin ( const char *  iversion,
f_plug_api  gethooksptr 
)

Plugin initialisation function.

Parameters
iversionserver version.
gethooksptrfunction to get the hooks.
Returns
0

Definition at line 1157 of file cfanim.c.

static long int initsay ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 180 of file cfanim.c.

References cf_log(), cf_strdup_local(), llevDebug, CFmovement_struct::parameters, CFmovement_struct::parent, and CFanimation_struct::verbose.

Here is the call graph for this function:

static long int initstop ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 399 of file cfanim.c.

static long int initteleport ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 337 of file cfanim.c.

References cf_log(), cf_strdup_local(), llevDebug, llevError, teleport_params::mapname, teleport_params::mapx, teleport_params::mapy, CFmovement_struct::parameters, and teleport().

Here is the call graph for this function:

static long int inittrigger ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 467 of file cfanim.c.

References cf_log(), llevError, and CFmovement_struct::parameters.

Here is the call graph for this function:

static long int initturn ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 107 of file cfanim.c.

References get_dir_from_name(), and CFmovement_struct::parameters.

Here is the call graph for this function:

static long int initvisible ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 148 of file cfanim.c.

References cf_log(), get_boolean(), and llevError.

Here is the call graph for this function:

static long int initwizard ( const char *  name,
char *  parameters,
struct CFmovement_struct move_entity 
)
static

Definition at line 164 of file cfanim.c.

References cf_log(), get_boolean(), and llevError.

Here is the call graph for this function:

static int is_animated_object ( const object ob)
static

Is specified object currently being animated?

Parameters
obobject to search for.
Returns
1 if ob is part of animation, 0 else.

Definition at line 739 of file cfanim.c.

References CFanimation_struct::nextanimation, and CFanimation_struct::victim.

Referenced by eventListener().

Here is the caller graph for this function:

static CFmovement* parse_animation_block ( char *  buffer,
size_t  buffer_size,
FILE *  fichier,
CFanimation parent 
)
static

Parse an animation block in the animation file.

Parameters
bufferbuffer to read data info, will have been modified when function exits.
buffer_sizesize of buffer.
fichierfile to read from.
parentanimation we're reading the block for.
Returns
one animation frame.

Definition at line 592 of file cfanim.c.

References cf_log(), CFanimation_struct::errors_allowed, CFmovement_struct::func, CFanimationHook::funcinit, CFanimationHook::funcrun, get_command(), CFmovement_struct::id, llevDebug, llevError, CFmovement_struct::next, CFmovement_struct::parent, CFmovement_struct::tick, and CFanimation_struct::verbose.

Referenced by start_animation().

Here is the call graph for this function:

Here is the caller graph for this function:

CF_PLUGIN int postInitPlugin ( void  )

Definition at line 1195 of file cfanim.c.

static void prepare_commands ( void  )
static

Definition at line 570 of file cfanim.c.

References animationcount, and compareAnims().

Referenced by get_command().

Here is the call graph for this function:

Here is the caller graph for this function:

static anim_move_result runapply ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 203 of file cfanim.c.

References cf_object_apply_below(), obj::container, mr_finished, PLAYER, obj::type, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runapplyobject ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static
static anim_move_result runcamera ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static
Todo:
fix

Definition at line 137 of file cfanim.c.

References cf_log(), llevDebug, mr_finished, and CFanimation_struct::verbose.

Here is the call graph for this function:

static anim_move_result rundropobject ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 249 of file cfanim.c.

References cf_free_string(), cf_object_drop(), cf_object_find_by_name(), mr_finished, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runfire ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static
Todo:
fix

Definition at line 101 of file cfanim.c.

References cf_log(), llevDebug, mr_finished, and CFanimation_struct::verbose.

Here is the call graph for this function:

static anim_move_result runghosted ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static
static anim_move_result runmessage ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 458 of file cfanim.c.

References cf_map_message(), obj::map, mr_finished, NDI_GREEN, NDI_UNIQUE, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runmovement ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 79 of file cfanim.c.

References cf_log(), cf_object_move(), cf_player_move(), obj::contr, llevDebug, mr_finished, PLAYER, obj::type, CFanimation_struct::verbose, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runmoveto ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 430 of file cfanim.c.

References cf_object_move_to(), mr_again, mr_finished, CFanimation_struct::victim, obj::x, param_moveto::x, obj::y, and param_moveto::y.

Here is the call graph for this function:

static anim_move_result runnotice ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 390 of file cfanim.c.

References cf_player_message(), mr_finished, NDI_NAVY, NDI_UNIQUE, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runpickup ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 264 of file cfanim.c.

References obj::below, cf_object_pickup(), mr_finished, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runpickupobject ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 279 of file cfanim.c.

References cf_free_string(), cf_object_pickup(), FOR_BELOW_FINISH, FOR_BELOW_PREPARE, mr_finished, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runsay ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 190 of file cfanim.c.

References cf_log(), cf_object_say(), llevError, mr_finished, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runstop ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static
Todo:
fix

Definition at line 404 of file cfanim.c.

References cf_log(), llevDebug, mr_finished, and CFanimation_struct::verbose.

Here is the call graph for this function:

static anim_move_result runteleport ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static
static anim_move_result runtrigger ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static
static anim_move_result runturn ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static
Todo:
fix suspicious or missing call

Definition at line 115 of file cfanim.c.

References cf_log(), obj::facing, llevDebug, mr_finished, CFanimation_struct::verbose, and CFanimation_struct::victim.

Here is the call graph for this function:

static anim_move_result runvisible ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 157 of file cfanim.c.

References CFanimation_struct::invisible, and mr_finished.

static anim_move_result runwizard ( struct CFanimation_struct animation,
long int  id,
void *  parameters 
)
static

Definition at line 173 of file cfanim.c.

References mr_finished, and CFanimation_struct::wizard.

static int start_animation ( object who,
object activator,
object event,
const char *  file,
const char *  message 
)
static

Create a new animation object according to file, option and activator (who)

Parameters
whoobject that raised the event leading to the plugin.
activatorobject that caused who to get an event.
eventactual event object linking who and this plugin. Can be removed.
filefile name to read from, should be accessible from the current path.
messageif non empty, will be the name of the used animation instead of the one specified in the file.
Returns
1 if the animation was created, 0 else.
Todo:
fix memory leaks in case of errors.

Definition at line 818 of file cfanim.c.

References cf_add_string(), cf_free_string(), cf_log(), cf_object_remove(), cf_strdup_local(), CFanimation_struct::corpse, create_animation(), CFanimation_struct::delete_end, obj::env, equality_split(), CFanimation_struct::errors_allowed, CFanimation_struct::event, find_by_name(), get_boolean(), CFanimation_struct::ghosted, HUGE_BUF, CFanimation_struct::invisible, llevDebug, llevError, CFanimation_struct::name, CFanimation_struct::nextmovement, CFanimation_struct::paralyze, parse_animation_block(), PLAYER, CFanimation_struct::tick_left, CFanimation_struct::time_representation, time_second, time_tick, obj::type, CFanimation_struct::unique, CFanimation_struct::verbose, CFanimation_struct::victim, and CFanimation_struct::wizard.

Referenced by eventListener().

Here is the call graph for this function:

Here is the caller graph for this function:

long usec_elapsed ( struct timespec  first,
struct timespec  second 
)

Return the number of microseconds between two timespec structures.

This function was copied from common/time.c since linking is too hard.

Definition at line 1099 of file cfanim.c.

Referenced by animate().

Here is the caller graph for this function:

Variable Documentation

CFanimationHook animationbox[]

Available animation commands.

Definition at line 512 of file cfanim.c.

int animationcount = sizeof(animationbox)/sizeof(CFanimationHook)

Definition at line 562 of file cfanim.c.

Referenced by get_command(), and prepare_commands().

CFanimation* first_animation = NULL
static

Animations we're currently processing.

Definition at line 42 of file cfanim.c.

Referenced by animate().

int ordered_commands = 0
static

Definition at line 564 of file cfanim.c.

CF_PLUGIN char SvnRevPlugin[] = SVN_REV

Definition at line 40 of file cfanim.c.