* 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
|
@ -43,6 +43,8 @@
|
|||
* itself, thus breaking compatibility with the original version. Who cares anyway?
|
||||
*/
|
||||
|
||||
#define NUM_SAVESLOTS 10
|
||||
#define SPECIAL_SAVESLOT 999
|
||||
|
||||
namespace Parallaction {
|
||||
|
||||
|
@ -75,7 +77,24 @@ public:
|
|||
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) {
|
||||
|
@ -87,17 +106,14 @@ void Parallaction_ns::doLoadGame(uint16 slot) {
|
|||
_introSarcData3 = 200;
|
||||
_introSarcData2 = 1;
|
||||
|
||||
char filename[PATH_LEN];
|
||||
sprintf(filename, "game.%i", slot);
|
||||
|
||||
Common::InSaveFile *f = _saveFileMan->openForLoading(filename);
|
||||
Common::InSaveFile *f = getInSaveFile(slot);
|
||||
if (!f) return;
|
||||
|
||||
char s[30];
|
||||
char s[200];
|
||||
char n[16];
|
||||
char l[16];
|
||||
|
||||
f->readLine(s, 29);
|
||||
f->readLine(s, 199);
|
||||
|
||||
f->readLine(n, 15);
|
||||
|
||||
|
@ -169,24 +185,22 @@ void Parallaction_ns::doLoadGame(uint16 slot) {
|
|||
|
||||
void Parallaction_ns::doSaveGame(uint16 slot, const char* name) {
|
||||
|
||||
char path[PATH_LEN];
|
||||
sprintf(path, "game.%i", slot);
|
||||
|
||||
Common::OutSaveFile *f = _saveFileMan->openForSaving(path);
|
||||
Common::OutSaveFile *f = getOutSaveFile(slot);
|
||||
if (f == 0) {
|
||||
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);
|
||||
dialog.runModal();
|
||||
return;
|
||||
}
|
||||
|
||||
char s[30];
|
||||
char s[200];
|
||||
memset(s, 0, sizeof(s));
|
||||
|
||||
if (!name || name[0] == '\0') {
|
||||
sprintf(s, "default_%i", slot);
|
||||
} else {
|
||||
strncpy(s, name, 29);
|
||||
strncpy(s, name, 199);
|
||||
}
|
||||
|
||||
f->writeString(s);
|
||||
|
@ -327,19 +341,16 @@ void SaveLoadChooser::reflowLayout() {
|
|||
|
||||
int Parallaction_ns::buildSaveFileList(Common::StringList& l) {
|
||||
|
||||
char name[16];
|
||||
char buf[30];
|
||||
char buf[200];
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
sprintf(name, "game.%i", i);
|
||||
|
||||
for (int i = 0; i < NUM_SAVESLOTS; i++) {
|
||||
buf[0] = '\0';
|
||||
Common::InSaveFile *f = _saveFileMan->openForLoading(name);
|
||||
|
||||
Common::InSaveFile *f = getInSaveFile(i);
|
||||
if (f) {
|
||||
f->readLine(buf, 29);
|
||||
f->readLine(buf, 199);
|
||||
delete f;
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue