From f52600e3795cd8a40c716ff92db6d8f55cc8e7cf Mon Sep 17 00:00:00 2001 From: Fate Date: Sat, 8 Nov 2008 06:43:20 +0000 Subject: * Change SLang interpreter time handling to be universally unsigned * Add debug output to SLang guard checking to print why particular guards failed --- src/map/magic-interpreter-base.c | 16 ++++++++++------ src/map/map.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/map/magic-interpreter-base.c b/src/map/magic-interpreter-base.c index 6da7acb..dc0fa02 100644 --- a/src/map/magic-interpreter-base.c +++ b/src/map/magic-interpreter-base.c @@ -290,15 +290,17 @@ 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) { - int tick = gettick(); + unsigned int tick = gettick(); int retval = check_prerequisites(caster, check->catalysts); -/* - fprintf(stderr, "Check: can satisfy? %d%d%d%d\n", retval, + + fprintf(stderr, "MC(%d/%s)? %d%d%d%d (%u <= %u)\n", + caster->bl.id, caster->status.name, + retval, caster->cast_tick <= tick, check->mana <= caster->status.sp, - check_prerequisites(caster, check->components)); -*/ + check_prerequisites(caster, check->components), + caster->cast_tick, tick); if (retval && near_miss) *near_miss = 1; // close enough! @@ -309,13 +311,15 @@ spellguard_can_satisfy(spellguard_check_t *check, character_t *caster, env_t *en && check_prerequisites(caster, check->components); if (retval) { - int casttime = check->casttime; + unsigned int casttime = (unsigned int) check->casttime; if (VAR(VAR_MIN_CASTTIME).ty == TY_INT) casttime = MAX(casttime, VAR(VAR_MIN_CASTTIME).v.v_int); caster->cast_tick = tick + casttime; /* Make sure not to cast too frequently */ + fprintf(stderr, " -> NC %u + %u = %u\n", tick, casttime, caster->cast_tick); + consume_components(caster, check->components); pc_heal(caster, 0, -check->mana); } diff --git a/src/map/map.h b/src/map/map.h index bc34d7c..54179ac 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -208,7 +208,7 @@ struct map_session_data { int followtimer; // [MouseJstr] int followtarget; - int cast_tick; // [Fate] Next tick at which spellcasting is allowed + unsigned int cast_tick; // [Fate] Next tick at which spellcasting is allowed struct invocation *active_spells; // [Fate] Singly-linked list of active spells linked to this PC int attack_spell_override; // [Fate] When an attack spell is active for this player, they trigger it // like a weapon. Check pc_attack_timer() for details. -- cgit v1.2.3-70-g09d2