[Scummvm-cvs-logs] SF.net SVN: scummvm:[55485] scummvm/trunk/engines/hugo

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Sun Jan 23 23:51:13 CET 2011


Revision: 55485
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55485&view=rev
Author:   strangerke
Date:     2011-01-23 22:51:12 +0000 (Sun, 23 Jan 2011)

Log Message:
-----------
HUGO: Get rid of (almost) all the remaining defines

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/display.cpp
    scummvm/trunk/engines/hugo/display.h
    scummvm/trunk/engines/hugo/file.cpp
    scummvm/trunk/engines/hugo/file.h
    scummvm/trunk/engines/hugo/file_v1d.cpp
    scummvm/trunk/engines/hugo/file_v2d.cpp
    scummvm/trunk/engines/hugo/file_v3d.cpp
    scummvm/trunk/engines/hugo/game.h
    scummvm/trunk/engines/hugo/hugo.cpp
    scummvm/trunk/engines/hugo/hugo.h
    scummvm/trunk/engines/hugo/intro.cpp
    scummvm/trunk/engines/hugo/mouse.cpp
    scummvm/trunk/engines/hugo/mouse.h
    scummvm/trunk/engines/hugo/object.cpp
    scummvm/trunk/engines/hugo/object.h
    scummvm/trunk/engines/hugo/object_v1d.cpp
    scummvm/trunk/engines/hugo/object_v2d.cpp
    scummvm/trunk/engines/hugo/schedule.cpp
    scummvm/trunk/engines/hugo/schedule.h

Modified: scummvm/trunk/engines/hugo/display.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/display.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -41,11 +41,6 @@
 #include "hugo/util.h"
 
 namespace Hugo {
-
-#define INX(X, B) (X >= B->x && X <= B->x + B->dx)
-#define INY(Y, B) (Y >= B->y && Y <= B->y + B->dy)
-#define OVERLAP(A, B) ((INX(A->x, B) || INX(A->x + A->dx, B) || INX(B->x, A) || INX(B->x + B->dx, A)) && (INY(A->y, B) || INY(A->y + A->dy, B) || INY(B->y, A) || INY(B->y + B->dy, A)))
-
 Screen::Screen(HugoEngine *vm) : _vm(vm), _mainPalette(0), _curPalette(0) {
 	for (int i = 0; i < kNumFonts; i++) {
 		_arrayFont[i] = 0;
@@ -264,7 +259,7 @@
 		rect_t *bp = blist;
 		for (int16 b = 0; b < blen; b++, bp++) {
 			if (bp->dx)                             // blist entry used
-				if (OVERLAP(list, bp))
+				if (isOverlaping(list, bp))
 					coalesce[c++] = b;
 		}
 
@@ -592,6 +587,19 @@
 	CursorMan.showMouse(false);
 }
 
+bool Screen::isInX(int16 x, rect_t *rect) {
+	return (x >= rect->x) && (x <= rect->x + rect->dx);
+}
+
+bool Screen::isInY(int16 y, rect_t *rect) {
+	return (y >= rect->y) && (y <= rect->y + rect->dy);
+}
+
+bool Screen::isOverlaping(rect_t *rectA, rect_t *rectB) {
+	return (isInX(rectA->x, rectB) || isInX(rectA->x + rectA->dx, rectB) || isInX(rectB->x, rectA) || isInX(rectB->x + rectB->dx, rectA)) && 
+		   (isInY(rectA->y, rectB) || isInY(rectA->y + rectA->dy, rectB) || isInY(rectB->y, rectA) || isInY(rectB->y + rectB->dy, rectA));
+}
+
 Screen_v1d::Screen_v1d(HugoEngine *vm) : Screen(vm) {
 }
 
@@ -698,5 +706,6 @@
 			in.readByte();
 	}
 }
+
 } // End of namespace Hugo
 

