aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWalter van Niftrik2010-06-07 02:11:01 +0000
committerWalter van Niftrik2010-06-07 02:11:01 +0000
commitb04535d487dd292b16768b036a0b24fc6965ed36 (patch)
tree6bf44d0c473a591035b649318ec049b72f167307 /engines
parent1e56ea9ac9ec21490d2ee626d4c49cdf6794e2b0 (diff)
downloadscummvm-rg350-b04535d487dd292b16768b036a0b24fc6965ed36.tar.gz
scummvm-rg350-b04535d487dd292b16768b036a0b24fc6965ed36.tar.bz2
scummvm-rg350-b04535d487dd292b16768b036a0b24fc6965ed36.zip
SCI: Adjust kGetSaveFiles for SCI32.
svn-id: r49469
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kfile.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index c48fb4035f..3e0ecd1a28 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -460,29 +460,37 @@ reg_t kCheckSaveGame(EngineState *s, int argc, reg_t *argv) {
reg_t kGetSaveFiles(EngineState *s, int argc, reg_t *argv) {
Common::String game_id = s->_segMan->getString(argv[0]);
- reg_t nametarget = argv[1];
- reg_t *slot = s->_segMan->derefRegPtr(argv[2], 0);
debug(3, "kGetSaveFiles(%s)", game_id.c_str());
Common::Array<SavegameDesc> saves;
listSavegames(saves);
- s->r_acc = NULL_REG;
+ uint totalSaves = MIN<uint>(saves.size(), MAX_SAVEGAME_NR);
- for (uint i = 0; i < MIN<uint>(saves.size(), MAX_SAVEGAME_NR); i++) {
- *slot++ = s->r_acc; // Store savegame ID
- ++s->r_acc.offset; // Increase number of files found
+ reg_t *slot = s->_segMan->derefRegPtr(argv[2], totalSaves);
- s->_segMan->strcpy(nametarget, saves[i].name);
+ if (!slot) {
+ warning("kGetSaveFiles: %04X:%04X invalid or too small to hold slot data", PRINT_REG(argv[2]));
+ totalSaves = 0;
+ }
+
+ const uint bufSize = (totalSaves * SCI_MAX_SAVENAME_LENGTH) + 1;
+ char *saveNames = new char[bufSize];
+ char *saveNamePtr = saveNames;
- // Increase name offset pointer accordingly
- nametarget.offset += SCI_MAX_SAVENAME_LENGTH;
+ for (uint i = 0; i < totalSaves; i++) {
+ *slot++ = make_reg(0, i); // Store slot
+ strcpy(saveNamePtr, saves[i].name);
+ saveNamePtr += SCI_MAX_SAVENAME_LENGTH;
}
- s->_segMan->strcpy(nametarget, ""); // Terminate list
+ *saveNamePtr = 0; // Terminate list
- return s->r_acc;
+ s->_segMan->memcpy(argv[1], (byte *)saveNames, bufSize);
+ delete[] saveNames;
+
+ return make_reg(0, totalSaves);
}
reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) {