MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ParseCommandLine

Method ParseCommandLine

apps/cwr/GameBase/GameBase.cpp:50–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 std::printf("mod_names=%s\n", (const char*)Poseidon::ModSystem::GetModNames());
49 std::printf("mod_paths=%s\n", (const char*)Poseidon::ModSystem::GetModList());
50}
51} // namespace
52
53bool GameBase::InitializeMemorySystem()
54{
55 SetMemorySystemReady(true);
56
57 // Embed version string in binary for identification with tools like 'strings'
58 const char* volatile version = "VersionMapID" APP_VERSION_TEXT;
59 (void)version;
60
61 // ParamFile registration hooks + Poseidon-layer default callbacks. InitDefaults
62 // runs after dynamic init so it wins over any cross-library SIOF clobber.
63 InitLibraryElement();
64 Poseidon::InitDefaults();
65
66 LOG_DEBUG(Memory, "Memory system initialized");
67 return true;
68}
69
70bool GameBase::ParseCommandLine(const char* commandLine)
71{
72 m_commandLine = commandLine;
73
74 if (m_argc > 0 && m_argv)
75 {
76 AppConfig::Instance().ParseCommandLine(m_argc, m_argv);
77 }
78#ifdef _WIN32
79 else
80 {
81 // __argc / __argv are MSVC-specific globals available on Windows.
82 extern int __argc;
83 extern char** __argv;
84 AppConfig::Instance().ParseCommandLine(__argc, __argv);
85 }
86#endif
87
88 // Working directory change (-C) before any path resolution.
89 const std::string& workDir = AppConfig::Instance().GetWorkingDirectory();
90 if (!workDir.empty())
91 {
92#ifdef _WIN32
93 if (!SetCurrentDirectory(workDir.c_str()))
94#else
95 if (chdir(workDir.c_str()) != 0)
96#endif
97 {
98 LOG_ERROR(Core, "Failed to change working directory to: {}", workDir);
99 m_startupExitCode = 2;
100 return false;
101 }
102 }
103
104 // Logging early (after CLI parsing).
105 GetLoggingSystem().InitializeFromConfig(LogDomain());
106
107 if (AppConfig::Instance().HasParseFatalError())

Callers

nothing calls this directly

Calls 15

InitGlobalTaskPoolFunction · 0.85
GetGlobalTaskPoolFunction · 0.85
EnableFunction · 0.85
InstallCrashHandlerFunction · 0.85
InitCapsLockFunction · 0.85
InitializeFromConfigMethod · 0.80
HasParseFatalErrorMethod · 0.80
GetParseFatalExitCodeMethod · 0.80
GetMaxThreadsMethod · 0.80
ThreadCountMethod · 0.80

Tested by

no test coverage detected