[Scummvm-git-logs] scummvm master -> 49fe42cc332c7057cca5b746bd7dc98286da12f0

Strangerke Strangerke at scummvm.org
Sat Sep 7 01:27:44 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
49fe42cc33 HDB: Remove useless existence checks on entityName


Commit: 49fe42cc332c7057cca5b746bd7dc98286da12f0
    https://github.com/scummvm/scummvm/commit/49fe42cc332c7057cca5b746bd7dc98286da12f0
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-07T01:25:32+02:00

Commit Message:
HDB: Remove useless existence checks on entityName

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-inventory.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index e13fcc6..0078f89 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 c67c11c..cc1a281 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





More information about the Scummvm-git-logs mailing list