aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2007-11-18 13:22:38 +0000
committerNicola Mettifogo2007-11-18 13:22:38 +0000
commit6471eb84f25d156a98bcf0447862e4839f8cc24d (patch)
tree19d23a9a923a5733db332957a1019b6b65299618 /engines
parentade0b5a21222c705a8fe3a3e67d6c783904c6d5e (diff)
downloadscummvm-rg350-6471eb84f25d156a98bcf0447862e4839f8cc24d.tar.gz
scummvm-rg350-6471eb84f25d156a98bcf0447862e4839f8cc24d.tar.bz2
scummvm-rg350-6471eb84f25d156a98bcf0447862e4839f8cc24d.zip
Cleanup.
svn-id: r29556
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/disk_br.cpp3
-rw-r--r--engines/parallaction/disk_ns.cpp3
-rw-r--r--engines/parallaction/exec_ns.cpp9
-rw-r--r--engines/parallaction/font.cpp6
-rw-r--r--engines/parallaction/graphics.h4
-rw-r--r--engines/parallaction/objects.cpp31
-rw-r--r--engines/parallaction/objects.h6
-rw-r--r--engines/parallaction/parallaction.cpp44
-rw-r--r--engines/parallaction/parallaction.h2
-rw-r--r--engines/parallaction/parallaction_br.cpp3
-rw-r--r--engines/parallaction/parallaction_ns.cpp15
-rw-r--r--engines/parallaction/parser_ns.cpp4
-rw-r--r--engines/parallaction/walk.h3
13 files changed, 52 insertions, 81 deletions
diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp
index b2e8607c22..c89bc0ddde 100644
--- a/engines/parallaction/disk_br.cpp
+++ b/engines/parallaction/disk_br.cpp
@@ -42,8 +42,7 @@ struct Sprite {
}
~Sprite() {
- if (packedData)
- free(packedData);
+ free(packedData);
}
};
diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp
index a7dbefc6e3..1ec15c842c 100644
--- a/engines/parallaction/disk_ns.cpp
+++ b/engines/parallaction/disk_ns.cpp
@@ -933,8 +933,7 @@ void AmigaDisk_ns::unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 b
}
}
- if (tempBuffer)
- free(tempBuffer);
+ free(tempBuffer);
}
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index 034c7650f3..253025a461 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -241,9 +241,7 @@ DECLARE_COMMAND_OPCODE(speak) {
DECLARE_COMMAND_OPCODE(get) {
_cmdRunCtxt.cmd->u._zone->_flags &= ~kFlagsFixed;
- if (!runZone(_cmdRunCtxt.cmd->u._zone)) {
- runCommands(_cmdRunCtxt.cmd->u._zone->_commands);
- }
+ runZone(_cmdRunCtxt.cmd->u._zone);
}
@@ -443,6 +441,9 @@ label1:
void Parallaction::runCommands(CommandList& list, Zone *z) {
+ if (list.size() == 0)
+ return;
+
debugC(3, kDebugExec, "runCommands");
CommandList::iterator it = list.begin();
@@ -598,6 +599,8 @@ uint16 Parallaction::runZone(Zone *z) {
debugC(3, kDebugExec, "runZone completed");
+ runCommands(z->_commands, z);
+
return 0;
}
diff --git a/engines/parallaction/font.cpp b/engines/parallaction/font.cpp
index dc2f62f47c..e5aaa695a0 100644
--- a/engines/parallaction/font.cpp
+++ b/engines/parallaction/font.cpp
@@ -202,8 +202,7 @@ public:
}
~DosFont() {
- if (_data)
- delete _data;
+ delete _data;
}
void setData() {
@@ -455,8 +454,7 @@ AmigaFont::AmigaFont(Common::SeekableReadStream &stream) {
}
AmigaFont::~AmigaFont() {
- if (_data)
- free(_data);
+ free(_data);
}
uint16 AmigaFont::getSpacing(byte c) {
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 8a0779144a..a0aa19254f 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -102,7 +102,6 @@ public:
}
~Cnv() {
- if (_count == 0 || _data == NULL) return;
free(_data);
}
@@ -159,8 +158,7 @@ public:
}
void free() {
- if (data)
- ::free(data);
+ ::free(data);
data = 0;
w = 0;
h = 0;
diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp
index 3ada9d96be..c3e0a2dacc 100644
--- a/engines/parallaction/objects.cpp
+++ b/engines/parallaction/objects.cpp
@@ -51,14 +51,9 @@ Animation::Animation() {
}
Animation::~Animation() {
- if (_program)
- delete _program;
-
- if (_scriptName)
- free(_scriptName);
-
- if (_cnv)
- delete _cnv;
+ delete _program;
+ free(_scriptName);
+ delete _cnv;
}
uint16 Animation::width() const {
@@ -142,8 +137,7 @@ Zone::~Zone() {
case kZoneDoor:
free(u.door->_location);
free(u.door->_background);
- if (u.door->_cnv)
- delete u.door->_cnv;
+ delete u.door->_cnv;
delete u.door;
break;
@@ -207,8 +201,7 @@ Label::~Label() {
void Label::free() {
_cnv.free();
- if (_text)
- ::free(_text);
+ ::free(_text);
_text = 0;
resetPosition();
@@ -241,8 +234,7 @@ Answer::Answer() {
}
Answer::~Answer() {
- if (_text)
- free(_text);
+ free(_text);
}
Question::Question() {
@@ -256,8 +248,9 @@ Question::Question() {
Question::~Question() {
- for (uint32 i = 0; i < NUM_ANSWERS; i++)
- if (_answers[i]) delete _answers[i];
+ for (uint32 i = 0; i < NUM_ANSWERS; i++) {
+ delete _answers[i];
+ }
free(_text);
}
@@ -267,10 +260,8 @@ Instruction::Instruction() {
}
Instruction::~Instruction() {
- if (_text)
- free(_text);
- if (_text2)
- free(_text2);
+ free(_text);
+ free(_text2);
}
int16 ScriptVar::getRValue() {
diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h
index 742d0e4c90..f4246cf2ae 100644
--- a/engines/parallaction/objects.h
+++ b/engines/parallaction/objects.h
@@ -119,10 +119,8 @@ struct CommandData {
}
~CommandData() {
- if (_string)
- free(_string);
- if (_string2)
- free(_string2);
+ free(_string);
+ free(_string2);
}
};
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 0174474f39..54bf992dcd 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -278,8 +278,7 @@ void Parallaction::runGame() {
if (_activeZone) {
Zone *z = _activeZone; // speak Zone or sound
_activeZone = NULL;
- if (runZone( z ) == 0)
- runCommands( z->_commands, z );
+ runZone(z);
}
if (_engineFlags & kEngineChangeLocation) {
@@ -332,7 +331,6 @@ void Parallaction::hideLabel(uint priority) {
void Parallaction::processInput(InputData *data) {
- Zone *z;
switch (data->_event) {
case kEvEnterZone:
@@ -350,10 +348,7 @@ void Parallaction::processInput(InputData *data) {
_procCurrentHoverItem = -1;
_hoverZone = NULL;
pauseJobs();
- z = data->_zone;
- if (runZone(z) == 0) {
- runCommands( z->_commands, z );
- }
+ runZone(data->_zone);
resumeJobs();
break;
@@ -421,7 +416,7 @@ void Parallaction::processInput(InputData *data) {
void Parallaction::updateInput() {
- _keyDown = readInput();
+ int16 keyDown = readInput();
debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
!_mouseHidden,
@@ -438,13 +433,13 @@ void Parallaction::updateInput() {
return;
}
- if (_keyDown == kEvQuitGame) {
+ if (keyDown == kEvQuitGame) {
_input._event = kEvQuitGame;
} else
- if (_keyDown == kEvSaveGame) {
+ if (keyDown == kEvSaveGame) {
_input._event = kEvSaveGame;
} else
- if (_keyDown == kEvLoadGame) {
+ if (keyDown == kEvLoadGame) {
_input._event = kEvLoadGame;
} else {
_input._mousePos = _mousePos;
@@ -618,9 +613,8 @@ void Parallaction::showCursor(bool visible) {
void Parallaction::freeCharacter() {
debugC(1, kDebugExec, "freeCharacter()");
- if (_objectsNames)
- delete _objectsNames;
- _objectsNames = NULL;
+ delete _objectsNames;
+ _objectsNames = 0;
_char.free();
@@ -803,10 +797,8 @@ void Parallaction::freeLocation() {
freeZones();
freeAnimations();
- if (_location._comment) {
- free(_location._comment);
- }
- _location._comment = NULL;
+ free(_location._comment);
+ _location._comment = 0;
_location._commands.clear();
_location._aCommands.clear();
@@ -881,6 +873,10 @@ void Parallaction::showLocationComment(const char *text, bool end) {
void Parallaction::doLocationEnterTransition() {
debugC(2, kDebugExec, "doLocationEnterTransition");
+ if (!_location._comment) {
+ return;
+ }
+
if (_localFlags[_currentLocationIndex] & kFlagsVisited) {
debugC(2, kDebugExec, "skipping location transition");
return; // visited
@@ -996,14 +992,10 @@ void Character::scheduleWalk(int16 x, int16 y) {
void Character::free() {
- if (_ani._cnv)
- delete _ani._cnv;
- if (_talk)
- delete _talk;
- if (_head)
- delete _head;
- if (_objs)
- delete _objs;
+ delete _ani._cnv;
+ delete _talk;
+ delete _head;
+ delete _objs;
_ani._cnv = NULL;
_talk = NULL;
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 9f87f69312..a6eb625128 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -513,8 +513,6 @@ protected: // data
uint32 _baseTime;
char _characterName1[50]; // only used in changeCharacter
- int16 _keyDown;
-
JobList _jobs;
Common::String _saveFileName;
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index dfdadb56ea..eec5c1f15e 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -331,6 +331,9 @@ void Parallaction_br::freePart() {
delete _objectsNames;
delete _countersNames;
+ _globalTable = 0;
+ _objectsNames = 0;
+ _countersNames = 0;
}
void Parallaction_br::startPart() {
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index 8a70b31fff..4f2af806ef 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -46,8 +46,7 @@ LocationName::LocationName() {
}
LocationName::~LocationName() {
- if (_buf)
- free(_buf);
+ free(_buf);
}
@@ -70,8 +69,7 @@ LocationName::~LocationName() {
*/
void LocationName::bind(const char *s) {
- if (_buf)
- free(_buf);
+ free(_buf);
_buf = strdup(s);
_hasSlide = false;
@@ -165,7 +163,6 @@ void Parallaction_ns::freeFonts() {
delete _labelFont;
delete _menuFont;
- return;
}
void Parallaction_ns::renderLabel(Graphics::Surface *cnv, char *text) {
@@ -387,17 +384,13 @@ void Parallaction_ns::changeLocation(char *location) {
_gfx->swapBuffers();
}
- if (_location._comment) {
- doLocationEnterTransition();
- }
+ doLocationEnterTransition();
runJobs();
_gfx->swapBuffers();
_gfx->setPalette(_gfx->_palette);
- if (_location._aCommands.size() > 0) {
- runCommands(_location._aCommands);
- }
+ runCommands(_location._aCommands);
if (_hasLocationSound)
_soundMan->playSfx(_locationSound, 0, true);
diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp
index 3ce7ce881a..35f6f20346 100644
--- a/engines/parallaction/parser_ns.cpp
+++ b/engines/parallaction/parser_ns.cpp
@@ -529,8 +529,7 @@ DECLARE_COMMAND_PARSER(location) {
createCommand(_lookup);
- _locParseCtxt.cmd->u._string = (char*)malloc(strlen(_tokens[_locParseCtxt.nextToken])+1);
- strcpy(_locParseCtxt.cmd->u._string, _tokens[_locParseCtxt.nextToken]);
+ _locParseCtxt.cmd->u._string = strdup(_tokens[_locParseCtxt.nextToken]);
_locParseCtxt.nextToken++;
parseCommandFlags();
@@ -777,6 +776,7 @@ Dialogue *Parallaction_ns::parseDialogue(Script &script) {
int16 index = forwards.lookup(answer->_following._name);
free(answer->_following._name);
+ answer->_following._name = 0;
if (index == Table::notFound)
answer->_following._question = 0;
diff --git a/engines/parallaction/walk.h b/engines/parallaction/walk.h
index dcbc3d5aa9..e06ef02741 100644
--- a/engines/parallaction/walk.h
+++ b/engines/parallaction/walk.h
@@ -72,8 +72,7 @@ public:
}
void free() {
- if (data)
- ::free(data);
+ ::free(data);
data = 0;
w = 0;
h = 0;