[Scummvm-cvs-logs] CVS: scummvm/common rect.h,NONE,1.1 config-file.cpp,1.1.1.1,1.2 engine.h,1.1,1.2 file.cpp,1.2,1.3 gameDetector.cpp,1.2,1.3 gameDetector.h,1.1.1.1,1.2 main.cpp,1.1.1.1,1.2

Max Horn fingolfin at users.sourceforge.net
Sat Aug 31 06:30:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/common
In directory usw-pr-cvs1:/tmp/cvs-serv24010/common

Modified Files:
	config-file.cpp engine.h file.cpp gameDetector.cpp 
	gameDetector.h main.cpp 
Added Files:
	rect.h 
Log Message:
fixed compilation on Mac OS X; some cleanup; moved header file scumm/smusH/rect.h to common/rect.h

--- NEW FILE: rect.h ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2001/2002 The ScummVM project
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/common/rect.h,v 1.1 2002/08/31 13:29:09 fingolfin Exp $
 *
 */

#ifndef COMMON_RECT_H
#define COMMON_RECT_H

#include "scummsys.h"

namespace ScummVM {

/*! 	@brief simple class for handling both 2D position and size

	This small class is an helper for position and size values.
*/
class Point {
	friend class Rect;
private:
	int32 _x;	//!< The horizontal part of the point
	int32 _y;	//!< The vertical part of the point
public:
	Point() : _x(0), _y(0) {};
	Point(const Point & p) : _x(p._x), _y(p._y) {};
	explicit Point(int32 x, int32 y) : _x(x), _y(y) {};
	Point & operator=(const Point & p) { _x = p._x; _y = p._y; return *this; };
	bool operator==(const Point & p) const { return _x == p._x && _y == p._y; };
	const int32 & getX() const { return _x; };
	const int32 & getY() const { return _y; };
	int32 & getX() { return _x; };
	int32 & getY() { return _y; };
	Point operator+(const Point & p) const { return Point(_x + p._x, _y+p._y); };
	Point operator-(const Point & p) const { return Point(_x - p._x, _y-p._y); };
	Point & operator+=(const Point & p) { _x += p._x; _y += p._y; return *this; };
	Point & operator-=(const Point & p) { _x -= p._x; _y -= p._y; return *this; };
	bool isOrigin() const { return _x == 0 && _y == 0; };
	void set(int32 x, int32 y) { _x = x; _y = y; }
};

/*! 	@brief simple class for handling a rectangular zone.

	This small class is an helper for rectangles.
	It is mostly used by the blitter class.
*/
class Rect {
private:
	Point _topLeft;		//!< The point at the top left of the rectangle
	Point _bottomRight;	//!< The point at the bottom right of the rectangle
public:
	Rect() : _topLeft(0, 0), _bottomRight(0,0) {}
	Rect(int32 x, int32 y) : _topLeft(0, 0), _bottomRight(x, y) {}
	Rect(int32 x1, int32 y1, int32 x2, int32 y2) : _topLeft(x1, y1), _bottomRight(x2, y2) {}
	Point size() const { return (_bottomRight - _topLeft); };
	int32 width() const { return size()._x; }
	int32 height() const { return size()._y; }
	int32 left() const { return _topLeft._x; }
	int32 right() const { return _bottomRight._x; }
	int32 top() const { return _topLeft._y; }
	int32 bottom() const { return _bottomRight._y; }
	const Point & topLeft() const { return _topLeft; }
	const Point & bottomRight() const { return _bottomRight; }

	/*!	@brief check if given position is inside the rectangle
		
		@param x the horizontal position to check
		@param y the vertical position to check	
		
		@return true if the given position is inside the rectangle, false otherwise
	*/
	bool isInside(int32 x, int32 y) const {
		return (_topLeft._x <= x) && (_bottomRight._x > x) && (_topLeft._y <= y) && (_bottomRight._y > y);
	}
	/*!	@brief check if given point is inside the rectangle
		
		@param p the point to check
		
		@return true if the given point is inside the rectangle, false otherwise
	*/
	bool isInside(const Point & p) const {
		return (_topLeft._x <= p._x) && (_bottomRight._x > p._x) && (_topLeft._y <= p._y) && (_bottomRight._y > p._y);
	}

	bool clip(Rect & r) const;
};

};	// End of namespace ScummVM

#endif

Index: config-file.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-file.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- config-file.cpp	21 Aug 2002 16:07:22 -0000	1.1.1.1
+++ config-file.cpp	31 Aug 2002 13:29:08 -0000	1.2
@@ -30,6 +30,19 @@
 
 #define xfree(p) {if (p) free(p);}
 
