[Scummvm-git-logs] scummvm master -> 7ccea5e57c904d4b4883039578c83c1f1b4ae303

sev- sev at scummvm.org
Tue Jul 6 14:48:23 UTC 2021


This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c9c77e4aaf SAGA2: Fixed side effect in assertion. CID 1457988
20a3dd45d2 SAGA2: Cleanup hResMgr
b429407190 SAGA2: Use safer string copy function
9a0b5462bf SAGA2: Cleanup button.cpp
4f780ac05e SAGA2: Cleanup document.cpp
7ccea5e57c SAGA2: Use safer string copy function


Commit: c9c77e4aaf2e10ae4eb32e0df75bce91473db420
    https://github.com/scummvm/scummvm/commit/c9c77e4aaf2e10ae4eb32e0df75bce91473db420
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:28:22+02:00

Commit Message:
SAGA2: Fixed side effect in assertion. CID 1457988

Changed paths:
    engines/saga2/floating.cpp


diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 01230550ed..b6669c915c 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -522,7 +522,7 @@ void LabeledButton::drawClipped(
 
 FloatingWindow::FloatingWindow(const Rect16 &r, uint16 ident, const char saveas[], AppFunc *cmd)
 	: DecoratedWindow(r, ident, saveas, cmd) {
-	assert(db = new DragBar(*this, Rect16(0, 0, r.width, r.height)));
+	db = new DragBar(*this, Rect16(0, 0, r.width, r.height));
 
 	origPos.x = r.x;
 	origPos.y = r.y;


Commit: 20a3dd45d213c78e800a9e5a57b81c80bb5c8a37
    https://github.com/scummvm/scummvm/commit/20a3dd45d213c78e800a9e5a57b81c80bb5c8a37
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:36:31+02:00

Commit Message:
SAGA2: Cleanup hResMgr

Changed paths:
    engines/saga2/hresmgr.cpp
    engines/saga2/hresmgr.h
    engines/saga2/main.cpp


diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index a12ad435d4..cb0bd73973 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -132,24 +132,6 @@ uint32 hResContext::count(hResID id) {
 	return count;
 }
 
-Common::File *hResContext::openExternal(Common::File *fh) {
-	char    name[160];
-	int     len;
-	uint16  size;
-	Common::File *file;
-	file = &_file;
-
-	_bytecount = 0;
-	_bytepos = 0;
-	strcpy(name, _res->_externalPath);
-	len = strlen(name);
-	size = fh->readUint32LE();
-	fh->read(&name, sizeof(name));
-	name[len + size] = 0;
-	file->open(name);
-	return file;
-}
-
 // this function sets _handle
 
 bool hResContext::seek(hResID id) {
@@ -169,11 +151,7 @@ bool hResContext::seek(hResID id) {
 	_res->_handle->seek(_bytepos, SEEK_SET);
 
 	if (entry->isExternal()) {
-		// resource _data is actually a path name
-
-		_handle = openExternal(_res->_handle);
-
-		return (_handle != nullptr);
+		error("hResContext: External entries are not supported");
 	}
 
 	_handle = _res->_handle;
@@ -348,7 +326,7 @@ void hResource::readResource(hResEntry &element) {
 	debugC(3, kDebugResources, "%s, offset: %x, size: %d", tag2str(id), element.offset, element.size);
 }
 
-hResource::hResource(const char *resname, const char *extname, const char desc[]) {
+hResource::hResource(const char *resname, const char desc[]) {
 	hResEntry   origin;
 	int32      tableSize;
 	const int32 resourceSize = 4 + 4 + 4; // id, offset, size
@@ -359,8 +337,6 @@ hResource::hResource(const char *resname, const char *extname, const char desc[]
 	_numEntries = 0;
 	_filename = resname;
 
-	strncpy(_externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
-
 	debugC(1, kDebugResources, "Opening resource: %s", resname);
 	if (!_file.open(resname))
 		warning("Unable to open file %s", resname);
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index d03a68871d..9ebb2161ec 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -48,8 +48,6 @@ struct hResEntry;
 class hResContext;
 class hResource;
 
-#define EXTERNAL_PATH_SIZE 80
-
 /* ===================================================================== *
    hResEntry struct
  * ===================================================================== */
@@ -112,7 +110,6 @@ protected:
 	uint32          _bytepos;
 
 	hResEntry      *findEntry(hResID id);
-	Common::File   *openExternal(Common::File *fh);
 
 public:
 	bool            _valid;
@@ -158,11 +155,10 @@ class hResource : public hResContext {
 	friend class hResContext;
 
 	uint32          _firstGroupOffset;
-	char            _externalPath[EXTERNAL_PATH_SIZE];
 	hResEntry      *_table;
 
 public:
-	hResource(const char *resname, const char *extname, const char []);
+	hResource(const char *resname, const char []);
 	~hResource();
 
 	hResContext *newContext(hResID id, const char []);
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index e5d15984da..2b4edb2a68 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -562,20 +562,17 @@ inline char drive(char *path) {
 //-----------------------------------------------------------------------
 //	Routine to initialize an arbitrary resource file
 
-static bool openResource(
-    pHResource &hr,      // resource to initialize
-    const char *defaultPath,   // backup path
-    const char *fileName,      // file name & extension
-    const char *description) {
-	if (hr) delete hr;
+static bool openResource(pHResource &hr, const char *fileName, const char *description) {
+	if (hr)
+		delete hr;
 	hr = NULL;
 
-	hr = new hResource(fileName, defaultPath, description);
+	hr = new hResource(fileName, description);
 
 	while (hr == NULL || !hr->_valid) {
 		if (hr) delete hr;
 		hr = NULL;
-		hr = new hResource(fileName, defaultPath, description);
+		hr = new hResource(fileName, description);
 	}
 
 	if (hr == NULL || !hr->_valid) {
@@ -591,21 +588,12 @@ static bool openResource(
 bool openResources(void) {
 
 	if (
-	    openResource(resFile, "..\\resfile\\",  IMAGE_RESFILE,
-	                 "Imagery resource file")      &&
-
-	    openResource(objResFile, "..\\resfile\\",  OBJECT_RESFILE,
-	                 "Object resource file")      &&
-
-	    openResource(auxResFile, "..\\resfile\\",  AUX_RESFILE,
-	                 "Data resource file")      &&
-
-	    openResource(scriptResFile, "..\\scripts\\",  SCRIPT_RESFILE,
-	                 "Script resource file")      &&
-	    openResource(voiceResFile, "..\\sound\\",    VOICE_RESFILE,
-	                 "Voice resource file")       &&
-	    openResource(soundResFile, "..\\sound\\",    SOUND_RESFILE,
-	                 "Sound resource file")) {
+	    openResource(resFile, IMAGE_RESFILE, "Imagery resource file") &&
+	    openResource(objResFile, OBJECT_RESFILE, "Object resource file") &&
+	    openResource(auxResFile, AUX_RESFILE, "Data resource file") &&
+	    openResource(scriptResFile, SCRIPT_RESFILE, "Script resource file") &&
+	    openResource(voiceResFile, VOICE_RESFILE, "Voice resource file") &&
+	    openResource(soundResFile, SOUND_RESFILE, "Sound resource file")) {
 		return true;
 	}
 	return false;


Commit: b4294071908dbd72a06db4b329cf4a5925c62692
    https://github.com/scummvm/scummvm/commit/b4294071908dbd72a06db4b329cf4a5925c62692
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:37:44+02:00

Commit Message:
SAGA2: Use safer string copy function

Changed paths:
    engines/saga2/mapfeatr.cpp


diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index 17cb3c5ea7..19ad96c094 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -314,7 +314,7 @@ CMapFeature::CMapFeature(TilePoint where, int16 inWorld, const char *desc) {
 	visible = false;
 	featureCoords = where;
 	world = inWorld;
-	strncpy(name, desc, MAX_MAP_FEATURE_NAME_LENGTH);
+	Common::strlcpy(name, desc, MAX_MAP_FEATURE_NAME_LENGTH);
 }
 
 


Commit: 9a0b5462bfa09b9be5a112d7fe86e03491736d3d
    https://github.com/scummvm/scummvm/commit/9a0b5462bfa09b9be5a112d7fe86e03491736d3d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:38:46+02:00

Commit Message:
SAGA2: Cleanup button.cpp

Changed paths:
    engines/saga2/button.cpp


diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 4fdeeb038a..d1d16a6fda 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -105,7 +105,7 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, const c
 
 	if (!image) return;
 
-compImages = (void **)malloc(sizeof(void *) * 1); // allocate room for one pointer
+	compImages = (void **)malloc(sizeof(void *) * 1); // allocate room for one pointer
 
 	compImages[0] = image;
 	max             = 0;
@@ -113,23 +113,6 @@ compImages = (void **)malloc(sizeof(void *) * 1); // allocate room for one point
 	title           = text;
 	textFont        = &Onyx10Font;  // >>> this should be dynamic
 	textPal         = pal;
-
-#if 0
-	// setup the text if any
-	if (text) {
-		// copy the maximum number of chars to the text buffer
-		strncpy(imageText, text, textSize);
-
-		// cap it, in case of overflow
-		imageText[textSize - 1] = NULL;
-
-		// setup the text pallete and font type
-		textPal     = pal;
-		textFont    = &Onyx10Font;  // >>> this should be dynamic
-	} else {
-		*imageText = NULL;
-	}
-#endif
 }
 
 gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void **images,
@@ -162,21 +145,6 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void **images,
 	title       = text;
 	textFont    = &Onyx10Font;  // >>> this should be dynamic
 	textPal     = pal;
-
-#if 0
-	// setup the text if any
-	if (text) {
-		// copy the maximum number of chars to the text buffer
-		strncpy(imageText, text, textSize);
-
-		// cap it, in case of overflow
-		imageText[textSize - 1] = NULL;
-		textPal     = pal;
-		textFont    = &Onyx10Font;  // >>> this should be dynamic
-	} else {
-		*imageText = NULL;
-	}
-#endif
 }
 
 gCompImage::gCompImage(gPanelList &list, const StaticRect &box, void **images,


Commit: 4f780ac05ec07b3cb996dd5f5b078bf34c2eaa67
    https://github.com/scummvm/scummvm/commit/4f780ac05ec07b3cb996dd5f5b078bf34c2eaa67
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:45:18+02:00

Commit Message:
SAGA2: Cleanup document.cpp

Changed paths:
    engines/saga2/document.cpp


diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 1d3f3e630b..a3bd1688d8 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -353,159 +353,6 @@ void CDocument::pointerRelease(gPanelMessage &) {
 	deactivate();
 }
 
-// this does not work correctly yet
-
-#if 0
-void CDocument::setText(char * /* string */) {
-	if (string) {
-		int16   i;
-
-		for (i = 0; i < maxPages; i++) {
-			if (images[i]) {
-				RDisposePtr(images[i]);
-			}
-		}
-
-		// null out the image pointer array
-		memset(images, NULL, maxPages);
-
-
-		// get rid of the resource context
-		if (illustrationCon) resFile->disposeContext(illustrationCon);
-		illustrationCon = NULL;
-
-		// if text is real
-		if (text) {
-			// get rid of the working text buffer
-			RDisposePtr(text);
-		}
-
-		// set the original text pointer
-		origText    = string;
-
-		// get it's size
-		textSize    = clamp(0, strlen(origText), maxSize);
-
-		// make a working buffer
-		text = (char *)RNewPtr(textSize + 1, NULL, "book work text buffer");
-
-		// and fill it
-		strncpy(text, origText, textSize);
-
-		// make sure it's null terminated
-		text[textSize] = NULL;
-
-		// repage the book
-		makePages();
-	}
-}
-
-
-// add text to the book this does not work correctly yet
-void CDocument::appendText(char * /* string */) {
-	char    *expandedBuf;
-	char    *expandedTextBuf;
-
-	RMemIntegrity();
-
-	if (string && origText) {
-		int16   i;
-		int16   oldTextLen;
-		int16   newTextLen;
-		int16   expandedLen;
-
-		for (i = 0; i < maxPages; i++) {
-			memset(lineLen[i], 0, maxLines);
-		}
-
-		// free up the images
-		for (i = 0; i < maxPages; i++) {
-			if (images[i]) {
-				RDisposePtr(images[i]);
-			}
-		}
-
-		// null out the image pointer array
-		memset(images, NULL, maxPages);
-
-		// get rid of the resource context
-		if (illustrationCon) resFile->disposeContext(illustrationCon);
-		illustrationCon = NULL;
-
-		// reset text formatting page info
-		currentPage = 0;
-
-		// get the length of the old text
-		oldTextLen = strlen(origText);
-
-		// and the new text
-		newTextLen = strlen(string);
-
-		// set the total len
-		expandedLen = oldTextLen + newTextLen + 1024;
-
-		WriteStatusF(4, "len:%d", expandedLen);
-
-		// make space for the old text
-		//expandedBuf   = ( char * )RNewPtr( expandedLen + 1, NULL, "book expaned text buffer" );
-		expandedBuf     = new char[expandedLen + 1];
-		expandedTextBuf = new char[expandedLen + 1];
-
-		// save the old text
-		strcpy(expandedBuf, origText);
-
-		// add the string to the expanded buffer
-		strncat(expandedBuf, string, newTextLen);
-
-		/*
-		    // make space for the new and old text
-		origText = ( char * )RNewPtr( oldTextLen + newTextLen + 1, NULL, "book expaned buffer" );
-
-		    // copy the old text into the larger buffer
-		strcpy( origText, oldText );
-
-		origText[oldTextLen + newTextLen] = NULL;
-
-		    // add the appending text to the original text buffer replacment
-		strcat( origText, string );
-
-		    // get rid of the working text buffer
-		if( text )
-		{
-		    RDisposePtr( text );
-		}
-
-		    // and replace it with the new one
-		text = ( char * )RNewPtr( oldTextLen + newTextLen + 1, NULL, "book text buffer" );
-
-		    // copy from the original text buffer to the working text buffer
-		strcpy( text, origText );
-
-		text[oldTextLen + newTextLen] = NULL;
-		*/
-
-		// get rid of the old origText buffer
-		if (origText) {
-			//RDisposePtr( origText );
-			delete origText;
-			origText = NULL;
-		}
-
-		if (text) {
-			delete text;
-			text = NULL;
-		}
-
-		// set the new buffer pointer
-		origText    = expandedBuf;
-		text        = expandedTextBuf;
-	}
-
-	// repage the book
-	makePages();
-}
-#endif
-
 bool CDocument::checkForPageBreak(char *string, uint16 index, int32 &offset) {
 
 	// get the current index into the string
@@ -688,29 +535,6 @@ void CDocument::makePages(void) {
 		pageIndex++;
 		newPage     = false;
 
-		/* debug
-		WriteStatusF( 5, "page#:%d", pageIndex );
-		char buf[80];
-
-		strncpy( buf, str, 75 );
-
-		WriteStatusF( 6, "string:%s", buf );
-		*/
-
-		// check to see if there is an image; and make allowences if
-		// there is.
-		/*
-		if( images[pageIndex] )
-		{
-		        // set the next text line to the lineOffset
-		    lineIndex   = lineOffset[pageIndex];
-		}
-		else
-		{
-		    lineIndex   = 0;
-		}
-		*/
-
 		lineIndex = 0;
 	}
 


Commit: 7ccea5e57c904d4b4883039578c83c1f1b4ae303
    https://github.com/scummvm/scummvm/commit/7ccea5e57c904d4b4883039578c83c1f1b4ae303
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:48:00+02:00

Commit Message:
SAGA2: Use safer string copy function

Changed paths:
    engines/saga2/grequest.cpp
    engines/saga2/intrface.cpp
    engines/saga2/msgbox.cpp
    engines/saga2/savefile.cpp
    engines/saga2/uidialog.cpp


diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index 7a99499039..3f58da74c2 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -256,10 +256,7 @@ ModalRequestWindow::ModalRequestWindow(
 
 	int16   fontHeight = mainFont->height;
 
-	strncpy(
-	    buttonBuf,
-	    (buttonText ? buttonText : "_OK"),
-	    sizeof buttonBuf - 1);
+	Common::strlcpy(buttonBuf, (buttonText ? buttonText : "_OK"), sizeof(buttonBuf));
 
 	//  break up the button text string
 	buttonCount = SplitString(buttonBuf, buttonStrings, maxButtons, '|');
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 95d1a95df7..1e3a413274 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -586,7 +586,7 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
 	buf[size - 1] = '\0';
 
 	if (a->isDead()) {
-		strncpy(buf, DEAD_STATE, size - 1);
+		Common::strlcpy(buf, DEAD_STATE, size);
 		return;
 	}
 
@@ -753,7 +753,7 @@ void CStatusLine::experationCheck(void) {
 		minWaitAlarm.set(lineQueue[queueTail].frameTime / 5);
 
 		// copy upto the buffer's size in chars
-		strncpy(lineBuf, lineQueue[queueTail].text, bufSize - 1);
+		Common::strlcpy(lineBuf, lineQueue[queueTail].text, bufSize);
 		lineBuf[bufSize - 1] = '\0';
 
 		//  free the queue text buffer
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 569668d7f0..4a4a176a03 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -299,7 +299,7 @@ void SimpleWindow::writeWrappedPlaqText(gPort           &port,
 			i = (src - text);
 		tPos += i;
 		memset(lineBuf, '\0', 128);
-		strncpy(lineBuf, text, i);
+		Common::strlcpy(lineBuf, text, i);
 		writePlaqText(port, r2, font, textPos, pal, hiLite, lineBuf);
 		r2.y += font->height + 4;
 		r2.height -= font->height + 4;
diff --git a/engines/saga2/savefile.cpp b/engines/saga2/savefile.cpp
index 3724694883..5548e4659b 100644
--- a/engines/saga2/savefile.cpp
+++ b/engines/saga2/savefile.cpp
@@ -92,7 +92,7 @@ SaveFileConstructor::SaveFileConstructor(int16 saveNo, char *saveName) {
 	memset(&header, '\0', sizeof(header));
 
 	header.gameID = gameID;
-	strncpy(header.saveName, saveName, sizeof(header.saveName) - 1);
+	Common::strlcpy(header.saveName, saveName, sizeof(header.saveName));
 
 	//  Write the header
 	if (fwrite(&header, sizeof(header), 1, fileHandle) != 1)
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 8cf38937b1..5af47edd38 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -589,9 +589,9 @@ char **initFileFields(void) {
 		strings[i] = new char[editLen + 1];
 
 		if (getSaveName(i, header)) {
-			strncpy(strings[i], header.saveName.c_str(), editLen);
+			Common::strlcpy(strings[i], header.saveName.c_str(), editLen);
 		} else {
-			strncpy(strings[i], FILE_DIALOG_NONAME, editLen);
+			Common::strlcpy(strings[i], FILE_DIALOG_NONAME, editLen);
 			strings[i][0] |= 0x80;
 		}
 




More information about the Scummvm-git-logs mailing list