[Scummvm-git-logs] scummvm master -> c01598484e3ad00b231e54a430db224cefc65da0

digitall dgturner at iee.org
Fri Sep 13 23:45:07 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:
c01598484e HDB: Fix Some GCC Compiler Warnings


Commit: c01598484e3ad00b231e54a430db224cefc65da0
    https://github.com/scummvm/scummvm/commit/c01598484e3ad00b231e54a430db224cefc65da0
Author: D G Turner (digitall at scummvm.org)
Date: 2019-09-13T22:41:41+01:00

Commit Message:
HDB: Fix Some GCC Compiler Warnings

These were of the type memset of a complex structure.

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


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index cc1a281..272d41d 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -92,13 +92,11 @@ void AI::clearInventory() {
 	int keepslot = 0;
 	for (int i = 0; i < _numInventory; i++) {
 		if (!_inventory[i].keep) {
-			memset(&_inventory[i], 0, sizeof(InvEnt));
+			_inventory[i].reset();
 		} else {
 			if (i != keepslot) {
 				_inventory[keepslot] = _inventory[i];
-				_inventory[keepslot].ent = _inventory[i].ent;
-				_inventory[keepslot].keep = _inventory[i].keep;
-				memset(&_inventory[i], 0, sizeof(InvEnt));
+				_inventory[i].reset();
 			}
 			keepslot++;
 		}
@@ -154,10 +152,10 @@ bool AI::removeInvItem(const char *string, int amount) {
 		for (int i = _numInventory - 1; i >= 0; i--)
 			if (strstr(_inventory[i].ent.entityName, string)) {
 				int j = i;
-				memset(&_inventory[j], 0, sizeof(InvEnt));
+				_inventory[j].reset();
 				while (j < _numInventory - 1) {
-					memcpy(&_inventory[j], &_inventory[j + 1], sizeof(InvEnt));
-					memset(&_inventory[j + 1], 0, sizeof(InvEnt));
+					_inventory[j] = _inventory[j + 1];
+					_inventory[j + 1].reset();
 					j++;
 				}
 				_numInventory--;
@@ -228,10 +226,10 @@ bool AI::removeInvItemType(AIType which, int amount) {
 		for (int i = 0; i < _numInventory; i++) {
 			if (_inventory[i].ent.type == which) {
 				int j = i;
-				memset(&_inventory[j], 0, sizeof(InvEnt));
+				_inventory[j].reset();
 				while (j < _numInventory - 1) {
-					memcpy(&_inventory[j], &_inventory[j + 1], sizeof(InvEnt));
-					memset(&_inventory[j + 1], 0, sizeof(InvEnt));
+					_inventory[j] = _inventory[j + 1];
+					_inventory[j + 1].reset();
 					j++;
 				}
 				_numInventory--;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 572ab79..86c3709 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -456,7 +456,7 @@ struct AIEntity {
 	int16		moverightFrames;
 	Tile		*moverightGfx[kMaxAnimFrames];
 
-	AIEntity() {
+	void reset() {
 		luaFuncInit[0] = 0;
 		luaFuncAction[0] = 0;
 		luaFuncUse[0] = 0;
@@ -543,6 +543,11 @@ struct AIEntity {
 			moverightGfx[i] = NULL;
 		}
 	}
+
+	AIEntity() {
+		reset();
+	}
+
 	~AIEntity() {
 	}
 
@@ -602,7 +607,14 @@ struct InvEnt {
 	uint16 keep;
 	AIEntity ent;
 
-	InvEnt() : keep(0) {}
+	void reset() {
+		keep = 0;
+		ent.reset();
+	}
+
+	InvEnt() {
+		reset();
+	}
 };
 
 struct DlvEnt {





More information about the Scummvm-git-logs mailing list