[SOLVED]Javascript exception is thrown when jumping from a dialogue to another

Started by Giacomo, Fri 18/10/2024 13:50:53

Previous topic - Next topic

Giacomo

Hello, everybody I have a problem that I cannot solve.
It's about a dialogues series in which you have to give three right answers, otherwise you will have restart from the beginning.

The first dialogue opens some topics of the second dialogue, depending from the answer given. Then, the second dialogue opens some topics in a third dialogue, always depending from the answer. Because the topics were many, the third dialogue has been split in two dialogues.
If you give the wrong answer in the third dialogue, the options of the last two dialogues are set off and you restart from the first dialogue.

Before I had another problem: if I continued to say the wrong answer, restarting the dialogue for about 15 times, the game crashed displaying a message concerning a recursive call.
I solved this problem by forcing the player to give the solution after a certain number of attempts(and he gets a negative point!), but I felt there was still something to fix.

The new problem shows up in the web version of the game only. If I say the right answer at the first attempt, the problem won't show up. But if I miss the answer just once and then restart the dialogue, a javascript exception gets thrown with these error messages:

Aborted(RuntimeError: unreachable executed)
Uncaught RuntimeError: Aborted(RuntimeError: unreachable executed). Build with -sASSERTIONS for more info.

I'll try to reduce the script removing the recurring parts.

FIRST DIALOGUE(8 AVAILABLE ANSWERS):
Spoiler
Code: ags
// Dialog script file
@S  // Dialog startup entry point

  if(ominoTentativi == 12) //force to skip to final dialogue
  {
omino: Dad, I'm tired!
cUomoAppeso: Me too!
omino: You are too weak...
  Wait(20);
omino: I want sugar candies...
cUomoAppeso: Finally!
  dOminoPapaFinale.Start();
  }
  
  else if(ominoTentativi > 0) //after the first attempt, say the following
  {
omino: Wrong answer!
omino: Again, what am I thinking about?
  }
  
return

@1 //wrong answer, like options 2, 6
  _ominoDialoghi(1, 0); //see functions below
  if(ominoGiocattoli) //global var bool, a kind of "if option has been choosen"
omino: Maybe no...

  else
omino: Maybe.
    dOminoPapa2.Start();
stop

(...)

@3 //right answer
  _ominoDialoghi(7, 0);
omino: Maybe.
  dOminoPapa2.Start();
stop

@4 //options 4, 5, 7, 8 will return to current dialogue
  dOminoPapa1.SetOptionState(4, eOptionOffForever);
return

(...)
[close]

SECOND DIALOGUE(3 AVAILABLE ANSWERS):
Spoiler
Code: ags
// Dialog script file
@S  // Dialog startup entry point
return

@1
  if(ominoGiocattoli) //same global var bool, used for the three available options
omino: Maybe no!
  else
omino: Maybe...
  _ominoDialoghiCanc(33); //see function below
  _ominoDialoghi(1, 1); //see function below
  dOminoPapa31.Start(); //open part one of third dialogue
stop

@2
  if(ominoGiocattoli)
omino: Maybe no!
  else
omino: Maybe...
  _ominoDialoghiCanc(33);
  _ominoDialoghi(4, 1);
  dOminoPapa31.Start();
stop

@3
  if(ominoGiocattoli)
omino: Maybe no!
  else
omino: Maybe...
  _ominoDialoghiCanc(33);
  _ominoDialoghi(7, 1);
  dOminoPapa31.Start();
stop

(...)

@6
  if(ominoVideogame)
omino: Maybe no!
  else
omino: Maybe...
  _ominoDialoghiCanc(33);
  _ominoDialoghi(16, 1);
  dOminoPapa31.Start();
stop

@7
  if(ominoCiboCarne)
omino: Maybe no!
  else
omino: Maybe...
  _ominoDialoghiCanc(33);
  _ominoDialoghi(1, 2);
  dOminoPapa32.Start(); //open part two of third dialogue
stop

@8
  if(ominoCiboPizza)
omino: Maybe no!
  else
omino: Maybe...
  _ominoDialoghiCanc(33);
  _ominoDialoghi(4, 2);
  dOminoPapa32.Start();
