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

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Sat Sep 18 00:40:53 CEST 2010


Revision: 52787
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52787&view=rev
Author:   strangerke
Date:     2010-09-17 22:40:53 +0000 (Fri, 17 Sep 2010)

Log Message:
-----------
HUGO: Fix crash in the first screen of H1 Dos

- Fix crash in the first screen of H1 Dos
- Clean up

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/file.cpp
    scummvm/trunk/engines/hugo/file.h
    scummvm/trunk/engines/hugo/game.h
    scummvm/trunk/engines/hugo/hugo.cpp
    scummvm/trunk/engines/hugo/hugo.h
    scummvm/trunk/engines/hugo/parser.cpp

Modified: scummvm/trunk/engines/hugo/file.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file.cpp	2010-09-17 21:40:53 UTC (rev 52786)
+++ scummvm/trunk/engines/hugo/file.cpp	2010-09-17 22:40:53 UTC (rev 52787)
@@ -553,35 +553,6 @@
 	fclose(fpb);
 }
 
-char *FileManager::fetchString(int index) {
-//TODO : HUGO 1 DOS uses _stringtData instead of a strings.dat
-// Fetch string from file, decode and return ptr to string in memory
-	uint32 off1, off2;
-
-	debugC(1, kDebugFile, "fetchString(%d)", index);
-
-	// Get offset to string[index] (and next for length calculation)
-	_stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET);
-	if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0)
-		Utils::Error(FILE_ERR, "%s", "String offset");
-	if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0)
-		Utils::Error(FILE_ERR, "%s", "String offset");
-
-	// Check size of string
-	if ((off2 - off1) >= MAX_BOX)
-		Utils::Error(FILE_ERR, "%s", "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");
-
-	// Null terminate, decode and return it
-	_textBoxBuffer[off2-off1] = '\0';
-	_vm.scheduler().decodeString(_textBoxBuffer);
-	return _textBoxBuffer;
-}
-
 void FileManager::printBootText() {
 // Read the encrypted text from the boot file and print it
 	Common::File ofp;
@@ -802,6 +773,12 @@
 	_sceneryArchive1.close();
 }
 
+char *FileManager_v1d::fetchString(int index) {
+	debugC(1, kDebugFile, "fetchString(%d)", index);
+
+	return _vm._stringtData[index];
+}
+
 FileManager_v2d::FileManager_v2d(HugoEngine &vm) : FileManager(vm) {
 }
 
@@ -913,53 +890,39 @@
 	} while (k < OVL_SIZE);
 }
 
-FileManager_v1w::FileManager_v1w(HugoEngine &vm) : FileManager(vm) {
-}
+char *FileManager_v2d::fetchString(int index) {
+// Fetch string from file, decode and return ptr to string in memory
+	uint32 off1, off2;
 
-FileManager_v1w::~FileManager_v1w() {
-}
+	debugC(1, kDebugFile, "fetchString(%d)", index);
 
-void FileManager_v1w::openDatabaseFiles() {
-	debugC(1, kDebugFile, "openDatabaseFiles");
+	// Get offset to string[index] (and next for length calculation)
+	_stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET);
+	if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0)
+		Utils::Error(FILE_ERR, "%s", "String offset");
+	if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0)
+		Utils::Error(FILE_ERR, "%s", "String offset");
 
-	if (!_stringArchive.open(STRING_FILE))
-		Utils::Error(FILE_ERR, "%s", STRING_FILE);
-	if (!_sceneryArchive1.open("scenery.dat"))
-		Utils::Error(FILE_ERR, "%s", "scenery.dat");
-	if (!_objectsArchive.open(OBJECTS_FILE))
-		Utils::Error(FILE_ERR, "%s", OBJECTS_FILE);
-}
+	// Check size of string
+	if ((off2 - off1) >= MAX_BOX)
+		Utils::Error(FILE_ERR, "%s", "Fetched string too long!");
 
-void FileManager_v1w::closeDatabaseFiles() {
-	debugC(1, kDebugFile, "closeDatabaseFiles");
+	// 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");
 
-	_stringArchive.close();
-	_sceneryArchive1.close();
-	_objectsArchive.close();
+	// Null terminate, decode and return it
+	_textBoxBuffer[off2-off1] = '\0';
+	_vm.scheduler().decodeString(_textBoxBuffer);
+	return _textBoxBuffer;
 }
 
-void FileManager_v1w::readBackground(int screenIndex) {
-// Read a PCX image into dib_a
-	seq_t        seq;                               // Image sequence structure for Read_pcx
-	sceneBlock_t sceneBlock;                        // Read a database header entry
 
-	debugC(1, kDebugFile, "readBackground(%d)", screenIndex);
+FileManager_v1w::FileManager_v1w(HugoEngine &vm) : FileManager_v2d(vm) {
+}
 
-	_sceneryArchive1.seek((uint32) screenIndex * sizeof(sceneBlock_t), SEEK_SET);
-
-	sceneBlock.scene_off = _sceneryArchive1.readUint32LE();
-	sceneBlock.scene_len = _sceneryArchive1.readUint32LE();
-	sceneBlock.b_off = _sceneryArchive1.readUint32LE();
-	sceneBlock.b_len = _sceneryArchive1.readUint32LE();
-	sceneBlock.o_off = _sceneryArchive1.readUint32LE();
-	sceneBlock.o_len = _sceneryArchive1.readUint32LE();
-	sceneBlock.ob_off = _sceneryArchive1.readUint32LE();
-	sceneBlock.ob_len = _sceneryArchive1.readUint32LE();
-
-	_sceneryArchive1.seek(sceneBlock.scene_off, SEEK_SET);
-
-	// Read the image into dummy seq and static dib_a
-	readPCX(_sceneryArchive1, &seq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+FileManager_v1w::~FileManager_v1w() {
 }
 
 void FileManager_v1w::readOverlay(int screenNum, image_pt image, ovl_t overlayType) {
@@ -1007,7 +970,7 @@
 	_sceneryArchive1.read(tmpImage, OVL_SIZE);
 }
 
-FileManager_v3d::FileManager_v3d(HugoEngine &vm) : FileManager(vm) {
+FileManager_v3d::FileManager_v3d(HugoEngine &vm) : FileManager_v2d(vm) {
 }
 
 FileManager_v3d::~FileManager_v3d() {

Modified: scummvm/trunk/engines/hugo/file.h
===================================================================
--- scummvm/trunk/engines/hugo/file.h	2010-09-17 21:40:53 UTC (rev 52786)
+++ scummvm/trunk/engines/hugo/file.h	2010-09-17 22:40:53 UTC (rev 52787)
@@ -46,7 +46,6 @@
 
 
 	bool     fileExists(char *filename);
-	char    *fetchString(int index);
 	sound_pt getSound(short sound, uint16 *size);
 
 	void     closePlaybackFile();
@@ -66,6 +65,8 @@
 	virtual void readBackground(int screenIndex) = 0;
 	virtual void readOverlay(int screenNum, image_pt image, ovl_t overlayType) = 0;
 
+	virtual char *fetchString(int index) = 0;
+
 protected:
 	HugoEngine &_vm;
 
@@ -95,6 +96,7 @@
 	void closeDatabaseFiles();
 	void readBackground(int screenIndex);
 	void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+	char *fetchString(int index);
 };
 
 class FileManager_v2d : public FileManager {
@@ -106,31 +108,29 @@
 	void closeDatabaseFiles();
 	void readBackground(int screenIndex);
 	void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+	char *fetchString(int index);
 };
 
-class FileManager_v1w : public FileManager {
+class FileManager_v3d : public FileManager_v2d {
 public:
-	FileManager_v1w(HugoEngine &vm);
-	~FileManager_v1w();
+	FileManager_v3d(HugoEngine &vm);
+	~FileManager_v3d();
 
 	void openDatabaseFiles();
 	void closeDatabaseFiles();
 	void readBackground(int screenIndex);
 	void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+private:
+	Common::File _sceneryArchive2;                      /* Handle for scenery file */
 };
 
-class FileManager_v3d : public FileManager {
+class FileManager_v1w : public FileManager_v2d {
 public:
-	FileManager_v3d(HugoEngine &vm);
-	~FileManager_v3d();
+	FileManager_v1w(HugoEngine &vm);
+	~FileManager_v1w();
 
-	void openDatabaseFiles();
-	void closeDatabaseFiles();
-	void readBackground(int screenIndex);
 	void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
-private:
-	Common::File _sceneryArchive2;                      /* Handle for scenery file */
+};
 
-};
 } // End of namespace Hugo
 #endif //HUGO_FILE_H

Modified: scummvm/trunk/engines/hugo/game.h
===================================================================
--- scummvm/trunk/engines/hugo/game.h	2010-09-17 21:40:53 UTC (rev 52786)
+++ scummvm/trunk/engines/hugo/game.h	2010-09-17 22:40:53 UTC (rev 52787)
@@ -48,12 +48,6 @@
 // Copy helpedit\hugow_?.hlp to .\hugowin?.hlp
 // Type "PPG" in the game to enter cheat mode.
 
-#define DEBUG       false                           // Allow me to do special things (EDIT, GOTO)
-#define STORY       true                            // Skip any intro stuff if FALSE
-//#define DATABASE    TRUE                          // Use database instead of individual files. Individual files are used by Hugo1 DOS!
-//#define BETA        FALSE                         // Puts big msg in intro/about box
-#define EPISODE_NUM         1                       // Episode we are building
-#define TITLE       "Hugo for Windows"
 #define COPYRIGHT   "Copyright \xA9 1995-97, David P. Gray"
 // Started code on 04/01/95
 // Don't forget to update Hugowin.rc2 with version info
@@ -62,7 +56,7 @@
 //#define VER "v1.2"// 10/12/95 Added "background music" checkbox in volume dlg
 //#define VER "v1.3"// 10/23/95 Support game 1 as shareware
 //#define VER "v1.4"// 12/06/95 Faster graphics, logical palette
-#define VER "v1.5"  // 10/07/97 Added order form, new web site
+//#define VER "v1.5"  // 10/07/97 Added order form, new web site
 
 // Game specific equates
 #define MAX_TUNES      16                           // Max number of tunes
@@ -111,7 +105,14 @@
 // Macros:
 #define TPS           ((_config.turboFl) ? TURBO_TPS : NORMAL_TPS)
 
+#define MAX_UIFS   32                               // Max possible uif items in hdr
+#define NUM_FONTS  3                                // Number of dib fonts
+#define FIRST_FONT U_FONT5
+#define FONT_LEN   128                              // Number of chars in font
+#define FONTSIZE   1200                             // Max size of font data
 
+#define CRYPT "Copyright 1992, David P Gray, Gray Design Associates"
+
 enum TEXTCOLORS {
 	_TBLACK,    _TBLUE,         _TGREEN,       _TCYAN,
 	_TRED,      _TMAGENTA,      _TBROWN,       _TWHITE,
@@ -119,33 +120,8 @@
 	_TLIGHTRED, _TLIGHTMAGENTA, _TLIGHTYELLOW, _TBRIGHTWHITE
 };
 
-#define CRYPT "Copyright 1992, David P Gray, Gray Design Associates"
-
-struct hugo_boot_t {                                // Common HUGO boot file
-	char checksum;                                  // Checksum for boot structure (not exit text)
-	char registered;                                // TRUE if registered version, else FALSE
-	char pbswitch[8];                               // Playback switch string
-	char distrib[32];                               // Distributor branding string
-	uint16 exit_len;                                // Length of exit text (next in file)
-};
-
-#define MAX_UIFS   32                               // Max possible uif items in hdr
-#define NUM_FONTS  3                                // Number of dib fonts
-#define FIRST_FONT U_FONT5
-#define FONT_LEN   128                              // Number of chars in font
-#define FONTSIZE   1200                             // Max size of font data
-
-struct uif_hdr_t {                                  // UIF font/image look up
-	uint16  size;                                   // Size of uif item
-	uint32  offset;                                 // Offset of item in file
-};
-
 enum uif_t {U_FONT5, U_FONT6, U_FONT8, UIF_IMAGES, NUM_UIF_ITEMS};
 
-// Game specific type definitions
-typedef byte *image_pt;                             // ptr to an object image (sprite)
-typedef byte *sound_pt;                             // ptr to sound (or music) data
-
 // Enumerate overlay file types
 enum ovl_t {BOUNDARY, OVERLAY, OVLBASE};
 
@@ -213,21 +189,6 @@
 // Purpose of an automatic route
 enum go_t {GO_SPACE, GO_EXIT, GO_LOOK, GO_GET};
 
-// Following are points for achieving certain actions.
-struct point_t {
-	byte score;                                     // The value of the point
-	bool scoredFl;                                  // Whether scored yet
-};
-
-// Structure for initializing maze processing
-struct maze_t {
-	bool enabledFl;                                 // TRUE when maze processing enabled
-	byte size;                                      // Size of (square) maze matrix
-	int  x1, y1, x2, y2;                            // maze hotspot bounding box
-	int  x3, x4;                                    // north, south x entry coordinates
-	byte firstScreenIndex;                          // index of first screen in maze
-};
-
 // Following defines the action types and action list
 enum action_t {                                     // Parameters:
 	ANULL              = 0xff,                      // Special NOP used to 'delete' events in DEL_EVENTS
@@ -284,7 +245,38 @@
 	OLD_SONG           = 49                         // Added by Strangerke - Set currently playing sound, old way: that is, using a string index instead of a reference in a file
 };
 
+struct hugo_boot_t {                                // Common HUGO boot file
+	char checksum;                                  // Checksum for boot structure (not exit text)
+	char registered;                                // TRUE if registered version, else FALSE
+	char pbswitch[8];                               // Playback switch string
+	char distrib[32];                               // Distributor branding string
+	uint16 exit_len;                                // Length of exit text (next in file)
+};
 
+struct uif_hdr_t {                                  // UIF font/image look up
+	uint16  size;                                   // Size of uif item
+	uint32  offset;                                 // Offset of item in file
+};
+
+// Game specific type definitions
+typedef byte *image_pt;                             // ptr to an object image (sprite)
+typedef byte *sound_pt;                             // ptr to sound (or music) data
+
+// Following are points for achieving certain actions.
+struct point_t {
+	byte score;                                     // The value of the point
+	bool scoredFl;                                  // Whether scored yet
+};
+
+// Structure for initializing maze processing
+struct maze_t {
+	bool enabledFl;                                 // TRUE when maze processing enabled
+	byte size;                                      // Size of (square) maze matrix
+	int  x1, y1, x2, y2;                            // maze hotspot bounding box
+	int  x3, x4;                                    // north, south x entry coordinates
+	byte firstScreenIndex;                          // index of first screen in maze
+};
+
 struct act0 {                                       // Type 0 - Schedule
 	action_t actType;                               // The type of action
 	int      timer;                                 // Time to set off the action

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2010-09-17 21:40:53 UTC (rev 52786)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2010-09-17 22:40:53 UTC (rev 52787)
@@ -67,6 +67,9 @@
 	DebugMan.addDebugChannel(kDebugFile, "File", "File IO debug level");
 	DebugMan.addDebugChannel(kDebugRoute, "Route", "Route debug level");
 	DebugMan.addDebugChannel(kDebugInventory, "Inventory", "Inventory debug level");
+
+	for (int j = 0; j < NUM_FONTS; j++)
+		_arrayFont[j] = 0;
 }
 
 HugoEngine::~HugoEngine() {
@@ -258,7 +261,7 @@
 }
 
 void HugoEngine::initMachine() {
-	if (_gameVariant == 3)
+	if (_gameVariant == kGameVariantH1Dos)
 		readScreenFiles(0);
 	else
 		file().readBackground(_numScreens - 1);         // Splash screen
@@ -1349,9 +1352,6 @@
 			_alNewscrIndex = numElem;
 	}
 
-	for (int j = 0; j < NUM_FONTS; j++)
-		_arrayFont[j] = 0;
-
 	if (_gameVariant > 2) {
 		_arrayFontSize[0] = in.readUint16BE();
 		_arrayFont[0] = (byte *)malloc(sizeof(byte) * _arrayFontSize[0]);

Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h	2010-09-17 21:40:53 UTC (rev 52786)
+++ scummvm/trunk/engines/hugo/hugo.h	2010-09-17 22:40:53 UTC (rev 52787)
@@ -33,7 +33,7 @@
 #include "hugo/game.h"
 
 #define HUGO_DAT_VER_MAJ 0  // 1 byte
-#define HUGO_DAT_VER_MIN 22 // 1 byte
+#define HUGO_DAT_VER_MIN 23 // 1 byte
 #define DATAALIGNMENT 4
 
 namespace Common {
@@ -48,6 +48,15 @@
 	kGameTypeHugo3
 };
 
+enum GameVariant {
+	kGameVariantH1Win = 0,
+	kGameVariantH2Win,
+	kGameVariantH3Win,
+	kGameVariantH1Dos,
+	kGameVariantH2Dos,
+	kGameVariantH3Dos
+};
+
 enum HugoDebugChannels {
 	kDebugSchedule   = 1 <<  0,
 	kDebugEngine     = 1 <<  1,

Modified: scummvm/trunk/engines/hugo/parser.cpp
===================================================================
--- scummvm/trunk/engines/hugo/parser.cpp	2010-09-17 21:40:53 UTC (rev 52786)
+++ scummvm/trunk/engines/hugo/parser.cpp	2010-09-17 22:40:53 UTC (rev 52787)
@@ -266,7 +266,7 @@
 	// fetch <object name>                          Hero carries named object
 	// fetch all                                    Hero carries all possible objects
 	// find <object name>                           Takes hero to screen containing named object
-	if (DEBUG || gameStatus.godModeFl) {
+	if (gameStatus.godModeFl) {
 		// Special code to allow me to go straight to any screen
 		if (strstr(_line, "goto"))
 			for (int i = 0; i < _vm._numScreens; i++)


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