[Scummvm-cvs-logs] SF.net SVN: scummvm:[34268] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Sep 2 03:58:57 CEST 2008


Revision: 34268
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34268&view=rev
Author:   peres001
Date:     2008-09-02 01:58:55 +0000 (Tue, 02 Sep 2008)

Log Message:
-----------
Merging more of the GSoC 2008 RTL branch: PARALLACTION

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/detection.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/gui_br.cpp
    scummvm/trunk/engines/parallaction/gui_ns.cpp
    scummvm/trunk/engines/parallaction/input.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/saveload.cpp

Modified: scummvm/trunk/engines/parallaction/detection.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/detection.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/detection.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -243,9 +243,19 @@
 		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 @@
 	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

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -278,7 +278,8 @@
 
 
 DECLARE_COMMAND_OPCODE(quit) {
-	_engineFlags |= kEngineQuit;
+	_vm->_quit = true;
+	_vm->quitGame();
 }
 
 
@@ -356,7 +357,7 @@
 	_ctxt.suspend = false;
 
 	for ( ; first != last; first++) {
-		if (_engineFlags & kEngineQuit)
+		if (_vm->quit())
 			break;
 
 		CommandPtr cmd = *first;

Modified: scummvm/trunk/engines/parallaction/gui_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_br.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/gui_br.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -167,9 +167,11 @@
 
 	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");

Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -702,7 +702,8 @@
 		}
 
 		if (_isDemo) {
-			_engineFlags |= kEngineQuit;
+			_vm->_quit = true;
+			_vm->quitGame();
 			return 0;
 		}
 

Modified: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/input.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -131,8 +131,9 @@
 			_mousePos = e.mouse;
 			break;
 
+		case Common::EVENT_RTL:
 		case Common::EVENT_QUIT:
-			_engineFlags |= kEngineQuit;
+			_vm->_quit = true;
 			return;
 
 		default:

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -121,6 +121,8 @@
 	_location._comment = NULL;
 	_location._endComment = NULL;
 
+	_quit = false;
+
 	_pathBuffer = 0;
 
 	_screenSize = _screenWidth * _screenHeight;
@@ -324,7 +326,7 @@
 void Parallaction::runGame() {
 
 	int event = _input->updateInput();
-	if (_engineFlags & kEngineQuit)
+	if (quit())
 		return;
 
 	runGuiFrame();
@@ -335,7 +337,7 @@
 		processInput(event);
 		runPendingZones();
 
-		if (_engineFlags & kEngineQuit)
+		if (quit())
 			return;
 
 		if (_engineFlags & kEngineChangeLocation) {
@@ -819,7 +821,7 @@
 
 
 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 @@
 		// 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 {

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-09-02 01:58:55 UTC (rev 34268)
@@ -71,7 +71,6 @@
 
 
 enum EngineFlags {
-	kEngineQuit			= (1 << 0),
 	kEnginePauseJobs	= (1 << 1),
 	kEngineWalking		= (1 << 3),
 	kEngineChangeLocation	= (1 << 4),
@@ -276,6 +275,11 @@
 	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();

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -104,7 +104,7 @@
 
 	bool splash = true;
 
-	while ((_engineFlags & kEngineQuit) == 0) {
+	while (!quit()) {
 
 		if (getFeatures() & GF_DEMO) {
 			scheduleLocationSwitch("camalb.1");
@@ -117,7 +117,7 @@
 
 //		initCharacter();
 
-		while ((_engineFlags & (kEngineReturn | kEngineQuit)) == 0) {
+		while (((_engineFlags & kEngineReturn) == 0) && (!quit())) {
 			runGame();
 		}
 		_engineFlags &= ~kEngineReturn;
@@ -125,7 +125,7 @@
 		cleanupGame();
 	}
 
-	return 0;
+	return _eventMan->shouldRTL();
 }
 
 

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -231,11 +231,11 @@
 
 	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 @@
 	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);

Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp	2008-09-02 00:31:27 UTC (rev 34267)
+++ scummvm/trunk/engines/parallaction/saveload.cpp	2008-09-02 01:58:55 UTC (rev 34268)
@@ -137,11 +137,11 @@
 	// 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);
 


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