aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorChristopher Page2008-06-02 21:08:49 +0000
committerChristopher Page2008-06-02 21:08:49 +0000
commita338d5fdb2715a7b29ae789c632a0cfa05803079 (patch)
treeb80b3e278050d5027dddd2723cf60b5108893f08 /engines/parallaction
parent203f62ad7cfc3f931c98c8fc3ecdbb01924b896f (diff)
downloadscummvm-rg350-a338d5fdb2715a7b29ae789c632a0cfa05803079.tar.gz
scummvm-rg350-a338d5fdb2715a7b29ae789c632a0cfa05803079.tar.bz2
scummvm-rg350-a338d5fdb2715a7b29ae789c632a0cfa05803079.zip
PARA: Got rid of calls to system->quit() so that the Parallaction engine can return to the launcher. Also fixed a couple of memory leaks.
svn-id: r32504
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/dialogue.cpp14
-rw-r--r--engines/parallaction/exec_ns.cpp2
-rw-r--r--engines/parallaction/graphics.h1
-rw-r--r--engines/parallaction/input.cpp5
-rw-r--r--engines/parallaction/parallaction.cpp13
-rw-r--r--engines/parallaction/parallaction_br.cpp3
-rw-r--r--engines/parallaction/parallaction_ns.cpp8
-rw-r--r--engines/parallaction/parser.cpp13
-rw-r--r--engines/parallaction/parser.h5
9 files changed, 54 insertions, 10 deletions
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp
index 70db637699..b9dea60dc0 100644
--- a/engines/parallaction/dialogue.cpp
+++ b/engines/parallaction/dialogue.cpp
@@ -105,10 +105,8 @@ uint16 DialogueManager::askPassword() {
if (g_system->getEventManager()->pollEvent(e)) {
if (e.type == Common::EVENT_QUIT) {
- // TODO: don't quit() here, just have caller routines to check
- // on kEngineQuit and exit gracefully to allow the engine to shut down
_engineFlags |= kEngineQuit;
- g_system->quit();
+ break;
}
if ((e.type == Common::EVENT_KEYDOWN) && isdigit(e.kbd.ascii)) {
@@ -231,11 +229,19 @@ void DialogueManager::run() {
answer = 0;
displayQuestion();
+
+ if (_engineFlags & kEngineQuit)
+ return;
+
if (_q->_answers[0] == NULL) break;
if (scumm_stricmp(_q->_answers[0]->_text, "NULL")) {
if (!displayAnswers()) break;
answer = getAnswer();
+
+ if (_engineFlags & kEngineQuit)
+ return;
+
cmdlist = &_q->_answers[answer]->_commands;
}
@@ -266,7 +272,7 @@ int16 DialogueManager::selectAnswer() {
uint32 event;
Common::Point p;
- while (true) {
+ while (_engineFlags & kEngineQuit == 0) {
_vm->_input->readInput();
_vm->_input->getCursorPos(p);
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index 68ae91c73e..f7c3b895c2 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -518,6 +518,8 @@ uint16 Parallaction::runZone(ZonePtr z) {
case kZoneSpeak:
runDialogue(z->u.speak);
+ if (_engineFlags & kEngineQuit)
+ return 0;
break;
}
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 8f1c14aef0..7528a20c67 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -95,6 +95,7 @@ public:
}
~SurfaceToFrames() {
+ _surf->free();
delete _surf;
}
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index 28d0ad888d..e758bbd41c 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -80,11 +80,8 @@ uint16 Input::readInput() {
break;
case Common::EVENT_QUIT:
- // TODO: don't quit() here, just have caller routines to check
- // on kEngineQuit and exit gracefully to allow the engine to shut down
_engineFlags |= kEngineQuit;
- _vm->_system->quit();
- break;
+ return KeyDown;
default:
break;
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index d66b1af1f1..cd723181d9 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -89,16 +89,18 @@ Parallaction::~Parallaction() {
delete _globalTable;
delete _callableNames;
- delete _localFlagNames;
+ //delete _localFlagNames;
freeLocation();
freeCharacter();
destroyInventory();
+ delete _localFlagNames;
delete _gfx;
delete _soundMan;
delete _disk;
+ delete _input;
}
@@ -354,12 +356,20 @@ void Parallaction::runGame() {
processInput(data);
}
+ if (_engineFlags & kEngineQuit)
+ return;
+
runPendingZones();
+ if (_engineFlags & kEngineQuit)
+ return;
+
if (_engineFlags & kEngineChangeLocation) {
changeLocation(_location._name);
}
+ if (_engineFlags & kEngineQuit)
+ return;
_gfx->beginFrame();
@@ -522,6 +532,7 @@ void Character::free() {
delete _talk;
delete _head;
delete _objs;
+ delete _ani->gfxobj;
_ani->gfxobj = NULL;
_talk = NULL;
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index f07d201ae9..06f728f603 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -107,6 +107,9 @@ int Parallaction_br::go() {
guiStart();
+ if (_engineFlags & kEngineQuit)
+ return 0;
+
// initCharacter();
_input->_inputMode = Input::kInputModeGame;
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index 8e0f83d46d..8254a85a34 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -241,9 +241,15 @@ int Parallaction_ns::go() {
_globalTable = _disk->loadTable("global");
guiStart();
-
+
+ if (_engineFlags & kEngineQuit)
+ return 0;
+
changeLocation(_location._name);
+ if (_engineFlags & kEngineQuit)
+ return 0;
+
_input->_inputMode = Input::kInputModeGame;
while ((_engineFlags & kEngineQuit) == 0) {
runGame();
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp
index f9de6eb4af..c166c8fe3a 100644
--- a/engines/parallaction/parser.cpp
+++ b/engines/parallaction/parser.cpp
@@ -31,6 +31,8 @@ namespace Parallaction {
char _tokens[20][MAX_TOKEN_LEN];
Script::Script(Common::ReadStream *input, bool disposeSource) : _input(input), _disposeSource(disposeSource), _line(0) {
+
+// clearAllTokens();
}
Script::~Script() {
@@ -73,6 +75,17 @@ void Script::clearTokens() {
}
+/*
+void Script::clearAllTokens() {
+
+ for (uint16 i = 0; i < 20; i++)
+ for (uint16 j = 0; j < 50; j++)
+ _tokens[i][j] = '\0';
+
+ return;
+}
+*/
+
void Script::skip(const char* endToken) {
while (scumm_stricmp(_tokens[0], endToken)) {
diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h
index d600f9eb9d..e8de07822e 100644
--- a/engines/parallaction/parser.h
+++ b/engines/parallaction/parser.h
@@ -44,6 +44,7 @@ class Script {
uint _line; // for debug messages
void clearTokens();
+ //void clearAllTokens();
uint16 fillTokens(char* line);
public:
@@ -239,8 +240,12 @@ public:
}
virtual ~LocationParser_ns() {
+ delete _parser;
+ delete _script;
delete _commandsNames;
delete _locationStmt;
+ delete _locationZoneStmt;
+ delete _locationAnimStmt;
delete _zoneTypeNames;
delete _zoneFlagNames;
}