diff options
author | Littleboy | 2012-07-14 14:02:44 -0400 |
---|---|---|
committer | Littleboy | 2012-07-14 14:26:00 -0400 |
commit | 0635d99ec74ad431146e14aba4ad07a5f9e7e221 (patch) | |
tree | 8b4958d1c162be31c93b0d700cf56192f264dfed /engines/lastexpress/fight | |
parent | 732a2c80ddde4cf0ffd1b1742f514ae940c5301d (diff) | |
download | scummvm-rg350-0635d99ec74ad431146e14aba4ad07a5f9e7e221.tar.gz scummvm-rg350-0635d99ec74ad431146e14aba4ad07a5f9e7e221.tar.bz2 scummvm-rg350-0635d99ec74ad431146e14aba4ad07a5f9e7e221.zip |
LASTEXPRESS: Cleanup
- Add missing initializer/destructors
- Add some const modifiers
- Remove some unneeded casts
- Use enumeration values in switch constructs
Diffstat (limited to 'engines/lastexpress/fight')
-rw-r--r-- | engines/lastexpress/fight/fight.cpp | 5 | ||||
-rw-r--r-- | engines/lastexpress/fight/fighter.cpp | 27 | ||||
-rw-r--r-- | engines/lastexpress/fight/fighter.h | 3 |
3 files changed, 23 insertions, 12 deletions
diff --git a/engines/lastexpress/fight/fight.cpp b/engines/lastexpress/fight/fight.cpp index be1653092f..22d9da80be 100644 --- a/engines/lastexpress/fight/fight.cpp +++ b/engines/lastexpress/fight/fight.cpp @@ -52,6 +52,8 @@ Fight::FightData::FightData() { index = 0; isFightRunning = false; + + memset(&sequences, 0, sizeof(sequences)); } Fight::FightData::~FightData() { @@ -398,6 +400,9 @@ end_load: } void Fight::setOpponents() { + if (!_data) + error("[Fight::setOpponents] Data not initialized"); + _data->player->setOpponent(_data->opponent); _data->opponent->setOpponent(_data->player); diff --git a/engines/lastexpress/fight/fighter.cpp b/engines/lastexpress/fight/fighter.cpp index bae7728a2b..4b1cddabd4 100644 --- a/engines/lastexpress/fight/fighter.cpp +++ b/engines/lastexpress/fight/fighter.cpp @@ -53,20 +53,20 @@ Fighter::Fighter(LastExpressEngine *engine) : _engine(engine) { } Fighter::~Fighter() { - clearSequences(); -} - -////////////////////////////////////////////////////////////////////////// -// Cleanup -////////////////////////////////////////////////////////////////////////// -void Fighter::clearSequences() { // The original game resets the function pointers to default values, just before deleting the struct getScenes()->removeAndRedraw(&_frame, false); // Free sequences - for (int i = 0; i < (int)_sequences.size(); i++) + for (uint i = 0; i < _sequences.size(); i++) SAFE_DELETE(_sequences[i]); + + // Zero-out passed pointers + _sequence = NULL; + _opponent = NULL; + _fight = NULL; + + _engine = NULL; } ////////////////////////////////////////////////////////////////////////// @@ -113,6 +113,9 @@ void Fighter::draw() { // Processing ////////////////////////////////////////////////////////////////////////// void Fighter::process() { + if (!_fight) + error("[Fighter::handleAction] Fighter not initialized properly"); + if (!_sequence) { if (_frame) { getScenes()->removeFromQueue(_frame); @@ -188,6 +191,9 @@ void Fighter::process() { // Default actions ////////////////////////////////////////////////////////////////////////// void Fighter::handleAction(FightAction action) { + if (!_opponent || !_fight) + error("[Fighter::handleAction] Fighter not initialized properly"); + switch (action) { default: return; @@ -243,7 +249,10 @@ void Opponent::update() { // Helpers ////////////////////////////////////////////////////////////////////////// bool Fighter::checkFrame(uint32 val) { - return (_frame->getInfo()->field_33 & val); + if (!_frame) + error("[Fighter::checkFrame] Invalid current frame"); + + return (bool)(_frame->getInfo()->field_33 & val); } } // End of namespace LastExpress diff --git a/engines/lastexpress/fight/fighter.h b/engines/lastexpress/fight/fighter.h index e37fe49d86..dad95af186 100644 --- a/engines/lastexpress/fight/fighter.h +++ b/engines/lastexpress/fight/fighter.h @@ -99,9 +99,6 @@ protected: void draw(); void process(); - // Cleanup - void clearSequences(); - // Helpers bool checkFrame(uint32 val); }; |