aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/exec_ns.cpp1
-rw-r--r--engines/parallaction/gui_br.cpp1
-rw-r--r--engines/parallaction/gui_ns.cpp1
-rw-r--r--engines/parallaction/input.cpp1
-rw-r--r--engines/parallaction/parallaction.cpp61
-rw-r--r--engines/parallaction/parallaction.h21
-rw-r--r--engines/parallaction/parallaction_br.cpp18
-rw-r--r--engines/parallaction/parallaction_ns.cpp43
-rw-r--r--engines/parallaction/saveload.cpp9
9 files changed, 69 insertions, 87 deletions
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index 9cbb5c33b4..4a398d582a 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -278,7 +278,6 @@ DECLARE_COMMAND_OPCODE(drop){
DECLARE_COMMAND_OPCODE(quit) {
- _vm->_quit = true;
_vm->quitGame();
}
diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp
index 3b6cde8fbf..6b39d5a06a 100644
--- a/engines/parallaction/gui_br.cpp
+++ b/engines/parallaction/gui_br.cpp
@@ -171,7 +171,6 @@ class MainMenuInputState_BR : public MenuInputState {
void performChoice(int selectedItem) {
switch (selectedItem) {
case kMenuQuit: {
- _vm->_quit = true;
_vm->quitGame();
break;
}
diff --git a/engines/parallaction/gui_ns.cpp b/engines/parallaction/gui_ns.cpp
index 9ea11fa200..458fa765fd 100644
--- a/engines/parallaction/gui_ns.cpp
+++ b/engines/parallaction/gui_ns.cpp
@@ -700,7 +700,6 @@ public:
}
if (_isDemo) {
- _vm->_quit = true;
_vm->quitGame();
return 0;
}
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index c91421e15e..67f2d9cfce 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -133,7 +133,6 @@ void Input::readInput() {
case Common::EVENT_RTL:
case Common::EVENT_QUIT:
- _vm->_quit = true;
return;
default:
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 4810c4af67..534f0e6eef 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -92,7 +92,6 @@ Parallaction::~Parallaction() {
_gfx->clearGfxObjects(kGfxObjCharacter | kGfxObjNormal);
hideDialogueStuff();
delete _balloonMan;
- freeLocation();
freeCharacter();
destroyInventory();
@@ -120,8 +119,6 @@ Common::Error Parallaction::init() {
_location._comment = NULL;
_location._endComment = NULL;
- _quit = false;
-
_pathBuffer = 0;
_screenSize = _screenWidth * _screenHeight;
@@ -200,12 +197,11 @@ AnimationPtr Parallaction::findAnimation(const char *name) {
return nullAnimationPtr;
}
-void Parallaction::freeAnimations() {
- for (AnimationList::iterator it = _location._animations.begin(); it != _location._animations.end(); it++) {
+void Location::freeAnimations() {
+ for (AnimationList::iterator it = _animations.begin(); it != _animations.end(); it++) {
(*it)->_commands.clear(); // See comment for freeZones(), about circular references.
}
- _location._animations.clear();
- return;
+ _animations.clear();
}
@@ -241,33 +237,36 @@ void Parallaction::allocateLocationSlot(const char *name) {
}
+Location::Location() : _comment(0), _endComment(0) {
+ cleanup(true);
+}
-void Parallaction::freeLocation() {
- debugC(2, kDebugExec, "freeLocation");
+Location::~Location() {
+ cleanup(true);
+}
- _soundMan->stopSfx(0);
- _soundMan->stopSfx(1);
- _soundMan->stopSfx(2);
- _soundMan->stopSfx(3);
+void Location::cleanup(bool removeAll) {
+ free(_comment); _comment = 0;
+ free(_endComment); _endComment = 0;
- _localFlagNames->clear();
+ freeZones(removeAll);
+ freeAnimations();
- _location._walkPoints.clear();
+ _programs.clear();
+ _commands.clear();
+ _aCommands.clear();
- _gfx->clearGfxObjects(kGfxObjNormal);
+ _hasSound = false;
- _location._programs.clear();
- freeZones();
- freeAnimations();
+ // NS specific
+ _walkPoints.clear();
- free(_location._comment);
- _location._comment = 0;
+ // BRA specific
+ _zeta0 = _zeta1 = _zeta2 = 0;
+ _escapeCommands.clear();
+}
- _location._commands.clear();
- _location._aCommands.clear();
- return;
-}
void Parallaction::showSlide(const char *name, int x, int y) {
BackgroundInfo *info = new BackgroundInfo;
@@ -819,24 +818,24 @@ ZonePtr Parallaction::findZone(const char *name) {
}
-void Parallaction::freeZones() {
- debugC(2, kDebugExec, "freeZones: _vm->_quit = %i", _vm->_quit);
+void Location::freeZones(bool removeAll) {
+ debugC(2, kDebugExec, "freeZones: removeAll = %i", removeAll);
- ZoneList::iterator it = _location._zones.begin();
+ ZoneList::iterator it = _zones.begin();
- while ( it != _location._zones.end() ) {
+ while ( it != _zones.end() ) {
// NOTE : this condition has been relaxed compared to the original, to allow the engine
// to retain special - needed - zones that were lost across location switches.
ZonePtr z = *it;
- if (((z->getY() == -1) || (z->getX() == -2)) && (_quit == 0)) {
+ if (((z->getY() == -1) || (z->getX() == -2)) && (!removeAll)) {
debugC(2, kDebugExec, "freeZones preserving zone '%s'", z->_name);
it++;
} else {
(*it)->_commands.clear(); // Since commands may reference zones, and both commands and zones are kept stored into
// SharedPtr's, we need to kill commands explicitly to destroy any potential circular
// reference.
- it = _location._zones.erase(it);
+ it = _zones.erase(it);
}
}
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 5b56f29e94..e6dddb5f02 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -150,6 +150,16 @@ struct Location {
int _zeta1;
int _zeta2;
CommandList _escapeCommands;
+
+protected:
+ void freeAnimations();
+ void freeZones(bool removeAll);
+
+public:
+ Location();
+ ~Location();
+
+ void cleanup(bool removeAll);
};
@@ -277,11 +287,6 @@ public:
ZonePtr _zoneTrap;
ZonePtr _commentZone;
- bool _quit; /* The only reason this flag exists is for freeZones() to properly
- * delete all zones when necessary. THIS FLAG IS NOT THE ENGINE QUIT FLAG,
- * use _eventMan->shouldQuit() for that.
- */
-
protected:
void runGame();
void runGuiFrame();
@@ -295,7 +300,6 @@ protected:
void updateView();
void drawAnimations();
void freeCharacter();
- void freeLocation();
void doLocationEnterTransition();
void allocateLocationSlot(const char *name);
void finalizeLocationParsing();
@@ -324,7 +328,7 @@ public:
ZonePtr findZone(const char *name);
ZonePtr hitZone(uint32 type, uint16 x, uint16 y);
void runZone(ZonePtr z);
- void freeZones();
+ void freeZones(bool removeAll);
bool pickupItem(ZonePtr z);
void updateDoor(ZonePtr z, bool close);
void showZone(ZonePtr z, bool visible);
@@ -390,6 +394,7 @@ private:
void startCreditSequence();
void startEndPartSequence();
void loadProgram(AnimationPtr a, const char *filename);
+ void freeLocation(bool removeAll);
// callables data
@@ -489,7 +494,7 @@ private:
void initResources();
void initFonts();
void freeFonts();
- void freeLocation();
+ void freeLocation(bool removeAll);
void loadProgram(AnimationPtr a, const char *filename);
void startGui(bool showSplash);
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index fe179a0ba4..9c71303aeb 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -169,7 +169,7 @@ void Parallaction_br::runPendingZones() {
}
}
-void Parallaction_br::freeLocation() {
+void Parallaction_br::freeLocation(bool removeAll) {
// free open location stuff
clearSubtitles();
@@ -178,24 +178,14 @@ void Parallaction_br::freeLocation() {
_gfx->freeLabels();
_subtitle[0] = _subtitle[1] = -1;
- _location._programs.clear();
-
_location._animations.remove(_char._ani);
-
- freeZones();
- freeAnimations();
-
+ _location.cleanup(removeAll);
_location._animations.push_front(_char._ani);
- free(_location._comment);
- _location._comment = 0;
- _location._commands.clear();
- _location._aCommands.clear();
-
}
void Parallaction_br::cleanupGame() {
- freeLocation();
+ freeLocation(true);
// freeCharacter();
@@ -241,7 +231,7 @@ void Parallaction_br::changeLocation(char *location) {
parseLocation("common.slf");
}
- freeLocation();
+ freeLocation(false);
// load new location
parseLocation(location);
// kFlagsRemove is cleared because the character is visible by default.
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index 90820a6f8f..daa4975220 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -202,6 +202,7 @@ Parallaction_ns::~Parallaction_ns() {
delete _locationParser;
delete _programParser;
+ freeLocation(true);
_location._animations.remove(_char._ani);
@@ -294,9 +295,8 @@ void Parallaction_ns::changeLocation(char *location) {
_input->setArrowCursor();
_gfx->showGfxObj(_char._ani->gfxobj, false);
- _location._animations.remove(_char._ani);
- freeLocation();
+ freeLocation(false);
LocationName locname;
locname.bind(location);
@@ -316,7 +316,6 @@ void Parallaction_ns::changeLocation(char *location) {
changeCharacter(locname.character());
}
- _location._animations.push_front(_char._ani);
_gfx->showGfxObj(_char._ani->gfxobj, true);
strcpy(_saveData1, locname.location());
@@ -423,37 +422,39 @@ void Parallaction_ns::changeCharacter(const char *name) {
return;
}
+void Parallaction_ns::freeLocation(bool removeAll) {
+ debugC(2, kDebugExec, "freeLocation");
+
+ _soundMan->stopSfx(0);
+ _soundMan->stopSfx(1);
+ _soundMan->stopSfx(2);
+ _soundMan->stopSfx(3);
+
+ _localFlagNames->clear();
+
+ _gfx->clearGfxObjects(kGfxObjNormal);
+
+ _location._animations.remove(_char._ani);
+ _location.cleanup(removeAll);
+ _location._animations.push_front(_char._ani);
+}
+
void Parallaction_ns::cleanupGame() {
- _inTestResult = false;
+ _soundMan->stopMusic();
+ _inTestResult = false;
_engineFlags &= ~kEngineTransformedDonna;
- // this code saves main character animation from being removed from the following code
- _location._animations.remove(_char._ani);
_numLocations = 0;
_globalFlags = 0;
-
memset(_localFlags, 0, sizeof(_localFlags));
memset(_locationNames, 0, sizeof(_locationNames));
- // this flag tells freeZones to unconditionally remove *all* Zones
- _vm->_quit = true;
-
- freeZones();
- freeAnimations();
-
- // this dangerous flag can now be cleared
- _vm->_quit = false;
+ freeLocation(true);
- // main character animation is restored
- _location._animations.push_front(_char._ani);
_score = 0;
-
- _soundMan->stopMusic();
_introSarcData3 = 200;
_introSarcData2 = 1;
-
- return;
}
} // namespace Parallaction
diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp
index 8093d4f234..033d502478 100644
--- a/engines/parallaction/saveload.cpp
+++ b/engines/parallaction/saveload.cpp
@@ -134,15 +134,6 @@ void SaveLoad_ns::doLoadGame(uint16 slot) {
f->readLine_OLD(s, 15);
- // TODO (LIST): unify (and parametrize) calls to freeZones.
- // We aren't calling freeAnimations because it is not needed, since
- // kChangeLocation will trigger a complete deletion. Anyway, we still
- // need to invoke freeZones here with _quit set, because the
- // call in changeLocation preserve certain zones.
- _vm->_quit = true;
- _vm->freeZones();
- _vm->_quit = false;
-
_vm->_numLocations = atoi(s);
uint16 _si;