[Scummvm-cvs-logs] SF.net SVN: scummvm: [29820] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Mon Dec 10 21:29:52 CET 2007
Revision: 29820
http://scummvm.svn.sourceforge.net/scummvm/?rev=29820&view=rev
Author: peres001
Date: 2007-12-10 12:29:51 -0800 (Mon, 10 Dec 2007)
Log Message:
-----------
* 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'.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/callables_ns.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/parallaction_ns.cpp
scummvm/trunk/engines/parallaction/saveload.cpp
Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp 2007-12-10 20:19:53 UTC (rev 29819)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp 2007-12-10 20:29:51 UTC (rev 29820)
@@ -392,29 +392,12 @@
const char **v2C = endMsg6;
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();
-
_gfx->setPalette(_gfx->_palette);
- if (gameCompleted) {
+ if (allPartsComplete()) {
_gfx->setFont(_menuFont);
_gfx->displayCenteredString(70, v4C[_language]);
_gfx->displayCenteredString(100, v3C[_language]);
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2007-12-10 20:19:53 UTC (rev 29819)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2007-12-10 20:29:51 UTC (rev 29820)
@@ -29,6 +29,7 @@
#include "common/str.h"
#include "common/stack.h"
#include "common/array.h"
+#include "common/savefile.h"
#include "engines/engine.h"
@@ -685,6 +686,12 @@
private:
void initFonts();
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:
void changeLocation(char *location);
Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp 2007-12-10 20:19:53 UTC (rev 29819)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp 2007-12-10 20:29:51 UTC (rev 29820)
@@ -247,6 +247,7 @@
int Parallaction_ns::go() {
+ renameOldSavefiles();
_globalTable = _disk->loadTable("global");
Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp 2007-12-10 20:19:53 UTC (rev 29819)
+++ scummvm/trunk/engines/parallaction/saveload.cpp 2007-12-10 20:29:51 UTC (rev 29820)
@@ -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,9 +77,26 @@
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) {
_soundMan->stopMusic();
@@ -87,17 +106,14 @@
_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::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 @@
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 @@
}
+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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list