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

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Mon Jan 31 00:08:05 CET 2011


Revision: 55669
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55669&view=rev
Author:   strangerke
Date:     2011-01-30 23:08:05 +0000 (Sun, 30 Jan 2011)

Log Message:
-----------
HUGO: 

- Replace several char* by Common::String
- Fix a bug in showDosInventory()

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

Modified: scummvm/trunk/engines/hugo/file.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file.cpp	2011-01-30 22:42:37 UTC (rev 55668)
+++ scummvm/trunk/engines/hugo/file.cpp	2011-01-30 23:08:05 UTC (rev 55669)
@@ -170,15 +170,13 @@
 
 		_objectsArchive.seek(objBlock.objOffset, SEEK_SET);
 	} else {
-		char *buf = (char *) malloc(2048 + 1);      // Buffer for file access
-		strcat(strcat(strcpy(buf, _vm->_picDir), _vm->_text->getNoun(objPtr->nounIndex, 0)), ".PIX");
+		Common::String buf;
+		buf = _vm->_picDir + Common::String(_vm->_text->getNoun(objPtr->nounIndex, 0)) + Common::String(".PIX");
 		if (!_objectsArchive.open(buf)) {
-			warning("File %s not found, trying again with %s%s", buf, _vm->_text->getNoun(objPtr->nounIndex, 0), ".PIX");
-			strcat(strcpy(buf, _vm->_text->getNoun(objPtr->nounIndex, 0)), ".PIX");
+			buf = Common::String(_vm->_text->getNoun(objPtr->nounIndex, 0)) + Common::String(".PIX");
 			if (!_objectsArchive.open(buf))
 				error("File not found: %s", buf);
 		}
-		free(buf);
 	}
 
 	bool  firstFl = true;                           // Initializes pcx read function
@@ -294,7 +292,7 @@
 /**
 * Return whether file exists or not
 */
