Illegal exception[SOLVED]

Started by Vincent, Wed 23/08/2017 01:15:35

Previous topic - Next topic

Vincent

Good Evening to all Agser.

Recently I had an issue but I am not sure how to solve it at the moment.
I am using a plugin "agsjoy" by Wyz with Ags 3.2.1.
Lately I have done a savestate with a joystick plugged into the pc.
But after closing the game and removing the joystick from the pc, when I am about to load the game I get this message.
I think I know what it's going on but I am not sure how can I avoid it into the script?

An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x62151082 ; program pointer is +2051, ACI version 3.21.1115, gtags (123,2)



Crimson Wizard

This is not a script error, this is either engine or plugin error, so you cannot fix it yourself.
The "program pointer is +2051" indicates it happens when save is loaded, so my guess is that plugin fails to restore its own data from savegame if no joystick is found.
I suggest reporting all this in plugin's thread.

Vincent

Thanks for the quickly response Crimson Wizard.
I think you guess is right, the plugin just fail to restore it's own data if no joystick is found.
So I was wondering if there's a way to check if the joystick is plugged or not when the game is about to be restored.

Crimson Wizard

#3
Quote from: Vincent on Wed 23/08/2017 01:42:03
So I was wondering if there's a way to check if the joystick is plugged or not when the game is about to be restored.

There is a way to know how many joysticks are found using plugin functions. But you won't be able to know what is inside savegame beforehand, and won't be able to tell plugin to load savegame differently.

Game restores all objects created in script at the moment of saving. If there were some objects created by plugin, it will try to recreate them anyway with the plugin's help. If plugin is failing at this task, there is nothing you can do.

Mandle

Quote from: Crimson Wizard on Wed 23/08/2017 02:36:52
If plugin is failing at this task, there is nothing you can do.

Well, he may be able to at least have the game not allow the game load and tell the player to plug in the joystick before attempting to load again, and prevent the crash.

Vincent

Thanks Crimson Wizard for the clarification and Mandle.
As the latter mentioned, I just would like to prevent somehow this crash.
Even though there is a way to know how many joysticks are found using plugin functions...
I won't be able to know what is inside savegame beforehand to see if a savegame was saved with a joystick or not.
I am surprised to be the first and only one to have this problem with this plugin?
What about the other people that used this plugin into their game?
How have you managed to solve this kind of issue?

Crimson Wizard

#6
Quote from: Mandle on Wed 23/08/2017 03:28:10
Quote from: Crimson Wizard on Wed 23/08/2017 02:36:52
If plugin is failing at this task, there is nothing you can do.
Well, he may be able to at least have the game not allow the game load and tell the player to plug in the joystick before attempting to load again, and prevent the crash.

If it is okay to do this check everytime regardless of what is in save, then yes, it is possible. All you have to do is to make such check before calling RestoreGameSlot or RestoreGameDialog. AFAIK there is plugin function "JoystickCount" that tells you amount of joysticks.

However, if in this game joystick is just an optional control method, such solution won't be a good one, because there is no way to tell whether player had joystick when making save in the first place.

(BTW, error in plugin is just a guess. This may be something in AGS too.)

Snarky

Quote from: Crimson Wizard on Wed 23/08/2017 15:06:36
However, if in this game joystick is just an optional control method, such solution won't be a good one, because there is no way to tell whether player had joystick when making save in the first place.

Well, he could write that info to a separate file upon save, then read it before trying to load the savegame.

Crimson Wizard

I see, so, again, instead of reporting and pursing to fix the actual error, invent 1000 workarounds. Okay.

Mandle

Quote from: Crimson Wizard on Wed 23/08/2017 15:40:37
I see, so, again, instead of reporting and pursing to fix the actual error, invent 1000 workarounds. Okay.

Those two options are not mutually exclusive.

Trying to get the plugin fixed is the best option but there's no telling if that will end up happening or how long it may take.

Meanwhile, use a workaround.

Seems reasonable to me.

Crimson Wizard

Yes, you are right, I was getting frustrated for some reason...

