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

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Thu Nov 11 11:36:10 CET 2010


Revision: 54198
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54198&view=rev
Author:   strangerke
Date:     2010-11-11 10:36:10 +0000 (Thu, 11 Nov 2010)

Log Message:
-----------
HUGO: Suppress the use of Utils::Error, cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/file.cpp
    scummvm/trunk/engines/hugo/file_v1d.cpp
    scummvm/trunk/engines/hugo/file_v1w.cpp
    scummvm/trunk/engines/hugo/file_v2d.cpp
    scummvm/trunk/engines/hugo/file_v3d.cpp
    scummvm/trunk/engines/hugo/global.h
    scummvm/trunk/engines/hugo/schedule.cpp
    scummvm/trunk/engines/hugo/schedule_v1d.cpp
    scummvm/trunk/engines/hugo/schedule_v1w.cpp
    scummvm/trunk/engines/hugo/schedule_v2d.cpp
    scummvm/trunk/engines/hugo/schedule_v3d.cpp
    scummvm/trunk/engines/hugo/util.cpp
    scummvm/trunk/engines/hugo/util.h

Modified: scummvm/trunk/engines/hugo/file.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/file.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -94,12 +94,12 @@
 	f.read(PCC_header.fill2, sizeof(PCC_header.fill2));
 
 	if (PCC_header.mfctr != 10)
-		Utils::Error(PCCH_ERR, "%s", name);
+		error("Bad data file format: %s", name);
 
 	// Allocate memory for seq_t if 0
 	if (seqPtr == 0) {
 		if ((seqPtr = (seq_t *)malloc(sizeof(seq_t))) == 0)
-			Utils::Error(HEAP_ERR, "%s", name);
+			error("Insufficient memory to run game.");
 	}
 
 	// Find size of image data in 8-bit DIB format
@@ -113,9 +113,9 @@
 
 	// Allocate memory for image data if NULL
 	if (imagePtr == 0) {
-		if ((imagePtr = (byte *)malloc((size_t) size)) == 0)
-			Utils::Error(HEAP_ERR, "%s", name);
+		imagePtr = (byte *)malloc((size_t) size);
 	}
+	assert(imagePtr);
 
 	seqPtr->imagePtr = imagePtr;
 
@@ -165,7 +165,7 @@
 			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);
 			if (!_objectsArchive.open(buf))
-				Utils::Error(FILE_ERR, "%s", buf);
+				error("File not found: %s", buf);
 		}
 		free(buf);
 	}
@@ -258,25 +258,22 @@
 
 	if (!has_read_header) {
 		if (fp.read(s_hdr, sizeof(s_hdr)) != sizeof(s_hdr))
-			Utils::Error(FILE_ERR, "%s", SOUND_FILE);
+			error("Wrong sound file format: %s", SOUND_FILE);
 		has_read_header = true;
 	}
 
 	*size = s_hdr[sound].size;
 	if (*size == 0)
-		Utils::Error(SOUND_ERR, "%s", SOUND_FILE);
+		error("Wrong sound file format or missing sound %d: %s", sound, SOUND_FILE);
 
 	// Allocate memory for sound or music, if possible
 	sound_pt soundPtr = (byte *)malloc(s_hdr[sound].size); // Ptr to sound data
-	if (soundPtr == 0) {
-		warning("Low on memory");
-		return 0;
-	}
+	assert(soundPtr);
 
 	// 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)
-		Utils::Error(FILE_ERR, "%s", SOUND_FILE);
+		error("File not found: %s", SOUND_FILE);
 
 	fp.close();
 
@@ -391,7 +388,7 @@
 	int saveVersion;
 	in->read(&saveVersion, sizeof(saveVersion));
 	if (saveVersion != kSavegameVersion) {
-		Utils::Error(GEN_ERR, "%s", "Savegame of incompatible version");
+		error("Savegame of incompatible version");
 		return;
 	}
 
@@ -473,7 +470,7 @@
 		saveGame(-1, "");
 		in = _vm->getSaveFileManager()->openForLoading(_vm->_initFilename);
 		if (!in) {
-			Utils::Error(WRITE_ERR, "%s", _vm->_initFilename.c_str());
+			warning("Unable to write file: %s", _vm->_initFilename.c_str());
 			return;
 		}
 	}
@@ -483,8 +480,8 @@
 	delete in;
 
 	// Check sanity - maybe disk full or path set to read-only drive?
