aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2008-09-02 01:58:55 +0000
committerNicola Mettifogo2008-09-02 01:58:55 +0000
commit4ab5d3fdc4c6692c48a3c01d26fffa5bd8f5c335 (patch)
treec154a67d24649af51b89e50779a2a97f4d953576
parent3fef592c205a07a7519132ea2fe602340d18eeed (diff)
parent852bc9dbb750b9995d31e70f4158c97d3758c46f (diff)
downloadscummvm-rg350-4ab5d3fdc4c6692c48a3c01d26fffa5bd8f5c335.tar.gz
scummvm-rg350-4ab5d3fdc4c6692c48a3c01d26fffa5bd8f5c335.tar.bz2
scummvm-rg350-4ab5d3fdc4c6692c48a3c01d26fffa5bd8f5c335.zip
Merging more of the GSoC 2008 RTL branch: PARALLACTION
svn-id: r34268
-rw-r--r--engines/parallaction/detection.cpp38
-rw-r--r--engines/parallaction/exec_ns.cpp5
-rw-r--r--engines/parallaction/gui_br.cpp6
-rw-r--r--engines/parallaction/gui_ns.cpp3
-rw-r--r--engines/parallaction/input.cpp3
-rw-r--r--engines/parallaction/parallaction.cpp10
-rw-r--r--engines/parallaction/parallaction.h6
-rw-r--r--engines/parallaction/parallaction_br.cpp6
-rw-r--r--engines/parallaction/parallaction_ns.cpp8
-rw-r--r--engines/parallaction/saveload.cpp6
10 files changed, 70 insertions, 21 deletions
diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp
index 0476b01454..bde4f7f6d6 100644
--- a/engines/parallaction/detection.cpp
+++ b/engines/parallaction/detection.cpp
@@ -243,9 +243,19 @@ public:
return "Nippon Safes Inc. (C) Dynabyte";
}
+ virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
+ virtual SaveStateList listSaves(const char *target) const;
};
+bool ParallactionMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return
+ (f == kSupportsRTL) ||
+ (f == kSupportsListSaves) ||
+ (f == kSupportsDirectLoad) ||
+ (f == kSupportsDeleteSave);
+}
+
bool ParallactionMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Parallaction::PARALLACTIONGameDescription *gd = (const Parallaction::PARALLACTIONGameDescription *)desc;
bool res = true;
@@ -265,6 +275,34 @@ bool ParallactionMetaEngine::createInstance(OSystem *syst, Engine **engine, cons
return res;
}
+SaveStateList ParallactionMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringList filenames;
+ char saveDesc[200];
+ Common::String pattern = target;
+ pattern += ".0??";
+
+ filenames = saveFileMan->listSavefiles(pattern.c_str());
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ SaveStateList saveList;
+ for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ // Obtain the last 2 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 2);
+
+ if (slotNum >= 0 && slotNum <= 99) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ if (in) {
+ in->readLine(saveDesc, 199);
+ saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file));
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
+}
+
#if PLUGIN_ENABLED_DYNAMIC(PARALLACTION)
REGISTER_PLUGIN_DYNAMIC(PARALLACTION, PLUGIN_TYPE_ENGINE, ParallactionMetaEngine);
#else
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index 7262fc0085..2ce50f498e 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -278,7 +278,8 @@ DECLARE_COMMAND_OPCODE(drop){
DECLARE_COMMAND_OPCODE(quit) {
- _engineFlags |= kEngineQuit;
+ _vm->_quit = true;
+ _vm->quitGame();
}
@@ -356,7 +357,7 @@ void CommandExec::runList(CommandList::iterator first, CommandList::iterator las
_ctxt.suspend = false;
for ( ; first != last; first++) {
- if (_engineFlags & kEngineQuit)
+ if (_vm->quit())
break;
CommandPtr cmd = *first;
diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp
index 4c98cc4634..b0beb5f953 100644
--- a/engines/parallaction/gui_br.cpp
+++ b/engines/parallaction/gui_br.cpp
@@ -167,9 +167,11 @@ class MainMenuInputState_BR : public MenuInputState {
void performChoice(int selectedItem) {
switch (selectedItem) {
- case kMenuQuit:
- _engineFlags |= kEngineQuit;
+ case kMenuQuit: {
+ _vm->_quit = true;
+ _vm->quitGame();
break;
+ }
case kMenuLoadGame:
warning("loadgame not yet implemented");
diff --git a/engines/parallaction/gui_ns.cpp b/engines/parallaction/gui_ns.cpp
index d172c30103..73cc1be12e 100644
--- a/engines/parallaction/gui_ns.cpp
+++ b/engines/parallaction/gui_ns.cpp
@@ -702,7 +702,8 @@ public:
}
if (_isDemo) {
- _engineFlags |= kEngineQuit;
+ _vm->_quit = true;
+ _vm->quitGame();
return 0;
}
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index 98198b88f7..c91421e15e 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -131,8 +131,9 @@ void Input::readInput() {
_mousePos = e.mouse;
break;
+ case Common::EVENT_RTL:
case Common::EVENT_QUIT:
- _engineFlags |= kEngineQuit;
+ _vm->_quit = true;
return;
default:
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index f69e39519c..03464d8a7e 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -121,6 +121,8 @@ int Parallaction::init() {
_location._comment = NULL;
_location._endComment = NULL;
+ _quit = false;
+
_pathBuffer = 0;
_screenSize = _screenWidth * _screenHeight;
@@ -324,7 +326,7 @@ void Parallaction::processInput(int event) {
void Parallaction::runGame() {
int event = _input->updateInput();
- if (_engineFlags & kEngineQuit)
+ if (quit())
return;
runGuiFrame();
@@ -335,7 +337,7 @@ void Parallaction::runGame() {
processInput(event);
runPendingZones();
- if (_engineFlags & kEngineQuit)
+ if (quit())
return;
if (_engineFlags & kEngineChangeLocation) {
@@ -819,7 +821,7 @@ ZonePtr Parallaction::findZone(const char *name) {
void Parallaction::freeZones() {
- debugC(2, kDebugExec, "freeZones: kEngineQuit = %i", _engineFlags & kEngineQuit);
+ debugC(2, kDebugExec, "freeZones: _vm->_quit = %i", _vm->_quit);
ZoneList::iterator it = _location._zones.begin();
@@ -828,7 +830,7 @@ void Parallaction::freeZones() {
// NOTE : this condition has been relaxed compared to the original, to allow the engine
// to retain special - needed - zones that were lost across location switches.
ZonePtr z = *it;
- if (((z->getY() == -1) || (z->getX() == -2)) && ((_engineFlags & kEngineQuit) == 0)) {
+ if (((z->getY() == -1) || (z->getX() == -2)) && (_quit == 0)) {
debugC(2, kDebugExec, "freeZones preserving zone '%s'", z->_name);
it++;
} else {
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index b8464e7c7a..d7add635cd 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -71,7 +71,6 @@ enum {
enum EngineFlags {
- kEngineQuit = (1 << 0),
kEnginePauseJobs = (1 << 1),
kEngineWalking = (1 << 3),
kEngineChangeLocation = (1 << 4),
@@ -276,6 +275,11 @@ public:
ZonePtr _zoneTrap;
ZonePtr _commentZone;
+ bool _quit; /* The only reason this flag exists is for freeZones() to properly
+ * delete all zones when necessary. THIS FLAG IS NOT THE ENGINE QUIT FLAG,
+ * use _eventMan->shouldQuit() for that.
+ */
+
protected:
void runGame();
void runGuiFrame();
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 7c0fa23e15..c2111777fe 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -104,7 +104,7 @@ int Parallaction_br::go() {
bool splash = true;
- while ((_engineFlags & kEngineQuit) == 0) {
+ while (!quit()) {
if (getFeatures() & GF_DEMO) {
scheduleLocationSwitch("camalb.1");
@@ -117,7 +117,7 @@ int Parallaction_br::go() {
// initCharacter();
- while ((_engineFlags & (kEngineReturn | kEngineQuit)) == 0) {
+ while (((_engineFlags & kEngineReturn) == 0) && (!quit())) {
runGame();
}
_engineFlags &= ~kEngineReturn;
@@ -125,7 +125,7 @@ int Parallaction_br::go() {
cleanupGame();
}
- return 0;
+ return _eventMan->shouldRTL();
}
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index 85a4689301..e0c86a4e37 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -231,11 +231,11 @@ int Parallaction_ns::go() {
startGui();
- while ((_engineFlags & kEngineQuit) == 0) {
+ while (!quit()) {
runGame();
}
- return 0;
+ return _eventMan->shouldRTL();
}
void Parallaction_ns::switchBackground(const char* background, const char* mask) {
@@ -440,13 +440,13 @@ void Parallaction_ns::cleanupGame() {
memset(_locationNames, 0, sizeof(_locationNames));
// this flag tells freeZones to unconditionally remove *all* Zones
- _engineFlags |= kEngineQuit;
+ _vm->_quit = true;
freeZones();
freeAnimations();
// this dangerous flag can now be cleared
- _engineFlags &= ~kEngineQuit;
+ _vm->_quit = false;
// main character animation is restored
_location._animations.push_front(_char._ani);
diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp
index 5620001d7d..b59863947e 100644
--- a/engines/parallaction/saveload.cpp
+++ b/engines/parallaction/saveload.cpp
@@ -137,11 +137,11 @@ void SaveLoad_ns::doLoadGame(uint16 slot) {
// TODO (LIST): unify (and parametrize) calls to freeZones.
// We aren't calling freeAnimations because it is not needed, since
// kChangeLocation will trigger a complete deletion. Anyway, we still
- // need to invoke freeZones here with kEngineQuit set, because the
+ // need to invoke freeZones here with _quit set, because the
// call in changeLocation preserve certain zones.
- _engineFlags |= kEngineQuit;
+ _vm->_quit = true;
_vm->freeZones();
- _engineFlags &= ~kEngineQuit;
+ _vm->_quit = false;
_vm->_numLocations = atoi(s);