[Scummvm-cvs-logs] SF.net SVN: scummvm: [29112] scummvm/trunk/engines/touche

cyx at users.sourceforge.net cyx at users.sourceforge.net
Thu Sep 27 22:38:23 CEST 2007


Revision: 29112
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29112&view=rev
Author:   cyx
Date:     2007-09-27 13:38:23 -0700 (Thu, 27 Sep 2007)

Log Message:
-----------
simplified touche savegame listing

Modified Paths:
--------------
    scummvm/trunk/engines/touche/menu.cpp
    scummvm/trunk/engines/touche/saveload.cpp
    scummvm/trunk/engines/touche/touche.cpp
    scummvm/trunk/engines/touche/touche.h

Modified: scummvm/trunk/engines/touche/menu.cpp
===================================================================
--- scummvm/trunk/engines/touche/menu.cpp	2007-09-27 20:38:04 UTC (rev 29111)
+++ scummvm/trunk/engines/touche/menu.cpp	2007-09-27 20:38:23 UTC (rev 29112)
@@ -92,8 +92,7 @@
 	uint buttonsCount;
 	bool quit;
 	bool exit;
-	bool saveLoadMarks[100];
-	char saveLoadDescriptionsTable[100][33];
+	char saveLoadDescriptionsTable[kMaxSaveStates][33];
 
 	void removeLastCharFromDescription(int slot) {
 		char *description = saveLoadDescriptionsTable[slot];
@@ -370,36 +369,15 @@
 				setupMenu(menuData.mode, &menuData);
 				curMode = menuData.mode;
 				if (menuData.mode == kMenuLoadStateMode || menuData.mode == kMenuSaveStateMode) {
-					assert(menuData.saveLoadMarks);
-
+					for (int i = 0; i < kMaxSaveStates; ++i) {
+						menuData.saveLoadDescriptionsTable[i][0] = 0;
+					}
 					char gameStateFileName[16];
 					generateGameStateFileName(999, gameStateFileName, 15, true);
-					char slot[2];
-					int slotNum;
-					Common::StringList filenames;
-
-					memset(menuData.saveLoadMarks, false, 100 * sizeof(bool));	//assume no savegames for this title
-					filenames = _saveFileMan->listSavefiles(gameStateFileName);
-
-					for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++){
-						//Obtain the last 1 or 2 digits of the filename, since they correspond to the save slot
-						//This engine can save games either with one or two digits, hence the additional if statement
-						slot[0] = file->c_str()[file->size()-2];
-						slot[1] = file->c_str()[file->size()-1];
-
-						if (!atoi(&slot[0])){
-							slotNum = atoi(&slot[1]);
-						} else {
-							slotNum = atoi(slot);
-						}
-
-						if (slotNum >= 0 && slotNum < 100)
-							menuData.saveLoadMarks[slotNum] = true;	//mark this slot as valid
-					}
-
-					for (int i = 0; i < 100; ++i) {
-						menuData.saveLoadDescriptionsTable[i][0] = 0;
-						if (menuData.saveLoadMarks[i]) {
+					Common::StringList filenames = _saveFileMan->listSavefiles(gameStateFileName);
+					for (Common::StringList::const_iterator it = filenames.begin(); it != filenames.end(); ++it) {
+						int i = getGameStateFileSlot(it->c_str());
+						if (i >= 0 && i < kMaxSaveStates) {
 							readGameStateDescription(i, menuData.saveLoadDescriptionsTable[i], 32);
 						}
 					}

Modified: scummvm/trunk/engines/touche/saveload.cpp
===================================================================
--- scummvm/trunk/engines/touche/saveload.cpp	2007-09-27 20:38:04 UTC (rev 29111)
+++ scummvm/trunk/engines/touche/saveload.cpp	2007-09-27 20:38:23 UTC (rev 29112)
@@ -407,4 +407,13 @@
 	dst[len] = 0;
 }
 
+int ToucheEngine::getGameStateFileSlot(const char *filename) const {
+	int i = -1;
+	const char *slot = strrchr(filename, '.');
+	if (slot) {
+		i = atoi(slot + 1);
+	}
+	return i;
+}
+
 } // namespace Touche

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2007-09-27 20:38:04 UTC (rev 29111)
+++ scummvm/trunk/engines/touche/touche.cpp	2007-09-27 20:38:23 UTC (rev 29112)
@@ -74,7 +74,7 @@
 	Common::addSpecialDebugLevel(kDebugOpcodes,  "Opcodes",  "Opcodes debug level");
 	Common::addSpecialDebugLevel(kDebugMenu,     "Menu",     "Menu debug level");
 
-	system->getEventManager()->registerRandomSource(_rnd, "touche");
+	_eventMan->registerRandomSource(_rnd, "touche");
 }
 
 ToucheEngine::~ToucheEngine() {

Modified: scummvm/trunk/engines/touche/touche.h
===================================================================
--- scummvm/trunk/engines/touche/touche.h	2007-09-27 20:38:04 UTC (rev 29111)
+++ scummvm/trunk/engines/touche/touche.h	2007-09-27 20:38:23 UTC (rev 29112)
@@ -327,7 +327,8 @@
 	kCursorWidth = 58,
 	kCursorHeight = 42,
 	kTextHeight = 16,
-	kMaxProgramDataSize = 61440
+	kMaxProgramDataSize = 61440,
+	kMaxSaveStates = 100
 };
 
 class MidiPlayer;
@@ -490,6 +491,7 @@
 	bool loadGameState(int num);
 	void readGameStateDescription(int num, char *description, int len);
 	void generateGameStateFileName(int num, char *dst, int len, bool prefixOnly = false) const;
+	int getGameStateFileSlot(const char *filename) const;
 
 	void setupOpcodes();
 	void op_nop();


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