MCPcopy Create free account
hub / github.com/ddnet/ddnet / main

Function main

src/engine/client/client.cpp:4626–5037  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4624int SDL_main(int argc, char *argv2[])
4625#else
4626int main(int argc, const char **argv)
4627#endif
4628{
4629 const int64_t MainStart = time_get();
4630
4631#if defined(CONF_PLATFORM_ANDROID)
4632 const char **argv = const_cast<const char **>(argv2);
4633 // Android might not unload the library from memory, causing globals like gs_AndroidStarted
4634 // not to be initialized correctly when starting the app again.
4635 if(gs_AndroidStarted)
4636 {
4637 ShowMessageBoxWithoutGraphics({.m_pTitle = "Android Error", .m_pMessage = "The app was started, but not closed properly, this causes bugs. Please restart or manually close this task."});
4638 std::exit(0);
4639 }
4640 gs_AndroidStarted = true;
4641#elif defined(CONF_FAMILY_WINDOWS)
4642 CWindowsComLifecycle WindowsComLifecycle(true);
4643#endif
4644 CCmdlineFix CmdlineFix(&argc, &argv);
4645
4646 std::vector<std::shared_ptr<ILogger>> vpLoggers;
4647 std::shared_ptr<ILogger> pStdoutLogger = nullptr;
4648#if defined(CONF_PLATFORM_ANDROID)
4649 pStdoutLogger = std::shared_ptr<ILogger>(log_logger_android());
4650#else
4651 bool Silent = false;
4652 for(int i = 1; i < argc; i++)
4653 {
4654 if(str_comp("-s", argv[i]) == 0 || str_comp("--silent", argv[i]) == 0)
4655 {
4656 Silent = true;
4657 }
4658 }
4659 if(!Silent)
4660 {
4661 pStdoutLogger = std::shared_ptr<ILogger>(log_logger_stdout());
4662 }
4663#endif
4664 if(pStdoutLogger)
4665 {
4666 vpLoggers.push_back(pStdoutLogger);
4667 }
4668 std::shared_ptr<CFutureLogger> pFutureFileLogger = std::make_shared<CFutureLogger>();
4669 vpLoggers.push_back(pFutureFileLogger);
4670 std::shared_ptr<CFutureLogger> pFutureConsoleLogger = std::make_shared<CFutureLogger>();
4671 vpLoggers.push_back(pFutureConsoleLogger);
4672 std::shared_ptr<CFutureLogger> pFutureAssertionLogger = std::make_shared<CFutureLogger>();
4673 vpLoggers.push_back(pFutureAssertionLogger);
4674 log_set_global_logger(log_logger_collection(std::move(vpLoggers)).release());
4675
4676#if defined(CONF_PLATFORM_ANDROID)
4677 // Initialize Android after logger is available
4678 const char *pAndroidInitError = InitAndroid();
4679 if(pAndroidInitError != nullptr)
4680 {
4681 log_error("android", "%s", pAndroidInitError);
4682 ShowMessageBoxWithoutGraphics({.m_pTitle = "Android Error", .m_pMessage = pAndroidInitError});
4683 std::exit(0);

Callers

nothing calls this directly

Calls 15

time_getFunction · 0.85
log_logger_androidFunction · 0.85
str_compFunction · 0.85
log_logger_stdoutFunction · 0.85
log_set_global_loggerFunction · 0.85
log_logger_collectionFunction · 0.85
InitAndroidFunction · 0.85
CreateClientFunction · 0.85
dbg_assert_set_handlerFunction · 0.85
os_version_strFunction · 0.85
str_formatFunction · 0.85

Tested by

no test coverage detected