in ReadInAttachmentComboMergeStats() added a missing fclose plus a missing XML_free

in Items.cpp added unfriendly code to trace + stop the game when pObj is corrupted.
(the corruption comes from somewhere outside the destructed foo!)


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@900 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sergeant_Kolja
2007-05-27 12:34:43 +00:00
parent bd22863e45
commit 09a26e3155
2 changed files with 11 additions and 1 deletions
+9 -1
View File
@@ -6556,8 +6556,16 @@ INT16 GetRateOfFireBonus( OBJECTTYPE * pObj )
INT8 bLoop;
INT16 bns=0;
if( (MAXITEMS <= pObj->usItem) || (MAXITEMS <= pObj->usGunAmmoItem) )
{
DebugMsg(TOPIC_JA2, DBG_LEVEL_1, String("GetRateOfFireBonus would crash: pObj->usItem=%d or pObj->usGunAmmoItem=%d ist higher than max %d", pObj->usItem, pObj->usGunAmmoItem, MAXITEMS ));
ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"GetRateOfFireBonus would crash: pObj->usItem=%d or pObj->usGunAmmoItem=%d ist higher than max %d", pObj->usItem, pObj->usGunAmmoItem, MAXITEMS );
AssertMsg( 0, "GetRateOfFireBonus would crash" );
return 0; /* cannot calculate Bonus, this only happens sometimes in FULLSCREEN */
}
bns = BonusReduceMore( Item[pObj->usItem].rateoffirebonus, pObj->bStatus[0] );
bns += Item[pObj->usGunAmmoItem].rateoffirebonus ;
bns += Item[pObj->usGunAmmoItem].rateoffirebonus;
for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++)
{
+2
View File
@@ -193,6 +193,7 @@ BOOLEAN ReadInAttachmentComboMergeStats(STR fileName)
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
{
MemFree(lpcBuffer);
FileClose( hFile ); /* added, Sgt. Kolja */
return( FALSE );
}
@@ -220,6 +221,7 @@ BOOLEAN ReadInAttachmentComboMergeStats(STR fileName)
LiveMessage(errorBuf);
MemFree(lpcBuffer);
XML_ParserFree(parser); /* added, Sgt. Kolja */
return FALSE;
}