stop

(...)

@12
  if(ominoTravestimenti)
omino: Maybe no!
  else
omino: Maybe...
  _ominoDialoghiCanc(33);
  _ominoDialoghi(16, 2);
  dOminoPapa32.Start();
stop
[close]

THIRD DIALOGUE(SPLIT IN 2, 3 AVAILABLE ANSWERS):
Spoiler
Code: ags
// Dialog script file
@S  // Dialog startup entry point
return

@1
  if(Game.DoOnceOnly("dOminoPapa3101")) //say once when the answer was choosen
  {
omino: I don't like that doll...
omino: ...I only like the video-game of Monkey Donk@!
  }
  if(Game.DoOnceOnly("ominoGiocattoli")) _ominoDialoghiFinale(0); //say once when the previous answer was choosen
  else _ominoDialoghiFinale(4); //the second time say another thing
  _ominoDialoghiCanc(34);
  dOminoPapa1.Start(); //restart
stop

(...)

@10
  if(Game.DoOnceOnly("dOminoPapa3110"))
omino: I want it but it's not here.

  if(Game.DoOnceOnly("ominoVideogames")) _ominoDialoghiFinale(1);
  else _ominoDialoghiFinale(5);
  _ominoDialoghiCanc(34);
  dOminoPapa1.Start();
stop

(...)
[close]

Spoiler
Code: ags
// Dialog script file
@S  // Dialog startup entry point
return

@1
  if(Game.DoOnceOnly("dOminoPapa3201"))
omino: That's what YOU want!

  if(Game.DoOnceOnly("ominoCibo")) _ominoDialoghiFinale(2);
  else _ominoDialoghiFinale(60);
  _ominoDialoghiCanc(35);
  ominoCiboCarne = true;
  dOminoPapa1.Start();
stop

@2
  if(Game.DoOnceOnly("dOminoPapa3202"))
  {
  cOmino.FaceDirection(eDirectionLeft);
omino: Like those?
cUomoAppeso: Yes!
  cGiostraia.FaceDirection(eDirectionRight);
giostraia: No way!
  cOmino.FaceDirection(eDirectionRight);
  cGiostraia.FaceDirection(eDirectionDown);
omino: Dad, I don't like chicken!
  }
  if(Game.DoOnceOnly("ominoCibo")) _ominoDialoghiFinale(2);
  else _ominoDialoghiFinale(60);
  _ominoDialoghiCanc(35);
  ominoCiboCarne = true;
  dOminoPapa1.Start();
stop

(...)

@7
  if(Game.DoOnceOnly("dOminoPapa3207"))
omino: I would like it but where can you see it?

  if(Game.DoOnceOnly("ominoCibo")) _ominoDialoghiFinale(2);
  else _ominoDialoghiFinale(62);
  _ominoDialoghiCanc(35);
  dOminoPapa1.Start();
stop

@8 //right answer
omino: Yes!
omino: You guessed it, daddy!
  dOminoPapaFinale.Start();
stop

@9
  if(Game.DoOnceOnly("dOminoPapa3209"))
omino: Maybe but it's not here.

  if(Game.DoOnceOnly("ominoCibo")) _ominoDialoghiFinale(2);
  else _ominoDialoghiFinale(62);
  _ominoDialoghiCanc(35);
  dOminoPapa1.Start();
stop

(...)

[close]

FUNCTIONS TO RESET DIALOGUES:
Spoiler
Code: ags
function _ominoDialoghi(int topic,  int dialogNumber) //set options state in next dialogue
{
  int w = topic;
  while(w <= topic + 2) //if I choose 1st answer, set option 1, 2, 3 on, 2nd answer set 4, 5, 6 on etc etc.
  {
    if(dialogNumber == 0) dialog[33].SetOptionState(w ,eOptionOn);
    else if (dialogNumber == 1) dialog[34].SetOptionState(w ,eOptionOn);
    else dialog[35].SetOptionState(w ,eOptionOn);
    w++;
  }
}

