[Scummvm-cvs-logs] SF.net SVN: scummvm:[33915] scummvm/branches/gsoc2008-rtl/engines/sword1

cpage88 at users.sourceforge.net cpage88 at users.sourceforge.net
Fri Aug 15 22:49:57 CEST 2008


Revision: 33915
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33915&view=rev
Author:   cpage88
Date:     2008-08-15 20:49:56 +0000 (Fri, 15 Aug 2008)

Log Message:
-----------
Fixes for Sword1 engine loading from launcher

Modified Paths:
--------------
    scummvm/branches/gsoc2008-rtl/engines/sword1/control.cpp
    scummvm/branches/gsoc2008-rtl/engines/sword1/control.h
    scummvm/branches/gsoc2008-rtl/engines/sword1/sword1.cpp

Modified: scummvm/branches/gsoc2008-rtl/engines/sword1/control.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/sword1/control.cpp	2008-08-15 19:44:17 UTC (rev 33914)
+++ scummvm/branches/gsoc2008-rtl/engines/sword1/control.cpp	2008-08-15 20:49:56 UTC (rev 33915)
@@ -703,7 +703,7 @@
 bool Control::saveToFile(void) {
 	if ((_selectedSavegame == 255) || !strlen((char*)_saveNames[_selectedSavegame]))
 		return false; // no saveslot selected or no name entered
-	saveGameToFile(_selectedSavegame);
+	saveGameToFile(_numSaves);
 	writeSavegameDescriptions();
 	return true;
 }
@@ -741,6 +741,7 @@
 				curFileNum++;
 		} while ((ch != 255) && (!inf->eos()));
 		_saveFiles = curFileNum;
+		_numSaves = _saveFiles;
 	}
 	delete inf;
 }

Modified: scummvm/branches/gsoc2008-rtl/engines/sword1/control.h
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/sword1/control.h	2008-08-15 19:44:17 UTC (rev 33914)
+++ scummvm/branches/gsoc2008-rtl/engines/sword1/control.h	2008-08-15 20:49:56 UTC (rev 33915)
@@ -98,6 +98,7 @@
 	void deselectSaveslots(void);
 	uint8 *_restoreBuf;
 	uint8 _saveFiles;
+	uint8 _numSaves;
 	uint8 _saveScrollPos;
 	uint8 _selectedSavegame;
 	uint8 _saveNames[64][32];

Modified: scummvm/branches/gsoc2008-rtl/engines/sword1/sword1.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/sword1/sword1.cpp	2008-08-15 19:44:17 UTC (rev 33914)
+++ scummvm/branches/gsoc2008-rtl/engines/sword1/sword1.cpp	2008-08-15 20:49:56 UTC (rev 33915)
@@ -199,12 +199,20 @@
 SaveStateList SwordMetaEngine::listSaves(const char *target) const {
 	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
 	SaveStateList saveList;
+
+	Common::String pattern = "SAVEGAME.???";
+	Common::StringList filenames = saveFileMan->listSavefiles(pattern.c_str());
+	sort(filenames.begin(), filenames.end());
+	Common::StringList::const_iterator file = filenames.begin();
+
 	Common::InSaveFile *in = saveFileMan->openForLoading("SAVEGAME.INF");
 	if (in) {
 		uint8 stop;
 		char saveDesc[32];
-		int slotNum = 0;
 		do {
+			// Obtain the last digit of the filename, since they correspond to the save slot
+			int slotNum = atoi(file->c_str() + file->size() - 1);
+
 			uint pos = 0;
 			do {
 				stop = in->readByte();
@@ -218,8 +226,8 @@
 				}
 			} while ((stop != 10) && (stop != 255) && (!in->eos()));
 			if (saveDesc[0] != 0) {
-				saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, "SAVEGAME.INF"));
-				slotNum++;
+				saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file));
+				file++;
 			}
 		} while ((stop != 255) && (!in->eos()));
 	}
@@ -688,7 +696,7 @@
 		int saveSlot = ConfMan.getInt("save_slot");
 		// Savegames are numbered starting from 1 in the dialog window,
 		// but their filenames are numbered starting from 0.
-		if (saveSlot > 0 && _control->restoreGameFromFile(saveSlot - 1)) {
+		if (saveSlot >= 0 && _control->savegamesExist() &&_control->restoreGameFromFile(saveSlot)) {
 			_control->doRestore();
 		} else if (_control->savegamesExist()) {
 			_systemVars.controlPanelMode = CP_NEWGAME;


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