From efb1d96d98e7bc856522772bbcdb266e11e26a29 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Wed, 4 Jul 2012 02:13:40 +0100 Subject: TEENAGENT: Fix erroneous files in savegame listing. This was achieved by making the detection pattern stricter to avoid matching the dat file or other extraneous files in the savegame path. This fixes bug #3539774 "TEENAGENT : teenagent.dat considered as a savegame". Also did some minor formatting and string function usage cleanup. --- engines/teenagent/detection.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'engines/teenagent') diff --git a/engines/teenagent/detection.cpp b/engines/teenagent/detection.cpp index f516ee06c1..2de6f49c44 100644 --- a/engines/teenagent/detection.cpp +++ b/engines/teenagent/detection.cpp @@ -80,7 +80,7 @@ static const ADGameDescription teenAgentGameDescriptions[] = { }; enum { - MAX_SAVES = 20 + MAX_SAVES = 20 }; class TeenAgentMetaEngine : public AdvancedMetaEngine { @@ -123,16 +123,15 @@ public: virtual SaveStateList listSaves(const char *target) const { Common::String pattern = target; - pattern += ".*"; + pattern += ".??"; Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles(pattern); Common::sort(filenames.begin(), filenames.end()); SaveStateList saveList; for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { - int slot; - const char *ext = strrchr(file->c_str(), '.'); - if (ext && (slot = atoi(ext + 1)) >= 0 && slot < MAX_SAVES) { + int slot = atoi(file->c_str() + file->size() - 2); + if (slot >= 0 && slot < MAX_SAVES) { Common::ScopedPtr in(g_system->getSavefileManager()->openForLoading(*file)); if (!in) continue; -- cgit v1.2.3