* Switched Nippon Safes to use new names for savefiles. User will be asked to perform conversion on engine start.
* Special files used for keeping track of completed parts of the game have been replaced by special savefile 'nippon.999'. svn-id: r29820
This commit is contained in:
parent
32a3b60167
commit
0b0ec8ee00
4 changed files with 138 additions and 39 deletions
|
@ -392,29 +392,12 @@ void Parallaction_ns::_c_finito(void *parm) {
|
||||||
const char **v2C = endMsg6;
|
const char **v2C = endMsg6;
|
||||||
const char **v1C = endMsg7;
|
const char **v1C = endMsg7;
|
||||||
|
|
||||||
Common::File stream;
|
setPartComplete(_char);
|
||||||
|
|
||||||
stream.open(_char.getBaseName(), Common::File::kFileWriteMode);
|
|
||||||
if (stream.isOpen())
|
|
||||||
stream.close();
|
|
||||||
|
|
||||||
Common::File streamDino, streamDough, streamDonna;
|
|
||||||
|
|
||||||
streamDino.open("dino");
|
|
||||||
streamDough.open("dough");
|
|
||||||
streamDonna.open("donna");
|
|
||||||
|
|
||||||
bool gameCompleted = streamDino.isOpen() && streamDough.isOpen() && streamDonna.isOpen();
|
|
||||||
|
|
||||||
streamDino.close();
|
|
||||||
streamDough.close();
|
|
||||||
streamDonna.close();
|
|
||||||
|
|
||||||
cleanInventory();
|
cleanInventory();
|
||||||
|
|
||||||
_gfx->setPalette(_gfx->_palette);
|
_gfx->setPalette(_gfx->_palette);
|
||||||
|
|
||||||
if (gameCompleted) {
|
if (allPartsComplete()) {
|
||||||
_gfx->setFont(_menuFont);
|
_gfx->setFont(_menuFont);
|
||||||
_gfx->displayCenteredString(70, v4C[_language]);
|
_gfx->displayCenteredString(70, v4C[_language]);
|
||||||
_gfx->displayCenteredString(100, v3C[_language]);
|
_gfx->displayCenteredString(100, v3C[_language]);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
#include "common/stack.h"
|
#include "common/stack.h"
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
|
#include "common/savefile.h"
|
||||||
|
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
|
|
||||||
|
@ -685,6 +686,12 @@ public:
|
||||||
private:
|
private:
|
||||||
void initFonts();
|
void initFonts();
|
||||||
void freeFonts();
|
void freeFonts();
|
||||||
|
void renameOldSavefiles();
|
||||||
|
Common::String genSaveFileName(uint slot, bool oldStyle = false);
|
||||||
|
Common::InSaveFile *getInSaveFile(uint slot);
|
||||||
|
Common::OutSaveFile *getOutSaveFile(uint slot);
|
||||||
|
bool allPartsComplete();
|
||||||
|
void setPartComplete(const Character& character);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeLocation(char *location);
|
void changeLocation(char *location);
|
||||||
|
|
|
@ -247,6 +247,7 @@ void Parallaction_ns::callFunction(uint index, void* parm) {
|
||||||
|
|
||||||
|
|
||||||
int Parallaction_ns::go() {
|
int Parallaction_ns::go() {
|
||||||
|
renameOldSavefiles();
|
||||||
|
|
||||||
_globalTable = _disk->loadTable("global");
|
_globalTable = _disk->loadTable("global");
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
* itself, thus breaking compatibility with the original version. Who cares anyway?
|
* itself, thus breaking compatibility with the original version. Who cares anyway?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define NUM_SAVESLOTS 10
|
||||||
|
#define SPECIAL_SAVESLOT 999
|
||||||
|
|
||||||
namespace Parallaction {
|
namespace Parallaction {
|
||||||
|
|
||||||
|
@ -75,7 +77,24 @@ public:
|
||||||
virtual void reflowLayout();
|
virtual void reflowLayout();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Common::String Parallaction_ns::genSaveFileName(uint slot, bool oldStyle) {
|
||||||
|
assert(slot < NUM_SAVESLOTS || slot == SPECIAL_SAVESLOT);
|
||||||
|
|
||||||
|
char s[20];
|
||||||
|
sprintf(s, (oldStyle ? "game.%i" : "nippon.%.3d"), slot );
|
||||||
|
|
||||||
|
return Common::String(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::InSaveFile *Parallaction_ns::getInSaveFile(uint slot) {
|
||||||
|
Common::String name = genSaveFileName(slot);
|
||||||
|
return _saveFileMan->openForLoading(name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::OutSaveFile *Parallaction_ns::getOutSaveFile(uint slot) {
|
||||||
|
Common::String name = genSaveFileName(slot);
|
||||||
|
return _saveFileMan->openForSaving(name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Parallaction_ns::doLoadGame(uint16 slot) {
|
void Parallaction_ns::doLoadGame(uint16 slot) {
|
||||||
|
@ -87,17 +106,14 @@ void Parallaction_ns::doLoadGame(uint16 slot) {
|
||||||
_introSarcData3 = 200;
|
_introSarcData3 = 200;
|
||||||
_introSarcData2 = 1;
|
_introSarcData2 = 1;
|
||||||
|
|
||||||
char filename[PATH_LEN];
|
Common::InSaveFile *f = getInSaveFile(slot);
|
||||||
sprintf(filename, "game.%i", slot);
|
|
||||||
|
|
||||||
Common::InSaveFile *f = _saveFileMan->openForLoading(filename);
|
|
||||||
if (!f) return;
|
if (!f) return;
|
||||||
|
|
||||||
char s[30];
|
char s[200];
|
||||||
char n[16];
|
char n[16];
|
||||||
char l[16];
|
char l[16];
|
||||||
|
|
||||||
f->readLine(s, 29);
|
f->readLine(s, 199);
|
||||||
|
|
||||||
f->readLine(n, 15);
|
f->readLine(n, 15);
|
||||||
|
|
||||||
|
@ -169,24 +185,22 @@ void Parallaction_ns::doLoadGame(uint16 slot) {
|
||||||
|
|
||||||
void Parallaction_ns::doSaveGame(uint16 slot, const char* name) {
|
void Parallaction_ns::doSaveGame(uint16 slot, const char* name) {
|
||||||
|
|
||||||
char path[PATH_LEN];
|
Common::OutSaveFile *f = getOutSaveFile(slot);
|
||||||
sprintf(path, "game.%i", slot);
|
|
||||||
|
|
||||||
Common::OutSaveFile *f = _saveFileMan->openForSaving(path);
|
|
||||||
if (f == 0) {
|
if (f == 0) {
|
||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "Can't save game in slot %i\n\n(%s)", slot, path);
|
sprintf(buf, "Can't save game in slot %i\n\n", slot);
|
||||||
GUI::MessageDialog dialog(buf);
|
GUI::MessageDialog dialog(buf);
|
||||||
dialog.runModal();
|
dialog.runModal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char s[30];
|
char s[200];
|
||||||
|
memset(s, 0, sizeof(s));
|
||||||
|
|
||||||
if (!name || name[0] == '\0') {
|
if (!name || name[0] == '\0') {
|
||||||
sprintf(s, "default_%i", slot);
|
sprintf(s, "default_%i", slot);
|
||||||
} else {
|
} else {
|
||||||
strncpy(s, name, 29);
|
strncpy(s, name, 199);
|
||||||
}
|
}
|
||||||
|
|
||||||
f->writeString(s);
|
f->writeString(s);
|
||||||
|
@ -327,19 +341,16 @@ void SaveLoadChooser::reflowLayout() {
|
||||||
|
|
||||||
int Parallaction_ns::buildSaveFileList(Common::StringList& l) {
|
int Parallaction_ns::buildSaveFileList(Common::StringList& l) {
|
||||||
|
|
||||||
char name[16];
|
char buf[200];
|
||||||
char buf[30];
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < NUM_SAVESLOTS; i++) {
|
||||||
sprintf(name, "game.%i", i);
|
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
Common::InSaveFile *f = _saveFileMan->openForLoading(name);
|
|
||||||
|
|
||||||
|
Common::InSaveFile *f = getInSaveFile(i);
|
||||||
if (f) {
|
if (f) {
|
||||||
f->readLine(buf, 29);
|
f->readLine(buf, 199);
|
||||||
delete f;
|
delete f;
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
@ -411,7 +422,104 @@ bool Parallaction_ns::saveGame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Parallaction_ns::setPartComplete(const Character& character) {
|
||||||
|
char buf[30];
|
||||||
|
bool alreadyPresent = false;
|
||||||
|
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
|
Common::InSaveFile *inFile = getInSaveFile(SPECIAL_SAVESLOT);
|
||||||
|
if (inFile) {
|
||||||
|
inFile->readLine(buf, 29);
|
||||||
|
delete inFile;
|
||||||
|
|
||||||
|
if (strstr(buf, character.getBaseName())) {
|
||||||
|
alreadyPresent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!alreadyPresent) {
|
||||||
|
Common::OutSaveFile *outFile = getOutSaveFile(SPECIAL_SAVESLOT);
|
||||||
|
outFile->writeString(buf);
|
||||||
|
outFile->writeString(character.getBaseName());
|
||||||
|
outFile->finalize();
|
||||||
|
delete outFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Parallaction_ns::allPartsComplete() {
|
||||||
|
char buf[30];
|
||||||
|
|
||||||
|
Common::InSaveFile *inFile = getInSaveFile(SPECIAL_SAVESLOT);
|
||||||
|
inFile->readLine(buf, 29);
|
||||||
|
delete inFile;
|
||||||
|
|
||||||
|
return strstr(buf, "dino") && strstr(buf, "donna") && strstr(buf, "dough");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Parallaction_ns::renameOldSavefiles() {
|
||||||
|
|
||||||
|
bool exists[NUM_SAVESLOTS];
|
||||||
|
uint num = 0;
|
||||||
|
uint i;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_SAVESLOTS; i++) {
|
||||||
|
exists[i] = false;
|
||||||
|
Common::String name = genSaveFileName(i, true);
|
||||||
|
Common::InSaveFile *f = _saveFileMan->openForLoading(name.c_str());
|
||||||
|
if (f) {
|
||||||
|
exists[i] = true;
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
delete f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num == 0) {
|
||||||
|
// there are no old savefiles: nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI::MessageDialog dialog0(
|
||||||
|
"ScummVM found that you have old savefiles for Nippon Safes that should be renamed.\n"
|
||||||
|
"The old names are no longer supported, so you will not be able to load your games if you don't convert them.\n\n"
|
||||||
|
"Press OK to convert them now, otherwise you will be asked you next time.\n", "OK", "Cancel");
|
||||||
|
|
||||||
|
int choice = dialog0.runModal();
|
||||||
|
if (choice == 0) {
|
||||||
|
// user pressed cancel
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint success = 0;
|
||||||
|
for (i = 0; i < NUM_SAVESLOTS; i++) {
|
||||||
|
if (exists[i]) {
|
||||||
|
Common::String oldName = genSaveFileName(i, true);
|
||||||
|
Common::String newName = genSaveFileName(i, false);
|
||||||
|
if (_saveFileMan->renameSavefile(oldName.c_str(), newName.c_str())) {
|
||||||
|
success++;
|
||||||
|
} else {
|
||||||
|
warning("Error %i (%s) occurred while renaming %s to %s", _saveFileMan->getError(),
|
||||||
|
_saveFileMan->getErrorDesc().c_str(), oldName.c_str(), newName.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char msg[200];
|
||||||
|
if (success == num) {
|
||||||
|
sprintf(msg, "ScummVM successfully converted all your savefiles.");
|
||||||
|
} else {
|
||||||
|
sprintf(msg,
|
||||||
|
"ScummVM printed some warnings in your console window and can't guarantee all your files have been converted.\n\n"
|
||||||
|
"Please report to the team.");
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI::MessageDialog dialog1(msg);
|
||||||
|
dialog1.runModal();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Parallaction
|
} // namespace Parallaction
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue