[Scummvm-cvs-logs] scummvm master -> 5813ac1bcf57f592472c9d095c26781cd8b47a05

fingolfin max at quendi.de
Wed May 18 15:33:01 CEST 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f143668db4 TINSEL: Correctly handle the pDispList OBJECT linked lists, i.e. use OBJECT** for a pointer to the head.
5813ac1bcf TINSEL: Remove declarations for non-existent functions FindObject() and GetNextObject().


Commit: f143668db4b0bb1efee9e97fc3b764cb90489c3a
    https://github.com/scummvm/scummvm/commit/f143668db4b0bb1efee9e97fc3b764cb90489c3a
Author: Christoph Mallon (christoph.mallon at gmx.de)
Date: 2011-05-18T06:30:23-07:00

Commit Message:
TINSEL: Correctly handle the pDispList OBJECT linked lists, i.e. use OBJECT** for a pointer to the head.

Signed-off-by: Max Horn <max at quendi.de>

Changed paths:
    engines/tinsel/background.cpp
    engines/tinsel/background.h
    engines/tinsel/cliprect.cpp
    engines/tinsel/cliprect.h
    engines/tinsel/multiobj.cpp
    engines/tinsel/multiobj.h
    engines/tinsel/object.cpp
    engines/tinsel/object.h
    engines/tinsel/text.cpp
    engines/tinsel/text.h



diff --git a/engines/tinsel/background.cpp b/engines/tinsel/background.cpp
index 79a8d4a..5e2ebaa 100644
--- a/engines/tinsel/background.cpp
+++ b/engines/tinsel/background.cpp
@@ -149,7 +149,7 @@ int PlayfieldGetCenterX(int which) {
  * @param which			Which playfield
  */
 
-OBJECT *GetPlayfieldList(int which) {
+OBJECT **GetPlayfieldList(int which) {
 	PLAYFIELD *pPlayfield;	// pointer to relavent playfield
 
 	// make sure there is a background
@@ -162,22 +162,7 @@ OBJECT *GetPlayfieldList(int which) {
 	pPlayfield = pCurBgnd->fieldArray + which;
 
 	// return the display list pointer for this playfield
-	//
-	// HACK: We pretend that pPlayfield is an OBJECT here, by explicitly
-	// casting a pointer to it (resp. to its first member) to an OBJECT
-	// pointer.
-	// Of course it isn't, but its first member is pDispList, an OBJECT
-	// pointer, just like the first member of an OBJECT is pNext, also
-	// an OBJECT pointer. This (classic) trick allows us to use
-	// pPlayfield as a fake anchor element for the linked list of
-	// objects pDispList points to, which in turn simplifies some list
-	// manipulation code. Alas, this is prone to confuse aliasing
-	// analysis in compilers, and also silly developers like myself ;).
-	// So at the very least, I figured we should document this trick
-	// here explicitly.
-	// Personally, I would prefer if we got rid of this trick, e.g. by
-	// introducing an explicit anchor element.
-	return (OBJECT *)&pPlayfield->pDispList;
+	return &pPlayfield->pDispList;
 }
 
 /**
@@ -217,10 +202,10 @@ void DrawBackgnd() {
 			pPlay->bMoved = true;
 
 		// sort the display list for this background - just in case somebody has changed object Z positions
-		SortObjectList((OBJECT *)&pPlay->pDispList);
+		SortObjectList(&pPlay->pDispList);
 
 		// generate clipping rects for all objects that have moved etc.
-		FindMovingObjects((OBJECT *)&pPlay->pDispList, &ptWin,
+		FindMovingObjects(&pPlay->pDispList, &ptWin,
 			&pPlay->rcClip,	false, pPlay->bMoved);
 
 		// clear playfield moved flag
@@ -247,8 +232,7 @@ void DrawBackgnd() {
 
 			if (IntersectRectangle(rcPlayClip, pPlay->rcClip, *r))
 				// redraw all objects within this clipping rect
-				UpdateClipRect((OBJECT *)&pPlay->pDispList,
-						&ptWin,	&rcPlayClip);
+				UpdateClipRect(&pPlay->pDispList, &ptWin,	&rcPlayClip);
 		}
 	}
 
diff --git a/engines/tinsel/background.h b/engines/tinsel/background.h
index 55754b5..37ab4d4 100644
--- a/engines/tinsel/background.h
+++ b/engines/tinsel/background.h
@@ -93,7 +93,7 @@ void PlayfieldGetPos(		// Returns the xy position of the specified playfield in
 int PlayfieldGetCenterX(	// Returns the xy position of the specified playfield in the current background
 	int which);		// which playfield
 
-OBJECT *GetPlayfieldList(	// Returns the display list for the specified playfield
+OBJECT **GetPlayfieldList(	// Returns the display list for the specified playfield
 	int which);		// which playfield
 
 void KillPlayfieldList(		// Kills all the objects on the display list for the specified playfield
diff --git a/engines/tinsel/cliprect.cpp b/engines/tinsel/cliprect.cpp
index 34724c4..f8d8011 100644
--- a/engines/tinsel/cliprect.cpp
+++ b/engines/tinsel/cliprect.cpp
@@ -105,10 +105,10 @@ static bool LooseIntersectRectangle(const Common::Rect &pSrc1, const Common::Rec
  * @param bNoVelocity		When reset, objects pos is updated with velocity
  * @param bScrolled)		When set, playfield has scrolled
  */
-void FindMovingObjects(OBJECT *pObjList, Common::Point *pWin, Common::Rect *pClip, bool bNoVelocity, bool bScrolled) {
+void FindMovingObjects(OBJECT **pObjList, Common::Point *pWin, Common::Rect *pClip, bool bNoVelocity, bool bScrolled) {
 	OBJECT *pObj;			// object list traversal pointer
 
-	for (pObj = pObjList->pNext; pObj != NULL; pObj = pObj->pNext) {
+	for (pObj = *pObjList; pObj != NULL; pObj = pObj->pNext) {
 		if (!bNoVelocity) {
 			// we want to add velocities to objects position
 
@@ -203,7 +203,7 @@ void MergeClipRect() {
  * @param pWin			Window top left position
  * @param pClip			Pointer to clip rectangle
  */
-void UpdateClipRect(OBJECT *pObjList, Common::Point *pWin, Common::Rect *pClip) {
+void UpdateClipRect(OBJECT **pObjList, Common::Point *pWin, Common::Rect *pClip) {
 	int x, y, right, bottom;	// object corners
 	int hclip, vclip;			// total size of object clipping
 	DRAWOBJECT currentObj;		// filled in to draw the current object in list
@@ -212,7 +212,7 @@ void UpdateClipRect(OBJECT *pObjList, Common::Point *pWin, Common::Rect *pClip)
 	// Initialise the fields of the drawing object to empty
 	memset(&currentObj, 0, sizeof(DRAWOBJECT));
 
-	for (pObj = pObjList->pNext; pObj != NULL; pObj = pObj->pNext) {
+	for (pObj = *pObjList; pObj != NULL; pObj = pObj->pNext) {
 		if (pObj->flags & DMA_ABS) {
 			// object position is absolute
 			x = fracToInt(pObj->xPos);
diff --git a/engines/tinsel/cliprect.h b/engines/tinsel/cliprect.h
index 64b2010..101289b 100644
--- a/engines/tinsel/cliprect.h
+++ b/engines/tinsel/cliprect.h
@@ -55,7 +55,7 @@ bool UnionRectangle(		// Creates the union of two rectangles
 	const Common::Rect &pSrc2);		// a source rectangle
 
 void FindMovingObjects(		// Creates clipping rectangles for all the objects that have moved on the specified object list
-	OBJECT *pObjList,	// playfield display list to draw
+	OBJECT **pObjList,	// playfield display list to draw
 	Common::Point *pWin,		// playfield window top left position
 	Common::Rect *pClip,		// playfield clipping rectangle
 	bool bVelocity,		// when set, objects pos is updated with velocity
@@ -64,7 +64,7 @@ void FindMovingObjects(		// Creates clipping rectangles for all the objects that
 void MergeClipRect();	// Merges any clipping rectangles that overlap
 
 void UpdateClipRect(		// Redraws all objects within this clipping rectangle
-	OBJECT *pObjList,	// object list to draw
+	OBJECT **pObjList,	// object list to draw
 	Common::Point *pWin,		// window top left position
 	Common::Rect *pClip);		// pointer to clip rectangle
 
diff --git a/engines/tinsel/multiobj.cpp b/engines/tinsel/multiobj.cpp
index fbccd31..4a9d4b6 100644
--- a/engines/tinsel/multiobj.cpp
+++ b/engines/tinsel/multiobj.cpp
@@ -90,7 +90,7 @@ OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) {
 
  */
 
-void MultiInsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
+void MultiInsertObject(OBJECT **pObjList, OBJECT *pInsObj) {
 	// validate object pointer
 	assert(isValidObject(pInsObj));
 
@@ -111,7 +111,7 @@ void MultiInsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
  * @param pMultiObj			Multi-part object to be deleted
  */
 
-void MultiDeleteObject(OBJECT *pObjList, OBJECT *pMultiObj) {
+void MultiDeleteObject(OBJECT **pObjList, OBJECT *pMultiObj) {
 	// validate object pointer
 	assert(isValidObject(pMultiObj));
 
diff --git a/engines/tinsel/multiobj.h b/engines/tinsel/multiobj.h
index 3d4ca9b..a467fac 100644
--- a/engines/tinsel/multiobj.h
+++ b/engines/tinsel/multiobj.h
@@ -57,11 +57,11 @@ OBJECT *MultiInitObject(	// Initialise a multi-part object
 	const MULTI_INIT *pInitTbl);	// pointer to multi-object initialisation table
 
 void MultiInsertObject(		// Insert a multi-part object onto a object list
-	OBJECT *pObjList,	// list to insert multi-part object onto
+	OBJECT **pObjList,	// list to insert multi-part object onto
 	OBJECT *pInsObj);	// head of multi-part object to insert
 
 void MultiDeleteObject(		// Delete all the pieces of a multi-part object
-	OBJECT *pObjList,	// list to delete multi-part object from
+	OBJECT **pObjList,	// list to delete multi-part object from
 	OBJECT *pMultiObj);	// multi-part object to be deleted
 
 void MultiHideObject(		// Hide a multi-part object
diff --git a/engines/tinsel/object.cpp b/engines/tinsel/object.cpp
index 68e9d5c..b109005 100644
--- a/engines/tinsel/object.cpp
+++ b/engines/tinsel/object.cpp
@@ -162,13 +162,13 @@ void CopyObject(OBJECT *pDest, OBJECT *pSrc) {
  * @param pInsObj			Object to insert
  */
 
-void InsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
-	OBJECT *pPrev, *pObj;	// object list traversal pointers
+void InsertObject(OBJECT **pObjList, OBJECT *pInsObj) {
+	OBJECT **pAnchor, *pObj;	// object list traversal pointers
 
 	// validate object pointer
 	assert(isValidObject(pInsObj));
 
-	for (pPrev = pObjList, pObj = pObjList->pNext; pObj != NULL; pPrev = pObj, pObj = pObj->pNext) {
+	for (pAnchor = pObjList, pObj = *pAnchor; pObj != NULL; pAnchor = &pObj->pNext, pObj = *pAnchor) {
 		// check Z order
 		if (pInsObj->zPos < pObj->zPos) {
 			// object Z is lower than list Z - insert here
@@ -182,9 +182,9 @@ void InsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
 		}
 	}
 
-	// insert obj between pPrev and pObj
+	// insert obj between pAnchor and pObj
 	pInsObj->pNext = pObj;
-	pPrev->pNext = pInsObj;
+	*pAnchor = pInsObj;
 }
 
 
@@ -194,8 +194,8 @@ void InsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
  * @param pObjList			List to delete object from
  * @param pDelObj			Object to delete
  */
-void DelObject(OBJECT *pObjList, OBJECT *pDelObj) {
-	OBJECT *pPrev, *pObj;	// object list traversal pointers
+void DelObject(OBJECT **pObjList, OBJECT *pDelObj) {
+	OBJECT **pAnchor, *pObj;	// object list traversal pointers
 	const Common::Rect rcScreen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
 
 	// validate object pointer
@@ -207,7 +207,7 @@ void DelObject(OBJECT *pObjList, OBJECT *pDelObj) {
 	assert(numObj >= 0);
 #endif
 
-	for (pPrev = pObjList, pObj = pObjList->pNext; pObj != NULL; pPrev = pObj, pObj = pObj->pNext) {
+	for (pAnchor = pObjList, pObj = *pAnchor; pObj != NULL; pAnchor = &pObj->pNext, pObj = *pAnchor) {
 		if (pObj == pDelObj) {
 			// found object to delete
 
@@ -217,7 +217,7 @@ void DelObject(OBJECT *pObjList, OBJECT *pDelObj) {
 			}
 
 			// make PREV next = OBJ next - removes OBJ from list
-			pPrev->pNext = pObj->pNext;
+			*pAnchor = pObj->pNext;
 
 			// place free list in OBJ next
 			pObj->pNext = pFreeObjects;
@@ -245,12 +245,12 @@ void DelObject(OBJECT *pObjList, OBJECT *pDelObj) {
  * Sort the specified object list in Z Y order.
  * @param pObjList			List to sort
  */
-void SortObjectList(OBJECT *pObjList) {
+void SortObjectList(OBJECT **pObjList) {
 	OBJECT *pPrev, *pObj;	// object list traversal pointers
 	OBJECT head;		// temporary head of list - because pObjList is not usually a OBJECT
 
 	// put at head of list
-	head.pNext = pObjList->pNext;
+	head.pNext = *pObjList;
 
 	// set head of list dummy OBJ Z Y values to lowest possible
 	head.yPos = intToFrac(MIN_INT16);
diff --git a/engines/tinsel/object.h b/engines/tinsel/object.h
index dbe2445..ed5ec69 100644
--- a/engines/tinsel/object.h
+++ b/engines/tinsel/object.h
@@ -134,15 +134,15 @@ void CopyObject(		// copy one object to another
 	OBJECT *pSrc);		// source object
 
 void InsertObject(		// insert a object onto a sorted object list
-	OBJECT *pObjList,	// list to insert object onto
+	OBJECT **pObjList,	// list to insert object onto
 	OBJECT *pInsObj);	// object to insert
 
 void DelObject(			// delete a object from a object list and add to free list
-	OBJECT *pObjList,	// list to delete object from
+	OBJECT **pObjList,	// list to delete object from
 	OBJECT *pDelObj);	// object to delete
 
 void SortObjectList(		// re-sort an object list
-	OBJECT *pObjList);	// list to sort
+	OBJECT **pObjList);	// list to sort
 
 OBJECT *GetNextObject(		// object list iterator - returns next obj in list
 	OBJECT *pObjList,	// which object list
diff --git a/engines/tinsel/text.cpp b/engines/tinsel/text.cpp
index b074c17..ecb1e15 100644
--- a/engines/tinsel/text.cpp
+++ b/engines/tinsel/text.cpp
@@ -104,7 +104,7 @@ int JustifyText(char *szStr, int xPos, const FONT *pFont, int mode) {
  * @param mode			Mode flags for the string
  * @param sleepTime		Sleep time between each character (if non-zero)
  */
-OBJECT *ObjectTextOut(OBJECT *pList, char *szStr, int color,
+OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color,
 					  int xPos, int yPos, SCNHANDLE hFont, int mode, int sleepTime) {
 	int xJustify;	// x position of text after justification
 	int yOffset;	// offset to next line of text
diff --git a/engines/tinsel/text.h b/engines/tinsel/text.h
index fadb677..4c80300 100644
--- a/engines/tinsel/text.h
+++ b/engines/tinsel/text.h
@@ -95,7 +95,7 @@ struct TEXTOUT {
  * @param mode			mode flags for the string
  * @param sleepTime		Sleep time between each character (if non-zero)
  */
-OBJECT *ObjectTextOut(OBJECT *pList, char *szStr, int color,
+OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color,
 					int xPos, int yPos, SCNHANDLE hFont, int mode, int sleepTime = 0);
 
 OBJECT *ObjectTextOutIndirect(	// output a string of text


Commit: 5813ac1bcf57f592472c9d095c26781cd8b47a05
    https://github.com/scummvm/scummvm/commit/5813ac1bcf57f592472c9d095c26781cd8b47a05
Author: Christoph Mallon (christoph.mallon at gmx.de)
Date: 2011-05-18T06:30:33-07:00

Commit Message:
TINSEL: Remove declarations for non-existent functions FindObject() and GetNextObject().

Signed-off-by: Max Horn <max at quendi.de>

Changed paths:
    engines/tinsel/object.h



diff --git a/engines/tinsel/object.h b/engines/tinsel/object.h
index ed5ec69..5644ddf 100644
--- a/engines/tinsel/object.h
+++ b/engines/tinsel/object.h
@@ -144,15 +144,6 @@ void DelObject(			// delete a object from a object list and add to free list
 void SortObjectList(		// re-sort an object list
 	OBJECT **pObjList);	// list to sort
 
-OBJECT *GetNextObject(		// object list iterator - returns next obj in list
-	OBJECT *pObjList,	// which object list
-	OBJECT *pStrtObj);	// object to start from - when NULL will start from beginning of list
-
-OBJECT *FindObject(		// Searches the specified obj list for a object matching the specified OID
-	OBJECT *pObjList,	// object list to search
-	int oidDesired,		// object identifer of object to find
-	int oidMask);		// mask to apply to object identifiers before comparison
-
 void GetAniOffset(	// returns the anim offsets of a image, takes into account orientation
 	SCNHANDLE hImg,	// image to get animation offset of
 	int flags,	// images current flags






More information about the Scummvm-git-logs mailing list