Mandle

Quote from: Crimson Wizard on Thu 24/08/2017 02:03:47
Yes, you are right, I was getting frustrated for some reason...

My wife shows me cat videos on her phone when that happens to me.

I pretend to calm down while it secretly annoys me further, just to make it stop...

(laugh)

Vincent

So guys, I found a text document made by Wyz about using the plugin and found this note inside.

[ Basic usage ]
     
First you need to know how many, if any, joysticks are available. You can
retrieve the name of them with out having to open them to give the user a
possibility to select one. After you are going to use one, you need to open
it and store the object at an appropriate place. After that you can access
all variables from the object.  If you want to use events,  you  have to
enable them, the  are turned  off by default.  When you're done with the
joystick you can close the object. This will not destroy it but will stop
it from updating, and renders it in valid. If you were using events, first
disable them. Another way for a joystick object to become invalid is when
the player restored a save game and the joystick was disconnected. In that
case you can show a windows or do something useful.


Well, I am still not sure how to do that?
Also, regarding Snarky's workaround, how should go ahead and do something like that via script?
Thanks a lot for all your help guys, I really appreciated.

Snarky

#13
Quote from: Vincent on Fri 25/08/2017 07:50:48
Well, I am still not sure how to do that?

You should start by doing what CW recommended way back in the first response:

Quote from: Crimson Wizard on Wed 23/08/2017 01:22:38
I suggest reporting all this in plugin's thread.

Here's a link: http://www.adventuregamestudio.co.uk/forums/index.php?topic=41658.0;all

Vincent

Thanks for the suggestion once again and for sharing the link so far... I appreciated! :)

Wyz

Hmmm, I guess this is a bug of some kind. Every plug-in object is serialized--turned into a data blob which is added to the save file--when the game is saved. When the game loads again the plug-in is then responsible for unserializing the objects, basically do whatever to make it work again. Looks like something goes wrong at the unserializing stage. I store the joystick state (which buttons are down etc) and the joystick's name. When the game loads again the state is restored and the plug-in checks whether the joystick's name has changed. It either is no longer present or the order of joysticks plugged in has changed; in both cases the object is invalidated.

That said I do have an idea what might be causing this. Which exact version of the plugin are you using?

Spoiler
I seriously need to revisit this plug-in; reading that poorly written manual alone made me cringe. :D
[close]
Life is like an adventure without the pixel hunts.

Vincent

Thank you very much for the clarifications. :)
Yes, that's what we thought was going on indeed. I hope somehow it could be fixed. :(

I am using agsjoy v.1.2.0.0 (Last modified says 17/10/2010) which I am not sure if it's the latest version?

Crimson Wizard

I'd also suggest to upgrade your game to AGS 3.3.0 at least, if you can, because we may diagnose its crash dumps to at least know where error occurs exactly, but we cannot do the same with AGS 3.2.1.

Wyz

#18
I've compiled a new version of the plug-in and uploaded it here (temporarily).
Kindly give it a go and see if it works. ;)

If so I'll re-release it then. (although I don't have a place to host such things anymore unfortunately)

Let me know and thanks for your feedback. :)
Life is like an adventure without the pixel hunts.

Vincent

First of all I would like to say thank you very much for the time you spent to do this fix.
I really much appreciated! I just hope it will work fine. :)
I am going to download this newest version and let you know as soon as possible, still thank you very much!

Vincent

#20
I was confident that everything would go well but unfortunately I get the same error (or almost).
I notice that this time the error it's slightly different from the first one that I got a couple of days ago.

This is how the newest error looks like:
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x70441082 ; program pointer is +2051, ACI version 3.21.1115, gtags (123,2)

And the old one was like this:
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x62151082 ; program pointer is +2051, ACI version 3.21.1115, gtags (123,2)


:EDIT:
I have done this process once again and I get another different error!? (not sure if it is important or not?!)
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x6F8B18B0 ; program pointer is +2051, ACI version 3.21.1115, gtags (123,2)

Monsieur OUXX

Do you still get the error when you restore a saved game while there is no joystick plugged?

If yes, then, while Wyz might be working on it (you're a lucky AGSer having a plugin author look specifically into your issue! ;) ), you can extremely easily do what was suggested earlier, both by the plugin's manual (even though not explained in detail) and by Crimson Wizard: just before calling the RestoreSavedGame, check if there is a joystick plugged. If not, then display a message and do not call RestoreSavedGame
 

Vincent

#22
Quote from: Monsieur OUXX on Sat 26/08/2017 15:45:16
Do you still get the error when you restore a saved game while there is no joystick plugged?

Yes, I have just done to test this, what do you think I've tried until now?! :)

Quote from: Monsieur OUXX on Sat 26/08/2017 15:45:16
If yes, then, while Wyz might be working on it (you're a lucky AGSer having a plugin author look specifically into your issue! ;) ), you can extremely easily do what was suggested earlier, both by the plugin's manual (even though not explained in detail) and by Crimson Wizard: just before calling the RestoreSavedGame, check if there is a joystick plugged. If not, then display a message and do not call RestoreSavedGame

Yes, you are right, I feel much lucky about this indeed!
I can not thank enough Wyz that he's giving me an help on this issue, really.
About what CW and Snarky suggest before it's just fine but I really would like to avoid this (if possible).
I mean if a joystick it's not plugged anymore (in a previous savestate that it was plugged in) then the plugin should turn off or something alike to prevent this issue and the game will keep running normally (not sure if this is possible at the moment, it sound like a twisted logic of mine).

Wyz

Ok, I finally got round to test this myself and good news: I was able to replicate the error. I should be able to fix this relatively easy. ;-D

You should probably still do something when the game is restored (using on_event). When the game is restored and the plugin misses it, it will be marked invalid. You can test this by checking the Valid function. A good moment to reset the input configuration, or inform the player, or something.

I'll keep you posted. :)
Life is like an adventure without the pixel hunts.

Vincent

#24
Fantastic, I am really much HAPPY to hear this news from you! :)
It's ok about using extra check like the valid function, maybe it should be something like this?
Code: ags

function on_event (EventType event, int data) 
{
  if (event == eEventRestoreGame)
  {
    if (joy == null || (!joy.Valid()))
    {
      // do stuff
    }
  }
}


Most likely however, there will need something else in the code that will have to do with your updates in the plugin I guess. I am not sure about this, but it would be amazing if you could even show me a safe way to use a code in the function on_event? That's just to be to the safe side.

Best regards!

Wyz

Well, the plug-in should never crash the game when restoring a save game that has a different joystick setup; when that happens you can consider that a bug in the plug-in, and then please let me know. When a Joystick object you made becomes invalid for whatever reason, it is replaced with a dummy object that acts like a joystick but is frozen in time. However I recommend the check to make sure the players aren't confused about the situation.
For instance when you have a single joystick setup and you let the game find (or players pick) one at the start of the game; when the players restore a game and have inadvertently changed their joystick setup you'll want to repeat this bit. If you have a game where the joystick use is optional and players have to select it in a menu or something, you'll want to show them a warning things changed and they may want to reconfigure it.
Of course I'm not telling you how to build your game, but since this matter came up, I thought I'll just give you the tip. :-D

So I think I've fixed it now. :) You can download it here (temporarily). Let me know if it works. ;-D

Btw, special thanks go to CW for suggesting to use a virtual joystick in the other thread; that really sped things up, as I didn't have to crawl through the attic opening lots of boxes, trying to find my gamepad. Thanks! :-D
Life is like an adventure without the pixel hunts.

Vincent

#26
Okay, I think I understand everything and I will try to keep these info in mind!
So... I have downloaded this newest version of the plugin and...
DEAR LORD, THIS IS WORKING LIKE A CHARM NOW!!! :-D
I really can't believe the hardest work you have done here and the time you spent to fix this issue! :)
Still thank you very much, I really much appreciated your help once again!!! :)

SMF spam blocked by CleanTalk