From 4eef7a42e3f45a18a57674898f5fb5409f6daf5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Andersson?= Date: Sat, 5 Jan 2019 20:12:42 +0100 Subject: [PATCH] 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. --- engines/fullpipe/anihandler.cpp | 2 +- engines/fullpipe/anihandler.h | 25 ++++++++++++++++++++++++- engines/fullpipe/motion.cpp | 4 ++-- engines/fullpipe/scenes/scene04.cpp | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/engines/fullpipe/anihandler.cpp b/engines/fullpipe/anihandler.cpp index 4ae870bb93f..05cde7567d7 100644 --- a/engines/fullpipe/anihandler.cpp +++ b/engines/fullpipe/anihandler.cpp @@ -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; } diff --git a/engines/fullpipe/anihandler.h b/engines/fullpipe/anihandler.h index f73d755aa95..ed4e382869e 100644 --- a/engines/fullpipe/anihandler.h +++ b/engines/fullpipe/anihandler.h @@ -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 { diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index d907c3d65c7..c667ac2aa5d 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -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; diff --git a/engines/fullpipe/scenes/scene04.cpp b/engines/fullpipe/scenes/scene04.cpp index 45ada3ea6ff..59adf37c66a 100644 --- a/engines/fullpipe/scenes/scene04.cpp +++ b/engines/fullpipe/scenes/scene04.cpp @@ -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;