[Scummvm-cvs-logs] scummvm master -> 5f699929c85bc14cbcba8197f58c71ec1ffe5d8e

sev- sev at scummvm.org
Sat Dec 21 21:37:30 CET 2013


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:
5f699929c8 FULLPIPE: Do not memcpy non-POD objects.


Commit: 5f699929c85bc14cbcba8197f58c71ec1ffe5d8e
    https://github.com/scummvm/scummvm/commit/5f699929c85bc14cbcba8197f58c71ec1ffe5d8e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2013-12-21T12:36:19-08:00

Commit Message:
FULLPIPE: Do not memcpy non-POD objects.

Thanks to eriktorbjorn for finding out.

Changed paths:
    engines/fullpipe/motion.cpp
    engines/fullpipe/motion.h



diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index 1ecb973..56ef478 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::Array<MovGraphL
 }
 
 MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) {
-	MovInfo1 movinfo;
-
-	memcpy(&movinfo, movInfo, sizeof(movinfo));
+	MovInfo1 movinfo(movInfo);
 
 	int curX = movInfo->pt1.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 029b25b..a4d68e1 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -372,6 +372,10 @@ struct MovInfo1 {
 	Common::Array<MovInfo1Sub *> items;
 	int itemsCount;
 	int flags;
+
+	MovInfo1() { clear(); }
+	MovInfo1(MovInfo1 *src);
+	void clear();
 };
 
 struct MovGraph2Item { // 744






More information about the Scummvm-git-logs mailing list