diff options
author | Colin Snover | 2017-07-26 16:05:50 -0500 |
---|---|---|
committer | Colin Snover | 2017-07-26 22:02:37 -0500 |
commit | 4357809ce8238cfd0bc5d8c92b6da28068607d55 (patch) | |
tree | 3533164e2439796ceee5f9d6ee2d33d899518bf1 /engines/sci/engine | |
parent | 14907039fe092e0ee5ac8176480ca08803cd82c2 (diff) | |
download | scummvm-rg350-4357809ce8238cfd0bc5d8c92b6da28068607d55.tar.gz scummvm-rg350-4357809ce8238cfd0bc5d8c92b6da28068607d55.tar.bz2 scummvm-rg350-4357809ce8238cfd0bc5d8c92b6da28068607d55.zip |
SCI32: Fix truncated save game names in Phant2
Phant2 creates save game names that append "<PROTECTED>" at the
end of the game name, with an assumption that the game name is
always exactly 36 characters long. This seems to be OK with other
games too (tested GK1, SQ6, and Torin).
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/file.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/file.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp index 2128433b90..7e218bc81c 100644 --- a/engines/sci/engine/file.cpp +++ b/engines/sci/engine/file.cpp @@ -371,7 +371,9 @@ bool fillSavegameDesc(const Common::String &filename, SavegameDesc *desc) { if (meta.name.lastChar() == '\n') meta.name.deleteLastChar(); - Common::strlcpy(desc->name, meta.name.c_str(), SCI_MAX_SAVENAME_LENGTH); + // At least Phant2 requires use of strncpy, since it creates save game + // names of exactly SCI_MAX_SAVENAME_LENGTH + strncpy(desc->name, meta.name.c_str(), SCI_MAX_SAVENAME_LENGTH); return desc; } diff --git a/engines/sci/engine/file.h b/engines/sci/engine/file.h index fee628aad5..1657dd3c7c 100644 --- a/engines/sci/engine/file.h +++ b/engines/sci/engine/file.h @@ -35,7 +35,7 @@ enum kFileOpenMode { }; enum { - SCI_MAX_SAVENAME_LENGTH = 36, ///< Maximum length of a savegame name (including terminator character). + SCI_MAX_SAVENAME_LENGTH = 36, ///< Maximum length of a savegame name (including optional terminator character). MAX_SAVEGAME_NR = 20 ///< Maximum number of savegames }; diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 1a6695f882..eb6cacbe19 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -426,7 +426,7 @@ reg_t kFileIOOpen(EngineState *s, int argc, reg_t *argv) { byte *out = buffer; for (uint i = 0; i < numSaves; ++i) { WRITE_UINT16(out, saves[i].id - kSaveIdShift); - Common::strlcpy((char *)out + sizeof(int16), saves[i].name, SCI_MAX_SAVENAME_LENGTH); + strncpy((char *)out + sizeof(int16), saves[i].name, SCI_MAX_SAVENAME_LENGTH); out += recordSize; } WRITE_UINT16(out, 0xFFFF); @@ -1372,7 +1372,9 @@ reg_t kGetSaveFiles32(EngineState *s, int argc, reg_t *argv) { for (uint i = 0; i < saves.size(); ++i) { const SavegameDesc &save = saves[i]; char *target = &descriptions.charAt(SCI_MAX_SAVENAME_LENGTH * i); - Common::strlcpy(target, save.name, SCI_MAX_SAVENAME_LENGTH); + // At least Phant2 requires use of strncpy, since it creates save game + // names of exactly SCI_MAX_SAVENAME_LENGTH + strncpy(target, save.name, SCI_MAX_SAVENAME_LENGTH); saveIds.setFromInt16(i, save.id - kSaveIdShift); } |