summaryrefslogtreecommitdiff
path: root/src/map/magic-stmt.c
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2009-08-29 04:14:17 +0000
committerFate <fate-tmw@googlemail.com>2009-08-29 04:14:17 +0000
commit3e35855d56e8a20959520e921b19832b2b5eaf8f (patch)
tree209c37f27251e45fa1e20331337506240510ae94 /src/map/magic-stmt.c
parent6ff9a550e3f22eaa906722143f94b75666ebbd30 (diff)
downloadtmwa-3e35855d56e8a20959520e921b19832b2b5eaf8f.tar.gz
tmwa-3e35855d56e8a20959520e921b19832b2b5eaf8f.tar.bz2
tmwa-3e35855d56e8a20959520e921b19832b2b5eaf8f.tar.xz
tmwa-3e35855d56e8a20959520e921b19832b2b5eaf8f.zip
If a spell is continued via the NPC handler callback, double-check that it is really waiting for a script. This fixes #755 and #733.
Diffstat (limited to 'src/map/magic-stmt.c')
-rw-r--r--src/map/magic-stmt.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/map/magic-stmt.c b/src/map/magic-stmt.c
index 4c866ca..cba0659 100644
--- a/src/map/magic-stmt.c
+++ b/src/map/magic-stmt.c
@@ -1402,10 +1402,15 @@ spell_execute_d(invocation_t *invocation, int allow_deletion)
spell_update_location(invocation);
delta = spell_run(invocation, allow_deletion);
- if (delta > 0)
+ if (delta > 0) {
+ if (invocation->timer) {
+ fprintf(stderr, "[magic] FATAL ERROR: Trying to add multiple timers to the same spell! Already had timer: %d\n", invocation->timer);
+ /* *((int *)0x0) = 0; */
+ }
invocation->timer = add_timer(gettick() + delta,
&invocation_timer_callback,
invocation->bl.id, 0);
+ }
/* If 0, the script cleaned itself. If -1 (wait-for-script), we must wait for the user. */
}
@@ -1416,6 +1421,17 @@ spell_execute(invocation_t *invocation)
spell_execute_d(invocation, 1);
}
+void
+spell_execute_script(invocation_t *invocation)
+{
+ if (invocation->script_pos)
+ spell_execute_d(invocation, 1);
+ /* Otherwise the script-within-the-spell has been terminated by some other means.
+ * In practice this happens when the script doesn't wait for user input: the client
+ * may still notify the server that it's done. Without the above check, we'd be
+ * running the same spell twice! */
+}
+
int
spell_attack(int caster_id, int target_id)
{