Crossfire Server, Trunk  R20513
Functions
anim.c File Reference

This file contains animation-related code. More...

#include "global.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.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)
 Utility function to compare 2 animations based on their name. More...
 
void animate_object (object *op, int dir)
 Updates the face-variable of an object. More...
 
void apply_anim_suffix (object *who, sstring suffix)
 Applies a compound animation to an object. More...
 
void dump_animations (void)
 Dump all animations to stderr, for debugging purposes. More...
 
int find_animation (const char *name)
 Finds the animation id that matches name. More...
 
void free_all_anim (void)
 Clears all animation-related memory. More...
 
void init_anim (void)
 Loads the lib/animations file. More...
 
int try_find_animation (const char *name)
 Tries to find the animation id that matches name, don't LOG() an error if not found. More...
 

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 132 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, ...). This function correctly handles FLAG_IS_TURNABLE too.

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. This parameter is ignored if the object has a head or is turnable.

Definition at line 186 of file anim.c.

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

Referenced by animate_object(), apply_anim_suffix(), apply_changes_to_player(), dragon_ability_gain(), fix_stopped_arrow(), monster_move(), monster_use_scroll(), move_hole(), move_player(), move_to(), object_give_identified_properties(), object_update_turn_face(), 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 292 of file anim.c.

References animate_object(), obj::animation_id, animations, obj::facing, animations_struct::facings, 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, and try_find_animation().

Referenced by apply_by_living(), attack_ob_simple(), cast_spell(), do_skill(), fire_bow(), and god_intervention().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_animations ( void  )

Dump all animations to stderr, for debugging purposes.

Definition at line 322 of file anim.c.

References animations, and num_animations.

Referenced by server_dump_animations().

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 144 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 30 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 44 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, new_faces, animations_struct::num, animations_struct::num_animations, num_animations, settings, and snprintf.

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 159 of file anim.c.

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

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

Here is the call graph for this function:

Here is the caller graph for this function: