Fatal exception on game restart

Started by wynni2, Mon 10/04/2017 21:42:02

Previous topic - Next topic

wynni2

Hi all -

My game has started crashing with a fatal exception error whenever I call the "game restart" function.  Here is the crashdump report:

Code: ags

---------------------------
Adventure Game Studio
---------------------------
An error occurred whilst trying to load your game. The error was: 



Data at the root level is invalid. Line 1, position 1.

Error details: System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

   at System.Xml.XmlTextReaderImpl.Throw(Exception e)

   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)

   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()

   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()

   at System.Xml.XmlTextReaderImpl.Read()

   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)

   at System.Xml.XmlDocument.Load(XmlReader reader)

   at System.Xml.XmlDocument.Load(String filename)

   at AGS.Editor.AGSEditor.LoadGameFile(String fileName)

   at AGS.Editor.Tasks.LoadGameFromDisk(String gameToLoad, Boolean interactive)

   at AGS.Editor.InteractiveTasks.LoadGameFromDisk(String gameToLoad)
---------------------------


I've seen that these exceptions can be triggered by problems with sprite handling, and just before this issue occurred the game crashed while running an animation (which had previously run without issue).  I suppose I can start by reimporting some of my sprites and see if that helps.

Any other thoughts?

Thanks.

wynni2

#1
Update: I think I found the piece of code that is causing the issue.  I have a dynamic array of DynamicSprite pointers that I'm using for inventory objects:

Code: ags

DynamicSprite* dsinv[];

export dsinv; 

void LoadInventorySprites() {
  dsinv = new DynamicSprite[Game.InventoryItemCount+1]; 
    int i=1; 
      while (i <= Game.InventoryItemCount) { //loop through and create sprites
        dsinv[i] = DynamicSprite.Create(invInventory1.ItemWidth, invInventory1.ItemHeight); 
          DrawingSurface *drinvsp = dsinv[i].GetDrawingSurface(); 
            drinvsp.Clear(50712); 
            String s = inventory[i].Name; 
              drinvsp.DrawingColor = 0; 
              drinvsp.DrawString(5, 5, Game.NormalFont, s); 
                drinvsp.DrawingColor = 33808; 
                drinvsp.DrawLine(2, dsinv[i].Height, (dsinv[i].Width-2), dsinv[i].Height, 2); 
                  drinvsp.Release(); 
                  
                    inventory[i].Graphic = dsinv[i].Graphic; 
                    
                    i++; //next index
      }
        
}


That command is called on game_start.  If this command isn't called, the game restarts without issue.  The initial startup goes fine either way. 

I can see a few ways to fix this problem, but it's probably happening because I don't understand the engine well enough.  Any thoughts on what I'm doing wrong? 

Thanks.

Crimson Wizard

#2
I am confused by the error message you posted first, it is rather an Editor error which indicates that the project file that you are trying to open got corrupted somehow. Did that happen after your game crashed and you tried to load project into editor? And were you able to fix that error and load project eventually?

Was there actual game crash message?


Regarding game restart, RestartGame loads a special save slot created either with SetRestartPoint or automatically by the engine. Automatic save is created right after game_start was called, so in theory it should load game state with valid dynamic sprites.
If it did not restore them properly for some reason, then inventory items may receive invalid sprite IDs.

I may suggest making an experiment: use function "on_event" to catch game restore event and check whether sprites exist at that point.
Code: ags

function on_event (EventType event, int data) 
{
    if (event == eEventRestoreGame)
    {
        // check dsinv array
    }
}

wynni2

Sorry, I posted the .dmp file first.  Here is the error message:

Code: ags

---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x0041DB91 ; program pointer is +2051, ACI version 3.3.3.0, gtags (15,7)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.


The issue resolved when I changed the dsinv[] array from a dynamic array to an array with a fixed size, so I'm assuming the issue was in the way I declared the size of the array. 

Thanks.


Crimson Wizard

#4
Quote from: wynni2 on Mon 10/04/2017 22:46:55
Sorry, I posted the .dmp file first.

Ah, wait, did you try to open the dmp file in AGS somehow? Because it cannot do that. The message you posted is probably AGS telling you it cannot open it.

The dmp files are to be opened in the Microsoft Visual Studio, it's the development tool we use to create AGS. We sometimes ask to upload this file so that developers could check it.



SMF spam blocked by CleanTalk