function _ominoDialoghiCanc(int dialogNumber) //reset options of the choosen dialogue
{
  for(int o = 1; o <= dialog[dialogNumber].OptionCount; o++)
  {
    if(dialog[dialogNumber].GetOptionState(o) == eOptionOn) dialog[dialogNumber].SetOptionState(o, eOptionOff);
  }
}

function _ominoDialoghiFinale(int field) //custom functions for a dialog
{
  if(field == 0) //toy
  {
    //say something
    ominoGiocattoli = true;
  }
  else if(field == 1) //videogame
  {
    //say something
    ominoVideogame = true;
  }
  else if(field == 2) //food
  {
   //say something once, this is the right field so I manage it in another way
  }
  else if(field == 3) //disguise
  {
    //say something once
    ominoTravestimenti = true;
  } //say these things if you choose a field twice, the field food has 3 different phrases because it is the right first answer and I reply according to what you chose for as next answer(1st answer: food --> 2nd answer: meat/flours/sweets) 

  else if(field == 4) cOmino.Say("I said it's not about toys!"); //toy 2nd time
  else if(field == 5) cOmino.Say("I can't get any video-game here!"); //videogame 2ndtime
  else if(field == 60) cOmino.Say("I don't want meat right now!"); //food/meat
  else if(field == 61) cOmino.Say("I don't want anything like pizza, pasta or panini!"); //food/flours
  else if(field == 62) cOmino.Say("A sweet may be interesting!"); //food/sweet
  else if(field == 7) cOmino.Say("I only want that football shirt and I can't have it!"); //disguises 2nd time
  ominoTentativi++; //this function is called when the chose answer is wrong, so I count the attempts at the end
}
[close]

If it can help, I can share a video where you can see the moment in which the game crashes and when the error message shows up.

I know that the question might be complex and I hope I wrote enough to understand how the script works. I tested it a lot and the logic seems to be correct (maybe the script can be reduced as well), I don't know what triggers the error in the web version. I hope there's a solution.

Thank you,
Giacomo
https://ko-fi.com/giacomo97557 To support Falco's adventures

Crimson Wizard

Sorry, following is not directly related to your problem, but I wanted to mention this, seeing as you use dialog numbers in many places: usually you can use Dialog variables (pointers) instead:

Code: ags
    //if(dialogNumber == 0) dialog[33].SetOptionState(w ,eOptionOn); >>>>
    if(dialogNumber == 0) dWhatIsDialogName.SetOptionState(w ,eOptionOn);

And then, if you need to pass dialog number into another function, you may do either this:
Code: ags
//_ominoDialoghiCanc(33); >>>>
_ominoDialoghiCanc(dWhatIsDialogName.ID);

Or you may rewrite the function to use Dialog pointer instead of its number:
Code: ags
function _ominoDialoghiCanc(Dialog* dlg) //reset options of the choosen dialogue
{
  for(int o = 1; o <= dlg.OptionCount; o++)
  {
    if(dlg.GetOptionState(o) == eOptionOn) dlg.SetOptionState(o, eOptionOff);
  }
}
then you may call it like
Code: ags
_ominoDialoghiCanc(dWhatIsDialogName);


This overall makes the script more readable, and less prone to accidental mistakes.

eri0o

Which browser are you using? Can you see anything else on the console? You can set the acsetup.cfg to have ags spit more log information. I think it's just

Code: ags
[log]
stdout = all:all

To get literally everything, and then you can put the log somewhere we can read - when you read it hopefully will give information on where things are just before the crash.

Other than this the way I usually go with my code to figure the origin of the problem is to remove things in large areas to get the game to go back working quickly and slowly add things back until something breaks, and then I remove the last thing to verify if it works again, and so this helps me isolate the issue.

And regarding the code, please use pointers and when possible instead of hardcoding integers as IDs of anything, those a bound to have human mistakes.

Giacomo

Thank you, Crimson. I will follow your suggestion.

Eri0o, I am using Firefox but the problem doesn't depend from the browser, I guess. It was my brother who realized of the error and I know he uses Brave.

