From 765e37dc2ed7e18b3543fa9d3b52fbd51f41e7cb Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 9 Nov 2008 19:14:39 +0000 Subject: [PATCH] - The save list iterator should now be synced correctly - Numbering of save slots starts from 0 again, not 1 svn-id: r34968 --- gui/launcher.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 76bcf0c3beb..c11cc58ae16 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -483,6 +483,7 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel) // Add choice list _list = new GUI::ListWidget(this, "ScummSaveLoad.List"); + _list->setNumberingMode(GUI::kListNumberingZero); setSaveMode(false); _gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10); @@ -542,7 +543,6 @@ const Common::String &SaveLoadChooser::getResultString() const { void SaveLoadChooser::setSaveMode(bool saveMode) { _list->setEditable(saveMode); - _list->setNumberingMode(GUI::kListNumberingOne); } void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { @@ -752,12 +752,19 @@ void SaveLoadChooser::updateSaveList() { for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) { // Handle gaps in the list of save games saveSlot = atoi(x->save_slot().c_str()); - while (curSlot < saveSlot) { - SaveStateDescriptor dummySave(curSlot, ""); - _saveList.insert_at(curSlot, dummySave); - saveNames.push_back(dummySave.description()); - ++x; // sync the save list iterator - curSlot++; + if (curSlot < saveSlot) { + while (curSlot < saveSlot) { + SaveStateDescriptor dummySave(curSlot, ""); + _saveList.insert_at(curSlot, dummySave); + saveNames.push_back(dummySave.description()); + curSlot++; + } + + // Sync the save list iterator + for (x = _saveList.begin(); x != _saveList.end(); ++x) { + if (atoi(x->save_slot().c_str()) == saveSlot) + break; + } } saveNames.push_back(x->description());