[Scummvm-git-logs] scummvm master -> 0cda7d140b3aae783e21df85db590bfdaf4b018f

sluicebox noreply at scummvm.org
Sun Jan 19 04:26:43 UTC 2025


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

Summary:
18943653d7 TETRAEDGE: Fix memory leak. PVS-Studio V773
95f4ad146d AGI: PREAGI: Initialize members
0cda7d140b AGI: Add `diskdump` debug command


Commit: 18943653d7dd200f055f01e5cb129a9e3eabc732
    https://github.com/scummvm/scummvm/commit/18943653d7dd200f055f01e5cb129a9e3eabc732
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-01-18T20:14:59-08:00

Commit Message:
TETRAEDGE: Fix memory leak. PVS-Studio V773

Changed paths:
    engines/tetraedge/obb_archive.cpp


diff --git a/engines/tetraedge/obb_archive.cpp b/engines/tetraedge/obb_archive.cpp
index 5869f48e0b0..e11a6d1c1d1 100644
--- a/engines/tetraedge/obb_archive.cpp
+++ b/engines/tetraedge/obb_archive.cpp
@@ -108,8 +108,10 @@ Common::SeekableReadStream *ObbArchive::createReadStreamForMember(const Common::
 	FileDescriptor desc = _files.getVal(translated);
 
 	Common::File *f = new Common::File();
-	if (!f->open(_obbName))
+	if (!f->open(_obbName)) {
+		delete f;
 		return nullptr;
+	}
 
 	return new Common::SeekableSubReadStream(f, desc._fileOffset, desc._fileOffset + desc._fileSize, DisposeAfterUse::YES);
 }


Commit: 95f4ad146d502e79d2518db19b5b64752fe6e6a9
    https://github.com/scummvm/scummvm/commit/95f4ad146d502e79d2518db19b5b64752fe6e6a9
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-01-18T20:15:00-08:00

Commit Message:
AGI: PREAGI: Initialize members

Changed paths:
    engines/agi/preagi/picture_troll.cpp