I send you a video where you can see the error showing up, it's about after 40 second from the beginning:
https://www.dropbox.com/scl/fi/s09sq0t1v024c7lftjgs5/recordException.zip?rlkey=2r77p7o9aiobz9u15s05nzgz0&st=2j0u7rbp&dl=0

I don't have more information even by adding the [log] string in the config file(I guess it can be inserted anywhere).

I agree with you about removing parts of the code to isolate the problem, but in this case it's quite annoying. I know that the problem is triggered when I switch to another dialogue. I will try to isolate the problem as well and use pointers instead of integers.

I also have another problem that concern with the Scrolling Dialogs module by Khris, indeed I told him about it.
If I press on arrow buttons the game crashes and also this happen on web only.

Anyway, I will try to follow all your suggestions and see if I can manage it somehow. Thank you for your help!



P.S. I have a question regarding android and the conversion of right/left click into taps, can I post it on beginner's tech questions?
https://ko-fi.com/giacomo97557 To support Falco's adventures

Crimson Wizard

@Giacomo could you copy-paste the contents of errors panel here (or save to a text file and upload)?
I mean the errors panel that you show in that video.

Quote from: Giacomo on Fri 18/10/2024 21:04:44P.S. I have a question regarding android and the conversion of right/left click into taps, can I post it on beginner's tech questions?

Sure, I think.

Crimson Wizard

Giacomo could not make a post for some reason (forum problem), so he sent me these callstacks via PM:

Looking at the length of the first callstack, can this be a stack overflow because of a recursion?

ERROR 1
Spoiler
Aborted(RuntimeError: unreachable executed) localhost:8080:1:12484
    printErr http://localhost:8080/:1
    abort http://localhost:8080/ags.js:1
    runAndAbortIfError http://localhost:8080/ags.js:1
    maybeStopUnwind http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    doRewind http://localhost:8080/ags.js:1
    handleSleep http://localhost:8080/ags.js:1
    callUserCallback http://localhost:8080/ags.js:1
    safeSetTimeout http://localhost:8080/ags.js:1
    (Asinc.: setTimeout handler)
    safeSetTimeout http://localhost:8080/ags.js:1
    _emscripten_sleep http://localhost:8080/ags.js:1
    handleSleep http://localhost:8080/ags.js:1
    _emscripten_sleep http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:3127678
    <anonima> http://localhost:8080/ags.wasm:6290554
    <anonima> http://localhost:8080/ags.wasm:1474006
    <anonima> http://localhost:8080/ags.wasm:673255
    <anonima> http://localhost:8080/ags.wasm:5888127
    <anonima> http://localhost:8080/ags.wasm:6718508
    <anonima> http://localhost:8080/ags.wasm:5888349
    <anonima> http://localhost:8080/ags.wasm:2433407
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:228403
    <anonima> http://localhost:8080/ags.wasm:396044
    <anonima> http://localhost:8080/ags.wasm:412727
    <anonima> http://localhost:8080/ags.wasm:401156
    <anonima> http://localhost:8080/ags.wasm:692903
    <anonima> http://localhost:8080/ags.wasm:1247968
    <anonima> http://localhost:8080/ags.wasm:555818
    <anonima> http://localhost:8080/ags.wasm:5992611
    <anonima> http://localhost:8080/ags.wasm:2486394
    <anonima> http://localhost:8080/ags.wasm:2079011
    <anonima> http://localhost:8080/ags.wasm:2073672
    <anonima> http://localhost:8080/ags.wasm:2083564
    <anonima> http://localhost:8080/ags.wasm:6541308
    <anonima> http://localhost:8080/ags.wasm:2852711
    x http://localhost:8080/ags.js:1
    invoke_iiiii http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:204605
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174598
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174598
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174598
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174598
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174598
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174598
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174127
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174598
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:2381559
    <anonima> http://localhost:8080/ags.wasm:6174598
    <anonima> http://localhost:8080/ags.wasm:2557198
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:2378943
    <anonima> http://localhost:8080/ags.wasm:6540280
    <anonima> http://localhost:8080/ags.wasm:2853185
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4876650
    <anonima> http://localhost:8080/ags.wasm:6541119
    <anonima> http://localhost:8080/ags.wasm:1416519
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:205172
    <anonima> http://localhost:8080/ags.wasm:839132
    <anonima> http://localhost:8080/ags.wasm:6540085
    <anonima> http://localhost:8080/ags.wasm:2852711
    x http://localhost:8080/ags.js:1
    invoke_iiiii http://localhost:8080/ags.js:1
    <anonima> http://localhost:8080/ags.wasm:4877443
    <anonima> http://localhost:8080/ags.wasm:6541119
