From 80838af4a225a08cda020d9eb77b5023cf51909f Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 28 Jun 2015 09:48:01 -0400 Subject: [PATCH] Work around eFindMap_FuzzyMatch never actually being returned in TF2. --- core/HalfLife2.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 87745032..0f4695b3 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -1252,7 +1252,16 @@ SMFindMapResult CHalfLife2::FindMap(char *pMapName, int nMapNameMax) return SMFindMapResult::FuzzyMatch; } #elif SOURCE_ENGINE == SE_TF2 - return static_cast(engine->FindMap(pMapName, nMapNameMax)); + // Save off name passed in so that we can compare to output. + // There is a bug where eFindMap_FuzzyMap is never returned, even for fuzzy matches. + char *pOriginal = sm_strdup(pMapName); + SMFindMapResult res = static_cast(engine->FindMap(pMapName, nMapNameMax)); + bool bExactMatch = strcmp(pOriginal, pMapName) == 0; + delete [] pOriginal; + if (res == SMFindMapResult::Found && !bExactMatch) + return SMFindMapResult::FuzzyMatch; + else + return res; #else return engine->IsMapValid(pMapName) == 0 ? SMFindMapResult::NotFound : SMFindMapResult::Found; #endif