Hello, I'm using an up-to-date rAthena version and I encountered an odd bug from the prompt script command. When a player clicks on "Cancel", it closes the window and ends the script immediatly. Here is my source code for prompt command: /src/map/script.c (begin from line 4856)
else if( sd->npc_menu == 0xff )
{// Cancel was pressed
sd->state.menu_or_input = 0;
pc_setreg(sd, add_str("@menu"), 0xff);
script_pushint(st, 0xff);
st->state = END;
}
So, it does effectively return the value "255" with this script (and set the @menu variable to 255 too) but it ends the script after doing that : (st->state = END;). Here is my test script used if you'd like to try to reproduce this problem:
sec_in02,141,176,5 script TestPrompt#sec_in02 56,{
mes "[TestPrompt]";
mes "@menu = " + @menu;
mes "Hey.";
@result = prompt("#1", "#2", "#3");
mes "[TestPrompt]";
mes "Result : " + @result;
close;
}
sec_in02,143,176,5 script TestPrompt2#sec_in02 56,{
mes "[TestPrompt]";
mes "Hey.";
switch(prompt("#1", "#2", "#3")) {
case 1:
mes "#1";
break;
case 2:
mes "#2";
break;
case 3:
mes "#3";
break;
case 255:
mes "SELECT CATCHED";
break;
}
close;
}
So I changed the last line, from st->state = END; to st->state = RUN; src/map/script.c (begin from line 4856)
else if( sd->npc_menu == 0xff )
{// Cancel was pressed
sd->state.menu_or_input = 0;
pc_setreg(sd, add_str("@menu"), 0xff);
script_pushint(st, 0xff);
st->state = RUN; // [Lyyn] Don't end the script plz.
//st->state = END;
}
And it works quite fine. I then encountered another bug ; if you add a next to the first NPC after the line "@result = prompt [...]", it will throw a blank window with a next and, if you click on the next button, you'll just get a blank window that will stuck your character (ALT+F4 needed). I would like to know whether my "fix" is fine or if I'm totally wrong. And in this case, it'll be great to tell me what to do in order to get a functionnal prompt command. Thanks in advance!
Edit :
Okay, I used grep to check where prompt was used within the npc folder. Result ; nowhere, excepted custom scripts.
Anyway, I think my fix is kinda good, what do you think about it?