[Scummvm-git-logs] scummvm master -> 73081f4d03245aa5bac4c10fffa68dc6cc0e9a0b
mduggan
noreply at scummvm.org
Sat Apr 12 06:01:33 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
cfe602fd2f DGDS: Remove a small memory leak on game restart
1b12febed0 DGDS: assert images loaded in HoC intro code
73081f4d03 DGDS: Fix RST file loading in HoC
Commit: cfe602fd2f0e7a87fe3b487adcf5a72aad747a20
https://github.com/scummvm/scummvm/commit/cfe602fd2f0e7a87fe3b487adcf5a72aad747a20
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-04-12T15:55:18+10:00
Commit Message:
DGDS: Remove a small memory leak on game restart
Changed paths:
engines/dgds/dgds.cpp
diff --git a/engines/dgds/dgds.cpp b/engines/dgds/dgds.cpp
index 949f0dfff2e..42abb74c309 100644
--- a/engines/dgds/dgds.cpp
+++ b/engines/dgds/dgds.cpp
@@ -356,6 +356,8 @@ void DgdsEngine::init(bool restarting) {
delete _hocIntro;
delete _chinaTank;
delete _chinaTrain;
+ delete _gameGlobals;
+ _gameGlobals = nullptr; // This will be recreated in loadGameFiles
}
_gamePals = new GamePalettes(_resource, _decompressor);
Commit: 1b12febed0df8de359fc80c409e57c15af0befce
https://github.com/scummvm/scummvm/commit/1b12febed0df8de359fc80c409e57c15af0befce
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-04-12T15:56:01+10:00
Commit Message:
DGDS: assert images loaded in HoC intro code
Changed paths:
engines/dgds/hoc_intro.cpp
diff --git a/engines/dgds/hoc_intro.cpp b/engines/dgds/hoc_intro.cpp
index 53118d196b6..873a8dc4554 100644
--- a/engines/dgds/hoc_intro.cpp
+++ b/engines/dgds/hoc_intro.cpp
@@ -169,6 +169,7 @@ void HocIntro::clean2(int16 xoff) {
}
void HocIntro::draw1(int16 xoff) {
+ assert(_noMaskImg && _noMaskImg->isLoaded() && _maskImg && _maskImg->isLoaded());
Graphics::ManagedSurface &dst = DgdsEngine::getInstance()->_compositionBuffer;
_noMaskImg->drawBitmap(1, xoff + 0xcc, 0x33, _drawWin, dst);
_noMaskImg->drawBitmap(0, xoff + 0xf8, 0x14, _drawWin, dst);
@@ -182,6 +183,7 @@ void HocIntro::draw1(int16 xoff) {
}
void HocIntro::draw2(int16 xoff) {
+ assert(_noMaskImg && _noMaskImg->isLoaded() && _maskImg && _maskImg->isLoaded());
Graphics::ManagedSurface &dst = DgdsEngine::getInstance()->_compositionBuffer;
if (8 < xoff)
Commit: 73081f4d03245aa5bac4c10fffa68dc6cc0e9a0b
https://github.com/scummvm/scummvm/commit/73081f4d03245aa5bac4c10fffa68dc6cc0e9a0b
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-04-12T16:00:19+10:00
Commit Message:
DGDS: Fix RST file loading in HoC
The HoC format is more like Willy Beamish than Dragon.
This should fix #15859.
Changed paths:
engines/dgds/scene.cpp
diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index 82388d1bb2a..7ee29f4e971 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -1809,14 +1809,20 @@ bool GDSScene::load(const Common::String &filename, ResourceManager *resourceMan
return result;
}
+
bool GDSScene::loadRestart(const Common::String &filename, ResourceManager *resourceManager, Decompressor *decompressor) {
+ // TODO: RST file format is also the original save game format, so this
+ // function could be used to load saves from the original games.
+ // The only thing to change would be supporting loading of sound bank
+ // and game time (which would need converting to our game time)
+
Common::SeekableReadStream *file = resourceManager->getResource(filename);
if (!file)
- error("Restart data %s not found", filename.c_str());
+ error("Game state data %s not found", filename.c_str());
uint32 magic = file->readUint32LE();
if (magic != _magic)
- error("Restart file magic doesn't match (%04X vs %04X)", magic, _magic);
+ error("%s file magic doesn't match game (%04X vs %04X)", filename.c_str(), magic, _magic);
uint16 num = file->readUint16LE();
// Find matching game item and load its values
@@ -1836,15 +1842,18 @@ bool GDSScene::loadRestart(const Common::String &filename, ResourceManager *reso
}
}
if (!found)
- error("Reset file references unknown item %d", num);
+ error("%s file references unknown item %d", filename.c_str(), num);
num = file->readUint16LE();
}
initIconSizes();
DgdsEngine *engine = DgdsEngine::getInstance();
- Common::Array<Global *> &globs = engine->getGameGlobals()->getAllGlobals();
- if (engine->getGameId() == GID_DRAGON || engine->getGameId() == GID_HOC) {
+ // From here the data format varies by game
+ const DgdsGameId gameId = engine->getGameId();
+
+ // Per scene globals are stored with scene+val in Dragon and HOC
+ if (gameId == GID_DRAGON || gameId == GID_HOC) {
num = file->readUint16LE();
while (num && !file->eos()) {
uint16 scene = file->readUint16LE();
@@ -1858,43 +1867,12 @@ bool GDSScene::loadRestart(const Common::String &filename, ResourceManager *reso
}
}
if (!found)
- error("Reset file references unknown scene global %d", num);
+ error("%s file references unknown scene global %d", filename.c_str(), num);
num = file->readUint16LE();
}
- /*uint32 unk = */ file->readUint32LE();
-
- if (globs.size() > 50)
- error("Too many globals to load from RST file");
-
- int g = 0;
- for (Global *glob : globs) {
- int16 val = file->readUint16LE();
- glob->setRaw(val);
- g++;
- }
- // Always 50 int16s worth of globals in the file, skip any unused.
- if (g < 50)
- file->skip(2 * (50 - g));
-
- uint16 triggers[100];
- for (int i = 0; i < ARRAYSIZE(triggers); i++) {
- triggers[i] = file->readUint16LE();
- }
-
- engine->_compositionBuffer.fillRect(Common::Rect(SCREEN_WIDTH, SCREEN_HEIGHT), 0);
- // TODO: FIXME: What should this scene num be? For now hacked to work with Dragon.
- engine->changeScene(3);
- SDSScene *scene = engine->getScene();
- int t = 0;
- num = triggers[t++];
- while (num) {
- uint16 val = triggers[t++];
- scene->enableTrigger(0, num, (bool)val);
- num = triggers[t++];
- }
} else {
- // Willy Beamish stores the globals differently
+ // Willy Beamish stores the Per-scene globals differently
num = file->readUint16LE();
while (num && !file->eos()) {
int16 val = file->readSint16LE();
@@ -1907,12 +1885,40 @@ bool GDSScene::loadRestart(const Common::String &filename, ResourceManager *reso
}
}
if (!found)
- error("Reset file references unknown scene global %d", num);
+ error("%s file references unknown scene global %d", filename.c_str(), num);
num = file->readUint16LE();
}
+ }
+
+ // Game time in original save games - ignore when we're doing a reset.
+ /*uint32 gameTime = */ file->readUint32LE();
- /*uint32 unk = */ file->readUint32LE();
+ Common::Array<Global *> &globs = engine->getGameGlobals()->getAllGlobals();
+
+ uint16 triggers[256];
+ ARRAYCLEAR(triggers);
+
+ if (gameId == GID_DRAGON) {
+ // Dragon has a fixed length section for game globals and triggers
+ if (globs.size() > 50)
+ error("Too many globals to load from file %s", filename.c_str());
+ int g = 0;
+ for (Global *glob : globs) {
+ int16 val = file->readUint16LE();
+ glob->setRaw(val);
+ g++;
+ }
+ // Always 50 int16s worth of globals in the file, skip any unused.
+ if (g < 50)
+ file->skip(2 * (50 - g));
+
+ // Always 100 uint16s of trigger config.
+ for (int i = 0; i < 100; i++) {
+ triggers[i] = file->readUint16LE();
+ }
+ } else {
+ // HOC and Willy both have number+val lists for game globals
num = file->readUint16LE();
while (num && !file->eos()) {
bool found = false;
@@ -1925,27 +1931,53 @@ bool GDSScene::loadRestart(const Common::String &filename, ResourceManager *reso
}
}
if (!found)
- error("Reset file references unknown game global %d", num);
+ error("%s references unknown game global %d", filename.c_str(), num);
num = file->readUint16LE();
}
- //
- // TODO: What is this block of data? In practice there is only one of them
- //
- while (!file->eos()) {
- num = file->readUint16LE();
- if (!num)
- break;
- /*int16 val1 = */ file->readUint16LE();
- /*int16 val2 = */ file->readUint16LE();
- /*int16 val3 = */ file->readUint16LE();
+ if (gameId == GID_HOC) {
+ // Triggers are stored
+ for (int i = 0; i < ARRAYSIZE(triggers); i += 2) {
+ triggers[i] = file->readUint16LE();
+ if (triggers[i] == 0 || file->eos())
+ break;
+ triggers[i + 1] = file->readUint16LE();
+ }
+ } else {
+ // Willy Beamish has an unknown block of 1 item long, probably trigger-related?
+
+ //
+ // TODO: What is this block of data?
+ //
+ while (!file->eos()) {
+ num = file->readUint16LE();
+ if (!num)
+ break;
+ // Probably enabled, timesToCheckBeforeRunning, checksUntilRun
+ /*int16 x = */ file->readUint16LE();
+ /*int16 y = */ file->readUint16LE();
+ /*int16 z = */ file->readUint16LE();
+ }
}
+ // Sound bank number is in original save files.
/*uint16 soundBankNum = */ file->readUint16LE();
+ }
+
+ engine->_compositionBuffer.fillRect(Common::Rect(SCREEN_WIDTH, SCREEN_HEIGHT), 0);
+
+ int16 targetScene = engine->getGameGlobals()->getLastSceneNum();
+ engine->changeScene(targetScene);
- engine->_compositionBuffer.fillRect(Common::Rect(SCREEN_WIDTH, SCREEN_HEIGHT), 0);
- // TODO: FIXME: What should this scene num be?
- engine->changeScene(3);
+ if (gameId == GID_DRAGON || gameId == GID_HOC) {
+ SDSScene *scene = engine->getScene();
+ int t = 0;
+ num = triggers[t++];
+ while (num) {
+ uint16 val = triggers[t++];
+ scene->enableTrigger(0, num, (bool)val);
+ num = triggers[t++];
+ }
}
return true;
More information about the Scummvm-git-logs
mailing list