[close]

ERROR 2
Spoiler
Uncaught RuntimeError: Aborted(RuntimeError: unreachable executed). Build with -sASSERTIONS for more info.
    abort http://localhost:8080/ags.js:1
    runAndAbortIfError http://localhost:8080/ags.js:1
    maybeStopUnwind http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    doRewind http://localhost:8080/ags.js:1
    handleSleep http://localhost:8080/ags.js:1
    callUserCallback http://localhost:8080/ags.js:1
    safeSetTimeout http://localhost:8080/ags.js:1
    setTimeout handler*safeSetTimeout http://localhost:8080/ags.js:1
    _emscripten_sleep http://localhost:8080/ags.js:1
    handleSleep http://localhost:8080/ags.js:1
    _emscripten_sleep http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_iiiii http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_vi http://localhost:8080/ags.js:1
    x http://localhost:8080/ags.js:1
    invoke_v http://localhost:8080/ags.js:1
    ags.js:1:8009
[close]




eri0o

@Giacomo  Can the game be configured to load and cause the error as soon as possible? If it can it would be nice to get a link to such build.

The callstack in the web build is a bit complex because there's some magic going on to handle the different game loops in AGS engine, so I would need to run it through a debugger to make some sense of it.

Giacomo

I can post again. Sure, @eri0o:

Here's the download link.
https://www.dropbox.com/scl/fo/8ftrdybiq5ognywcrv7a6/APv3A42uW15PSLo9PVNyGWs?rlkey=vw0ldgdywa2hvqk07av74w9hl&st=yt3d0dvi&dl=0


1) Start the game.
2) Open menu and click on character drawn on the right of the menu GUI
3) Click on "All dialogues" button. Now all the introducing dialogues have been set to done.
4) Walk right and go to 3rd scenario, walk close to the pole in the right of the screen.
5) Save the game
6) Look at the pole to start conversation with the hanging man.
7) Choose option 6(talk about a plan B)and then option 6 again(say you don't have any ideas)
8) Now the dialogues quest start. I left a little of phrases that I found funny, anyway, with a really few clicks you will skip them all and start the dialogue.

One last thing, I put it in spoiler because it's a solution of the game!
Spoiler
Answers 4, 5, 7, 8 don't affect with the process, but if you click on them, they will be set off.

Correct answer is: food / sweets / sugar candies
All the others will take you back to the beginning

If you go straight for "sugar candies", the exception won't be thrown.
If you go for "sugar candies" the 2nd time, the exception will be thrown.
If you go for any wrong answer, the 2nd time you start the dialog, the exception will be thrown.
[close]


If you need anything else, just send me a message. Thank you very much.
https://ko-fi.com/giacomo97557 To support Falco's adventures

eri0o

@Giacomo , the link you shared is not for the game, it looks like some sheet music for some classical music, and I think there is one for Monkey Island (and One Piece?)  :-D

Giacomo

Sorry...this happen when you're on rush because your family is buzzing around you...

Here's the link to the game:
https://www.dropbox.com/scl/fi/evlq81tgw77ogsj6benvc/falco_debugCopy.zip?rlkey=mqipijes6vwrz2yaodxtsbn5i&st=gj0qu7dy&dl=0

Yes, there's also Bink no sake of One Piece! yohohoho
https://ko-fi.com/giacomo97557 To support Falco's adventures

Crimson Wizard

I can confirm that error reproduces 100% following the steps under the "spoiler".
(i've been running on local server, so it's not related to where the game is, alright.)

Something that bugs me, why is ags.js written as a single line? Lol. This makes it extra difficult to understand the callstack, because there are several calls to "ags.js:1".
Is there a way to regenerate ags.js with proper line indentation, at least for debugging purposes?

