[Scummvm-cvs-logs] SF.net SVN: scummvm: [30680] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Jan 28 17:52:42 CET 2008


Revision: 30680
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30680&view=rev
Author:   peres001
Date:     2008-01-28 08:52:41 -0800 (Mon, 28 Jan 2008)

Log Message:
-----------
Fixed animation sorting: everything should be drawn like before revision 30673 now. Character may still disappear when changing location because of wrong resource management, though.

Revision Links:
--------------
    http://scummvm.svn.sourceforge.net/scummvm/?rev=30673&view=rev

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/defs.h
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/gfxbase.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h

Modified: scummvm/trunk/engines/parallaction/defs.h
===================================================================
--- scummvm/trunk/engines/parallaction/defs.h	2008-01-28 15:20:47 UTC (rev 30679)
+++ scummvm/trunk/engines/parallaction/defs.h	2008-01-28 16:52:41 UTC (rev 30680)
@@ -75,30 +75,6 @@
 			Common_List::insert(it, element);
 	}
 
-	// FIXME: this routine is a copy of the sort routine that can be found in common/func.cpp
-	// That wasn't usable because the 'less than' operator was hardcoded. Any comments or
-	// suggestions are welcome.
-	void sort(CompareFunction compare) {
-		iterator first = Common_List::begin();
-		iterator last = Common_List::end();
-
-		if (first == last)
-			return;
-
-		// Simple selection sort
-		iterator i(first);
-		for (; i != last; ++i) {
-			iterator minElem(i);
-			iterator j(i);
-			++j;
-			for (; j != last; ++j)
-				if (compare(*j, *minElem) < 0)
-					minElem = j;
-			if (minElem != i)
-				SWAP(*minElem, *i);
-		}
-	}
-
 };
 
 } // namespace Parallaction
@@ -110,3 +86,4 @@
 
 
 
