aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-06-20 01:46:40 +0530
committerEugene Sandulenko2019-09-03 17:16:51 +0200
commit1c268c03bb5ece0e45afc3af1020842eb3b228c7 (patch)
tree712ce7171b7626577863b6cbc3b3fec20599c3aa /engines
parenta9a2ee04796bc93b64acbf2a4db91d91fb6d6c51 (diff)
downloadscummvm-rg350-1c268c03bb5ece0e45afc3af1020842eb3b228c7.tar.gz
scummvm-rg350-1c268c03bb5ece0e45afc3af1020842eb3b228c7.tar.bz2
scummvm-rg350-1c268c03bb5ece0e45afc3af1020842eb3b228c7.zip
HDB: Add initAllEnts()
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-funcs.cpp15
-rw-r--r--engines/hdb/ai.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 3a425beb76..d0888d3473 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -37,6 +37,21 @@ void AI::removeEntity(AIEntity *e) {
_ents->erase(&e);
}
+// Initializes each entity after map is loaded
+void AI::initAllEnts() {
+ for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+ (*it)->aiInit((*it));
+ if ((*it)->luaFuncInit[0]) {
+ if (g_hdb->_lua->callFunction((*it)->luaFuncInit, 2)) {
+ strcpy((*it)->entityName, g_hdb->_lua->getStringOffStack());
+ strcpy((*it)->printedName, g_hdb->_lua->getStringOffStack());
+ } else {
+ warning("'%s' doesn't exists", (*it)->luaFuncInit);
+ }
+ }
+ }
+}
+
// Check to see if we can get this entity
bool AI::getTableEnt(AIType type) {
switch (type) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index aaa8385fd5..8dcb34797f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -413,6 +413,7 @@ public:
// Entity Functions
AIEntity *locateEntity(const char *luaName);
void removeEntity(AIEntity *e);
+ void initAllEnts();
bool getTableEnt(AIType type);
bool walkThroughEnt(AIType type);
void getItemSound(AIType type);