99#include " MemoryManager.h"
1010
1111static const char * InputsConfigPath = " config/inputs.json" ;
12+ static const char * GTA1MapFileExtension = " .CMP" ;
1213
1314// ////////////////////////////////////////////////////////////////////////
1415
@@ -23,11 +24,45 @@ bool CarnageGame::Initialize()
2324 SetInputActionsFromConfig ();
2425
2526 gGameRules .LoadDefaults ();
27+
28+ // scan all gta1 maps
29+ std::vector<std::string> gtaMapNames;
30+ for (const std::string& currSearchPlace: gFiles .mSearchPlaces )
31+ {
32+ cxx::enum_files (currSearchPlace, [>aMapNames](const std::string& curr)
33+ {
34+ if (cxx::get_file_extension (curr) == GTA1MapFileExtension)
35+ {
36+ gtaMapNames.push_back (curr);
37+ }
38+ });
39+ }
40+
41+ if (gtaMapNames.size ())
42+ {
43+ gConsole .LogMessage (eLogMessage_Info, " Found GTA1 maps:" );
44+ for (const std::string& currMapname: gtaMapNames)
45+ {
46+ gConsole .LogMessage (eLogMessage_Info, " - %s" , currMapname.c_str ());
47+ }
48+ }
49+ else
50+ {
51+ gConsole .LogMessage (eLogMessage_Warning, " No GTA1 maps found within search places" );
52+ }
53+
2654 if (gSystem .mStartupParams .mDebugMapName .empty ())
2755 {
28- gSystem .mStartupParams .mDebugMapName .set_content (" NYC.CMP" );
56+ // try load first found map
57+ if (gtaMapNames.size ())
58+ {
59+ gSystem .mStartupParams .mDebugMapName = gtaMapNames[0 ].c_str ();
60+ }
2961 }
3062
63+ if (gSystem .mStartupParams .mDebugMapName .empty ())
64+ return false ;
65+
3166 gGameMap .LoadFromFile (gSystem .mStartupParams .mDebugMapName .c_str ());
3267 gSpriteManager .Cleanup ();
3368 gRenderManager .mMapRenderer .BuildMapMesh ();
0 commit comments