MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / onMainFrameReady

Method onMainFrameReady

radiant/map/StartupMapLoader.cpp:22–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20{
21
22void StartupMapLoader::onMainFrameReady()
23{
24 std::string mapToLoad = "";
25
26 const auto& args(
27 module::GlobalModuleRegistry().getApplicationContext().getCmdLineArgs()
28 );
29
30 for (const std::string& candidate : args)
31 {
32 if (os::getExtension(candidate) != "map" &&
33 os::getExtension(candidate) != "mapx") continue;
34
35 // We have a map file, check if it exists (and where)
36
37 // First, look if we have an absolute map path
38 if (os::fileOrDirExists(candidate))
39 {
40 mapToLoad = candidate;
41 break;
42 }
43
44 fs::path mapsPath = GlobalGameManager().getMapPath();
45
46 fs::path fullMapPath = mapsPath / candidate;
47
48 // Next, look in the regular maps path
49 if (os::fileOrDirExists(fullMapPath.string()))
50 {
51 mapToLoad = fullMapPath.string();
52 break;
53 }
54 }
55
56 if (!mapToLoad.empty())
57 {
58 loadMapSafe(mapToLoad);
59 }
60 else if (registry::getValue<bool>(RKEY_LOAD_LAST_MAP))
61 {
62 std::string lastMap = GlobalMRU().getLastMapName();
63
64 if (!lastMap.empty() && os::fileOrDirExists(lastMap))
65 {
66 loadMapSafe(lastMap);
67 }
68 }
69 else
70 {
71 GlobalMapModule().createNewMap();
72 }
73}
74
75void StartupMapLoader::loadMapSafe(const std::string& mapToLoad)
76{

Callers

nothing calls this directly

Calls 6

getExtensionFunction · 0.85
fileOrDirExistsFunction · 0.85
stringMethod · 0.80
getLastMapNameMethod · 0.80
createNewMapMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected