| 3051 | } |
| 3052 | |
| 3053 | void 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 | } |
no test coverage detected