MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / OnPreInitialize

Method OnPreInitialize

Sources/Main.cpp:182–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180};
181
182void GameEventHandler::OnPreInitialize(AppConfiguration& config)
183{
184 ZoneScopedC(0x888888);
185
186#if defined(WITH_MULTIPLAYER) && defined(DEDICATED_SERVER)
187 constexpr bool isServer = true;
188#elif defined(DEATH_TARGET_APPLE) || defined(DEATH_TARGET_UNIX) || (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT))
189 // Allow `/extract-pak` and `/server` only on PC platforms
190 bool isServer = false;
191 for (std::int32_t i = 0; i < config.argc(); i++) {
192 auto arg = config.argv(i);
193 if (arg == "/extract-pak"_s && i + 2 < config.argc()) {
194# if defined(DEATH_TRACE) && defined(DEATH_TARGET_WINDOWS)
195 // Always attach to console in this case
196 theApplication().AttachTraceTarget(Application::ConsoleTarget);
197# endif
198 auto pakFile = config.argv(i + 1);
199 if (fs::FileExists(pakFile)) {
200 ExtractPakFile(pakFile, config.argv(i + 2));
201 } else {
202 LOGE("\"{}\" not found", pakFile);
203 }
204
205 theApplication().Quit();
206 return;
207 }
208# if defined(WITH_MULTIPLAYER) && (!defined(DEATH_TARGET_WINDOWS) || defined(DEATH_DEBUG))
209 if (arg == "/server"_s || arg == "--server"_s) {
210 isServer = true;
211 }
212# endif
213 }
214#else
215 constexpr bool isServer = false;
216#endif
217
218 PreferencesCache::Initialize(config);
219
220 config.windowTitle = NCINE_APP_NAME;
221 if (isServer) {
222 config.withGraphics = false;
223 config.withAudio = false;
224 config.withVSync = false;
225 config.frameLimit = (std::uint32_t)FrameTimer::FramesPerSecond;
226
227 auto& resolver = ContentResolver::Get();
228 resolver.SetHeadless(true);
229 } else {
230 if (PreferencesCache::MaxFps == PreferencesCache::UseVsync) {
231 config.withVSync = true;
232 } else {
233 config.withVSync = false;
234 config.frameLimit = PreferencesCache::MaxFps;
235 }
236#if !defined(DEATH_TARGET_SWITCH)
237 config.resolution.Set(LevelHandler::DefaultWidth, LevelHandler::DefaultHeight);
238#endif
239

Callers

nothing calls this directly

Calls 8

argcMethod · 0.80
argvMethod · 0.80
AttachTraceTargetMethod · 0.80
SetHeadlessMethod · 0.80
GetCachePathMethod · 0.80
QuitMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected