Fixed a script engine problem where warping away while having a menu window open and talking to an another npc with a menu would produce menu option count mismatch errors (bugreport:1208)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12703 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2008-05-12 09:18:24 +00:00
parent ad166c8f5f
commit 836deebfb9
4 changed files with 16 additions and 6 deletions

View File

@ -3,6 +3,10 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2008/05/12
* Fixed a script engine problem where warping away while having a menu
window open and talking to an another npc with a menu would produce
menu option count mismatch errors (bugreport:1208)
2008/05/10 2008/05/10
* Fixed @showmobs not working (bugreport:1487) * Fixed @showmobs not working (bugreport:1487)
2008/05/09 2008/05/09

View File

@ -7948,6 +7948,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
// abort currently running script // abort currently running script
sd->state.using_fake_npc = 0; sd->state.using_fake_npc = 0;
sd->state.menu_or_input = 0;
sd->npc_menu = 0;
if(sd->npc_id) if(sd->npc_id)
npc_event_dequeue(sd); npc_event_dequeue(sd);

View File

@ -146,7 +146,7 @@ struct map_session_data {
unsigned int client_tick; unsigned int client_tick;
int npc_id,areanpc_id,npc_shopid; int npc_id,areanpc_id,npc_shopid;
int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse) int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
int npc_menu; int npc_menu; // internal variable, used in npc menu handling
int npc_amount; int npc_amount;
struct script_state *st; struct script_state *st;
char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine

View File

@ -3812,8 +3812,10 @@ BUILDIN_FUNC(menu)
st->state = END; st->state = END;
return 1; return 1;
} }
StringBuf_Init(&buf); StringBuf_Init(&buf);
for( i = 2, sd->npc_menu = 0; i < script_lastdata(st); i += 2 ) sd->npc_menu = 0;
for( i = 2; i < script_lastdata(st); i += 2 )
{ {
// menu options // menu options
text = script_getstr(st, i); text = script_getstr(st, i);
@ -3909,13 +3911,14 @@ BUILDIN_FUNC(select)
struct StringBuf buf; struct StringBuf buf;
StringBuf_Init(&buf); StringBuf_Init(&buf);
for( i = 2, sd->npc_menu = 0; i <= script_lastdata(st); ++i ) sd->npc_menu = 0;
for( i = 2; i <= script_lastdata(st); ++i )
{ {
text = script_getstr(st, i); text = script_getstr(st, i);
if( sd->npc_menu > 0 ) if( sd->npc_menu > 0 )
StringBuf_AppendStr(&buf, ":"); StringBuf_AppendStr(&buf, ":");
StringBuf_AppendStr(&buf, text); StringBuf_AppendStr(&buf, text);
sd ->npc_menu += menu_countoptions(text, 0, NULL); sd->npc_menu += menu_countoptions(text, 0, NULL);
} }
st->state = RERUNLINE; st->state = RERUNLINE;
@ -3969,13 +3972,14 @@ BUILDIN_FUNC(prompt)
struct StringBuf buf; struct StringBuf buf;
StringBuf_Init(&buf); StringBuf_Init(&buf);
for( i = 2, sd->npc_menu = 0; i <= script_lastdata(st); ++i ) sd->npc_menu = 0;
for( i = 2; i <= script_lastdata(st); ++i )
{ {
text = script_getstr(st, i); text = script_getstr(st, i);
if( sd->npc_menu > 0 ) if( sd->npc_menu > 0 )
StringBuf_AppendStr(&buf, ":"); StringBuf_AppendStr(&buf, ":");
StringBuf_AppendStr(&buf, text); StringBuf_AppendStr(&buf, text);
sd ->npc_menu += menu_countoptions(text, 0, NULL); sd->npc_menu += menu_countoptions(text, 0, NULL);
} }
st->state = RERUNLINE; st->state = RERUNLINE;