aboutsummaryrefslogtreecommitdiff
path: root/sky
diff options
context:
space:
mode:
authorRobert Göffringmann2005-12-13 14:31:13 +0000
committerRobert Göffringmann2005-12-13 14:31:13 +0000
commitc477d545707aacaa8dbfe1bfcc0f8f83f9e772fc (patch)
tree7ba72d4204ce17800b4fcb1d2c0f30a3062d0b5a /sky
parent55178803000823e5090aa0316abd92855eafc0f1 (diff)
downloadscummvm-rg350-c477d545707aacaa8dbfe1bfcc0f8f83f9e772fc.tar.gz
scummvm-rg350-c477d545707aacaa8dbfe1bfcc0f8f83f9e772fc.tar.bz2
scummvm-rg350-c477d545707aacaa8dbfe1bfcc0f8f83f9e772fc.zip
fixed Sky memory leaks on quitting
svn-id: r19791
Diffstat (limited to 'sky')
-rw-r--r--sky/control.cpp19
-rw-r--r--sky/logic.cpp4
-rw-r--r--sky/screen.cpp35
-rw-r--r--sky/sky.cpp2
4 files changed, 35 insertions, 25 deletions
diff --git a/sky/control.cpp b/sky/control.cpp
index c5139ca35f..f0f2bb4d02 100644
--- a/sky/control.cpp
+++ b/sky/control.cpp
@@ -237,7 +237,12 @@ void Control::removePanel(void) {
delete _restartPanButton; delete _fxPanButton;
delete _musicPanButton; delete _bodge;
delete _yesNo; delete _text;
- delete _statusBar;
+ delete _statusBar; delete _restoreButton;
+
+ if (_textSprite) {
+ free(_textSprite);
+ _textSprite = NULL;
+ }
}
void Control::initPanel(void) {
@@ -318,13 +323,16 @@ void Control::initPanel(void) {
_restorePanLookList[6] = _autoSaveButton;
_statusBar = new ControlStatus(_skyText, _system, _screenBuf);
+
+ _textSprite = NULL;
}
void Control::buttonControl(ConResource *pButton) {
char autoSave[] = "Restore Autosave";
if (pButton == NULL) {
- if (_textSprite) free(_textSprite);
+ if (_textSprite)
+ free(_textSprite);
_textSprite = NULL;
_curButtonText = 0;
_text->setSprite(NULL);
@@ -431,7 +439,6 @@ void Control::doLoadSavePanel(void) {
_skyMouse->spriteMouse(MOUSE_NORMAL, 0, 0);
_lastButton = -1;
_curButtonText = 0;
- _textSprite = NULL;
saveRestorePanel(false);
@@ -469,7 +476,6 @@ void Control::doControlPanel(void) {
bool quitPanel = false;
_lastButton = -1;
_curButtonText = 0;
- _textSprite = NULL;
uint16 clickRes = 0;
while (!quitPanel && !SkyEngine::_systemVars.quitGame) {
@@ -841,7 +847,7 @@ uint16 Control::saveRestorePanel(bool allowSave) {
bool refreshNames = true;
bool refreshAll = true;
uint16 clickRes = 0;
- while (!quitPanel) {
+ while (!quitPanel && !SkyEngine::_systemVars.quitGame) {
clickRes = 0;
if (refreshNames || refreshAll) {
if (refreshAll) {
@@ -920,7 +926,8 @@ uint16 Control::saveRestorePanel(bool allowSave) {
refreshNames = true;
}
}
- if (!haveButton) buttonControl(NULL);
+ if (!haveButton)
+ buttonControl(NULL);
}
for (cnt = 0; cnt < MAX_ON_SCREEN + 1; cnt++)
diff --git a/sky/logic.cpp b/sky/logic.cpp
index f88e5d233d..b5a05c9e31 100644
--- a/sky/logic.cpp
+++ b/sky/logic.cpp
@@ -90,6 +90,10 @@ Logic::Logic(SkyCompact *skyCompact, Screen *skyScreen, Disk *skyDisk, Text *sky
Logic::~Logic(void) {
delete _skyGrid;
delete _skyAutoRoute;
+
+ for (int i = 0; i < ARRAYSIZE(_moduleList); i++)
+ if (_moduleList[i])
+ free(_moduleList[i]);
}
void Logic::initScreen0(void) {
diff --git a/sky/screen.cpp b/sky/screen.cpp
index d196edd09f..18087eab03 100644
--- a/sky/screen.cpp
+++ b/sky/screen.cpp
@@ -91,6 +91,8 @@ Screen::~Screen(void) {
free(_gameGrid);
if (_currentScreen)
free(_currentScreen);
+ if (_scrollScreen)
+ free(_scrollScreen);
}
void Screen::clearScreen(void) {
@@ -246,14 +248,7 @@ void Screen::fnDrawScreen(uint32 palette, uint32 scroll) {
void Screen::fnFadeDown(uint32 scroll) {
- if (scroll && (!(SkyEngine::_systemVars.systemFlags & SF_NO_SCROLL))) {
- // scrolling is performed by fnFadeUp. It's just prepared here
- _scrollScreen = _currentScreen;
- _currentScreen = (uint8 *)malloc(FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
- // the game will draw the new room into _currentScreen which
- // will be scrolled into the visible screen by fnFadeUp
- // fnFadeUp also frees the _scrollScreen
- } else {
+ if (((scroll != 123) && (scroll != 321)) || (SkyEngine::_systemVars.systemFlags & SF_NO_SCROLL)) {
uint32 delayTime = _system->getMillis();
for (uint8 cnt = 0; cnt < 32; cnt++) {
delayTime += 20;
@@ -265,6 +260,13 @@ void Screen::fnFadeDown(uint32 scroll) {
waitTime = 0;
_system->delayMillis((uint)waitTime);
}
+ } else {
+ // scrolling is performed by fnFadeUp. It's just prepared here
+ _scrollScreen = _currentScreen;
+ _currentScreen = (uint8 *)malloc(FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
+ // the game will draw the new room into _currentScreen which
+ // will be scrolled into the visible screen by fnFadeUp
+ // fnFadeUp also frees the _scrollScreen
}
}
@@ -325,9 +327,8 @@ void Screen::fnFadeUp(uint32 palNum, uint32 scroll) {
//_currentScreen points to new screen,
//_scrollScreen points to graphic showing old room
- if ((scroll != 123) && (scroll != 321)) {
+ if ((scroll != 123) && (scroll != 321))
scroll = 0;
- }
if ((scroll == 0) || (SkyEngine::_systemVars.systemFlags & SF_NO_SCROLL)) {
uint8 *palette = (uint8 *)_skyCompact->fetchCpt(palNum);
@@ -342,10 +343,7 @@ void Screen::fnFadeUp(uint32 palNum, uint32 scroll) {
paletteFadeUp(palette);
#endif
} else if (scroll == 123) { // scroll left (going right)
- if (!_currentScreen)
- error("Screen::fnFadeUp[Scroll L]: _currentScreen is NULL");
- if (!_scrollScreen)
- error("Screen::fnFadeUp[Scroll L]: _scrollScreen is NULL");
+ assert(_currentScreen && _scrollScreen);
uint8 *scrNewPtr, *scrOldPtr;
for (uint8 scrollCnt = 0; scrollCnt < (GAME_SCREEN_WIDTH / SCROLL_JUMP) - 1; scrollCnt++) {
scrNewPtr = _currentScreen + scrollCnt * SCROLL_JUMP;
@@ -360,12 +358,8 @@ void Screen::fnFadeUp(uint32 palNum, uint32 scroll) {
waitForTimer();
}
showScreen(_currentScreen);
- free(_scrollScreen);
} else if (scroll == 321) { // scroll right (going left)
- if (!_currentScreen)
- error("Screen::fnFadeUp[Scroll R]: _currentScreen is NULL");
- if (!_scrollScreen)
- error("Screen::fnFadeUp[Scroll R]: _scrollScreen is NULL");
+ assert(_currentScreen && _scrollScreen);
uint8 *scrNewPtr, *scrOldPtr;
for (uint8 scrollCnt = 0; scrollCnt < (GAME_SCREEN_WIDTH / SCROLL_JUMP) - 1; scrollCnt++) {
scrNewPtr = _currentScreen + GAME_SCREEN_WIDTH - (scrollCnt + 1) * SCROLL_JUMP;
@@ -380,7 +374,10 @@ void Screen::fnFadeUp(uint32 palNum, uint32 scroll) {
waitForTimer();
}
showScreen(_currentScreen);
+ }
+ if (_scrollScreen) {
free(_scrollScreen);
+ _scrollScreen = NULL;
}
}
diff --git a/sky/sky.cpp b/sky/sky.cpp
index 2534841045..97db0b402d 100644
--- a/sky/sky.cpp
+++ b/sky/sky.cpp
@@ -133,6 +133,8 @@ SkyEngine::~SkyEngine() {
delete _skyScreen;
delete _debugger;
delete _skyDisk;
+ delete _skyControl;
+ delete _skyCompact;
for (int i = 0; i < 300; i++)
if (_itemList[i])