FULLPIPE: Silence GCC memset() warnings

Recent GCC versions complain if you memset() a class or struct that
contain non-POD data types. Get around that by either initializing
the object when created, or by adding a reset() method.
This commit is contained in:
Torbjörn Andersson 2019-01-05 20:12:42 +01:00 committed by Filippos Karapetis
parent b5b136b177
commit 4eef7a42e3
4 changed files with 28 additions and 5 deletions

View File

@ -528,7 +528,7 @@ int AniHandler::seekWay(int idx, int st1idx, int st2idx, bool flip, bool flop) {
debugC(2, kDebugPathfinding, "AniHandler::seekWay(%d, %d, %d, %d, %d)", idx, st1idx, st2idx, flip, flop);
if (st1idx == st2idx) {
memset(&item.subItems[subIdx], 0, sizeof(item.subItems[subIdx]));
item.subItems[subIdx].reset();
return 0;
}

View File

@ -38,6 +38,15 @@ struct MGMSubItem {
int y;
MGMSubItem();
void reset() {
movement = nullptr;
staticsIndex = 0;
field_8 = 0;
field_C = 0;
x = 0;
y = 0;
}
};
struct MGMItem {
@ -63,7 +72,21 @@ struct MakeQueueStruct {
int y2;
int flags;
MakeQueueStruct() { memset(this, 0, sizeof(MakeQueueStruct)); }
MakeQueueStruct() { reset(); }
void reset() {
ani = nullptr;
staticsId1 = 0;
staticsId2 = 0;
movementId = 0;
field_10 = 0;
x1 = 0;
y1 = 0;
field_1C = 0;
x2 = 0;
y2 = 0;
flags = 0;
}
};
class AniHandler : public CObject {

View File

@ -1230,7 +1230,7 @@ MessageQueue *MovGraph::makeWholeQueue(StaticANIObject *ani, MovArr *movarr, int
MakeQueueStruct mkQueue;
memset(&mkQueue, 0, sizeof(mkQueue));
mkQueue.reset();
mkQueue.ani = ani;
mkQueue.staticsId2 = id2;
mkQueue.staticsId1 = id1;
@ -1996,7 +1996,7 @@ MessageQueue *MctlGraph::makeWholeQueue(MctlMQ &mctlMQ) {
} else {
MakeQueueStruct mkQueue;
memset(&mkQueue, 0, sizeof(mkQueue));
mkQueue.reset();
mkQueue.ani = _items2[mctlMQ.index]._obj;
mkQueue.staticsId2 = mg2i->_mov->_staticsObj2->_staticsId;

View File

@ -645,7 +645,7 @@ MessageQueue *sceneHandler04_kozFly5(StaticANIObject *ani, double phase) {
MessageQueue *mq1 = aniHandler.makeRunQueue(&mkQueue);
memset(&mkQueue, 0, sizeof(mkQueue));
mkQueue.reset();
mkQueue.ani = ani;
mkQueue.staticsId1 = ST_KZW_JUMPOUT;
mkQueue.staticsId2 = ST_KZW_SIT;