diff options
author | Nipun Garg | 2019-06-30 04:36:23 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:06 +0200 |
commit | 2a9c34f95b954d9ac64d7c08a71fb79ca2b7afa2 (patch) | |
tree | f923f07cd9cfb1771e240fe42412cde746533c9e | |
parent | 810dc15f97eb0c7be03cf2004f577fb7849d942a (diff) | |
download | scummvm-rg350-2a9c34f95b954d9ac64d7c08a71fb79ca2b7afa2.tar.gz scummvm-rg350-2a9c34f95b954d9ac64d7c08a71fb79ca2b7afa2.tar.bz2 scummvm-rg350-2a9c34f95b954d9ac64d7c08a71fb79ca2b7afa2.zip |
HDB: Add getEntityXY()
-rw-r--r-- | engines/hdb/ai-funcs.cpp | 32 | ||||
-rw-r--r-- | engines/hdb/ai.h | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp index 6c0feec8f2..f3686ef2bb 100644 --- a/engines/hdb/ai-funcs.cpp +++ b/engines/hdb/ai-funcs.cpp @@ -564,6 +564,38 @@ AIEntity *AI::findEntityType(AIType type, int x, int y) { return NULL; } +void AI::getEntityXY(const char *entName, int *x, int *y) { + AIEntity *e; + HereT *h; + + for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) { + e = *it; + if (e->entityName && !scumm_stricmp(entName, e->entityName)) { + *x = e->tileX; + *y = e->tileY; + return; + } + } + + for (Common::Array<AIEntity *>::iterator jt = _floats->begin(); jt != _floats->end(); jt++) { + e = *jt; + if (e->entityName && !scumm_stricmp(entName, e->entityName)) { + *x = e->tileX; + *y = e->tileY; + return; + } + } + + for (Common::Array<HereT *>::iterator kt = _hereList->begin(); kt != _hereList->end(); kt++) { + h = *kt; + if (!scumm_stricmp(entName, h->entName)) { + *x = h->x; + *y = h->y; + return; + } + } +} + void AI::removeEntity(AIEntity *e) { _ents->erase(&e); } diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 40be5af840..31a6766151 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -739,6 +739,7 @@ public: AIEntity *findEntity(int x, int y); AIEntity *findEntityIgnore(int x, int y, AIEntity *ignore); AIEntity *findEntityType(AIType type, int x, int y); + void getEntityXY(const char *entName, int *x, int *y); void removeEntity(AIEntity *e); void setEntityGoal(AIEntity *e, int x, int y); void initAllEnts(); |