Modified: scummvm/trunk/engines/hugo/display.h
===================================================================
--- scummvm/trunk/engines/hugo/display.h	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/display.h	2011-01-23 22:51:12 UTC (rev 55485)
@@ -145,6 +145,10 @@
 	static const int kRectListSize = 16;            // Size of add/restore rect lists
 	static const int kBlitListSize = kRectListSize * 2; // Size of dirty rect blit list
 
+	inline bool isInX(int16 x, rect_t *rect);
+	inline bool isInY(int16 y, rect_t *rect);
+	inline bool isOverlaping(rect_t *rectA, rect_t *rectB);
+
 	bool fontLoadedFl[kNumFonts];
 
 	// Fonts used in dib (non-GDI)

Modified: scummvm/trunk/engines/hugo/file.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/file.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -170,10 +170,10 @@
 		_objectsArchive.seek(objBlock.objOffset, SEEK_SET);
 	} else {
 		char *buf = (char *) malloc(2048 + 1);      // Buffer for file access
-		strcat(strcat(strcpy(buf, _vm->_picDir), _vm->_arrayNouns[objPtr->nounIndex][0]), OBJEXT);
+		strcat(strcat(strcpy(buf, _vm->_picDir), _vm->_arrayNouns[objPtr->nounIndex][0]), ".PIX");
 		if (!_objectsArchive.open(buf)) {
-			warning("File %s not found, trying again with %s%s", buf, _vm->_arrayNouns[objPtr->nounIndex][0], OBJEXT);
-			strcat(strcpy(buf, _vm->_arrayNouns[objPtr->nounIndex][0]), OBJEXT);
+			warning("File %s not found, trying again with %s%s", buf, _vm->_arrayNouns[objPtr->nounIndex][0], ".PIX");
+			strcat(strcpy(buf, _vm->_arrayNouns[objPtr->nounIndex][0]), ".PIX");
 			if (!_objectsArchive.open(buf))
 				error("File not found: %s", buf);
 		}
@@ -257,8 +257,8 @@
 
 	// Open sounds file
 	Common::File fp;                                // Handle to SOUND_FILE
-	if (!fp.open(SOUND_FILE)) {
-		warning("Hugo Error: File not found %s", SOUND_FILE);
+	if (!fp.open(getSoundFilename())) {
+		warning("Hugo Error: File not found %s", getSoundFilename());
 		return 0;
 	}
 
@@ -268,13 +268,13 @@
 
 	if (!has_read_header) {
 		if (fp.read(s_hdr, sizeof(s_hdr)) != sizeof(s_hdr))
-			error("Wrong sound file format: %s", SOUND_FILE);
+			error("Wrong sound file format");
 		has_read_header = true;
 	}
 
 	*size = s_hdr[sound].size;
 	if (*size == 0)
-		error("Wrong sound file format or missing sound %d: %s", sound, SOUND_FILE);
+		error("Wrong sound file format or missing sound %d", sound);
 
 	// Allocate memory for sound or music, if possible
 	sound_pt soundPtr = (byte *)malloc(s_hdr[sound].size); // Ptr to sound data
@@ -283,7 +283,7 @@
 	// Seek to data and read it
 	fp.seek(s_hdr[sound].offset, SEEK_SET);
 	if (fp.read(soundPtr, s_hdr[sound].size) != s_hdr[sound].size)
-		error("File not found: %s", SOUND_FILE);
+		error("Wrong sound file format");
 
 	fp.close();
 
@@ -516,11 +516,11 @@
 * Read the encrypted text from the boot file and print it
 */
 void FileManager::printBootText() {
-	debugC(1, kDebugFile, "printBootText");
+	debugC(1, kDebugFile, "printBootText()");
 	static const char *cypher = getBootCypher();
 
 	Common::File ofp;
-	if (!ofp.open(BOOTFILE)) {
+	if (!ofp.open(getBootFilename())) {
 		if (_vm->_gameVariant == kGameVariantH1Dos) {
 			//TODO initialize properly _boot structure
 			warning("printBootText - Skipping as H1 Dos may be a freeware");
@@ -556,11 +556,11 @@
 * file checksum is bad.  De-crypts structure while checking checksum
 */
 void FileManager::readBootFile() {
-	debugC(1, kDebugFile, "readBootFile");
+	debugC(1, kDebugFile, "readBootFile()");
 	static const char *cypher = getBootCypher();
 
 	Common::File ofp;
-	if (!ofp.open(BOOTFILE)) {
+	if (!ofp.open(getBootFilename())) {
 		if (_vm->_gameVariant == kGameVariantH1Dos) {
 			//TODO initialize properly _boot structure
 			warning("readBootFile - Skipping as H1 Dos may be a freeware");
@@ -594,6 +594,8 @@
 
 /**
 * Returns address of uif_hdr[id], reading it in if first call
+* This file contains, between others, the bitmaps of the fonts used in the application
+* UIF means User interface database (Windows Only)
 */
 uif_hdr_t *FileManager::getUIFHeader(uif_t id) {
 	debugC(1, kDebugFile, "getUIFHeader(%d)", id);
@@ -606,11 +608,11 @@
 		firstFl = false;
 		// Open unbuffered to do far read
 		Common::File ip;                            // Image data file
-		if (!ip.open(UIF_FILE))
-			error("File not found: %s", UIF_FILE);
+		if (!ip.open(getUifFilename()))
+			error("File not found: %s", getUifFilename());
 
 		if (ip.size() < (int32)sizeof(UIFHeader))
-			error("Wrong file format: %s", UIF_FILE);
+			error("Wrong UIF file format");
 
 		for (int i = 0; i < kMaxUifs; ++i) {
 			UIFHeader[i].size = ip.readUint16LE();
@@ -630,8 +632,8 @@
 
 	// Open uif file to read data
 	Common::File ip;                                // UIF_FILE handle
-	if (!ip.open(UIF_FILE))
-		error("File not found: %s", UIF_FILE);
+	if (!ip.open(getUifFilename()))
+		error("File not found: %s", getUifFilename());
 
 	// Seek to data
 	uif_hdr_t *UIFHeaderPtr = getUIFHeader((uif_t)id);
@@ -641,12 +643,12 @@
 	seq_t *dummySeq;                                // Dummy seq_t for image data
 	switch (id) {
 	case UIF_IMAGES:                                // Read uif images file
-		dummySeq = readPCX(ip, 0, buf, true, UIF_FILE);
+		dummySeq = readPCX(ip, 0, buf, true, getUifFilename());
 		free(dummySeq);
 		break;
 	default:                                        // Read file data into supplied array
 		if (ip.read(buf, UIFHeaderPtr->size) != UIFHeaderPtr->size)
-			error("Wrong file format: %s", UIF_FILE);
+			error("Wrong UIF file format");
 		break;
 	}
 
@@ -657,7 +659,7 @@
 * Read the uif image file (inventory icons)
 */
 void FileManager::readUIFImages() {
-	debugC(1, kDebugFile, "readUIFImages");
+	debugC(1, kDebugFile, "readUIFImages()");
 
 	readUIFItem(UIF_IMAGES, _vm->_screen->getGUIBuffer());   // Read all uif images
 }

Modified: scummvm/trunk/engines/hugo/file.h
===================================================================
--- scummvm/trunk/engines/hugo/file.h	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/file.h	2011-01-23 22:51:12 UTC (rev 55485)
@@ -33,14 +33,7 @@
 #ifndef HUGO_FILE_H
 #define HUGO_FILE_H
 
-// TODO get rid of those defines
-#define HELPFILE "help.dat"
-#define BOOTFILE "HUGO.BSF"                         // Name of boot structure file
-#define EOP '#'                                     // Marks end of a page in help file
-
 namespace Hugo {
-
-
 /**
 * Enumerate overlay file types
 */
@@ -61,6 +54,14 @@
 	bool     restoreGame(int16 slot);
 	bool     saveGame(int16 slot, Common::String descrip);
 
+	// Name scenery and objects picture databases
+	const char *getBootFilename()    { return "HUGO.BSF";    }
+	const char *getObjectFilename()  { return "objects.dat"; }
+	const char *getSceneryFilename() { return "scenery.dat"; }
+	const char *getSoundFilename()   { return "sounds.dat";  }
+	const char *getStringFilename()  { return "strings.dat"; }
+	const char *getUifFilename()     { return "uif.dat";     }
+
 	virtual void openDatabaseFiles() = 0;
 	virtual void closeDatabaseFiles() = 0;
 	virtual void instructions() = 0;

Modified: scummvm/trunk/engines/hugo/file_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v1d.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/file_v1d.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -110,7 +110,7 @@
 */
 void FileManager_v1d::instructions() {
 	Common::File f;
-	if (!f.open(HELPFILE)) {
+	if (!f.open("help.dat")) {
 		warning("help.dat not found");
 		return;
 	}
@@ -123,7 +123,7 @@
 		wrkLine++;
 		do {
 			f.read(wrkLine, 1);
-		} while (*wrkLine++ != EOP);
+		} while (*wrkLine++ != '#');                // '#' is EOP
 		wrkLine[-2] = '\0';                         // Remove EOP and previous CR
 		Utils::Box(kBoxAny, "%s", line);
 		wrkLine = line;

Modified: scummvm/trunk/engines/hugo/file_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v2d.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/file_v2d.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -51,12 +51,12 @@
 void FileManager_v2d::openDatabaseFiles() {
 	debugC(1, kDebugFile, "openDatabaseFiles");
 
-	if (!_stringArchive.open(STRING_FILE))
-		error("File not found: %s", STRING_FILE);
-	if (!_sceneryArchive1.open("scenery.dat"))
-		error("File not found: scenery.dat");
-	if (!_objectsArchive.open(OBJECTS_FILE))
-		error("File not found: %s", OBJECTS_FILE);
+	if (!_stringArchive.open(getStringFilename()))
+		error("File not found: %s", getStringFilename());
+	if (!_sceneryArchive1.open(getSceneryFilename()))
+		error("File not found: %s", getSceneryFilename());
+	if (!_objectsArchive.open(getObjectFilename()))
+		error("File not found: %s", getObjectFilename());
 }
 
 /**

Modified: scummvm/trunk/engines/hugo/file_v3d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v3d.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/file_v3d.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -81,14 +81,14 @@
 void FileManager_v3d::openDatabaseFiles() {
 	debugC(1, kDebugFile, "openDatabaseFiles");
 
-	if (!_stringArchive.open(STRING_FILE))
-		error("File not found: %s", STRING_FILE);
+	if (!_stringArchive.open(getStringFilename()))
+		error("File not found: %s", getStringFilename());
 	if (!_sceneryArchive1.open("scenery1.dat"))
 		error("File not found: scenery1.dat");
 	if (!_sceneryArchive2.open("scenery2.dat"))
 		error("File not found: scenery2.dat");
-	if (!_objectsArchive.open(OBJECTS_FILE))
-		error("File not found: %s", OBJECTS_FILE);
+	if (!_objectsArchive.open(getObjectFilename()))
+		error("File not found: %s", getObjectFilename());
 }
 
 /**

Modified: scummvm/trunk/engines/hugo/game.h
===================================================================
--- scummvm/trunk/engines/hugo/game.h	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/game.h	2011-01-23 22:51:12 UTC (rev 55485)
@@ -42,35 +42,9 @@
 
 namespace Hugo {
 
-// WARNING!!
-// Type "PPG" in the game to enter cheat mode.
-
-#define COPYRIGHT   "Copyright 1989-1997 David P Gray, All Rights Reserved."
-
-// Started code on 04/01/95
-// VER "1.0"  // 10/01/95 Initial Release
-// VER "1.1"  // 10/06/95 Restore system volume levels on exit
-// VER "v1.2" // 10/12/95 Added "background music" checkbox in volume dlg
-// VER "v1.3" // 10/23/95 Support game 1 as shareware
-// VER "v1.4" // 12/06/95 Faster graphics, logical palette
-// VER "v1.5" // 10/07/97 Added order form, new web site
-
 // Game specific equates
-#define TAKE_TEXT      "Picked up the %s ok."
+#define TAKE_TEXT   "Picked up the %s ok."
 
-// Only for non-database
-#define BKGEXT         ".PCX"                       // Extension of background files
-#define OBJEXT         ".PIX"                       // Extension of object picture files
-
-// Name scenery and objects picture databases
-#define OBJECTS_FILE   "objects.dat"
-#define STRING_FILE    "strings.dat"
-#define SOUND_FILE     "sounds.dat"
-
-// User interface database (Windows Only)
-// This file contains, between others, the bitmaps of the fonts used in the application
-#define UIF_FILE   "uif.dat"
-
 enum {LOOK_NAME = 1, TAKE_NAME};                    // Index of name used in showing takeables and in confirming take
 
 // Definitions of 'generic' commands: Max # depends on size of gencmd in

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -1286,7 +1286,7 @@
 
 	if (!_boot.registered)
 		Utils::Box(kBoxAny, "%s", _textEngine[kEsAdvertise]);
-	Utils::Box(kBoxAny, "%s\n%s", _episode, COPYRIGHT);
+	Utils::Box(kBoxAny, "%s\n%s", _episode, getCopyrightString());
 	_status.viewState = kViewExit;
 }
 

Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/hugo.h	2011-01-23 22:51:12 UTC (rev 55485)
@@ -405,6 +405,9 @@
 		return (f == kSupportsRTL) || (f == kSupportsLoadingDuringRuntime) || (f == kSupportsSavingDuringRuntime);
 	}
 
+	const char *getCopyrightString() { return "Copyright 1989-1997 David P Gray, All Rights Reserved."; }
+
+
 	FileManager *_file;
 	Scheduler *_scheduler;
 	Screen *_screen;

Modified: scummvm/trunk/engines/hugo/intro.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/intro.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -93,7 +93,7 @@
 				strcpy(buffer, "Shareware Version");
 
 			font.drawString(&surf, buffer, 0, 163, 320, _TLIGHTMAGENTA, Graphics::kTextAlignCenter);
-			font.drawString(&surf, COPYRIGHT, 0, 176, 320, _TLIGHTMAGENTA, Graphics::kTextAlignCenter);
+			font.drawString(&surf, _vm->getCopyrightString(), 0, 176, 320, _TLIGHTMAGENTA, Graphics::kTextAlignCenter);
 
 			if (scumm_stricmp(_boot.distrib, "David P. Gray")) {
 				sprintf(buffer, "Distributed by %s.", _boot.distrib);
@@ -219,9 +219,9 @@
 		error("Unable to load font TMSRB.FON, face 'Tms Rmn', size 8");
 
 	if (_boot.registered)
-		sprintf(buffer, "%s  Registered Version", COPYRIGHT);
+		sprintf(buffer, "%s  Registered Version", _vm->getCopyrightString());
 	else
-		sprintf(buffer, "%s  Shareware Version", COPYRIGHT);
+		sprintf(buffer, "%s  Shareware Version", _vm->getCopyrightString());
 
 	font.drawString(&surf, buffer, 0, 186, 320, _TLIGHTRED, Graphics::kTextAlignCenter);
 
@@ -259,9 +259,9 @@
 
 	char buffer[128];
 	if (_boot.registered)
-		sprintf(buffer, "%s  Registered Version", COPYRIGHT);
+		sprintf(buffer, "%s  Registered Version", _vm->getCopyrightString());
 	else
-		sprintf(buffer,"%s  Shareware Version", COPYRIGHT);
+		sprintf(buffer,"%s  Shareware Version", _vm->getCopyrightString());
 
 	// TROMAN, size 10-5
 	if (!font.loadFromFON("TMSRB.FON", Graphics::WinFontDirEntry("Tms Rmn", 8)))

Modified: scummvm/trunk/engines/hugo/mouse.cpp
===================================================================
--- scummvm/trunk/engines/hugo/mouse.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/mouse.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -261,7 +261,7 @@
 			// Display object name next to cursor (unless CURSOR_NOCHAR)
 			// Note test for swapped hero name
 			char *name = _vm->_arrayNouns[_vm->_object->_objects[(objId == kHeroIndex) ? _vm->_heroImage : objId].nounIndex][kCursorNameIndex];
-			if (name[0] != CURSOR_NOCHAR)
+			if (name[0] != kCursorNochar)
 				cursorText(name, cx, cy, U_FONT8, _TBRIGHTWHITE);
 
 			// Process right click over object in view or iconbar

Modified: scummvm/trunk/engines/hugo/mouse.h
===================================================================
--- scummvm/trunk/engines/hugo/mouse.h	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/mouse.h	2011-01-23 22:51:12 UTC (rev 55485)
@@ -43,7 +43,7 @@
 private:
 	HugoEngine *_vm;
 
-	#define CURSOR_NOCHAR  '~'                          // Don't show name of object under cursor
+	static const char kCursorNochar = '~';              // Don't show name of object under cursor
 
 	static const int kExitHotspot = -4;                 // Cursor over Exit hotspot
 	static const int kCursorNameIndex = 2;              // Index of name used under cursor

Modified: scummvm/trunk/engines/hugo/object.cpp
===================================================================
--- scummvm/trunk/engines/hugo/object.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/object.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -314,14 +314,14 @@
 	bool foundFl = true;
 	// Try left rear corner
 	for (int16 x = *destx = obj->x + curImage->x1; x < *destx + kHeroMaxWidth; x++) {
-		if (BOUND(x, y))
+		if (checkBoundary(x, y))
 			foundFl = false;
 	}
 
 	if (!foundFl) {                                 // Try right rear corner
 		foundFl = true;
 		for (int16 x = *destx = obj->x + curImage->x2 - kHeroMaxWidth + 1; x <= obj->x + (int16)curImage->x2; x++) {
-			if (BOUND(x, y))
+			if (checkBoundary(x, y))
 				foundFl = false;
 		}
 	}
@@ -330,7 +330,7 @@
 		foundFl = true;
 		y += 2;
 		for (int16 x = *destx = obj->x + curImage->x1; x < *destx + kHeroMaxWidth; x++) {
-			if (BOUND(x, y))
+			if (checkBoundary(x, y))
 				foundFl = false;
 		}
 	}
@@ -338,7 +338,7 @@
 	if (!foundFl) {                                 // Try right rear corner
 		foundFl = true;
 		for (int16 x = *destx = obj->x + curImage->x2 - kHeroMaxWidth + 1; x <= obj->x + (int16)curImage->x2; x++) {
-			if (BOUND(x, y))
+			if (checkBoundary(x, y))
 				foundFl = false;
 		}
 	}
@@ -573,7 +573,7 @@
 	int score = 0;
 	for (int i = 0; i < _numObj; i++)
 		score += _objects[i].objValue;
-	return(score);
+	return score;
 }
 
 /**
@@ -586,4 +586,9 @@
 		_vm->_file->readImage(i, &_objects[i]);
 }
 
+bool ObjectHandler::checkBoundary(int16 x, int16 y) {
+	// Check if Boundary bit set
+	return (_vm->getBoundaryOverlay()[y * kCompLineSize + x / 8] & (0x80 >> x % 8)) != 0;
+}
+
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/object.h
===================================================================
--- scummvm/trunk/engines/hugo/object.h	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/object.h	2011-01-23 22:51:12 UTC (rev 55485)
@@ -35,8 +35,6 @@
 
 #include "common/file.h"
 
-#define BOUND(X, Y)     ((_vm->getBoundaryOverlay()[Y * kCompLineSize + X / 8] & (0x80 >> X % 8)) != 0)  // Boundary bit set
-
 namespace Hugo {
 
 class ObjectHandler {
@@ -101,6 +99,10 @@
 	uint16     _objCount;
 
 	void restoreSeq(object_t *obj);
+
+	inline bool checkBoundary(int16 x, int16 y);
+	template <typename T> 
+	inline int sign(T a) { if ( a < 0) return -1; else return 1; }
 };
 
 class ObjectHandler_v1d : public ObjectHandler {

Modified: scummvm/trunk/engines/hugo/object_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/object_v1d.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/object_v1d.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -380,11 +380,11 @@
 		dy = 1;
 
 	if (abs(dx) > abs(dy)) {
-		obj1->vx = objDx * -SIGN(dx);
-		obj1->vy = abs((objDy * dy) / dx) * -SIGN(dy);
+		obj1->vx = objDx * -sign<int8>(dx);
+		obj1->vy = abs((objDy * dy) / dx) * -sign<int8>(dy);
 	} else {
-		obj1->vy = objDy * SIGN(dy);
-		obj1->vx = abs((objDx * dx) / dy) * SIGN(dx);
+		obj1->vy = objDy * sign<int8>(dy);
+		obj1->vx = abs((objDx * dx) / dy) * sign<int8>(dx);
 	}
 }
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/object_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/object_v2d.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/object_v2d.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -374,11 +374,11 @@
 		dy = 1;
 
 	if (abs(dx) > abs(dy)) {
-		obj1->vx = objDx * -SIGN(dx);
-		obj1->vy = abs((objDy * dy) / dx) * -SIGN(dy);
+		obj1->vx = objDx * -sign<int8>(dx);
+		obj1->vy = abs((objDy * dy) / dx) * -sign<int8>(dy);
 	} else {
-		obj1->vy = objDy * -SIGN(dy);
-		obj1->vx = abs((objDx * dx) / dy) * -SIGN(dx);
+		obj1->vy = objDy * -sign<int8>(dy);
+		obj1->vx = abs((objDx * dx) / dy) * -sign<int8>(dx);
 	}
 }
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/schedule.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule.cpp	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/schedule.cpp	2011-01-23 22:51:12 UTC (rev 55485)
@@ -161,7 +161,7 @@
 	// Make sure the background file exists!
 	if (!_vm->isPacked()) {
 		char line[32];
-		if (!_vm->_file->fileExists(strcat(strncat(strcpy(line, _vm->_picDir), _vm->_screenNames[screenIndex], kFilenameLength), BKGEXT)) &&
+		if (!_vm->_file->fileExists(strcat(strncat(strcpy(line, _vm->_picDir), _vm->_screenNames[screenIndex], kFilenameLength), ".PCX")) &&
 		    !_vm->_file->fileExists(strcat(strcpy(line, _vm->_screenNames[screenIndex]), ".ART"))) {
 				error("Unable to find background file for %s", _vm->_screenNames[screenIndex]);
 			return;

Modified: scummvm/trunk/engines/hugo/schedule.h
===================================================================
--- scummvm/trunk/engines/hugo/schedule.h	2011-01-23 22:08:14 UTC (rev 55484)
+++ scummvm/trunk/engines/hugo/schedule.h	2011-01-23 22:51:12 UTC (rev 55485)
@@ -37,8 +37,6 @@
 
 namespace Hugo {
 
-#define SIGN(X)       ((X < 0) ? -1 : 1)
-
 struct act0 {                                       // Type 0 - Schedule
 	action_t actType;                               // The type of action
 	int      timer;                                 // Time to set off the action


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