mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-21 03:31:40 +00:00
STARK: Use the target in the save file name pattern
Saves are incompatible between game versions. Also increase the maximum save slot to 999.
This commit is contained in:
parent
e4bac8c77d
commit
bedf5e2725
@ -304,7 +304,7 @@ public:
|
||||
}
|
||||
|
||||
int getMaximumSaveSlot() const override {
|
||||
return 99;
|
||||
return 999;
|
||||
}
|
||||
|
||||
static bool cmpSave(const SaveStateDescriptor &x, const SaveStateDescriptor &y) {
|
||||
@ -312,15 +312,19 @@ public:
|
||||
}
|
||||
|
||||
SaveStateList listSaves(const char *target) const override {
|
||||
SaveStateList saveList;
|
||||
Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("Save##.tlj");
|
||||
Common::String pattern = Common::String::format("%s-###.tlj", target);
|
||||
Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles(pattern);
|
||||
|
||||
char slot[3];
|
||||
int targetLen = strlen(target);
|
||||
|
||||
SaveStateList saveList;
|
||||
for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
|
||||
// Extract the slot number from the filename
|
||||
slot[0] = filename->c_str()[4];
|
||||
slot[1] = filename->c_str()[5];
|
||||
slot[2] = '\0';
|
||||
char slot[4];
|
||||
slot[0] = (*filename)[targetLen + 1];
|
||||
slot[1] = (*filename)[targetLen + 2];
|
||||
slot[2] = (*filename)[targetLen + 3];
|
||||
slot[3] = '\0';
|
||||
|
||||
// Read the description from the save
|
||||
Common::String description;
|
||||
@ -339,7 +343,7 @@ public:
|
||||
}
|
||||
|
||||
void removeSaveState(const char *target, int slot) const override {
|
||||
Common::String filename = Common::String::format("Save%02d.tlj", slot);
|
||||
Common::String filename = StarkEngine::formatSaveName(target, slot);
|
||||
g_system->getSavefileManager()->removeSavefile(filename);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ StateReadStream::~StateReadStream() {
|
||||
|
||||
Common::String StateReadStream::readString() {
|
||||
// Read the string length
|
||||
uint16 length = readUint32LE();
|
||||
uint32 length = readUint32LE();
|
||||
|
||||
// Read the string
|
||||
char *data = new char[length];
|
||||
|
@ -268,7 +268,7 @@ bool StarkEngine::canLoadGameStateCurrently() {
|
||||
|
||||
Common::Error StarkEngine::loadGameState(int slot) {
|
||||
// Open the save file
|
||||
Common::String filename = Common::String::format("Save%02d.tlj", slot);
|
||||
Common::String filename = formatSaveName(_targetName.c_str(), slot);
|
||||
Common::InSaveFile *save = _saveFileMan->openForLoading(filename);
|
||||
if (!save) {
|
||||
return _saveFileMan->getError();
|
||||
@ -319,7 +319,7 @@ Common::Error StarkEngine::saveGameState(int slot, const Common::String &desc) {
|
||||
_resourceProvider->commitActiveLocationsState();
|
||||
|
||||
// Open the save file
|
||||
Common::String filename = Common::String::format("Save%02d.tlj", slot);
|
||||
Common::String filename = formatSaveName(_targetName.c_str(), slot);
|
||||
Common::OutSaveFile *save = _saveFileMan->openForSaving(filename);
|
||||
if (!save) {
|
||||
return _saveFileMan->getError();
|
||||
@ -360,4 +360,7 @@ bool StarkEngine::isDemo() {
|
||||
return _gameDescription->flags & ADGF_DEMO;
|
||||
}
|
||||
|
||||
Common::String StarkEngine::formatSaveName(const char *target, int slot) {
|
||||
return Common::String::format("%s-%03d.tlj", target, slot);
|
||||
}
|
||||
} // End of namespace Stark
|
||||
|
@ -57,6 +57,9 @@ public:
|
||||
StarkEngine(OSystem *syst, const ADGameDescription *gameDesc);
|
||||
virtual ~StarkEngine();
|
||||
|
||||
/** Build a save file name for the specified target and slot */
|
||||
static Common::String formatSaveName(const char *target, int slot);
|
||||
|
||||
protected:
|
||||
// Engine APIs
|
||||
virtual Common::Error run() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user