-	if (_vm->getGameStatus().saveSize == -1)
-		Utils::Error(WRITE_ERR, "%s", _vm->_initFilename.c_str());
+	if (_vm->getGameStatus().saveSize <= 0)
+		warning("Unable to write file: %s", _vm->_initFilename.c_str());
 }
 
 /**
@@ -500,7 +497,7 @@
 			warning("printBootText - Skipping as H1 Dos may be a freeware");
 			return;
 		} else {
-			Utils::Error(FILE_ERR, "%s", BOOTFILE);
+			error("Missing startup file");
 		}
 	}
 
@@ -510,7 +507,7 @@
 		// Skip over the boot structure (already read) and read exit text
 		ofp.seek((long)sizeof(_boot), SEEK_SET);
 		if (ofp.read(buf, _boot.exit_len) != (size_t)_boot.exit_len)
-			Utils::Error(FILE_ERR, "%s", BOOTFILE);
+			error("Error while reading startup file");
 
 		// Decrypt the exit text, using CRYPT substring
 		int i;
@@ -518,9 +515,7 @@
 			buf[i] ^= CRYPT[i % strlen(CRYPT)];
 
 		buf[i] = '\0';
-		//Box(BOX_OK, "%s", buf_p);
-		//MessageBox(hwnd, buf_p, "License", MB_ICONINFORMATION);
-		warning("printBootText(): License: %s", buf);
+		Utils::Box(BOX_OK, "%s", buf);
 	}
 
 	free(buf);
@@ -541,12 +536,12 @@
 			warning("readBootFile - Skipping as H1 Dos may be a freeware");
 			return;
 		} else {
-			Utils::Error(FILE_ERR, "%s", BOOTFILE);
+			error("Missing startup file");
 		}
 	}
 
 	if (ofp.size() < (int32)sizeof(_boot))
-		Utils::Error(FILE_ERR, "%s", BOOTFILE);
+		error("Corrupted startup file");
 
 	_boot.checksum = ofp.readByte();
 	_boot.registered = ofp.readByte();
@@ -564,7 +559,7 @@
 	ofp.close();
 
 	if (checksum)
-		Utils::Error(GEN_ERR, "%s", "Program startup file invalid");
+		error("Corrupted startup file");
 }
 
 /**
@@ -582,10 +577,10 @@
 		// Open unbuffered to do far read
 		Common::File ip;                            // Image data file
 		if (!ip.open(UIF_FILE))
-			Utils::Error(FILE_ERR, "%s", UIF_FILE);
+			error("File not found: %s", UIF_FILE);
 
 		if (ip.size() < (int32)sizeof(UIFHeader))
-			Utils::Error(FILE_ERR, "%s", UIF_FILE);
+			error("Wrong file format: %s", UIF_FILE);
 
 		for (int i = 0; i < MAX_UIFS; ++i) {
 			UIFHeader[i].size = ip.readUint16LE();
@@ -606,7 +601,7 @@
 	// Open uif file to read data
 	Common::File ip;                                // UIF_FILE handle
 	if (!ip.open(UIF_FILE))
-		Utils::Error(FILE_ERR, "%s", UIF_FILE);
+		error("File not found: %s", UIF_FILE);
 
 	// Seek to data
 	uif_hdr_t *UIFHeaderPtr = getUIFHeader((uif_t)id);
@@ -621,7 +616,7 @@
 		break;
 	default:                                        // Read file data into supplied array
 		if (ip.read(buf, UIFHeaderPtr->size) != UIFHeaderPtr->size)
-			Utils::Error(FILE_ERR, "%s", UIF_FILE);
+			error("Wrong file format: %s", UIF_FILE);
 		break;
 	}
 

Modified: scummvm/trunk/engines/hugo/file_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v1d.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/file_v1d.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -70,7 +70,7 @@
 	}
 
 	if (!_sceneryArchive1.open(buf))
-		Utils::Error(FILE_ERR, "%s", buf);
+		error("File not found: %s", buf);
 
 	image_pt tmpImage = image;                      // temp ptr to overlay file
 
@@ -88,7 +88,7 @@
 	char *buf = (char *) malloc(2048 + 1);          // Buffer for file access
 	strcat(strcpy(buf, _vm->_screenNames[screenIndex]), ".ART");
 	if (!_sceneryArchive1.open(buf))
-		Utils::Error(FILE_ERR, "%s", buf);
+		error("File not found: %s", buf);
 	// Read the image into dummy seq and static dib_a
 	seq_t *dummySeq;                                // Image sequence structure for Read_pcx
 	dummySeq = readPCX(_sceneryArchive1, 0, _vm->_screen->getFrontBuffer(), true, _vm->_screenNames[screenIndex]);

Modified: scummvm/trunk/engines/hugo/file_v1w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v1w.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/file_v1w.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -77,7 +77,7 @@
 		i = sceneBlock.ob_len;
 		break;
 	default:
-		Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
+		error("Bad overlayType: %d", overlayType);
 		break;
 	}
 	if (i == 0) {

Modified: scummvm/trunk/engines/hugo/file_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v2d.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/file_v2d.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -53,11 +53,11 @@
 	debugC(1, kDebugFile, "openDatabaseFiles");
 
 	if (!_stringArchive.open(STRING_FILE))
-		Utils::Error(FILE_ERR, "%s", STRING_FILE);
+		error("File not found: %s", STRING_FILE);
 	if (!_sceneryArchive1.open("scenery.dat"))
-		Utils::Error(FILE_ERR, "%s", "scenery.dat");
+		error("File not found: scenery.dat");
 	if (!_objectsArchive.open(OBJECTS_FILE))
-		Utils::Error(FILE_ERR, "%s", OBJECTS_FILE);
+		error("File not found: %s", OBJECTS_FILE);
 }
 
 /**
@@ -131,7 +131,7 @@
 		i = sceneBlock.ob_len;
 		break;
 	default:
-		Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
+		error("Bad overlayType: %d", overlayType);
 		break;
 	}
 	if (i == 0) {
@@ -168,18 +168,18 @@
 	_stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET);
 	uint32 off1, off2;
 	if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0)
-		Utils::Error(FILE_ERR, "%s", "String offset");
+		error("An error has occurred: bad String offset");
 	if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0)
-		Utils::Error(FILE_ERR, "%s", "String offset");
+		error("An error has occurred: bad String offset");
 
 	// Check size of string
 	if ((off2 - off1) >= MAX_BOX)
-		Utils::Error(FILE_ERR, "%s", "Fetched string too long!");
+		error("Fetched string too long!");
 
 	// Position to string and read it into gen purpose _textBoxBuffer
 	_stringArchive.seek(off1, SEEK_SET);
 	if (_stringArchive.read(_textBoxBuffer, (uint16)(off2 - off1)) == 0)
-		Utils::Error(FILE_ERR, "%s", "Fetch_string");
+		error("An error has occurred: fetchString");
 
 	// Null terminate, decode and return it
 	_textBoxBuffer[off2-off1] = '\0';

Modified: scummvm/trunk/engines/hugo/file_v3d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v3d.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/file_v3d.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -83,13 +83,13 @@
 	debugC(1, kDebugFile, "openDatabaseFiles");
 
 	if (!_stringArchive.open(STRING_FILE))
-		Utils::Error(FILE_ERR, "%s", STRING_FILE);
+		error("File not found: %s", STRING_FILE);
 	if (!_sceneryArchive1.open("scenery1.dat"))
-		Utils::Error(FILE_ERR, "%s", "scenery1.dat");
+		error("File not found: scenery1.dat");
 	if (!_sceneryArchive2.open("scenery2.dat"))
-		Utils::Error(FILE_ERR, "%s", "scenery2.dat");
+		error("File not found: scenery2.dat");
 	if (!_objectsArchive.open(OBJECTS_FILE))
-		Utils::Error(FILE_ERR, "%s", OBJECTS_FILE);
+		error("File not found: %s", OBJECTS_FILE);
 }
 
 /**
@@ -140,7 +140,7 @@
 			i = sceneBlock.ob_len;
 			break;
 		default:
-			Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
+			error("Bad overlayType: %d", overlayType);
 			break;
 		}
 		if (i == 0) {
@@ -180,7 +180,7 @@
 			i = sceneBlock.ob_len;
 			break;
 		default:
-			Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
+			error("Bad overlayType: %d", overlayType);
 			break;
 		}
 		if (i == 0) {

Modified: scummvm/trunk/engines/hugo/global.h
===================================================================
--- scummvm/trunk/engines/hugo/global.h	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/global.h	2010-11-11 10:36:10 UTC (rev 54198)
@@ -38,7 +38,6 @@
 #define MAX_SOUNDS     64                           // Max number of sounds
 #define BOOTFILE       "HUGO.BSF"                   // Name of boot structure file
 #define LEN_MASK       0x3F                         // Lower 6 bits are length
-#define PBFILE         "playback.dat"
 
 // Name scenery and objects picture databases
 #define OBJECTS_FILE   "objects.dat"

Modified: scummvm/trunk/engines/hugo/schedule.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/schedule.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -75,7 +75,7 @@
 	debugC(4, kDebugSchedule, "getQueue");
 
 	if (!_freeEvent)                                // Error: no more events available
-		Utils::Error(EVNT_ERR, "%s", "getQueue");
+		error("An error has occurred: %s", "getQueue");
 	event_t *resEvent = _freeEvent;
 	_freeEvent = _freeEvent->nextEvent;
 	resEvent->nextEvent = 0;

Modified: scummvm/trunk/engines/hugo/schedule_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule_v1d.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/schedule_v1d.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -313,7 +313,7 @@
 		warning("STUB: doAction(act49)");
 		break;
 	default:
-		Utils::Error(EVNT_ERR, "%s", "doAction");
+		error("An error has occurred: %s", "doAction");
 		break;
 	}
 

Modified: scummvm/trunk/engines/hugo/schedule_v1w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule_v1w.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/schedule_v1w.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -340,7 +340,7 @@
 			_vm->_object->_objects[action->a48.objNumb].currImagePtr = _vm->_object->_objects[action->a48.objNumb].currImagePtr->nextSeqPtr;
 		break;
 	default:
-		Utils::Error(EVNT_ERR, "%s", "doAction");
+		error("An error has occurred: %s", "doAction");
 		break;
 	}
 

Modified: scummvm/trunk/engines/hugo/schedule_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule_v2d.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/schedule_v2d.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -380,7 +380,7 @@
 		warning("STUB: doAction(act49)");
 		break;
 	default:
-		Utils::Error(EVNT_ERR, "%s", "doAction");
+		error("An error has occurred: %s", "doAction");
 		break;
 	}
 

Modified: scummvm/trunk/engines/hugo/schedule_v3d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule_v3d.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/schedule_v3d.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -313,7 +313,7 @@
 		warning("STUB: doAction(act49)");
 		break;
 	default:
-		Utils::Error(EVNT_ERR, "%s", "doAction");
+		error("An error has occurred: %s", "doAction");
 		break;
 	}
 

Modified: scummvm/trunk/engines/hugo/util.cpp
===================================================================
--- scummvm/trunk/engines/hugo/util.cpp	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/util.cpp	2010-11-11 10:36:10 UTC (rev 54198)
@@ -136,51 +136,6 @@
 }
 
 /**
- * Fatal error handler.  Reset environment, print error and exit
- * Arguments are same as printf
- */
-void Utils::Error(int error_type, const char *format, ...) {
-	char buffer[ERRLEN + 1];
-	bool fatal = true;                              // Fatal error, else continue
-
-	switch (error_type) {
-	case FILE_ERR:
-		strcpy(buffer, HugoEngine::get()._textUtil[kErr1]);
-		break;
-	case WRITE_ERR:
-		strcpy(buffer, HugoEngine::get()._textUtil[kErr2]);
-		fatal = false;                              // Allow continuation
-		break;
-	case PCCH_ERR:
-		strcpy(buffer, HugoEngine::get()._textUtil[kErr3]);
-		break;
-	case HEAP_ERR:
-		strcpy(buffer, HugoEngine::get()._textUtil[kErr4]);
-		break;
-	case SOUND_ERR:
-		strcpy(buffer, HugoEngine::get()._textUtil[kErr5]);
-		break;
-	default:
-		strcpy(buffer, HugoEngine::get()._textUtil[kErr6]);
-		break;
-	}
-
-	if (fatal)
-		HugoEngine::get().shutdown();                                   // Restore any devices before exit
-
-	va_list marker;
-	va_start(marker, format);
-	vsnprintf(&buffer[strlen(buffer)], ERRLEN - strlen(buffer), format, marker);
-	va_end(marker);
-	//MessageBeep(MB_ICONEXCLAMATION);
-	//MessageBox(hwnd, buffer, "HugoWin Error", MB_OK | MB_ICONEXCLAMATION);
-	warning("Hugo Error: %s", buffer);
-
-	if (fatal)
-		exit(1);
-}
-
-/**
  * Print options for user when dead
  */
 void Utils::gameOverMsg(void) {

Modified: scummvm/trunk/engines/hugo/util.h
===================================================================
--- scummvm/trunk/engines/hugo/util.h	2010-11-11 10:09:57 UTC (rev 54197)
+++ scummvm/trunk/engines/hugo/util.h	2010-11-11 10:36:10 UTC (rev 54198)
@@ -54,7 +54,6 @@
 
 void     gameOverMsg();
 void     reverseByte(byte *data);
-void     Error(int code, const char *format, ...) GCC_PRINTF(2, 3);
 
 char    *Box(box_t, const char *, ...) GCC_PRINTF(2, 3);
 char    *strlwr(char *buffer);


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