I also wish that viewing ags.wasm in browser displayed comments around functions to let know which original engine function this relates too... No idea if that's possible at all.

EDIT: @Giacomo, somehow nobody asked before, but which version of AGS did you make this game with?
judging by some lines in ags.wasm, it is 3.6.0.52, is that correct?

Giacomo

@Crimson Wizard, I confirm that the version of AGS I am using is the last one.


Anyway, I contacted Khris for another problem with the web version of the game. It seems to concern with his Scrolling Dialogs module:
when I press on arrow buttons, the game crashes and he said that it seems to be stacking in a loop. Scrolling with the mouse trough the dialogue options works fine instead.

Maybe the two problems are correlated as the game crashes when I am inside a dialogue and I'm using his module; he's doing some tests to understand why this happen on web.
https://ko-fi.com/giacomo97557 To support Falco's adventures

Crimson Wizard

Quote from: Giacomo on Mon 21/10/2024 08:47:07Anyway, I contacted Khris for another problem with the web version of the game. It seems to concern with his Scrolling Dialogs module:
when I press on arrow buttons, the game crashes and he said that it seems to be stacking in a loop. Scrolling with the mouse trough the dialogue options works fine instead.

Hmm, yes, it happens immediately when you click on a scroll button. Although there's no crash it seems, only game update hangs forever for some reason.
Usually this is an indication of script running in an endless loop, or engine doing the same.

Can you tell where I can get this module, or is it exclusively made for your game?
I see this one:
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-scrollingdialog-v3-0-updated-27-january-2016/
but it's made by monkey0506, not Khris.

eri0o

I tried to build the AGS engine for debugging. I didn't attempt to build the exact version you used but instead I decided to build the one in this commit here https://github.com/adventuregamestudio/ags/tree/744406cd444ca935685d235ca8368af71f7d1154 (it was current master when I built).

I actually put a build of it here publicly, along with the corresponding ags source files, so one can run it on the Chrome Dev Tools debugger and follow along in the cpp files. You just attach your game files there and it should start.

Unfortunately, I am having an error much earlier, in Step 6, I started the conversation with the hanging man, but as I understand to do step 7 I need to click to scroll the dialogs to get to the sixth option, but unfortunately clicking on the scroll hangs the game. You can easily reproduce it by running in the url above.

I put a release build in agsjs website, using the same commit, just to test if it's some issue with the debug build, but unfortunately, it reproduces.

Could you give me the code for how you make that scroll in the dialog? I would like to figure the minimal thing necessary to reproduce that bug. After that one can be fixed we can try moving to the other.

Spoiler
Also I see a few messages in the console reggarding the save

Code: ags
22:59:28:194: Unable to read save's description.
agsjs/:1 22:59:28:194: File not found or could not be opened.
agsjs/:1 22:59:28:195: Requested filename: /home/web_user/saved_games/Lightning strike in town festival/agssave.052.
agsjs/:1 22:59:28:198: Unable to read save's description.
agsjs/:1 22:59:28:198: File not found or could not be opened.
agsjs/:1 22:59:28:198: Requested filename: /home/web_user/saved_games/Lightning strike in town festival/agssave.053.
agsjs/:1 22:59:28:203: Unable to read save's screenshot.
agsjs/:1 22:59:28:204: File not found or could not be opened.
agsjs/:1 22:59:28:204: Requested filename: /home/web_user/saved_games/Lightning strike in town festival/agssave.050.
agsjs/:1 22:59:28:204: Unable to read save's screenshot.
agsjs/:1 22:59:28:204: File not found or could not be opened.
agsjs/:1 22:59:28:204: Requested filename: /home/web_user/saved_games/Lightning strike in town festival/agssave.050.
agsjs/:1 22:59:28:205: Unable to read save's screenshot.
agsjs/:1 22:59:28:205: File not found or could not be opened.
agsjs/:1 22:59:28:205: Requested filename: /home/web_user/saved_games/Lightning strike in town festival/agssave.050.

