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

Method Run

src/engine/client/client.cpp:3053–3423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3051}
3052
3053void CClient::Run()
3054{
3055 m_LocalStartTime = m_GlobalStartTime = time_get();
3056#if defined(CONF_VIDEORECORDER)
3057 IVideo::SetLocalStartTime(m_LocalStartTime);
3058#endif
3059 m_aSnapshotParts[0] = 0;
3060 m_aSnapshotParts[1] = 0;
3061
3062 if(m_GenerateTimeoutSeed)
3063 {
3064 GenerateTimeoutSeed();
3065 }
3066
3067 unsigned int Seed;
3068 secure_random_fill(&Seed, sizeof(Seed));
3069 srand(Seed);
3070
3071 if(g_Config.m_Debug)
3072 {
3073 g_UuidManager.DebugDump();
3074 }
3075
3076 char aNetworkError[256];
3077 if(!InitNetworkClient(aNetworkError, sizeof(aNetworkError)))
3078 {
3079 log_error("client", "%s", aNetworkError);
3080 ShowMessageBox({.m_pTitle = "Network Error", .m_pMessage = aNetworkError});
3081 return;
3082 }
3083
3084 if(!m_Http.Init(std::chrono::seconds{1}))
3085 {
3086 const char *pErrorMessage = "Failed to initialize the HTTP client.";
3087 log_error("client", "%s", pErrorMessage);
3088 ShowMessageBox({.m_pTitle = "HTTP Error", .m_pMessage = pErrorMessage});
3089 return;
3090 }
3091
3092 // init graphics
3093 m_pGraphics = CreateEngineGraphicsThreaded();
3094 Kernel()->RegisterInterface(m_pGraphics); // IEngineGraphics
3095 Kernel()->RegisterInterface(static_cast<IGraphics *>(m_pGraphics), false);
3096 {
3097 CMemoryLogger MemoryLogger;
3098 MemoryLogger.SetParent(log_get_scope_logger());
3099 bool Success;
3100 {
3101 CLogScope LogScope(&MemoryLogger);
3102 Success = m_pGraphics->Init() == 0;
3103 }
3104 if(!Success)
3105 {
3106 log_error("client", "Failed to initialize the graphics (see details above)");
3107 std::string Message = std::string("Failed to initialize the graphics. See details below.\n\n") + MemoryLogger.ConcatenatedLines();
3108 ShowMessageBox({.m_pTitle = "Graphics Error", .m_pMessage = Message.c_str()});
3109 return;
3110 }

Callers 4

FetchFileMethod · 0.45
ProcessServerPacketMethod · 0.45
mainFunction · 0.45
RequestDDNetInfoMethod · 0.45

Calls 15

time_getFunction · 0.85
secure_random_fillFunction · 0.85
log_get_scope_loggerFunction · 0.85
GraphicsFunction · 0.85
InputFunction · 0.85
str_formatFunction · 0.85
LocalizeFunction · 0.85
time_get_nanosecondsFunction · 0.85
set_new_tickFunction · 0.85
str_startswithFunction · 0.85
str_endswithFunction · 0.85

Tested by

no test coverage detected