diff --git a/engines/agi/preagi/picture_troll.cpp b/engines/agi/preagi/picture_troll.cpp
index 1681873981f..dcbd5ab9833 100644
--- a/engines/agi/preagi/picture_troll.cpp
+++ b/engines/agi/preagi/picture_troll.cpp
@@ -49,6 +49,8 @@ namespace Agi {
 
 PictureMgr_Troll::PictureMgr_Troll(AgiBase *agi, GfxMgr *gfx) :
 	PictureMgr(agi, gfx) {
+	_stopOnF3 = false;
+	_trollMode = false;
 }
 
 void PictureMgr_Troll::drawPicture() {


Commit: 0cda7d140b3aae783e21df85db590bfdaf4b018f
    https://github.com/scummvm/scummvm/commit/0cda7d140b3aae783e21df85db590bfdaf4b018f
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-01-18T20:15:00-08:00

Commit Message:
AGI: Add `diskdump` debug command

Changed paths:
    engines/agi/console.cpp
    engines/agi/console.h


diff --git a/engines/agi/console.cpp b/engines/agi/console.cpp
index c8d006715f9..24919316401 100644
--- a/engines/agi/console.cpp
+++ b/engines/agi/console.cpp
@@ -27,6 +27,8 @@
 #include "agi/preagi/mickey.h"
 #include "agi/preagi/winnie.h"
 
+#include "common/file.h"
+
 namespace Agi {
 
 Console::Console(AgiEngine *vm) : GUI::Debugger() {
@@ -54,6 +56,7 @@ Console::Console(AgiEngine *vm) : GUI::Debugger() {
 	registerCmd("vmvars",          WRAP_METHOD(Console, Cmd_VmVars));
 	registerCmd("vmflags",         WRAP_METHOD(Console, Cmd_VmFlags));
 	registerCmd("disableautosave", WRAP_METHOD(Console, Cmd_DisableAutomaticSave));
+	registerCmd("diskdump",        WRAP_METHOD(Console, Cmd_DiskDump));
 }
 
 bool Console::Cmd_SetVar(int argc, const char **argv) {
@@ -606,6 +609,80 @@ bool Console::Cmd_DisableAutomaticSave(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::Cmd_DiskDump(int argc, const char **argv) {
+	static const char *resTypes[4] = { "logic", "picture", "view", "sound" };
+
+	if (!(argc == 3 || (argc == 2 && strcmp(argv[1], "*") == 0))) {
+		debugPrintf("Dumps the specified resource to disk as a file\n");
+		debugPrintf("Usage: %s <resource type> <resource number>\n", argv[0]);
+		debugPrintf("       <resource type> may be logic, picture, view, sound, or '*' for all resources\n");
+		debugPrintf("       <resource number> may be '*' to dump all resources of given type\n");
+		return true;
+	}
+
+	int resType = -1; // -1 == all
+	if (strcmp(argv[1], "*") != 0) {
+		for (int i = 0; i < ARRAYSIZE(resTypes); i++) {
+			if (scumm_stricmp(argv[1], resTypes[i]) == 0) {
+				resType = i;
+				break;
+			}
+		}
+		if (resType == -1) {
+			debugPrintf("Resource type '%s' is not valid\n", argv[1]);
+			return true;
+		}
+	}
+
+	int resNr = -1; // -1 == all
+	if (argc >= 3 && strcmp(argv[2], "*") != 0) {
+		if (!parseInteger(argv[2], resNr)) {
+			return true;
+		}
+		if (!(0 <= resNr && resNr < MAX_DIRECTORY_ENTRIES)) {
+			debugPrintf("Invalid resource number: %d\n", resNr);
+			return true;
+		}
+	}
+
+	AgiDir *resDirs[4] = { _vm->_game.dirLogic, _vm->_game.dirPic, _vm->_game.dirView, _vm->_game.dirSound };
+	for (int t = 0; t < ARRAYSIZE(resDirs); t++) {
+		if (resType != -1 && resType != t) {
+			continue;
+		}
+
+		AgiDir *resDir = resDirs[t];
+		for (int i = 0; i < MAX_DIRECTORY_ENTRIES; i++) {
+			if (resNr != -1 && resNr != i) {
+				continue;
+			}
+
+			if (resDir[i].offset == _EMPTY) {
+				if (resNr != -1) {
+					debugPrintf("Resource does not exist: %s.%03d\n", resTypes[t], i);
+				}
+				continue;
+			}
+
+			Common::String fileName = Common::String::format("%s.%03d", resTypes[t], i);
+			byte *resData = _vm->_loader->loadVolumeResource(&resDir[i]);
+			if (resData != nullptr) {
+				Common::DumpFile file;
+				if (file.open(Common::Path(fileName))) {
+					file.write(resData, resDir[i].len);
+					debugPrintf("%s has been dumped to disk\n", fileName.c_str());
+				} else {
+					debugPrintf("Error dumping %s to disk\n", fileName.c_str());
+				}
+				free(resData);
+			} else {
+				debugPrintf("Error dumping %s to disk\n", fileName.c_str());
+			}
+		}
+	}
+	return true;
+}
+
 bool Console::parseInteger(const char *argument, int &result) {
 	char *endPtr = nullptr;
 	int idxLen = strlen(argument);
diff --git a/engines/agi/console.h b/engines/agi/console.h
index 2dd2ef78155..58233f55b82 100644
--- a/engines/agi/console.h
+++ b/engines/agi/console.h
@@ -66,6 +66,7 @@ private:
 	bool Cmd_VmVars(int argc, const char **argv);
 	bool Cmd_VmFlags(int argc, const char **argv);
 	bool Cmd_DisableAutomaticSave(int argc, const char **argv);
+	bool Cmd_DiskDump(int argc, const char **argv);
 
 	bool parseInteger(const char *argument, int &result);
 




More information about the Scummvm-git-logs mailing list