+#ifdef NEED_STRDUP
+char *strdup(const char *s) {
+	if (s) {
+		int len = strlen(s) + 1;
+		char *d = (char *)malloc(len);
+		if (d)
+			memcpy(d, s, len);
+		return d;
+	}
+	return NULL;
+}
+#endif /* NEED_STRDUP */
+
 
 static char *ltrim(char *t)
 {

Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/engine.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- engine.h	21 Aug 2002 16:53:11 -0000	1.1
+++ engine.h	31 Aug 2002 13:29:08 -0000	1.2
@@ -56,5 +56,17 @@
 	static Engine *createFromDetector(GameDetector *detector, OSystem *syst);
 };
 
+#if defined(__GNUC__)
+void CDECL error(const char *s, ...) NORETURN;
+#else
+void CDECL NORETURN error(const char *s, ...);
+#endif
+
+void CDECL warning(const char *s, ...);
+
+void CDECL debug(int level, const char *s, ...);
+void checkHeap();
+
 
 #endif
+

Index: file.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/file.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- file.cpp	31 Aug 2002 09:55:58 -0000	1.2
+++ file.cpp	31 Aug 2002 13:29:08 -0000	1.3
@@ -21,19 +21,6 @@
 
 #include "file.h"
 
-#ifdef NEED_STRDUP
-char *strdup(const char *s) {
-	if (s) {
-		int len = strlen(s) + 1;
-		char *d = (char *)malloc(len);
-		if (d)
-			memcpy(d, s, len);
-		return d;
-	}
-	return NULL;
-}
-#endif /* NEED_STRDUP */
-
 File::File() {
 	_handle = NULL;
 	_readFailed = false;
@@ -45,28 +32,35 @@
 }
 
 bool File::open(const char *filename, int mode, byte encbyte) {
-	char * buf;
+	char buf[256], *ptr;
 	if (_handle) {
 		debug(2, "File %s already opened", filename);
 		return false;
 	}
 
 	clearReadFailed();
-	buf = strdup(filename);
+	strcpy(buf, filename);
 	if (mode == 1) {
 		_handle = fopen(buf, "rb");
 		if (_handle == NULL) {
-			_handle = fopen(strupr(buf), "rb");
-			if (_handle == NULL) {
-				_handle = fopen(strlwr(buf), "rb");
-			}
-			else {
-				debug(2, "File %s not found", filename);
-				return false;
-			}
+			ptr = buf;
+			do
+				*ptr++ = toupper(*ptr);
+			while (*ptr);
+			_handle = fopen(buf, "rb");
 		}
-	}
-	else {
+		if (_handle == NULL) {
+			ptr = buf;
+			do
+				*ptr++ = tolower(*ptr);
+			while (*ptr);
+			_handle = fopen(buf, "rb");
+		}
+		if (_handle == NULL) {
+			debug(2, "File %s not found", filename);
+			return false;
+		}
+	} else {
 		warning("Only read mode supported!");
 		return false;
 	}

Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- gameDetector.cpp	29 Aug 2002 16:57:43 -0000	1.2
+++ gameDetector.cpp	31 Aug 2002 13:29:09 -0000	1.3
@@ -29,6 +29,9 @@
 #include "common/config-file.h"
 
 
+extern uint16 _debugLevel;
+
+
 #define CHECK_OPTION() if ((current_option != NULL) || (*s != '\0')) goto ShowHelpAndExit
 #define HANDLE_OPTION() if ((*s == '\0') && (current_option == NULL)) goto ShowHelpAndExit;  \
                         if ((*s != '\0') && (current_option != NULL)) goto ShowHelpAndExit; \
@@ -450,14 +453,14 @@
 	return true;
 }
 
-char *GameDetector::getGameName()
+const char *GameDetector::getGameName()
 {
 	if (_gameText == NULL) {
 		char buf[256];
 		sprintf(buf, "Unknown game: \"%s\"", _exe_name);
-		return strdup(buf);
+		_gameText = strdup(buf);
 	}
-	return strdup(_gameText);
+	return _gameText;
 }
 
 int GameDetector::detectMain(int argc, char **argv)

Index: gameDetector.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- gameDetector.h	21 Aug 2002 16:07:22 -0000	1.1.1.1
+++ gameDetector.h	31 Aug 2002 13:29:09 -0000	1.2
@@ -31,7 +31,7 @@
 	int detectMain(int argc, char **argv);
 	void parseCommandLine(int argc, char **argv);
 	bool detectGame(void);
-	char *getGameName(void);
+	const char *getGameName(void);
 
 	bool _fullScreen;
 	byte _gameId;

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/main.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- main.cpp	21 Aug 2002 16:07:22 -0000	1.1.1.1
+++ main.cpp	31 Aug 2002 13:29:09 -0000	1.2
@@ -130,12 +130,10 @@
 	OSystem *system = detector.createSystem();
 
 	{
-		char *s = detector.getGameName();
 		OSystem::Property prop;
 
-		prop.caption = s;
+		prop.caption = detector.getGameName();
 		system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
-		free(s);
 	}
 
 	// Create the game engine





More information about the Scummvm-git-logs mailing list