[Scummvm-git-logs] scummvm master -> 1bd9b5521d90bb0e8e292456556d3d6322e3997c

mgerhardy martin.gerhardy at gmail.com
Sat Aug 28 17:53:08 UTC 2021


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:
c58fc049a2 TWINE: cleanup model header parsing
05675b4700 TWINE: allow to rename your savegame
1bd9b5521d TWINE: fixed savegame menu entry handling


Commit: c58fc049a2fd222854b6950721ec2e4b8914b86b
    https://github.com/scummvm/scummvm/commit/c58fc049a2fd222854b6950721ec2e4b8914b86b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-28T19:34:27+02:00

Commit Message:
TWINE: cleanup model header parsing

Changed paths:
    engines/twine/parser/body.cpp
    engines/twine/parser/body.h


diff --git a/engines/twine/parser/body.cpp b/engines/twine/parser/body.cpp
index eca1a05875..9e870e0503 100644
--- a/engines/twine/parser/body.cpp
+++ b/engines/twine/parser/body.cpp
@@ -159,7 +159,8 @@ void BodyData::loadSpheres(Common::SeekableReadStream &stream) {
 bool BodyData::loadFromStream(Common::SeekableReadStream &stream, bool lba1) {
 	reset();
 	if (lba1) {
-		bodyFlag.value = stream.readUint16LE();
+		const uint16 flags = stream.readUint16LE();
+		animated = (flags & 2) != 0;
 		bbox.mins.x = stream.readSint16LE();
 		bbox.maxs.x = stream.readSint16LE();
 		bbox.mins.y = stream.readSint16LE();
@@ -175,7 +176,8 @@ bool BodyData::loadFromStream(Common::SeekableReadStream &stream, bool lba1) {
 		loadLines(stream);
 		loadSpheres(stream);
 	} else {
-		bodyFlag.value = stream.readUint32LE();
+		const uint32 flags = stream.readUint32LE();
+		animated = (flags & 2) != 0;
 		stream.skip(4);
 		bbox.mins.x = stream.readSint32LE();
 		bbox.maxs.x = stream.readSint32LE();
diff --git a/engines/twine/parser/body.h b/engines/twine/parser/body.h
index 0fca681557..3f41846757 100644
--- a/engines/twine/parser/body.h
+++ b/engines/twine/parser/body.h
@@ -55,33 +55,13 @@ protected:
 	void reset() override;
 
 public:
-	union BodyFlags {
-		struct BitMask {
-			uint32 unk1 : 1;            // 1 << 0
-			uint32 animated : 1;        // 1 << 1
-			uint32 unk3 : 1;            // 1 << 2
-			uint32 unk4 : 1;            // 1 << 3
-			uint32 unk5 : 1;            // 1 << 4
-			uint32 unk6 : 1;            // 1 << 5
-			uint32 unk7 : 1;            // 1 << 6
-			uint32 alreadyPrepared : 1; // 1 << 7
-			uint32 unk9 : 1;            // 1 << 8
-			uint32 unk10 : 1;           // 1 << 9
-			uint32 unk11 : 1;           // 1 << 10
-			uint32 unk12 : 1;           // 1 << 11
-			uint32 unk13 : 1;           // 1 << 12
-			uint32 unk14 : 1;           // 1 << 13
-			uint32 unk15 : 1;           // 1 << 14
-			uint32 unk16 : 1;           // 1 << 15
-		} mask;
-		uint32 value;
-	} bodyFlag;
+	bool animated = false;
 
 	BoundingBox bbox;
 	int16 offsetToData = 0;
 
 	inline bool isAnimated() const {
-		return (bodyFlag.value & 2) != 0;
+		return animated;
 	}
 
 	inline uint getNumBones() const {


Commit: 05675b470055fb9d78bd1b68b5e8cf1b25134f85
    https://github.com/scummvm/scummvm/commit/05675b470055fb9d78bd1b68b5e8cf1b25134f85
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-28T19:34:27+02:00

Commit Message:
TWINE: allow to rename your savegame

see bug #12844

Changed paths:
    engines/twine/menu/menuoptions.cpp


diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index 532866568b..c2c23348e0 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -234,7 +234,6 @@ public:
 };
 
 bool MenuOptions::enterText(TextId textIdx, char *textTargetBuf, size_t bufSize) {
-	textTargetBuf[0] = '\0';
 	_engine->_text->initTextBank(TextBankId::Options_and_menus);
 	char buffer[256];
 	_engine->_text->getMenuText(textIdx, buffer, sizeof(buffer));
@@ -337,6 +336,7 @@ bool MenuOptions::enterText(TextId textIdx, char *textTargetBuf, size_t bufSize)
 
 bool MenuOptions::newGameMenu() {
 	_engine->restoreFrontBuffer();
+	_saveGameName[0] = '\0';
 	if (!enterText(TextId::kEnterYourName, _saveGameName, sizeof(_saveGameName))) {
 		return false;
 	}
@@ -420,7 +420,16 @@ bool MenuOptions::saveGameMenu() {
 	_engine->restoreFrontBuffer();
 	const int slot = chooseSave(TextId::kCreateSaveGame, true);
 	if (slot >= 0) {
-		Common::Error state = _engine->saveGameState(slot, _engine->_gameState->_sceneName, false);
+		char buf[30];
+		strncpy(buf, _engine->_gameState->_sceneName, sizeof(buf));
+		buf[sizeof(buf) - 1] = '\0';
+		_engine->restoreFrontBuffer();
+		enterText(TextId::kEnterYourNewName, buf, sizeof(buf));
+		// may not be empty
+		if (buf[0] == '\0') {
+			strncpy(buf, _engine->_gameState->_sceneName, sizeof(buf));
+		}
+		Common::Error state = _engine->saveGameState(slot, buf, false);
 		if (state.getCode() != Common::kNoError) {
 			error("Failed to save slot %i", slot);
 			return false;


Commit: 1bd9b5521d90bb0e8e292456556d3d6322e3997c
    https://github.com/scummvm/scummvm/commit/1bd9b5521d90bb0e8e292456556d3d6322e3997c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-28T19:51:58+02:00

Commit Message:
TWINE: fixed savegame menu entry handling

Changed paths:
    engines/twine/menu/menuoptions.cpp


diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index c2c23348e0..62b108c083 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -357,17 +357,21 @@ int MenuOptions::chooseSave(TextId textIdx, bool showEmptySlots) {
 	saveFiles.addButton(TextId::kReturnMenu);
 
 	const int maxButtons = _engine->getMetaEngine()->getMaximumSaveSlot() + 1;
-	for (const SaveStateDescriptor &savegame : savegames) {
-		saveFiles.addButton(savegame.getDescription().encode().c_str(), savegame.getSaveSlot());
-		if (saveFiles.getButtonCount() >= maxButtons) {
-			break;
-		}
-	}
-
-	if (showEmptySlots) {
-		while (saveFiles.getButtonCount() < maxButtons) {
-			// the first button is the back button - to subtract that one again to get the real slot index
-			saveFiles.addButton("EMPTY", saveFiles.getButtonCount() - 1);
+	uint savesIndex = 0;
+	for (int i = 1; i < maxButtons; ++i) {
+		if (savesIndex < savegames.size()) {
+			const SaveStateDescriptor &savegame = savegames[savesIndex];
+			if (savegame.getSaveSlot() == i - 1) {
+				// manually creating a savegame should not overwrite the autosave slot
+				if (textIdx != TextId::kCreateSaveGame || i > 1) {
+					saveFiles.addButton(savegame.getDescription().encode().c_str(), i);
+				}
+				++savesIndex;
+			} else if (showEmptySlots) {
+				saveFiles.addButton("EMPTY", i);
+			}
+		} else if (showEmptySlots) {
+			saveFiles.addButton("EMPTY", i);
 		}
 	}
 
@@ -378,8 +382,8 @@ int MenuOptions::chooseSave(TextId textIdx, bool showEmptySlots) {
 		case (int32)TextId::kReturnMenu:
 			return -1;
 		default:
-			const int16 slot = saveFiles.getButtonState(id);
-			debug("Selected slot %d for saving", slot);
+			const int16 slot = saveFiles.getButtonState(id) - 1;
+			debug("Selected savegame slot %d", slot);
 			return slot;
 		}
 	}




More information about the Scummvm-git-logs mailing list