-bool FileManager::fileExists(char *filename) {
+bool FileManager::fileExists(Common::String filename) {
 	Common::File f;
 	return(f.exists(filename));
 }

Modified: scummvm/trunk/engines/hugo/file.h
===================================================================
--- scummvm/trunk/engines/hugo/file.h	2011-01-30 22:42:37 UTC (rev 55668)
+++ scummvm/trunk/engines/hugo/file.h	2011-01-30 23:08:05 UTC (rev 55669)
@@ -44,7 +44,7 @@
 	FileManager(HugoEngine *vm);
 	virtual ~FileManager();
 
-	bool     fileExists(char *filename);
+	bool     fileExists(Common::String filename);
 	sound_pt getSound(int16 sound, uint16 *size);
 
 	void     readBootFile();

Modified: scummvm/trunk/engines/hugo/file_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v1d.cpp	2011-01-30 22:42:37 UTC (rev 55668)
+++ scummvm/trunk/engines/hugo/file_v1d.cpp	2011-01-30 23:08:05 UTC (rev 55669)
@@ -60,25 +60,22 @@
 	debugC(1, kDebugFile, "readOverlay(%d, ...)", screenNum);
 
 	const char *ovl_ext[] = {".b", ".o", ".ob"};
-	char *buf = (char *) malloc(2048 + 1);          // Buffer for file access
+	Common::String buf = Common::String(_vm->_text->getScreenNames(screenNum)) + Common::String(ovl_ext[overlayType]);
 
-	strcat(strcpy(buf, _vm->_text->getScreenNames(screenNum)), ovl_ext[overlayType]);
-
 	if (!fileExists(buf)) {
 		for (int i = 0; i < kOvlSize; i++)
 			image[i] = 0;
-		warning("File not found: %s", buf);
+		warning("File not found: %s", buf.c_str());
 		return;
 	}
 
 	if (!_sceneryArchive1.open(buf))
-		error("File not found: %s", buf);
+		error("File not found: %s", buf.c_str());
 
 	image_pt tmpImage = image;                      // temp ptr to overlay file
 
 	_sceneryArchive1.read(tmpImage, kOvlSize);
 	_sceneryArchive1.close();
-	free(buf);
 }
 
 /**
@@ -87,16 +84,15 @@
 void FileManager_v1d::readBackground(int screenIndex) {
 	debugC(1, kDebugFile, "readBackground(%d)", screenIndex);
 
-	char *buf = (char *) malloc(2048 + 1);          // Buffer for file access
-	strcat(strcpy(buf, _vm->_text->getScreenNames(screenIndex)), ".ART");
+	Common::String buf;
+	buf = Common::String(_vm->_text->getScreenNames(screenIndex)) + Common::String(".ART");
 	if (!_sceneryArchive1.open(buf))
-		error("File not found: %s", buf);
+		error("File not found: %s", buf.c_str());
 	// 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->_text->getScreenNames(screenIndex));
 	free(dummySeq);
 	_sceneryArchive1.close();
-	free(buf);
 }
 
 char *FileManager_v1d::fetchString(int index) {

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2011-01-30 22:42:37 UTC (rev 55668)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2011-01-30 23:08:05 UTC (rev 55669)
@@ -826,27 +826,27 @@
 	switch (_gameVariant) {
 	case kGameVariantH1Dos:
 		_episode = "\"Hugo's House of Horrors\"";
-		_picDir = "";
+		_picDir = Common::String("");
 		break;
 	case kGameVariantH2Dos:
 		_episode = "\"Hugo II: Whodunit?\"";
-		_picDir = "";
+		_picDir = Common::String("");
 		break;
 	case kGameVariantH3Dos:
 		_episode = "\"Hugo III: Jungle of Doom\"";
-		_picDir = "pictures/";
+		_picDir = Common::String("pictures/");
 		break;
 	case kGameVariantH1Win:
 		_episode = "\"Hugo's Horrific Adventure\"";
-		_picDir = "hugo1/";
+		_picDir = Common::String("hugo1/");
 		break;
 	case kGameVariantH2Win:
 		_episode = "\"Hugo's Mystery Adventure\"";
-		_picDir = "hugo2/";
+		_picDir = Common::String("hugo2/");
 		break;
 	case kGameVariantH3Win:
 		_episode = "\"Hugo's Amazon Adventure\"";
-		_picDir = "hugo3/";
+		_picDir = Common::String("hugo3/");
 		break;
 	default:
 		error("Unknown game");

Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h	2011-01-30 22:42:37 UTC (rev 55668)
+++ scummvm/trunk/engines/hugo/hugo.h	2011-01-30 23:08:05 UTC (rev 55669)
@@ -297,7 +297,7 @@
 	Common::RandomSource *_rnd;
 
 	const char *_episode;
-	const char *_picDir;
+	Common::String _picDir;
 
 	Common::String _saveFilename;
 

Modified: scummvm/trunk/engines/hugo/parser.cpp
===================================================================
--- scummvm/trunk/engines/hugo/parser.cpp	2011-01-30 22:42:37 UTC (rev 55668)
+++ scummvm/trunk/engines/hugo/parser.cpp	2011-01-30 23:08:05 UTC (rev 55669)
@@ -319,7 +319,8 @@
 
 	for (int i = 0; i < _vm->_object->_numObj; i++) { // Find widths of 2 columns
 		if (_vm->_object->isCarried(i)) {
-			uint16 len = strlen(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 1));
+			uint16 len = strlen(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2));
+			printf("%s %d\n", _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2), strlen(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)));
 			if (index++ & 1)                        // Right hand column
 				len2 = (len > len2) ? len : len2;
 			else
@@ -331,23 +332,24 @@
 	if (len1 + len2 < (uint16)strlen(_vm->_text->getTextParser(kTBOutro)))
 		len1 = strlen(_vm->_text->getTextParser(kTBOutro));
 
-	char buffer[kCompLineSize * kMaxTextRows] = "\0";
-	strncat(buffer, blanks, (len1 + len2 - strlen(_vm->_text->getTextParser(kTBIntro))) / 2);
-	strcat(strcat(buffer, _vm->_text->getTextParser(kTBIntro)), "\n");
+	Common::String buffer;
+	assert(len1 + len2 - strlen(_vm->_text->getTextParser(kTBIntro)) / 2 < strlen(blanks));
+	buffer = Common::String(blanks, (len1 + len2 - strlen(_vm->_text->getTextParser(kTBIntro))) / 2);
+
+	buffer += Common::String(_vm->_text->getTextParser(kTBIntro)) + Common::String("\n");
 	index = 0;
 	for (int i = 0; i < _vm->_object->_numObj; i++) { // Assign strings
 		if (_vm->_object->isCarried(i)) {
 			if (index++ & 1)
-				strcat(strcat(buffer, _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 1)), "\n");
+				buffer += Common::String(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)) + Common::String("\n");
 			else
-				strncat(strcat(buffer, _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 1)), blanks, len1 - strlen(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 1)));
+				buffer += Common::String(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)) + Common::String(blanks, len1 - strlen(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)));
 		}
 	}
 	if (index & 1)
-		strcat(buffer, "\n");
-	strcat(buffer, _vm->_text->getTextParser(kTBOutro));
-
-	Utils::Box(kBoxAny, "%s", buffer);
+		buffer += Common::String("\n");
+	buffer += Common::String(_vm->_text->getTextParser(kTBOutro));
+	Utils::Box(kBoxAny, "%s", buffer.c_str());
 }
 
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/schedule.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule.cpp	2011-01-30 22:42:37 UTC (rev 55668)
+++ scummvm/trunk/engines/hugo/schedule.cpp	2011-01-30 23:08:05 UTC (rev 55669)
@@ -162,10 +162,10 @@
 
 	// Make sure the background file exists!
 	if (!_vm->isPacked()) {
-		char line[32];
-		if (!_vm->_file->fileExists(strcat(strncat(strcpy(line, _vm->_picDir), _vm->_text->getScreenNames(screenIndex), kFilenameLength), ".PCX")) &&
-		    !_vm->_file->fileExists(strcat(strcpy(line, _vm->_text->getScreenNames(screenIndex)), ".ART"))) {
-				error("Unable to find background file for %s", _vm->_text->getScreenNames(screenIndex));
+		Common::String filename = Common::String(_vm->_text->getScreenNames(screenIndex));
+		if (!_vm->_file->fileExists(_vm->_picDir + filename + Common::String(".PCX")) &&
+			!_vm->_file->fileExists(filename + Common::String(".ART"))) {
+				error("Unable to find background file for %s", filename.c_str());
 			return;
 		}
 	}


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