Jump to content
  • 0

Prompt script command won't return 255 on cancel


Myskelz

Question


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  6
  • Reputation:   3
  • Joined:  06/29/14
  • Last Seen:  

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?
Edited by Myskelz
  • Upvote 1
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  46
  • Reputation:   1
  • Joined:  03/04/17
  • Last Seen:  

Still ? ?

I tried and it seems the same yet.

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

On 7/7/2014 at 3:31 AM, Myskelz said:

Perhaps I'm the only one in this world who uses this command  /??

 

Thanks Euphy!  /no1

why necro this? also I use it from time to time

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   7
  • Joined:  12/06/11
  • Last Seen:  

This change is 6 mounths old (r17699)

 

http://trac.rathena.org/changeset/17699/rathena/trunk/src/map/script.c

 

But I don't know why it was fixed like that, there is no log about this file. Interesting... Anyone?

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  6
  • Reputation:   3
  • Joined:  06/29/14
  • Last Seen:  

The source of the commit comes from here : http://rathena.org/board/tracker/issue-7932-prompts-feature-to-return-255-when-you-cancel-a-prompt-seems-to-cause-the-script-engine-not-to-continue-when-you-put-a-close-right-after-it/?gopid=21532#entry21532

 

The prompt command was made for NOT STOPPING the execution of the script after pressing cancel, it was EXPECTED. So, WHY this commit has been accepted?! Why no one has reported this bug?!

 

The commit: https://github.com/rathena/rathena/commit/7a9aa7f

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

It was probably a misunderstanding on Aleos' part. We haven't caught it because, as you've noted, this isn't used in any of the official scripts. Please file a bug report and wait for a developer to get to it--thanks!

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  6
  • Reputation:   3
  • Joined:  06/29/14
  • Last Seen:  

Perhaps I'm the only one in this world who uses this command  /??

 

Thanks Euphy!  /no1

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...