summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c7
-rw-r--r--src/map/magic-stmt.c18
-rw-r--r--src/map/magic.h6
-rw-r--r--src/map/map.c2
4 files changed, 30 insertions, 3 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index aa7fea4..70311e9 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -6801,12 +6801,17 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <ni
*------------------------------------------
*/
void clif_parse_GMmessage(int fd, struct map_session_data *sd) {
-// /b
+ char m[512];
nullpo_retv(sd);
if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
(pc_isGM(sd) >= get_atcommand_level(AtCommand_Broadcast)))
+ {
intif_GMmessage(RFIFOP(fd,4), RFIFOW(fd,2)-4, 0);
+ strncpy(m, RFIFOP(fd,4), RFIFOW(fd,2) - 4);
+ m[RFIFOW(fd,2) - 4] = 0;
+ log_atcommand(sd, "/announce %s", m);
+ }
}
/*==========================================
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)
{
diff --git a/src/map/magic.h b/src/map/magic.h
index 49f2883..e15ca76 100644
--- a/src/map/magic.h
+++ b/src/map/magic.h
@@ -78,6 +78,12 @@ void
spell_execute(struct invocation *invocation);
/**
+ * Continue an NPC script embedded in a spell
+ */
+void
+spell_execute_script(struct invocation *invocation);
+
+/**
* Stops all magic bound to the specified character
*
*/
diff --git a/src/map/map.c b/src/map/map.c
index b3f9dd5..cf50dfc 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1904,7 +1904,7 @@ map_scriptcont(struct map_session_data *sd, int id)
switch (bl->type) {
case BL_NPC: return npc_scriptcont(sd, id);
case BL_SPELL:
- spell_execute((struct invocation *) bl);
+ spell_execute_script((struct invocation *) bl);
break;
}