Home » MODDING HQ 1.13 » v1.13 Bug Reports » Crash after longer playing sessions + possible fix
Crash after longer playing sessions + possible fix[message #345261]
|
Mon, 02 May 2016 19:00
|
|
Subotai |
|
Messages:2
Registered:May 2016 |
|
|
Hi!
I found and tested the following in an older (ancient ) version of the 1.13 mod, but I think it's still a problem. ( Unfortunately I couldn't compile the fix with the latest version, but looking at the code, it's still looks the same to me, and the crash happens with JA2_Stable2014_r7798 too.)
So the bug is that, after playing for a longer period of time the game GUI messes up and crashes ( with this assert in debug mode, or in JA2_Stable2014_r7798):
Assertion Failure [Line 1944 in file Button System.cpp]. Attempting to do a debug save as SaveGame247.sav (this may fail)
"Attempting to QuickCreateButton with out of range ImageID -1."
To reproduce this bug I saved the game in tactical mode, with one of my merc's inventory panel open, and continuously quick-loaded the game. The crash always seemed to happen after reloading the game about 70 times.
I found that the problem is simply that,( I'm not a coder so my theory needs confirmation), when the game loads buttons in Interface Panels.cpp:
BOOLEAN CreateSMPanelButtons( ) the ...
iBurstButtonImages[ WM_AUTOFIRE ] = UseLoadedButtonImage( iSMPanelImages[ STANCEUP_IMAGES ], -1, 17, -1, -1, -1 );
... button is loaded, but not removed like all the other buttons in:
void RemoveSMPanelButtons( ) later in the code.
So every time the game loads buttons (switch between strategic/tactical interface, reloading game etc...) it has to reserve more and more image slots to the buttons, because the slot of the WM_AUTOFIRE button hasn't been cleared. This leads to an assert here in Button System.cpp:
INT32 QuickCreateButton (UINT32 Image,...)
...
if( Image < 0 || Image >= MAX_BUTTON_PICS )
{
sprintf( str, "Attempting to QuickCreateButton with out of range ImageID %d.", Image );
AssertMsg( 0, str );
}
...
I observed the maximum of "Image" slot count growing every time I reloaded ( every time around 70 times to reproduce the bug ) or switched between GUI layers, until it reached 256 (MAX_BUTTON_PICS) then it jumped up to 4294967295 ( 4gb ? possibly a memory leak related consequence, i haven't dug deeper, that's way beyond my knowledge ) , the GUI messed up and when i tried to switch to strategic map it crashed.
So long story short i added:
UnloadButtonImage( iBurstButtonImages[ WM_AUTOFIRE ] );
and it seems to be fixed for me now. The "Image" count is jumping between the same numbers every time I reload now, the maximum is not increasing ( I assume every button is created and dumped properly now), the game doesn't crash or assert.
Sorry for the long, and awkward explanation and wall of text, I'm not a coder at all, nor familiar with programming besides tinkering with the JA2 code , and as I said, couldn't test with a newer version, and don't know if this problem was solved already in an other way or not.
Report message to a moderator
|
Civilian
|
|
|
|
Re: Crash after longer playing sessions + possible fix[message #345263 is a reply to message #345262]
|
Mon, 02 May 2016 20:50
|
|
Subotai |
|
Messages:2
Registered:May 2016 |
|
|
It was simply missing from the bottom of RemoveSMPanelButtons( ) function here: (in Interface Panels.cpp) :
Toggle Spoilervoid RemoveSMPanelButtons( )
{
UINT32 cnt;
for ( cnt = 0; cnt < NUM_SM_BUTTONS; cnt++ )
{
if ( iSMPanelButtons[ cnt ] != -1 )
{
RemoveButton( iSMPanelButtons[ cnt ] );
}
}
for ( cnt = 0; cnt < NUM_SM_BUTTON_IMAGES; cnt++ )
{
if(iSMPanelImages[ cnt ] != -1)
{
UnloadButtonImage( iSMPanelImages[ cnt ] );
}
}
if ( giSMStealthButton != -1 )
{
RemoveButton( giSMStealthButton );
}
RenderBackpackButtons(DEACTIVATE_BUTTON); /* CHRISL: Needed for new inventory backpack buttons */
if ( giSMStealthImages != -1 )
{
UnloadButtonImage( giSMStealthImages );
}
RenderBackpackButtons(UNLOAD_BUTTON); /* CHRISL: Needed for new inventory backpack buttons */
UnloadButtonImage( iBurstButtonImages[ WM_NORMAL ] );
UnloadButtonImage( iBurstButtonImages[ WM_BURST ] );
HERE -> UnloadButtonImage( iBurstButtonImages[ WM_AUTOFIRE ] ); <- HERE
UnloadButtonImage( iBurstButtonImages[ WM_ATTACHED_GL ] );
UnloadButtonImage( iBurstButtonImages[ WM_ATTACHED_GL_BURST ] );
UnloadButtonImage( iBurstButtonImages[ WM_ATTACHED_GL_AUTO ] );
UnloadButtonImage( iBurstButtonImages[ WM_ATTACHED_UB ] );
UnloadButtonImage( iBurstButtonImages[ WM_ATTACHED_UB_BURST ] );
UnloadButtonImage( iBurstButtonImages[ WM_ATTACHED_UB_AUTO ] );
UnloadButtonImage( iBurstButtonImages[ WM_ATTACHED_BAYONET ] );
}
10 burst button image were loading every time in CreateSMPanelButtons( ), but only 9 of them were removed later.
I'm glad I could help if it works.
[Updated on: Mon, 02 May 2016 21:01] Report message to a moderator
|
Civilian
|
|
|
|
Goto Forum:
Current Time: Thu Apr 18 00:03:00 GMT+3 2024
Total time taken to generate the page: 0.01034 seconds
|