aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb
diff options
context:
space:
mode:
authorNipun Garg2019-06-18 22:07:30 +0530
committerEugene Sandulenko2019-09-03 17:16:48 +0200
commitcd233e7728d7a9ade729fccad2a388baa8e3effc (patch)
tree8af3b506c2ce36038d8fb2dc287b7ce04c3926fe /engines/hdb
parent59625b49c6717081d21a0b010deca371c2b277f4 (diff)
downloadscummvm-rg350-cd233e7728d7a9ade729fccad2a388baa8e3effc.tar.gz
scummvm-rg350-cd233e7728d7a9ade729fccad2a388baa8e3effc.tar.bz2
scummvm-rg350-cd233e7728d7a9ade729fccad2a388baa8e3effc.zip
HDB: Modify prcocessCines for complete and bailOut
Diffstat (limited to 'engines/hdb')
-rw-r--r--engines/hdb/ai.cpp86
-rw-r--r--engines/hdb/ai.h6
2 files changed, 46 insertions, 46 deletions
diff --git a/engines/hdb/ai.cpp b/engines/hdb/ai.cpp
index fd6499a68e..f65dca85b1 100644
--- a/engines/hdb/ai.cpp
+++ b/engines/hdb/ai.cpp
@@ -24,14 +24,6 @@
namespace HDB {
-AI::AI() {
- _cine = new Common::Array<CineCommand *>;
-}
-
-AI::~AI() {
- delete _cine;
-}
-
bool AI::init() {
warning("STUB: AI::init required");
return true;
@@ -53,12 +45,12 @@ void AI::processCines() {
// TODO: Check for Game Pause
- for (Common::Array<CineCommand *>::iterator it = _cine->begin(); it != _cine->end(); it++) {
- switch ((*it)->cmdType) {
+ for (uint i = 0; i < _cine.size();i++) {
+ switch (_cine[i]->cmdType) {
case C_SETCAMERA:
- _cameraX = (*it)->x;
- _cameraY = (*it)->y;
- g_hdb->_map->centerMapXY((int) _cameraX + 16, (int) _cameraY + 16);
+ _cameraX = _cine[i]->x;
+ _cameraY = _cine[i]->y;
+ g_hdb->_map->centerMapXY((int)_cameraX + 16, (int)_cameraY + 16);
_cameraLock = true;
complete = true;
break;
@@ -71,26 +63,26 @@ void AI::processCines() {
break;
case C_MOVECAMERA:
_cameraLock = true;
- if (!((*it)->start)) {
- (*it)->xv = (((double) (*it)->x) - _cameraX) / (double) (*it)->speed;
- (*it)->yv = (((double) (*it)->y) - _cameraY) / (double) (*it)->speed;
- (*it)->start = 1;
+ if (!(_cine[i]->start)) {
+ _cine[i]->xv = (((double)_cine[i]->x) - _cameraX) / (double)_cine[i]->speed;
+ _cine[i]->yv = (((double)_cine[i]->y) - _cameraY) / (double)_cine[i]->speed;
+ _cine[i]->start = 1;
}
- _cameraX += (*it)->xv;
- _cameraY += (*it)->yv;
- if (abs(_cameraX - (*it)->x) <= 1 && abs(_cameraY - (*it)->y) <= 1) {
- _cameraX = (*it)->x;
- _cameraY = (*it)->y;
+ _cameraX += _cine[i]->xv;
+ _cameraY += _cine[i]->yv;
+ if (abs(_cameraX - _cine[i]->x) <= 1 && abs(_cameraY - _cine[i]->y) <= 1) {
+ _cameraX = _cine[i]->x;
+ _cameraY = _cine[i]->y;
complete = true;
}
g_hdb->_map->centerMapXY((int)_cameraX + 16, (int)_cameraY + 16);
break;
case C_WAIT:
- if (!((*it)->start)) {
- (*it)->start = 1;
- (*it)->delay = g_system->getMillis() + (*it)->delay * 1000;
+ if (!(_cine[i]->start)) {
+ _cine[i]->start = 1;
+ _cine[i]->delay = g_system->getMillis() + _cine[i]->delay * 1000;
} else {
- if ((*it)->delay < g_system->getMillis()) {
+ if (_cine[i]->delay < g_system->getMillis()) {
complete = true;
} else {
bailOut = true;
@@ -98,32 +90,44 @@ void AI::processCines() {
}
break;
case C_WAITUNTILDONE:
- if ((uint) (it - _cine->begin()) == _cine->size() - 1) {
+ if (!i) {
complete = true;
} else {
bailOut = true;
}
break;
case C_FADEIN:
- if (!(*it)->start) {
- g_hdb->_drawMan->setFade(true, (bool)(*it)->end, (*it)->speed);
- (*it)->start = 1;
+ if (!_cine[i]->start) {
+ g_hdb->_drawMan->setFade(true, (bool)_cine[i]->end, _cine[i]->speed);
+ _cine[i]->start = 1;
} else if (!g_hdb->_drawMan->isFadeActive()) {
complete = true;
}
break;
case C_FADEOUT:
- if (!(*it)->start) {
- g_hdb->_drawMan->setFade(false, (bool)(*it)->end, (*it)->speed);
- (*it)->start = 1;
+ if (!_cine[i]->start) {
+ g_hdb->_drawMan->setFade(false, (bool)_cine[i]->end, _cine[i]->speed);
+ _cine[i]->start = 1;
} else if (!g_hdb->_drawMan->isFadeActive()) {
complete = true;
}
break;
default:
- warning("STUB: AI::PROCESSCINES incomplete for %d", (*it)->cmdType);
+ warning("STUB: AI::PROCESSCINES incomplete for %d", _cine[i]->cmdType);
break;
}
+
+ if (bailOut) {
+ return;
+ }
+
+ if (complete) {
+ if (_cine.size()) {
+ _cine.remove_at(i);
+ i--;
+ complete = false;
+ }
+ }
}
}
@@ -141,13 +145,13 @@ void AI::cineSetCamera(int x, int y) {
cmd->x = x * kTileWidth;
cmd->y = y * kTileHeight;
cmd->cmdType = C_SETCAMERA;
- _cine->push_back(cmd);
+ _cine.push_back(cmd);
}
void AI::cineResetCamera() {
CineCommand *cmd = new CineCommand;
cmd->cmdType = C_RESETCAMERA;
- _cine->push_back(cmd);
+ _cine.push_back(cmd);
}
void AI::cineMoveCamera(int x, int y, int speed) {
@@ -156,7 +160,7 @@ void AI::cineMoveCamera(int x, int y, int speed) {
cmd->x = x * kTileWidth;
cmd->y = y * kTileHeight;
cmd->cmdType = C_MOVECAMERA;
- _cine->push_back(cmd);
+ _cine.push_back(cmd);
}
void AI::cineWait(int seconds) {
@@ -164,13 +168,13 @@ void AI::cineWait(int seconds) {
cmd->start = 0;
cmd->cmdType = C_WAIT;
cmd->delay = seconds;
- _cine->push_back(cmd);
+ _cine.push_back(cmd);
}
void AI::cineWaitUntilDone() {
CineCommand *cmd = new CineCommand;
cmd->cmdType = C_WAITUNTILDONE;
- _cine->push_back(cmd);
+ _cine.push_back(cmd);
}
void AI::cineFadeIn(bool isBlack, int steps) {
@@ -179,7 +183,7 @@ void AI::cineFadeIn(bool isBlack, int steps) {
cmd->end = (int) isBlack;
cmd->start = 0;
cmd->cmdType = C_FADEIN;
- _cine->push_back(cmd);
+ _cine.push_back(cmd);
}
void AI::cineFadeOut(bool isBlack, int steps) {
@@ -188,7 +192,7 @@ void AI::cineFadeOut(bool isBlack, int steps) {
cmd->end = (int) isBlack;
cmd->start = 0;
cmd->cmdType = C_FADEOUT;
- _cine->push_back(cmd);
+ _cine.push_back(cmd);
}
} // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index af7e68f1db..bf02b46e72 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -81,10 +81,6 @@ struct CineCommand {
class AI {
public:
-
- AI();
- ~AI();
-
bool init();
// Cinematic Functions
@@ -98,7 +94,7 @@ public:
void cineFadeIn(bool isBlack, int steps);
void cineFadeOut(bool isBlack, int steps);
- Common::Array<CineCommand *> *_cine;
+ Common::Array<CineCommand *> _cine;
private:
// Cinematics Variables