+

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-01-28 15:20:47 UTC (rev 30679)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-01-28 16:52:41 UTC (rev 30680)
@@ -320,7 +320,7 @@
 
 void Parallaction_ns::drawAnimations() {
 
-	uint16 _si = 0;
+	uint16 layer = 0;
 
 	for (AnimationList::iterator it = _animations.begin(); it != _animations.end(); it++) {
 
@@ -331,16 +331,17 @@
 
 			int16 frame = CLIP((int)v18->_frame, 0, v18->getFrameNum()-1);
 			if (v18->_flags & kFlagsNoMasked)
-				_si = 3;
+				layer = 3;
 			else
-				_si = _gfx->queryMask(v18->_top + v18->height());
+				layer = _gfx->queryMask(v18->_top + v18->height());
 
 
 			_gfx->showGfxObj(obj, true);
 			obj->frame = frame;
 			obj->x = v18->_left;
 			obj->y = v18->_top;
-			obj->z = _si;
+			obj->z = v18->_z;
+			obj->layer = layer;
 		}
 
 		if (((v18->_flags & kFlagsActive) == 0) && (v18->_flags & kFlagsRemove))   {
@@ -426,7 +427,8 @@
 			a->_z = a->_top + a->height();
 	}
 
-	sortAnimations();
+	_char._ani._z = _char._ani.height() + _char._ani._top;
+	_char._ani.gfxobj->z = _char._ani._z;
 	modCounter++;
 
 	return;

Modified: scummvm/trunk/engines/parallaction/gfxbase.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-01-28 15:20:47 UTC (rev 30679)
+++ scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-01-28 16:52:41 UTC (rev 30680)
@@ -29,7 +29,7 @@
 
 namespace Parallaction {
 
-GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : type(objType), _frames(frames), x(0), y(0), z(3), frame(0), _flags(0), _keep(true) {
+GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : type(objType), _frames(frames), x(0), y(0), z(0), frame(0), layer(3), _flags(0), _keep(true) {
 	if (name) {
 		_name = strdup(name);
 	} else {
@@ -121,12 +121,42 @@
 
 }
 
+
+
+int compareAnimationZ(const GfxObj* a1, const GfxObj* a2) {
+	if (a1->z == a2->z) return 0;
+	return (a1->z < a2->z ? -1 : 1);
+}
+
+void Gfx::sortAnimations() {
+
+	GfxObjList::iterator first = _gfxobjList[kGfxObjTypeAnim].begin();
+	GfxObjList::iterator last = _gfxobjList[kGfxObjTypeAnim].end();
+
+	if (first == last)
+		return;
+
+	// Simple selection sort
+	GfxObjList::iterator i(first);
+	for (; i != last; ++i) {
+		GfxObjList::iterator minElem(i);
+		GfxObjList::iterator j(i);
+		++j;
+		for (; j != last; ++j)
+			if (compareAnimationZ(*j, *minElem) < 0)
+				minElem = j;
+		if (minElem != i)
+			SWAP(*minElem, *i);
+	}
+
+}
+
 void Gfx::drawGfxObjects(Graphics::Surface &surf) {
 
 	Common::Rect rect;
 	byte *data;
 
-	// TODO: sort animations before drawing
+	sortAnimations();
 	// TODO: some zones don't appear because of wrong masking (3 or 0?)
 	// TODO: Dr.Ki is not visible inside the club
 
@@ -142,7 +172,7 @@
 				obj->getRect(obj->frame, rect);
 				rect.moveTo(obj->x, obj->y);
 				data = obj->getData(obj->frame);
-				blt(rect, data, &surf, obj->z, 0);
+				blt(rect, data, &surf, obj->layer, 0);
 			}
 		}
 	}

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-01-28 15:20:47 UTC (rev 30679)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-01-28 16:52:41 UTC (rev 30680)
@@ -857,7 +857,7 @@
 }
 
 
-int16 Gfx::queryMask(int16 v) {
+uint16 Gfx::queryMask(uint16 v) {
 
 	for (uint16 _si = 0; _si < 3; _si++) {
 		if (_bgLayers[_si+1] > v) return _si;

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-01-28 15:20:47 UTC (rev 30679)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-01-28 16:52:41 UTC (rev 30680)
@@ -270,6 +270,7 @@
 	uint16 z;
 	uint type;
 	uint frame;
+	uint layer;
 
 	GfxObj(uint type, Frames *frames, const char *name = NULL);
 	virtual ~GfxObj();
@@ -312,6 +313,7 @@
 	void showGfxObj(GfxObj* obj, bool visible);
 	GfxObjList _gfxobjList[3];
 	void drawGfxObjects(Graphics::Surface &surf);
+	void sortAnimations();
 
 public:
 
@@ -368,7 +370,7 @@
 	void setProjectorPos(int x, int y);
 
 	// misc
-	int16 queryMask(int16 v);
+	uint16 queryMask(uint16 v);
 	void swapBuffers();
 	void updateScreen();
 	void setBackground(Graphics::Surface *surf);
@@ -464,3 +466,4 @@
 
 
 
+

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-01-28 15:20:47 UTC (rev 30679)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-01-28 16:52:41 UTC (rev 30680)
@@ -678,18 +678,8 @@
 	return;
 }
 
-int compareAnimationZ(const AnimationPointer &a1, const AnimationPointer &a2) {
-	if (a1->_z == a2->_z) return 0;
-	return (a1->_z < a2->_z ? -1 : 1);
-}
 
-void Parallaction::sortAnimations() {
-	_char._ani._z = _char._ani.height() + _char._ani._top;
-	_animations.sort(compareAnimationZ);
-	return;
-}
 
-
 void Parallaction::allocateLocationSlot(const char *name) {
 	// WORKAROUND: the original code erroneously incremented
 	// _currentLocationIndex, thus producing inconsistent

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-01-28 15:20:47 UTC (rev 30679)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-01-28 16:52:41 UTC (rev 30680)
@@ -361,7 +361,6 @@
 	void		runCommands(CommandList& list, Zone *z = NULL);
 
 	Animation	*findAnimation(const char *name);
-	void		sortAnimations();
 	void		freeAnimations();
 
 	void		setBackground(const char *background, const char *mask, const char *path);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list