| 20 | { |
| 21 | |
| 22 | void 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 | |
| 75 | void StartupMapLoader::loadMapSafe(const std::string& mapToLoad) |
| 76 | { |
nothing calls this directly
no test coverage detected