@@ -9,6 +9,35 @@ extern void OnKickedFromLobby();
99
1010extern NGMPGame* TheNGMPGame;
1111
12+ namespace
13+ {
14+ std::string ResolveLobbyMapPath (const std::string& relativeMapPath, bool isOfficial)
15+ {
16+ const std::string systemMapPath = std::format (" maps\\ {}" , relativeMapPath);
17+ if (isOfficial)
18+ {
19+ return systemMapPath;
20+ }
21+
22+ // Match retail map-list precedence: an unofficial map packaged under Maps wins an
23+ // ambiguous collision with a map of the same name in the user map directory.
24+ const MapMetaData* systemMapData = TheMapCache->findMap (AsciiString (systemMapPath.c_str ()));
25+ if (systemMapData != nullptr && !systemMapData->m_isOfficial )
26+ {
27+ return systemMapPath;
28+ }
29+
30+ const std::string userMapPath = std::format (" {}\\ {}" , TheMapCache->getUserMapDir (true ).str (), relativeMapPath);
31+ if (TheMapCache->findMap (AsciiString (userMapPath.c_str ())) != nullptr )
32+ {
33+ return userMapPath;
34+ }
35+
36+ // Preserve the existing missing-map path so normal custom-map transfer behavior is unchanged.
37+ return userMapPath;
38+ }
39+ }
40+
1241struct JoinLobbyResponse
1342{
1443 bool success = false ;
@@ -595,15 +624,7 @@ void NGMP_OnlineServices_LobbyInterface::SearchForLobbies(std::function<void()>
595624 }
596625 ++latencyIndex;
597626
598- // correct map path
599- if (lobbyEntry.map_official )
600- {
601- lobbyEntry.map_path = std::format (" maps\\ {}" , lobbyEntry.map_path .c_str ());
602- }
603- else
604- {
605- lobbyEntry.map_path = std::format (" {}\\ {}" , TheMapCache->getUserMapDir (true ).str (), lobbyEntry.map_path .c_str ());
606- }
627+ lobbyEntry.map_path = ResolveLobbyMapPath (lobbyEntry.map_path , lobbyEntry.map_official );
607628
608629 // NOTE: These fields won't be present becauase they're private properties
609630 // memberEntryIter["enc_key"].get_to(strEncKey);
@@ -858,19 +879,7 @@ void NGMP_OnlineServices_LobbyInterface::UpdateRoomDataCache(std::function<void(
858879 // store, we'll need it later and lobby obj gets destroyed on leave
859880 m_CurrentMatchID = lobbyEntry.match_id ;
860881
861- // correct map path
862- if (lobbyEntry.map_official )
863- {
864- lobbyEntry.map_path = std::format (" maps\\ {}" , lobbyEntry.map_path .c_str ());
865- }
866- else
867- {
868- // TODO_NGMP: This needs to match identically, but why did it change from the base game?
869- AsciiString strUserMapDIr = TheMapCache->getUserMapDir (true );
870- strUserMapDIr.toLower ();
871-
872- lobbyEntry.map_path = std::format (" {}\\ {}" , strUserMapDIr.str (), lobbyEntry.map_path .c_str ());
873- }
882+ lobbyEntry.map_path = ResolveLobbyMapPath (lobbyEntry.map_path , lobbyEntry.map_official );
874883
875884 // did the map change? cache that we need to reset and transmit our ready state
876885 bool bNeedsHasMapUpdate = false ;
0 commit comments