aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNipun Garg2019-06-22 07:41:58 +0530
committerEugene Sandulenko2019-09-03 17:16:55 +0200
commita39b9f373ca42c1ff25d2d479fee7efc071da498 (patch)
treed6aeef26dc149e9da44efe29b95f1e0c71bd3551
parent653960f58aa623d6155cda6a03632a718f47a2c5 (diff)
downloadscummvm-rg350-a39b9f373ca42c1ff25d2d479fee7efc071da498.tar.gz
scummvm-rg350-a39b9f373ca42c1ff25d2d479fee7efc071da498.tar.bz2
scummvm-rg350-a39b9f373ca42c1ff25d2d479fee7efc071da498.zip
HDB: Modify AI pointer arrays to be struct arrays
-rw-r--r--engines/hdb/ai-cinematic.cpp4
-rw-r--r--engines/hdb/ai-funcs.cpp36
-rw-r--r--engines/hdb/ai-init.cpp13
-rw-r--r--engines/hdb/ai-inventory.cpp10
-rw-r--r--engines/hdb/ai-lists.cpp36
-rw-r--r--engines/hdb/ai.h8
6 files changed, 48 insertions, 59 deletions
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index b9a55a51f9..eb4b14c879 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -216,8 +216,8 @@ void AI::processCines() {
}
warning("STUB: PROCESSCINES: USEENTITY: CheckActionList required;");
for (int i = 0;i < kMaxAutoActions;i++) {
- if (Common::matchString(_autoActions[i]->entityName, _cine[i]->string) && !_autoActions[i]->activated)
- checkAutoList(&_dummyPlayer, _autoActions[i]->x, _autoActions[i]->y);
+ if (Common::matchString(_autoActions[i].entityName, _cine[i]->string) && !_autoActions[i].activated)
+ checkAutoList(&_dummyPlayer, _autoActions[i].x, _autoActions[i].y);
}
complete = true;
break;
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index eab65387c1..6eadc92942 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -569,7 +569,7 @@ void AI::initAllEnts() {
}
for (int i = 0; i < _numInventory; i++) {
- AIEntity *temp = _inventory[i]->ent;
+ AIEntity *temp = _inventory[i].ent;
// Clear out all ptrs in entity before writing
for (int j = 0; i < kMaxAnimFrames; i++) {
@@ -1116,11 +1116,11 @@ void AI::drawEnts(int x, int y, int w, int h) {
if (e->type == AI_LASER || e->type == AI_DIVERTER) {
if (e->aiDraw) {
if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
- _entsLevel2[_numLevel2Ents]->aiDraw = e->aiDraw;
- _entsLevel2[_numLevel2Ents]->x = x;
- _entsLevel2[_numLevel2Ents]->y = y;
- _entsLevel2[_numLevel2Ents]->e = e;
- _entsLevel2[_numLevel2Ents]->stunnedWait = 0;
+ _entsLevel2[_numLevel2Ents].aiDraw = e->aiDraw;
+ _entsLevel2[_numLevel2Ents].x = x;
+ _entsLevel2[_numLevel2Ents].y = y;
+ _entsLevel2[_numLevel2Ents].e = e;
+ _entsLevel2[_numLevel2Ents].stunnedWait = 0;
_numLevel2Ents++;
} else {
e->aiDraw(e, x, y);
@@ -1132,12 +1132,12 @@ void AI::drawEnts(int x, int y, int w, int h) {
// If extra drawing func is present, call it
if (e->aiDraw && e->type != AI_LASER && e->type != AI_DIVERTER) {
if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
- _entsLevel2[_numLevel2Ents]->aiDraw = e->aiDraw;
- _entsLevel2[_numLevel2Ents]->draw = e->draw;
- _entsLevel2[_numLevel2Ents]->x = x;
- _entsLevel2[_numLevel2Ents]->y = y;
- _entsLevel2[_numLevel2Ents]->e = e;
- _entsLevel2[_numLevel2Ents]->stunnedWait = 0;
+ _entsLevel2[_numLevel2Ents].aiDraw = e->aiDraw;
+ _entsLevel2[_numLevel2Ents].draw = e->draw;
+ _entsLevel2[_numLevel2Ents].x = x;
+ _entsLevel2[_numLevel2Ents].y = y;
+ _entsLevel2[_numLevel2Ents].e = e;
+ _entsLevel2[_numLevel2Ents].stunnedWait = 0;
_numLevel2Ents++;
} else
e->aiDraw(e, x, y);
@@ -1153,12 +1153,12 @@ void AI::drawEnts(int x, int y, int w, int h) {
break;
default:
if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
- _entsLevel2[_numLevel2Ents]->aiDraw = NULL;
- _entsLevel2[_numLevel2Ents]->draw = e->draw;
- _entsLevel2[_numLevel2Ents]->x = e->x - x + e->drawXOff;
- _entsLevel2[_numLevel2Ents]->y = e->y - y + e->drawYOff;
- _entsLevel2[_numLevel2Ents]->e = NULL;
- _entsLevel2[_numLevel2Ents]->stunnedWait = e->stunnedWait;
+ _entsLevel2[_numLevel2Ents].aiDraw = NULL;
+ _entsLevel2[_numLevel2Ents].draw = e->draw;
+ _entsLevel2[_numLevel2Ents].x = e->x - x + e->drawXOff;
+ _entsLevel2[_numLevel2Ents].y = e->y - y + e->drawYOff;
+ _entsLevel2[_numLevel2Ents].e = NULL;
+ _entsLevel2[_numLevel2Ents].stunnedWait = e->stunnedWait;
_numLevel2Ents++;
} else {
if (e->draw)
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 05e939f821..7a7d47ddc6 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -671,16 +671,6 @@ AI::AI() {
_floats = new Common::Array<AIEntity *>;
_animTargets = new Common::Array<AnimTarget *>;
- for (int i = 0; i < kMaxLevel2Ents; i++) {
- _entsLevel2[i] = new AIEntLevel2;
- }
- for (int i = 0; i < kMaxActions; i++) {
- _actions[i] = new ActionInfo;
- }
- for (int i = 0; i < kMaxAutoActions; i++) {
- _autoActions[i] = new AutoAction;
- }
-
// REMOVE: Remove for final. Used here due to lack of a MENU
_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
}
@@ -689,9 +679,6 @@ AI::~AI() {
delete _ents;
delete _floats;
delete _animTargets;
- for (int i = 0; i < kMaxLevel2Ents;i++) {
- delete _entsLevel2[i];
- }
}
bool AI::init() {
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 7505aef3df..25376bf513 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -61,7 +61,7 @@ bool AI::addToInventory(AIEntity *e) {
return false;
}
- _inventory[_numInventory]->ent = e;
+ _inventory[_numInventory].ent = e;
_numInventory++;
// If weapon, ready it
@@ -84,12 +84,14 @@ bool AI::addToInventory(AIEntity *e) {
void AI::clearInventory() {
int keepslot = 0;
for (int i = 0; i < _numInventory; i++) {
- if (!_inventory[i]->keep) {
- _inventory[i] = NULL;
+ if (!_inventory[i].keep) {
+ memset(&_inventory[i], 0, sizeof(InvEnt));
} else {
if (i != keepslot) {
_inventory[keepslot] = _inventory[i];
- _inventory[i] = NULL;
+ _inventory[keepslot].ent = _inventory[i].ent;
+ _inventory[keepslot].keep = _inventory[i].keep;
+ memset(&_inventory[i], 0, sizeof(InvEnt));
}
keepslot++;
}
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 1ef2e41edd..5165313252 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -139,25 +139,25 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
const char *get;
for (int i = 0;i < kMaxAutoActions;i++) {
- if (!_autoActions[i]->x) {
- _autoActions[i]->x = x;
- _autoActions[i]->y = y;
- _autoActions[i]->activated = false;
+ if (!_autoActions[i].x) {
+ _autoActions[i].x = x;
+ _autoActions[i].y = y;
+ _autoActions[i].activated = false;
if (luaFuncInit[0] != '*')
- strcpy(&_autoActions[i]->luaFuncInit[0], luaFuncInit);
+ strcpy(&_autoActions[i].luaFuncInit[0], luaFuncInit);
if (luaFuncUse[0] != '*')
- strcpy(&_autoActions[i]->luaFuncUse[0], luaFuncUse);
+ strcpy(&_autoActions[i].luaFuncUse[0], luaFuncUse);
- if (_autoActions[i]->luaFuncInit[0]) {
- g_hdb->_lua->callFunction(_autoActions[i]->luaFuncInit, 2);
+ if (_autoActions[i].luaFuncInit[0]) {
+ g_hdb->_lua->callFunction(_autoActions[i].luaFuncInit, 2);
get = g_hdb->_lua->getStringOffStack();
if (!get)
return;
- strcpy(&_autoActions[i]->entityName[0], get);
+ strcpy(&_autoActions[i].entityName[0], get);
get = g_hdb->_lua->getStringOffStack();
if (!get)
return;
- strcpy(&_autoActions[i]->entityName[0], get);
+ strcpy(&_autoActions[i].entityName[0], get);
}
return;
}
@@ -166,8 +166,8 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
void AI::autoDeactivate(int x, int y) {
for (int i = 0; i < kMaxAutoActions;i++) {
- if (_autoActions[i]->x == x && _autoActions[i]->y == y) {
- _autoActions[i]->activated = false;
+ if (_autoActions[i].x == x && _autoActions[i].y == y) {
+ _autoActions[i].activated = false;
return;
}
}
@@ -299,12 +299,12 @@ bool AI::activateAction(AIEntity *e, int x, int y, int targetX, int targetY) {
bool AI::checkAutoList(AIEntity *e, int x, int y) {
for (int i = 0;i < kMaxAutoActions;i++) {
- if (_autoActions[i]->x == x && _autoActions[i]->y == y && !_autoActions[i]->activated) {
+ if (_autoActions[i].x == x && _autoActions[i].y == y && !_autoActions[i].activated) {
bool success = activateAction(e, x, y, 0, 0);
- _autoActions[i]->activated = true;
+ _autoActions[i].activated = true;
- if (success && _autoActions[i]->luaFuncUse[0])
- g_hdb->_lua->callFunction(_autoActions[i]->luaFuncUse, 0);
+ if (success && _autoActions[i].luaFuncUse[0])
+ g_hdb->_lua->callFunction(_autoActions[i].luaFuncUse, 0);
if (e == _player) {
lookAtXY(x, y);
@@ -319,8 +319,8 @@ bool AI::checkAutoList(AIEntity *e, int x, int y) {
bool AI::autoActive(int x, int y) {
for (int i = 0;i < kMaxAutoActions;i++) {
- if (_autoActions[i]->x == x && _autoActions[i]->y == y) {
- if (!_autoActions[i]->activated)
+ if (_autoActions[i].x == x && _autoActions[i].y == y) {
+ if (!_autoActions[i].activated)
return false;
return true;
}
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index d11442bc07..df700722e7 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -876,19 +876,19 @@ public:
int _kcHolderBlackOff;
int _kcHolderBlackOn;
- AIEntLevel2 *_entsLevel2[kMaxLevel2Ents];
+ AIEntLevel2 _entsLevel2[kMaxLevel2Ents];
int _numLevel2Ents;
- InvEnt *_inventory[kMaxInventory];
+ InvEnt _inventory[kMaxInventory];
int _numInventory;
Waypoint _waypoints[kMaxWaypoints];
int _numWaypoints;
Tile *_waypointGfx[4]; // Animating waypoint gfx
- ActionInfo *_actions[kMaxActions];
+ ActionInfo _actions[kMaxActions];
- AutoAction *_autoActions[kMaxAutoActions];
+ AutoAction _autoActions[kMaxAutoActions];
// Virtual Player
AIEntity _dummyPlayer;