Fix memory leaks in strategic pathing

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1536 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-10-20 08:40:25 +00:00
parent b170dbb1e5
commit 13288fd750
10 changed files with 68 additions and 28 deletions
+13
View File
@@ -0,0 +1,13 @@
#ifndef _JA2PROTOTYPES_H
#define _JA2PROTOTYPES_H
/*
* This header does not define any structures. It simply provides a way for all code that only needs a pointer
* reference to structures, to have it without getting locked into mutual includes and other
* hard-to-trace-and-fix behavior. More class and struct defs can be added as necessary.
*/
class SOLDIERTYPE;
struct AnimationSurfaceType;
#endif
+1 -1
View File
@@ -555,7 +555,7 @@ BOOLEAN CreateDestroyMainMenuButtons( BOOLEAN fCreate )
INT32 cnt;
SGPFILENAME filename;
INT16 sSlot;
INT32 iStartLoc=0;
//INT32 iStartLoc=0;
#ifndef _DEBUG
CHAR16 zText[512];
#endif
+21 -10
View File
@@ -629,11 +629,17 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN
}
InterruptTime();
PauseGame();
LockPauseState( 1 );
// Pause timers as well....
PauseTime( TRUE );
#if 0
gMsgBox.fWasPaused = GamePaused();
if (!gMsgBox.fWasPaused)
{
InterruptTime();
PauseGame();
LockPauseState( 1 );
// Pause timers as well....
PauseTime( TRUE );
}
#endif
// Save mouse restriction region...
GetRestrictedClipCursor( &gOldCursorLimitRectangle );
@@ -867,11 +873,16 @@ UINT32 ExitMsgBox( INT8 ubExitCode )
// Delete button images
UnloadButtonImage( gMsgBox.iButtonImages );
// Unpause game....
UnLockPauseState();
UnPauseGame();
// UnPause timers as well....
PauseTime( FALSE );
#if 0
if (!gMsgBox.fWasPaused)
{
// Unpause game....
UnLockPauseState();
UnPauseGame();
// UnPause timers as well....
PauseTime( FALSE );
}
#endif
// Restore mouse restriction region...
RestrictMouseCursor( &gOldCursorLimitRectangle );
+1
View File
@@ -71,6 +71,7 @@ typedef struct
INT8 bHandled;
INT32 iBoxId;
BOOLEAN fWasPaused;
} MESSAGE_BOX_STRUCT;
+4 -4
View File
@@ -470,7 +470,7 @@ Uncomment this to enable the check for files to activate the blood and gore opti
if( usTextWidth > OPT_TOGGLE_BOX_TEXT_WIDTH )
{
//Get how many lines will be used to display the string, without displaying the string
UINT8 ubNumLines = DisplayWrappedString( 0, 0, OPT_TOGGLE_BOX_TEXT_WIDTH, 2, OPT_MAIN_FONT, OPT_HIGHLIGHT_COLOR, zOptionsToggleText[ cnt ], FONT_MCOLOR_BLACK, TRUE, LEFT_JUSTIFIED | DONT_DISPLAY_TEXT ) / GetFontHeight( OPT_MAIN_FONT );
UINT8 ubNumLines = (UINT8) ( DisplayWrappedString( 0, 0, OPT_TOGGLE_BOX_TEXT_WIDTH, 2, OPT_MAIN_FONT, OPT_HIGHLIGHT_COLOR, zOptionsToggleText[ cnt ], FONT_MCOLOR_BLACK, TRUE, LEFT_JUSTIFIED | DONT_DISPLAY_TEXT ) / GetFontHeight( OPT_MAIN_FONT ) );
usTextWidth = OPT_TOGGLE_BOX_TEXT_WIDTH;
@@ -518,7 +518,7 @@ Uncomment this to enable the check for files to activate the blood and gore opti
if( usTextWidth > OPT_TOGGLE_BOX_TEXT_WIDTH )
{
//Get how many lines will be used to display the string, without displaying the string
UINT8 ubNumLines = DisplayWrappedString( 0, 0, OPT_TOGGLE_BOX_TEXT_WIDTH, 2, OPT_MAIN_FONT, OPT_HIGHLIGHT_COLOR, zOptionsToggleText[ cnt ], FONT_MCOLOR_BLACK, TRUE, LEFT_JUSTIFIED | DONT_DISPLAY_TEXT ) / GetFontHeight( OPT_MAIN_FONT );
UINT8 ubNumLines = (UINT8) ( DisplayWrappedString( 0, 0, OPT_TOGGLE_BOX_TEXT_WIDTH, 2, OPT_MAIN_FONT, OPT_HIGHLIGHT_COLOR, zOptionsToggleText[ cnt ], FONT_MCOLOR_BLACK, TRUE, LEFT_JUSTIFIED | DONT_DISPLAY_TEXT ) / GetFontHeight( OPT_MAIN_FONT ) );
usTextWidth = OPT_TOGGLE_BOX_TEXT_WIDTH;
@@ -1052,7 +1052,7 @@ void BtnOptionsTogglesCallback( GUI_BUTTON *btn, INT32 reason )
void HandleOptionToggle( UINT8 ubButton, BOOLEAN fState, BOOLEAN fDown, BOOLEAN fPlaySound )
{
static UINT32 uiOptionToggleSound = NO_SAMPLE;
UINT32 uiSideToPlaySoundOn = MIDDLEPAN;
//UINT32 uiSideToPlaySoundOn = MIDDLEPAN;
// static BOOLEAN fCheckBoxDrawnDownLastTime = FALSE;
if( fState )
@@ -1218,7 +1218,7 @@ void HandleSliderBarMovementSounds()
{
static UINT32 uiLastSoundFxTime=0;
static UINT32 uiLastSpeechTime=0;
UINT32 uiCurTime = GetJA2Clock();
//UINT32 uiCurTime = GetJA2Clock();
static UINT32 uiLastPlayingSoundID = NO_SAMPLE;
static UINT32 uiLastPlayingSpeechID = NO_SAMPLE;
+4 -4
View File
@@ -19,11 +19,11 @@ int iScreenMode = 0; /* 0 for Fullscreen */
#endif
BOOL bScreenModeCmdLine = FALSE;
int SCREEN_WIDTH;
int SCREEN_HEIGHT;
UINT16 SCREEN_WIDTH;
UINT16 SCREEN_HEIGHT;
int iScreenWidthOffset;
int iScreenHeightOffset;
INT16 iScreenWidthOffset;
INT16 iScreenHeightOffset;
BOOLEAN fDisplayOverheadMap;
+11 -4
View File
@@ -513,7 +513,7 @@ BOOLEAN SaveGame( UINT8 ubSaveGameID, STR16 pGameDesc )
HWFILE hFile=0;
SAVED_GAME_HEADER SaveGameHeader;
CHAR8 zSaveGameName[ MAX_PATH ];
UINT32 uiSizeOfGeneralInfo = sizeof( GENERAL_SAVE_INFO );
//UINT32 uiSizeOfGeneralInfo = sizeof( GENERAL_SAVE_INFO );
//UINT8 saveDir[100];
BOOLEAN fPausedStateBeforeSaving = gfGamePaused;
BOOLEAN fLockPauseStateBeforeSaving = gfLockPauseState;
@@ -1454,7 +1454,7 @@ BOOLEAN LoadSavedGame( UINT8 ubSavedGameID )
INT16 sLoadSectorY;
INT8 bLoadSectorZ;
CHAR8 zSaveGameName[ MAX_PATH ];
UINT32 uiSizeOfGeneralInfo = sizeof( GENERAL_SAVE_INFO );
//UINT32 uiSizeOfGeneralInfo = sizeof( GENERAL_SAVE_INFO );
UINT32 uiRelStartPerc;
UINT32 uiRelEndPerc;
@@ -3594,7 +3594,7 @@ BOOLEAN SaveEmailToSavedGame( HWFILE hFile )
UINT32 uiNumOfEmails=0;
UINT32 uiSizeOfEmails=0;
EmailPtr pEmail = pEmailList;
EmailPtr pTempEmail = NULL;
//EmailPtr pTempEmail = NULL;
UINT32 cnt;
UINT32 uiStringLength=0;
UINT32 uiNumBytesWritten=0;
@@ -4281,7 +4281,11 @@ BOOLEAN LoadMercPathToSoldierStruct( HWFILE hFile, UINT8 ubID )
//Allocate memory for the new node
pTemp = (PathStPtr) MemAlloc( sizeof( PathSt ) );
if( pTemp == NULL )
{
pTempPath = MoveToBeginningOfPathList( pTempPath );
ClearStrategicPathList( pTempPath, -1 );
return( FALSE );
}
memset( pTemp, 0 , sizeof( PathSt ) );
@@ -4289,6 +4293,9 @@ BOOLEAN LoadMercPathToSoldierStruct( HWFILE hFile, UINT8 ubID )
FileRead( hFile, pTemp, sizeof( PathSt ), &uiNumBytesRead );
if( uiNumBytesRead != sizeof( PathSt ) )
{
MemFree( pTemp);
pTempPath = MoveToBeginningOfPathList( pTempPath );
ClearStrategicPathList( pTempPath, -1 );
return(FALSE);
}
@@ -5109,7 +5116,7 @@ void GetBestPossibleSectorXYZValues( INT16 *psSectorX, INT16 *psSectorY, INT8 *p
INT16 sSoldierCnt;
SOLDIERTYPE *pSoldier;
INT16 bLastTeamID;
INT8 bCount=0;
//INT8 bCount=0;
BOOLEAN fFoundAMerc=FALSE;
// Set locator to first merc
+1 -1
View File
@@ -1813,7 +1813,7 @@ void SelectedSaveRegionMovementCallBack(MOUSE_REGION * pRegion, INT32 reason )
void InitSaveLoadScreenTextInputBoxes()
{
UINT32 uiStartLoc=0;
//UINT32 uiStartLoc=0;
UINT16 usPosY;
SAVED_GAME_HEADER SaveGameHeader;
+8
View File
@@ -255,6 +255,10 @@
RelativePath=".\Options Screen.cpp"
>
</File>
<File
RelativePath=".\profiler.cpp"
>
</File>
<File
RelativePath=".\SaveLoadGame.cpp"
>
@@ -377,6 +381,10 @@
RelativePath=".\Options Screen.h"
>
</File>
<File
RelativePath=".\profiler.h"
>
</File>
<File
RelativePath=".\SaveLoadGame.h"
>
+4 -4
View File
@@ -25,12 +25,12 @@
#define WINDOWED_MODE
#endif
extern int SCREEN_WIDTH;
extern int SCREEN_HEIGHT;
extern UINT16 SCREEN_WIDTH;
extern UINT16 SCREEN_HEIGHT;
extern int iResolution; // Resolution id from the ini file
extern int iScreenWidthOffset;
extern int iScreenHeightOffset;
extern INT16 iScreenWidthOffset;
extern INT16 iScreenHeightOffset;
extern BOOLEAN fDisplayOverheadMap;