diff options
Diffstat (limited to 'engines/hdb')
-rw-r--r-- | engines/hdb/ai-funcs.cpp | 12 | ||||
-rw-r--r-- | engines/hdb/ai-inventory.cpp | 14 |
2 files changed, 14 insertions, 12 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp index e13fcc6879..0078f89556 100644 --- a/engines/hdb/ai-funcs.cpp +++ b/engines/hdb/ai-funcs.cpp @@ -579,7 +579,7 @@ AIEntity *AI::findEntityType(AIType type, int x, int y) { void AI::getEntityXY(const char *entName, int *x, int *y) { for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) { AIEntity *e = *it; - if (e->entityName && !scumm_stricmp(entName, e->entityName)) { + if (!scumm_stricmp(entName, e->entityName)) { *x = e->tileX; *y = e->tileY; return; @@ -588,7 +588,7 @@ void AI::getEntityXY(const char *entName, int *x, int *y) { for (Common::Array<AIEntity *>::iterator jt = _floats->begin(); jt != _floats->end(); ++jt) { AIEntity *e = *jt; - if (e->entityName && !scumm_stricmp(entName, e->entityName)) { + if (!scumm_stricmp(entName, e->entityName)) { *x = e->tileX; *y = e->tileY; return; @@ -608,7 +608,7 @@ void AI::getEntityXY(const char *entName, int *x, int *y) { bool AI::useLuaEntity(const char *initName) { for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) { AIEntity *e = *it; - if (e->entityName && !scumm_stricmp(initName, e->entityName)) { + if (!scumm_stricmp(initName, e->entityName)) { e->aiUse(e); checkActionList(e, e->tileX, e->tileY, true); if (e->luaFuncUse) @@ -631,7 +631,7 @@ bool AI::useLuaEntity(const char *initName) { void AI::removeLuaEntity(const char *initName) { for (uint i = 0; i < _ents->size(); i++) { AIEntity *e = _ents->operator[](i); - if (e->entityName && !scumm_stricmp(initName, e->entityName)) { + if (!scumm_stricmp(initName, e->entityName)) { removeEntity(e); i--; } @@ -641,7 +641,7 @@ void AI::removeLuaEntity(const char *initName) { void AI::animLuaEntity(const char *initName, AIState st) { for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) { AIEntity *e = *it; - if (e->entityName && !scumm_stricmp(initName, e->entityName)) { + if (!scumm_stricmp(initName, e->entityName)) { e->state = st; e->animFrame = 0; e->animDelay = e->animCycle; @@ -652,7 +652,7 @@ void AI::animLuaEntity(const char *initName, AIState st) { void AI::setLuaAnimFrame(const char *initName, AIState st, int frame) { for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) { AIEntity *e = *it; - if (e->entityName && !scumm_stricmp(initName, e->entityName)) { + if (!scumm_stricmp(initName, e->entityName)) { e->state = st; e->animFrame = frame; e->animDelay = e->animCycle; diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp index c67c11c7d0..cc1a28162c 100644 --- a/engines/hdb/ai-inventory.cpp +++ b/engines/hdb/ai-inventory.cpp @@ -125,7 +125,7 @@ int AI::queryInventory(const char *string) { int count = 0; for (int i = _numInventory - 1; i >= 0; i--) - if (_inventory[i].ent.entityName && strstr(_inventory[i].ent.entityName, string)) + if (strstr(_inventory[i].ent.entityName, string)) count++; return count; @@ -152,7 +152,7 @@ bool AI::removeInvItem(const char *string, int amount) { found = false; for (int i = _numInventory - 1; i >= 0; i--) - if (_inventory[i].ent.entityName && strstr(_inventory[i].ent.entityName, string)) { + if (strstr(_inventory[i].ent.entityName, string)) { int j = i; memset(&_inventory[j], 0, sizeof(InvEnt)); while (j < _numInventory - 1) { @@ -187,10 +187,10 @@ int AI::queryInventoryType(AIType which) { return 0; int count = 0; - for (int i = 0; i < _numInventory; i++) + for (int i = 0; i < _numInventory; i++) { if (_inventory[i].ent.type == which) count++; - + } return count; } @@ -198,9 +198,10 @@ int AI::queryInventoryTypeSlot(AIType which) { if (!_numInventory) return 0; - for (int i = 0; i < _numInventory; i++) + for (int i = 0; i < _numInventory; i++) { if (_inventory[i].ent.type == which) return i; + } return -1; } @@ -224,7 +225,7 @@ bool AI::removeInvItemType(AIType which, int amount) { do { found = false; - for (int i = 0; i < _numInventory; i++) + for (int i = 0; i < _numInventory; i++) { if (_inventory[i].ent.type == which) { int j = i; memset(&_inventory[j], 0, sizeof(InvEnt)); @@ -239,6 +240,7 @@ bool AI::removeInvItemType(AIType which, int amount) { if (!amount) break; } + } } while (found && amount); // if we haven't removed them all, return false |