diff options
Diffstat (limited to 'src/map/magic-interpreter-base.cpp')
-rw-r--r-- | src/map/magic-interpreter-base.cpp | 86 |
1 files changed, 51 insertions, 35 deletions
diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp index 94e0a18..229dadb 100644 --- a/src/map/magic-interpreter-base.cpp +++ b/src/map/magic-interpreter-base.cpp @@ -1,9 +1,10 @@ #include "magic.hpp" -#include "magic-interpreter.hpp" #include "magic-expr.hpp" +#include "magic-interpreter.hpp" #include "magic-interpreter-aux.hpp" -static void set_int_p(val_t * v, int i, int t) +static +void set_int_p(val_t *v, int i, int t) { v->ty = t; v->v.v_int = i; @@ -14,21 +15,25 @@ static void set_int_p(val_t * v, int i, int t) #define SETTER(tty, dyn_ty, field) (val_t *v, tty x) { v->ty = dyn_ty; v->v.field = x; } -static void set_string SETTER(char *, TY_STRING, v_string); +static +void set_string SETTER(char *, TY_STRING, v_string); -static void set_entity(val_t * v, entity_t * e) +static +void set_entity(val_t *v, entity_t *e) { v->ty = TY_ENTITY; v->v.v_int = e->id; } -static void set_invocation(val_t * v, invocation_t * i) +static +void set_invocation(val_t *v, invocation_t *i) { v->ty = TY_INVOCATION; v->v.v_int = i->bl.id; } -static void set_spell SETTER(spell_t *, TY_SPELL, v_spell); +static +void set_spell SETTER(spell_t *, TY_SPELL, v_spell); #define setenv(f, v, x) f(&(env->vars[v]), x) @@ -44,7 +49,8 @@ static void set_spell SETTER(spell_t *, TY_SPELL, v_spell); magic_conf_t magic_conf; /* Global magic conf */ env_t magic_default_env = { &magic_conf, NULL }; -static int spells_sorted = 0; +static +int spells_sorted = 0; const char *magic_find_invocation(const char *spellname) { @@ -57,7 +63,8 @@ const char *magic_find_invocation(const char *spellname) return NULL; } -static int spell_compare(const void *lhs, const void *rhs) +static +int spell_compare(const void *lhs, const void *rhs) { return strcmp((*((spell_t **) lhs))->invocation, (*((spell_t **) rhs))->invocation); @@ -93,7 +100,8 @@ spell_t *magic_find_spell(char *invocation) /* Spell anchors */ /* -------------------------------------------------------------------------------- */ -static int compare_teleport_anchor(const void *lhs, const void *rhs) +static +int compare_teleport_anchor(const void *lhs, const void *rhs) { return strcmp((*((teleport_anchor_t **) lhs))->invocation, (*((teleport_anchor_t **) rhs))->invocation); @@ -141,7 +149,8 @@ teleport_anchor_t *magic_find_anchor(char *name) /* Spell guard checks */ /* -------------------------------------------------------------------------------- */ -static env_t *alloc_env(magic_conf_t * conf) +static +env_t *alloc_env(magic_conf_t *conf) { env_t *env; CREATE(env, env_t, 1); @@ -150,7 +159,8 @@ static env_t *alloc_env(magic_conf_t * conf) return env; } -static env_t *clone_env(env_t * src) +static +env_t *clone_env(env_t *src) { env_t *retval = alloc_env(src->base_env); int i; @@ -161,7 +171,7 @@ static env_t *clone_env(env_t * src) return retval; } -void magic_free_env(env_t * env) +void magic_free_env(env_t *env) { int i; for (i = 0; i < env->base_env->vars_nr; i++) @@ -169,8 +179,8 @@ void magic_free_env(env_t * env) free(env); } -env_t *spell_create_env(magic_conf_t * conf, spell_t * spell, - character_t * caster, int spellpower, char *param) +env_t *spell_create_env(magic_conf_t *conf, spell_t *spell, + character_t *caster, int spellpower, char *param) { env_t *env = alloc_env(conf); @@ -208,7 +218,8 @@ env_t *spell_create_env(magic_conf_t * conf, spell_t * spell, return env; } -static void free_components(component_t ** component_holder) +static +void free_components(component_t ** component_holder) { if (*component_holder == NULL) return; @@ -245,8 +256,8 @@ void magic_add_component(component_t ** component_holder, int id, int count) } } -static void -copy_components(component_t ** component_holder, component_t * component) +static +void copy_components(component_t ** component_holder, component_t *component) { if (component == NULL) return; @@ -262,7 +273,8 @@ typedef struct spellguard_check int mana, casttime; } spellguard_check_t; -static int check_prerequisites(character_t * caster, component_t * component) +static +int check_prerequisites(character_t *caster, component_t *component) { while (component) { @@ -276,7 +288,8 @@ static int check_prerequisites(character_t * caster, component_t * component) return 1; } -static void consume_components(character_t * caster, component_t * component) +static +void consume_components(character_t *caster, component_t *component) { while (component) { @@ -285,9 +298,9 @@ static void consume_components(character_t * caster, component_t * component) } } -static int -spellguard_can_satisfy(spellguard_check_t * check, character_t * caster, - env_t * env, int *near_miss) +static +int spellguard_can_satisfy(spellguard_check_t *check, character_t *caster, + env_t *env, int *near_miss) { unsigned int tick = gettick(); @@ -326,9 +339,10 @@ spellguard_can_satisfy(spellguard_check_t * check, character_t * caster, return retval; } -static effect_set_t *spellguard_check_sub(spellguard_check_t * check, - spellguard_t * guard, - character_t * caster, env_t * env, +static +effect_set_t *spellguard_check_sub(spellguard_check_t *check, + spellguard_t *guard, + character_t *caster, env_t *env, int *near_miss) { if (guard == NULL) @@ -394,8 +408,9 @@ static effect_set_t *spellguard_check_sub(spellguard_check_t * check, return spellguard_check_sub(check, guard->next, caster, env, near_miss); } -static effect_set_t *check_spellguard(spellguard_t * guard, - character_t * caster, env_t * env, +static +effect_set_t *check_spellguard(spellguard_t *guard, + character_t *caster, env_t *env, int *near_miss) { spellguard_check_t check; @@ -416,8 +431,8 @@ static effect_set_t *check_spellguard(spellguard_t * guard, /* Public API */ /* -------------------------------------------------------------------------------- */ -effect_set_t *spell_trigger(spell_t * spell, character_t * caster, - env_t * env, int *near_miss) +effect_set_t *spell_trigger(spell_t *spell, character_t *caster, + env_t *env, int *near_miss) { int i; spellguard_t *guard = spell->spellguard; @@ -432,7 +447,8 @@ effect_set_t *spell_trigger(spell_t * spell, character_t * caster, return check_spellguard(guard, caster, env, near_miss); } -static void spell_set_location(invocation_t * invocation, entity_t * entity) +static +void spell_set_location(invocation_t *invocation, entity_t *entity) { magic_clear_var(&invocation->env->vars[VAR_LOCATION]); invocation->env->vars[VAR_LOCATION].ty = TY_LOCATION; @@ -441,7 +457,7 @@ static void spell_set_location(invocation_t * invocation, entity_t * entity) invocation->env->vars[VAR_LOCATION].v.v_location.y = entity->y; } -void spell_update_location(invocation_t * invocation) +void spell_update_location(invocation_t *invocation) { if (invocation->spell->flags & SPELL_FLAG_LOCAL) return; @@ -455,7 +471,7 @@ void spell_update_location(invocation_t * invocation) } } -invocation_t *spell_instantiate(effect_set_t * effect_set, env_t * env) +invocation_t *spell_instantiate(effect_set_t *effect_set, env_t *env) { invocation_t *retval; CREATE(retval, invocation_t, 1); @@ -483,7 +499,7 @@ invocation_t *spell_instantiate(effect_set_t * effect_set, env_t * env) return retval; } -invocation_t *spell_clone_effect(invocation_t * base) +invocation_t *spell_clone_effect(invocation_t *base) { invocation_t *retval = (invocation_t *) malloc(sizeof(invocation_t)); env_t *env; @@ -513,7 +529,7 @@ invocation_t *spell_clone_effect(invocation_t * base) return retval; } -void spell_bind(character_t * subject, invocation_t * invocation) +void spell_bind(character_t *subject, invocation_t *invocation) { /* Only bind nonlocal spells */ @@ -539,7 +555,7 @@ void spell_bind(character_t * subject, invocation_t * invocation) spell_set_location(invocation, (entity_t *) subject); } -int spell_unbind(character_t * subject, invocation_t * invocation) +int spell_unbind(character_t *subject, invocation_t *invocation) { invocation_t **seeker = &subject->active_spells; |