|
@@ -49,6 +49,7 @@
|
|
|
#include "script.h"
|
|
|
#include "quest.h"
|
|
|
#include "elemental.h"
|
|
|
+#include "../config/core.h"
|
|
|
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
@@ -3602,7 +3603,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event)
|
|
|
/**
|
|
|
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
|
|
|
**/
|
|
|
-#if SECURE_NPCTIMEOUT
|
|
|
+#ifdef SECURE_NPCTIMEOUT
|
|
|
/**
|
|
|
* We're done with this NPC session, so we cancel the timer (if existent) and move on
|
|
|
**/
|
|
@@ -3648,7 +3649,7 @@ static void script_attach_state(struct script_state* st)
|
|
|
/**
|
|
|
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
|
|
|
**/
|
|
|
-#if SECURE_NPCTIMEOUT
|
|
|
+#ifdef SECURE_NPCTIMEOUT
|
|
|
if( sd->npc_idle_timer == INVALID_TIMER )
|
|
|
sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
|
|
|
sd->npc_idle_tick = gettick();
|
|
@@ -4361,6 +4362,8 @@ BUILDIN_FUNC(mes)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ st->mes_active = 1; // Invoking character has a NPC dialog box open.
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -4375,7 +4378,9 @@ BUILDIN_FUNC(next)
|
|
|
sd = script_rid2sd(st);
|
|
|
if( sd == NULL )
|
|
|
return 0;
|
|
|
-
|
|
|
+#ifdef SECURE_NPCTIMEOUT
|
|
|
+ sd->npc_idle_type = NPCT_WAIT;
|
|
|
+#endif
|
|
|
st->state = STOP;
|
|
|
clif_scriptnext(sd, st->oid);
|
|
|
return 0;
|
|
@@ -4393,7 +4398,15 @@ BUILDIN_FUNC(close)
|
|
|
if( sd == NULL )
|
|
|
return 0;
|
|
|
|
|
|
- st->state = END; //Should be CLOSE, but breaks backwards compatibility.
|
|
|
+ if( !st->mes_active ) {
|
|
|
+ TBL_NPC* nd = map_id2nd(st->oid);
|
|
|
+ st->state = END; // Keep backwards compatibility.
|
|
|
+ ShowWarning("Incorrect use of 'close'! (source:%s / path:%s)\n",nd?nd->name:"Unknown",nd?nd->path:"Unknown");
|
|
|
+ } else {
|
|
|
+ st->state = CLOSE;
|
|
|
+ st->mes_active = 0;
|
|
|
+ }
|
|
|
+
|
|
|
clif_scriptclose(sd, st->oid);
|
|
|
return 0;
|
|
|
}
|
|
@@ -4411,6 +4424,10 @@ BUILDIN_FUNC(close2)
|
|
|
return 0;
|
|
|
|
|
|
st->state = STOP;
|
|
|
+
|
|
|
+ if( st->mes_active )
|
|
|
+ st->mes_active = 0;
|
|
|
+
|
|
|
clif_scriptclose(sd, st->oid);
|
|
|
return 0;
|
|
|
}
|
|
@@ -4477,6 +4494,10 @@ BUILDIN_FUNC(menu)
|
|
|
if( sd == NULL )
|
|
|
return 0;
|
|
|
|
|
|
+#ifdef SECURE_NPCTIMEOUT
|
|
|
+ sd->npc_idle_type = NPCT_MENU;
|
|
|
+#endif
|
|
|
+
|
|
|
// TODO detect multiple scripts waiting for input at the same time, and what to do when that happens
|
|
|
if( sd->state.menu_or_input == 0 )
|
|
|
{
|
|
@@ -4602,6 +4623,10 @@ BUILDIN_FUNC(select)
|
|
|
if( sd == NULL )
|
|
|
return 0;
|
|
|
|
|
|
+#ifdef SECURE_NPCTIMEOUT
|
|
|
+ sd->npc_idle_type = NPCT_MENU;
|
|
|
+#endif
|
|
|
+
|
|
|
if( sd->state.menu_or_input == 0 ) {
|
|
|
struct StringBuf buf;
|
|
|
|
|
@@ -4677,6 +4702,10 @@ BUILDIN_FUNC(prompt)
|
|
|
if( sd == NULL )
|
|
|
return 0;
|
|
|
|
|
|
+#ifdef SECURE_NPCTIMEOUT
|
|
|
+ sd->npc_idle_type = NPCT_MENU;
|
|
|
+#endif
|
|
|
+
|
|
|
if( sd->state.menu_or_input == 0 )
|
|
|
{
|
|
|
struct StringBuf buf;
|
|
@@ -5418,6 +5447,10 @@ BUILDIN_FUNC(input)
|
|
|
min = (script_hasdata(st,3) ? script_getnum(st,3) : script_config.input_min_value);
|
|
|
max = (script_hasdata(st,4) ? script_getnum(st,4) : script_config.input_max_value);
|
|
|
|
|
|
+#ifdef SECURE_NPCTIMEOUT
|
|
|
+ sd->npc_idle_type = NPCT_WAIT;
|
|
|
+#endif
|
|
|
+
|
|
|
if( !sd->state.menu_or_input )
|
|
|
{ // first invocation, display npc input box
|
|
|
sd->state.menu_or_input = 1;
|
|
@@ -8209,7 +8242,18 @@ BUILDIN_FUNC(getgroupid)
|
|
|
/// end
|
|
|
BUILDIN_FUNC(end)
|
|
|
{
|
|
|
+ TBL_PC* sd;
|
|
|
+
|
|
|
+ sd = map_id2sd(st->rid);
|
|
|
+
|
|
|
st->state = END;
|
|
|
+
|
|
|
+ if( st->mes_active )
|
|
|
+ st->mes_active = 0;
|
|
|
+
|
|
|
+ if( sd )
|
|
|
+ clif_scriptclose(sd, st->oid); // If a menu/select/prompt is active, close it.
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|