HDB: Fix Some GCC Compiler Warnings

These were of the type memset of a complex structure.
This commit is contained in:
D G Turner 2019-09-13 22:41:41 +01:00
parent 1a3d24f220
commit c01598484e
2 changed files with 22 additions and 12 deletions

View File

@ -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--;

View File

@ -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 {