From 5f699929c85bc14cbcba8197f58c71ec1ffe5d8e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 21 Dec 2013 22:36:19 +0200 Subject: FULLPIPE: Do not memcpy non-POD objects. Thanks to eriktorbjorn for finding out. --- engines/fullpipe/motion.cpp | 32 ++++++++++++++++++++++++++++---- engines/fullpipe/motion.h | 4 ++++ 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'engines/fullpipe') diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 1ecb973066..56ef4782d4 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -354,6 +354,32 @@ MctlConnectionPoint::~MctlConnectionPoint() { delete _messageQueueObj; } +MovInfo1::MovInfo1(MovInfo1 *src) { + field_0 = src->field_0; + pt1 = src->pt1; + pt2 = src->pt2; + distance1 = src->distance1; + distance2 = src->distance2; + subIndex = src->subIndex; + item1Index = src->item1Index; + items = src->items; + itemsCount = src->itemsCount; + flags = src->flags; +} + +void MovInfo1::clear() { + field_0 = 0; + pt1.x = pt1.y = 0; + pt2.x = pt2.y = 0; + distance1 = 0; + distance2 = 0; + subIndex = 0; + item1Index = 0; + items.clear(); + itemsCount = 0; + flags = 0; +} + bool MctlCompoundArray::load(MfcArchive &file) { debug(5, "MctlCompoundArray::load()"); @@ -820,9 +846,7 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Arraypt1.x; int curY = movInfo->pt1.y; @@ -1141,7 +1165,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int if (minPath < 0.0 || ((linkInfoSource.node != linkInfoDest.node || !linkInfoSource.node) && !tempLinkList.size())) return 0; - memset(&movInfo1, 0, sizeof(movInfo1)); + movInfo1.clear(); movInfo1.subIndex = idxsub; movInfo1.pt1.x = obj->_ox; diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index 029b25bb19..a4d68e17fb 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -372,6 +372,10 @@ struct MovInfo1 { Common::Array items; int itemsCount; int flags; + + MovInfo1() { clear(); } + MovInfo1(MovInfo1 *src); + void clear(); }; struct MovGraph2Item { // 744 -- cgit v1.2.3