I guess you hardcoded the save files in the gui, the nice approach is to fill an out of screen or invisible list box with the saves and then retrieving them from the listbox.
[close]

Crimson Wizard

Quote from: eri0o on Wed 23/10/2024 03:05:01Unfortunately, I am having an error much earlier, in Step 6, I started the conversation with the hanging man, but as I understand to do step 7 I need to click to scroll the dialogs to get to the sixth option, but unfortunately clicking on the scroll hangs the game.

That's what Giacomo also mentioned in his last post. You need to use mouse wheel to scroll and get to the crash.

Snarky

Quote from: Crimson Wizard on Tue 22/10/2024 23:56:28
Quote from: Giacomo on Mon 21/10/2024 08:47:07Anyway, I contacted Khris for another problem with the web version of the game. It seems to concern with his Scrolling Dialogs module:
Can you tell where I can get this module, or is it exclusively made for your game?
I see this one:
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-scrollingdialog-v3-0-updated-27-january-2016/
but it's made by monkey0506, not Khris.

Could it be this module? It's been the cause of problems before.

Giacomo

Thank you people for your interest.

Khris sent me the module via PM, I tried to search for it in AGS website and I couldn't find it either.
I'd rather ask @Khris the permission to send you the module, though I guess there is no problem; but let's wait an answer from him.

@eri0o You are right, I harcoded the save GUI because I wanted to take a screenshot of the player in his position.
I wasn't able to use the list box and make it work using a loop.
I had no problem with it on windows and web(so far!), but of course the code can be reduced and be rewritten much better.
https://ko-fi.com/giacomo97557 To support Falco's adventures

Khris

It's this one: https://drive.google.com/file/d/19uyh4VBjeMkhg-oNX2RC-STsw7IGG9Bl/view?usp=drive_link

I only publish modules in their own threads after extensive testing (i.e. never). This one was thrown together in an afternoon.

Crimson Wizard

Quote from: Khris on Wed 23/10/2024 10:46:45It's this one: https://drive.google.com/file/d/19uyh4VBjeMkhg-oNX2RC-STsw7IGG9Bl/view?usp=drive_link

This is likely a culprit:

Code: ags
void noloopcheck dialog_options_mouse_click(DialogOptionsRenderingInfo *info, MouseButton button) {
  if (button == eMouseLeft) {
    if (_mouseOverUpArrow && _showUpArrow) {
      while (mouse.IsButtonDown(eMouseLeft)) {} // <--------------------------------------
      _scrolledDown--;
    }
    if (_mouseOverDownArrow && _showDownArrow) {
      while (mouse.IsButtonDown(eMouseLeft)) {} // <--------------------------------------
      _scrolledDown++;
    }
  }

  <...>
}

void noloopcheck dialog_options_key_press(DialogOptionsRenderingInfo *info, eKeyCode keycode, int mod) {
  if (_keyboardScrolling && keycode == eKeyUpArrow && _showUpArrow) {
    while (IsKeyPressed(eKeyUpArrow)) {} // <--------------------------------------
    _scrolledDown--;
    return;
  }
  if (_keyboardScrolling && keycode == eKeyDownArrow && _showDownArrow) {
    while (IsKeyPressed(eKeyDownArrow)) {} // <--------------------------------------
    _scrolledDown++;
    return;
  }

  <...>
}


The problem is that engine does not guarantee updates of mouse or key states unless control is passed back to it. So empty loops like that are not reliable.
I would even say that this should not work.
Frankly, I'm not sure how it works on desktop systems, maybe by accident... Like, maybe the buttons are no longer pressed anymore when the script enters these lines. Probably it works bit differently on Web version.


EDIT:
roflmao... just like I knew it, this is a comment from the engine code inside IsKeyPressed:
Code: cpp

    // old input handling: update key state in realtime
    // left only in case if necessary for some ancient game, but
    // this really may only be required if there's a key waiting loop in
    // script without Wait(1) to let engine poll events in a natural way.
    if (game.options[OPT_KEYHANDLEAPI] == 0)
        SDL_PumpEvents();

Mouse.IsButtonDown does not have this.

Khris


SMF spam blocked by CleanTalk