view calling functions

Started by wynni2, Tue 25/09/2018 00:31:00

Previous topic - Next topic

wynni2

Hi all -

Short version: If the game crashes, is there a way to view the last series of functions that were called before the crash? I've tried using the AbortGame command, but it just directs to the last function called, not the calling function. 

More detailed: My game has a reference list of "families" that used to live in the post-apocalyptic game world.  I have a command GetName(int f) that returns the name of family "f." This command is called by many other functions, for example to give the player information about the inhabitants of an abandoned house.

Occasionally the game crashes because a calling function passes GetName(-1). Is there a way to see which function called GetName(-1)? It would save me some time.

Thanks.

Crimson Wizard

#1
Usually when you are running the game under the editor and game detects error on its own (such as accessing non-existant element of array), editor will then report error and display the "Call Stack" in the special panel at the bottom, which will show you how exactly the script execution got there. This information will be shown only until you click on "I've finished examining error..." button, so make sure you don't click that immediately.

Same thing is supposed to happen if you use AbortGame.

If you don't have that panel for some reason you may enable it with "Window -> Call Stack" menu command.

If nothing of above works for some reason or you cannot/do not want to use AbortGame, then you may try something like this:
Code: ags

if (f < 0)
{
    int a = 0; // random dummy command
}

Then set breakpoint there on dummy command and Editor will stop the game and display Call Stack again if you ever get there.

Of course all this assumes you are running from the Editor. Currently AGS does not support printing call stack at any moment otherwise (perhaps might be a wanted feature).
Only alternate option I can think of is scripting custom log file and printing names of functions there. That may slow game down to some degree so make sure to implement a switch that turns it all off if you consider this solution.

Khris

Is there no other way to find out how an array index ends up -1? Is the parameter calculated?

SMF spam blocked by CleanTalk