Crossfire Server, Branches 1.12  R18729
anim.c File Reference
#include <global.h>
#include <stdio.h>
#include <assert.h>
+ Include dependency graph for anim.c:

Go to the source code of this file.

Functions

static int anim_compare (const Animations *a, const Animations *b)
 
void animate_object (object *op, int dir)
 
void apply_anim_suffix (object *who, sstring suffix)
 
int find_animation (const char *name)
 
void free_all_anim (void)
 
void init_anim (void)
 
int try_find_animation (const char *name)
 

Detailed Description

This file contains animation-related code.

Definition in file anim.c.

Function Documentation

static int anim_compare ( const Animations a,
const Animations b 
)
static

Utility function to compare 2 animations based on their name. Used for sorting/searching.

Definition at line 134 of file anim.c.

References animations_struct::name.

Referenced by try_find_animation().

+ Here is the caller graph for this function:

void animate_object ( object op,
int  dir 
)

Updates the face-variable of an object. If the object is the head of a multi-object, all objects are animated. The object's state is not changed, but merely updated if needed (out of bounds of new animation, reached end of animation, ...)

Parameters
opis the object to animate.
diris the direction the object is facing. This is generally same as op->direction, but in some cases, op->facing is used instead - the caller has a better idea which one it really wants to be using, so let it pass along the right one.

Definition at line 186 of file anim.c.

References animate_object(), obj::animation_id, obj::arch, blank_face, CLEAR_FLAG, archt::clone, obj::direction, dump_object(), obj::face, FLAG_ALIVE, obj::head, obj::invisible, llevError, LOG(), obj::more, NUM_ANIMATIONS, NUM_FACINGS, new_face_struct::number, PLAYER, QUERY_FLAG, SET_ANIMATION, SET_FLAG, obj::state, stringbuffer_finish(), stringbuffer_new(), obj::temp_animation_id, obj::type, UP_OBJ_FACE, and update_object().

Referenced by add_abilities(), animate_object(), apply_anim_suffix(), apply_changes_to_player(), dragon_ability_gain(), monster_use_scroll(), move_hole(), move_monster(), move_player(), process_events(), process_object(), turn_one_transport(), and turn_transport().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void apply_anim_suffix ( object who,
sstring  suffix 
)

Applies a compound animation to an object.

Parameters
whoobject to apply the animation to. Must not be NULL.
suffixanimation suffix to apply. Must not be NULL.

Definition at line 289 of file anim.c.

References animate_object(), obj::animation_id, animations, obj::facing, animations_struct::facings, obj::head, obj::last_anim, MAX_BUF, obj::more, animations_struct::name, animations_struct::num_animations, snprintf(), obj::state, obj::temp_anim_speed, obj::temp_animation_id, obj::temp_last_anim, and try_find_animation().

Referenced by attack_ob_simple(), cast_spell(), do_skill(), and player_apply().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int find_animation ( const char *  name)

Finds the animation id that matches name. Will LOG() an error if not found.

Parameters
namethe animation's name.
Returns
animation number, or 0 if no match found (animation 0 is initialized as the 'bug' face).
See Also
try_find_animation

Definition at line 146 of file anim.c.

References llevError, LOG(), and try_find_animation().

Referenced by cfapi_system_find_animation(), and transport_type_apply().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void free_all_anim ( void  )

Clears all animation-related memory.

Definition at line 41 of file anim.c.

References animations, free_string(), and num_animations.

Referenced by cleanup().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void init_anim ( void  )

Loads the lib/animations file. Can be called multiple times without ill effects.

Definition at line 55 of file anim.c.

References add_string(), animations, animations_allocated, Settings::datadir, animations_struct::faces, animations_struct::facings, find_face(), llevDebug, llevError, LOG(), MAX_ANIMATIONS, MAX_BUF, animations_struct::name, animations_struct::num, animations_struct::num_animations, num_animations, settings, snprintf(), and strerror_local().

Referenced by cctk_init_std_archetypes(), and init_library().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int try_find_animation ( const char *  name)

Tries to find the animation id that matches name, don't LOG() an error if not found.

Parameters
namethe animation's name.
Returns
animation number, or 0 if no match found (animation 0 is initialized as the 'bug' face).
See Also
find_animation

Definition at line 161 of file anim.c.

References anim_compare(), animations, animations_struct::name, animations_struct::num, and num_animations.

Referenced by apply_anim_suffix(), apply_changes_to_player(), and find_animation().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: