[Scummvm-cvs-logs] scummvm master -> 56b0b6f06636904d8cd520345088c2ee8cf10617

fingolfin max at quendi.de
Wed May 18 13:46:34 CEST 2011


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

Summary:
39ab4a2dc4 AGI: Constify stuff
904739cc00 COMMON: Document that Stream API is meant to imitate ISO C FILE semantics
56b0b6f066 TINSEL: Revert commit 43ca9c86ab to fix bug #3303799


Commit: 39ab4a2dc481ee794cafb5e2548404a7121eb96d
    https://github.com/scummvm/scummvm/commit/39ab4a2dc481ee794cafb5e2548404a7121eb96d
Author: Max Horn (max at quendi.de)
Date: 2011-05-18T04:06:33-07:00

Commit Message:
AGI: Constify stuff

Changed paths:
    engines/agi/agi.h
    engines/agi/words.cpp



diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 1934387..a42148b 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -969,7 +969,7 @@ public:
 	int showWords();
 	int loadWords(const char *);
 	void unloadWords();
-	int findWord(char *word, int *flen);
+	int findWord(const char *word, int *flen);
 	void dictionaryWords(char *);
 
 	// Motion
diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp
index e18b183..4b96fdf 100644
--- a/engines/agi/words.cpp
+++ b/engines/agi/words.cpp
@@ -37,7 +37,7 @@ static uint32 wordsFlen;	// length of word memory
 // Local implementation to avoid problems with strndup() used by
 // gcc 3.2 Cygwin (see #635984)
 //
-static char *myStrndup(char *src, int n) {
+static char *myStrndup(const char *src, int n) {
 	char *tmp = strncpy((char *)malloc(n + 1), src, n);
 	tmp[n] = 0;
 	return tmp;
@@ -86,11 +86,11 @@ void AgiEngine::unloadWords() {
  *
  * Thomas Akesson, November 2001
  */
-int AgiEngine::findWord(char *word, int *flen) {
+int AgiEngine::findWord(const char *word, int *flen) {
 	int mchr = 0;		// matched chars
 	int len, fchr, id = -1;
-	uint8 *p = words;
-	uint8 *q = words + wordsFlen;
+	const uint8 *p = words;
+	const uint8 *q = words + wordsFlen;
 	*flen = 0;
 
 	debugC(2, kDebugLevelScripts, "find_word(%s)", word);


Commit: 904739cc00c2ce4bf9f6f7d14d8866f09494fb91
    https://github.com/scummvm/scummvm/commit/904739cc00c2ce4bf9f6f7d14d8866f09494fb91
Author: Max Horn (max at quendi.de)
Date: 2011-05-18T04:06:41-07:00

Commit Message:
COMMON: Document that Stream API is meant to imitate ISO C FILE semantics

Changed paths:
    common/stream.h



diff --git a/common/stream.h b/common/stream.h
index 1e9e025..26c04e5 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -42,12 +42,18 @@ public:
 	 * Returns true if an I/O failure occurred.
 	 * This flag is never cleared automatically. In order to clear it,
 	 * client code has to call clearErr() explicitly.
+	 *
+	 * @note The semantics of any implementation of this method are
+	 * supposed to match those of ISO C ferror().
 	 */
 	virtual bool err() const { return false; }
 
 	/**
 	 * Reset the I/O error status as returned by err().
 	 * For a ReadStream, also reset the end-of-stream status returned by eos().
+	 *
+	 * @note The semantics of any implementation of this method are
+	 * supposed to match those of ISO C clearerr().
 	 */
 	virtual void clearErr() {}
 };
@@ -61,6 +67,9 @@ public:
 	 * Write data into the stream. Subclasses must implement this
 	 * method; all other write methods are implemented using it.
 	 *
+	 * @note The semantics of any implementation of this method are
+	 * supposed to match those of ISO C fwrite().
+	 *
 	 * @param dataPtr	pointer to the data to be written
 	 * @param dataSize	number of bytes to be written
 	 * @return the number of bytes which were actually written.
@@ -72,6 +81,9 @@ public:
 	 * storage medium; unbuffered streams can use the default
 	 * implementation.
 	 *
+	 * @note The semantics of any implementation of this method are
+	 * supposed to match those of ISO C fflush().
+	 *
 	 * @return true on success, false in case of a failure
 	 */
 	virtual bool flush() { return true; }
@@ -155,6 +167,11 @@ public:
 	 * Returns true if a read failed because the stream end has been reached.
 	 * This flag is cleared by clearErr().
 	 * For a SeekableReadStream, it is also cleared by a successful seek.
+	 *
+	 * @note The semantics of any implementation of this method are
+	 * supposed to match those of ISO C feof(). In particular, in a stream
+	 * with N bytes, reading exactly N bytes from the start should *not*
+	 * set eos; only reading *beyond* the available data should set it.
 	 */
 	virtual bool eos() const = 0;
 
@@ -162,6 +179,10 @@ public:
 	 * Read data from the stream. Subclasses must implement this
 	 * method; all other read methods are implemented using it.
 	 *
+	 * @note The semantics of any implementation of this method are
+	 * supposed to match those of ISO C fread(), in particular where
+	 * it concerns setting error and end of file/stream flags.
+	 *
 	 * @param dataPtr	pointer to a buffer into which the data is read
 	 * @param dataSize	number of bytes to be read
 	 * @return the number of bytes which were actually read.
@@ -335,6 +356,9 @@ public:
 	 * position indicator, or end-of-file, respectively. A successful call
 	 * to the seek() method clears the end-of-file indicator for the stream.
 	 *
+	 * @note The semantics of any implementation of this method are
+	 * supposed to match those of ISO C fseek().
+	 *
 	 * @param offset	the relative offset in bytes
 	 * @param whence	the seek reference: SEEK_SET, SEEK_CUR, or SEEK_END
 	 * @return true on success, false in case of a failure


Commit: 56b0b6f06636904d8cd520345088c2ee8cf10617
    https://github.com/scummvm/scummvm/commit/56b0b6f06636904d8cd520345088c2ee8cf10617
Author: Max Horn (max at quendi.de)
Date: 2011-05-18T04:43:52-07:00

Commit Message:
TINSEL: Revert commit 43ca9c86ab to fix bug #3303799

Commit 43ca9c86ab causes segfaults when trying to start a game in tinsel.

However, the code in question still should be investigated, as it
casts OBJECT** pointers to OBJECT*. Very fishy.

Changed paths:
  A engines/tinsel/background.cpp.orig
    engines/tinsel/background.cpp



diff --git a/engines/tinsel/background.cpp b/engines/tinsel/background.cpp
index a5b7198..4f0623d 100644
--- a/engines/tinsel/background.cpp
+++ b/engines/tinsel/background.cpp
@@ -162,7 +162,7 @@ OBJECT *GetPlayfieldList(int which) {
 	pPlayfield = pCurBgnd->fieldArray + which;
 
 	// return the display list pointer for this playfield
-	return pPlayfield->pDispList;
+	return (OBJECT *)&pPlayfield->pDispList;
 }
 
 /**
@@ -202,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(pPlay->pDispList);
+		SortObjectList((OBJECT *)&pPlay->pDispList);
 
 		// generate clipping rects for all objects that have moved etc.
-		FindMovingObjects(pPlay->pDispList, &ptWin,
+		FindMovingObjects((OBJECT *)&pPlay->pDispList, &ptWin,
 			&pPlay->rcClip,	false, pPlay->bMoved);
 
 		// clear playfield moved flag
@@ -232,7 +232,7 @@ void DrawBackgnd() {
 
 			if (IntersectRectangle(rcPlayClip, pPlay->rcClip, *r))
 				// redraw all objects within this clipping rect
-				UpdateClipRect(pPlay->pDispList,
+				UpdateClipRect((OBJECT *)&pPlay->pDispList,
 						&ptWin,	&rcPlayClip);
 		}
 	}
diff --git a/engines/tinsel/background.cpp.orig b/engines/tinsel/background.cpp.orig
new file mode 100644
index 0000000..a5b7198
--- /dev/null
+++ b/engines/tinsel/background.cpp.orig
@@ -0,0 +1,254 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Background handling code.
+ */
+
+#include "tinsel/background.h"
+#include "tinsel/cliprect.h"	// object clip rect defs
+#include "tinsel/graphics.h"
+#include "tinsel/sched.h"	// process sheduler defs
+#include "tinsel/object.h"
+#include "tinsel/pid.h"	// process identifiers
+#include "tinsel/tinsel.h"
+
+namespace Tinsel {
+
+// FIXME: Avoid non-const global vars
+
+// current background
+const BACKGND *pCurBgnd = NULL;
+
+/**
+ * Called to initialise a background.
+ * @param pBgnd			Pointer to data struct for current background
+ */
+
+void InitBackground(const BACKGND *pBgnd) {
+	int i;			// playfield counter
+	PLAYFIELD *pPlayfield;	// pointer to current playfield
+
+	// set current background
+	pCurBgnd = pBgnd;
+
+	// init background sky color
+	SetBgndColor(pBgnd->rgbSkyColor);
+
+	// start of playfield array
+	pPlayfield = pBgnd->fieldArray;
+
+	// for each background playfield
+	for (i = 0; i < pBgnd->numPlayfields; i++, pPlayfield++) {
+		// init playfield pos
+		pPlayfield->fieldX = intToFrac(pBgnd->ptInitWorld.x);
+		pPlayfield->fieldY = intToFrac(pBgnd->ptInitWorld.y);
+
+		// no scrolling
+		pPlayfield->fieldXvel = intToFrac(0);
+		pPlayfield->fieldYvel = intToFrac(0);
+
+		// clear playfield display list
+		pPlayfield->pDispList = NULL;
+
+		// clear playfield moved flag
+		pPlayfield->bMoved = false;
+	}
+}
+
+/**
+ * Sets the xy position of the specified playfield in the current background.
+ * @param which			Which playfield
+ * @param newXpos		New x position
+ * @param newYpos		New y position
+ */
+
+void PlayfieldSetPos(int which, int newXpos, int newYpos) {
+	PLAYFIELD *pPlayfield;	// pointer to relavent playfield
+
+	// make sure there is a background
+	assert(pCurBgnd != NULL);
+
+	// make sure the playfield number is in range
+	assert(which >= 0 && which < pCurBgnd->numPlayfields);
+
+	// get playfield pointer
+	pPlayfield = pCurBgnd->fieldArray + which;
+
+	// set new integer position
+	pPlayfield->fieldX = intToFrac(newXpos);
+	pPlayfield->fieldY = intToFrac(newYpos);
+
+	// set moved flag
+	pPlayfield->bMoved = true;
+}
+
+/**
+ * Returns the xy position of the specified playfield in the current background.
+ * @param which			Which playfield
+ * @param pXpos			Returns current x position
+ * @param pYpos			Returns current y position
+ */
+
+void PlayfieldGetPos(int which, int *pXpos, int *pYpos) {
+	PLAYFIELD *pPlayfield;	// pointer to relavent playfield
+
+	// make sure there is a background
+	assert(pCurBgnd != NULL);
+
+	// make sure the playfield number is in range
+	assert(which >= 0 && which < pCurBgnd->numPlayfields);
+
+	// get playfield pointer
+	pPlayfield = pCurBgnd->fieldArray + which;
+
+	// get current integer position
+	*pXpos = fracToInt(pPlayfield->fieldX);
+	*pYpos = fracToInt(pPlayfield->fieldY);
+}
+
+/**
+ * Returns the x position of the center of the specified playfield
+ * @param which			Which playfield
+ */
+
+int PlayfieldGetCenterX(int which) {
+	PLAYFIELD *pPlayfield; // pointer to relavent playfield
+
+	// make sure there is a background
+	assert(pCurBgnd != NULL);
+
+	// make sure the playfield number is in range
+	assert(which >= 0 && which < pCurBgnd->numPlayfields);
+
+	// get playfield pointer
+	pPlayfield = pCurBgnd->fieldArray + which;
+
+	// get current integer position
+	return fracToInt(pPlayfield->fieldX) + SCREEN_WIDTH/2;
+}
+
+/**
+ * Returns the display list for the specified playfield.
+ * @param which			Which playfield
+ */
+
+OBJECT *GetPlayfieldList(int which) {
+	PLAYFIELD *pPlayfield;	// pointer to relavent playfield
+
+	// make sure there is a background
+	assert(pCurBgnd != NULL);
+
+	// make sure the playfield number is in range
+	assert(which >= 0 && which < pCurBgnd->numPlayfields);
+
+	// get playfield pointer
+	pPlayfield = pCurBgnd->fieldArray + which;
+
+	// return the display list pointer for this playfield
+	return pPlayfield->pDispList;
+}
+
+/**
+ * Draws all the playfield object lists for the current background.
+ * The playfield velocity is added to the playfield position in order
+ * to scroll each playfield before it is drawn.
+ */
+
+void DrawBackgnd() {
+	int i;			// playfield counter
+	PLAYFIELD *pPlay;	// playfield pointer
+	int prevX, prevY;	// save interger part of position
+	Common::Point ptWin;	// window top left
+
+	if (pCurBgnd == NULL)
+		return;		// no current background
+
+	// scroll each background playfield
+	for (i = 0; i < pCurBgnd->numPlayfields; i++) {
+		// get pointer to correct playfield
+		pPlay = pCurBgnd->fieldArray + i;
+
+		// save integer part of position
+		prevX = fracToInt(pPlay->fieldX);
+		prevY = fracToInt(pPlay->fieldY);
+
+		// update scrolling
+		pPlay->fieldX += pPlay->fieldXvel;
+		pPlay->fieldY += pPlay->fieldYvel;
+
+		// convert fixed point window pos to a int
+		ptWin.x = fracToInt(pPlay->fieldX);
+		ptWin.y = fracToInt(pPlay->fieldY);
+
+		// set the moved flag if the playfield has moved
+		if (prevX != ptWin.x || prevY != ptWin.y)
+			pPlay->bMoved = true;
+
+		// sort the display list for this background - just in case somebody has changed object Z positions
+		SortObjectList(pPlay->pDispList);
+
+		// generate clipping rects for all objects that have moved etc.
+		FindMovingObjects(pPlay->pDispList, &ptWin,
+			&pPlay->rcClip,	false, pPlay->bMoved);
+
+		// clear playfield moved flag
+		pPlay->bMoved = false;
+	}
+
+	// merge the clipping rectangles
+	MergeClipRect();
+
+	// redraw all playfields within the clipping rectangles
+	const RectList &clipRects = GetClipRects();
+	for (RectList::const_iterator r = clipRects.begin(); r != clipRects.end(); ++r) {
+		// clear the clip rectangle on the virtual screen
+		// for each background playfield
+		for (i = 0; i < pCurBgnd->numPlayfields; i++) {
+			Common::Rect rcPlayClip;	// clip rect for this playfield
+
+			// get pointer to correct playfield
+			pPlay = pCurBgnd->fieldArray + i;
+
+			// convert fixed point window pos to a int
+			ptWin.x = fracToInt(pPlay->fieldX);
+			ptWin.y = fracToInt(pPlay->fieldY);
+
+			if (IntersectRectangle(rcPlayClip, pPlay->rcClip, *r))
+				// redraw all objects within this clipping rect
+				UpdateClipRect(pPlay->pDispList,
+						&ptWin,	&rcPlayClip);
+		}
+	}
+
+	// transfer any new palettes to the video DAC
+	PalettesToVideoDAC();
+
+	// update the screen within the clipping rectangles
+	for (RectList::const_iterator r = clipRects.begin(); r != clipRects.end(); ++r) {
+		UpdateScreenRect(*r);
+	}
+
+	g_system->updateScreen();
+
+	// delete all the clipping rectangles
+	ResetClipRect();
+}
+
+} // End of namespace Tinsel






More information about the Scummvm-git-logs mailing list