| 1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
| 2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
| 3 | #ifndef ENGINE_CLIENT_CLIENT_H |
| 4 | #define ENGINE_CLIENT_CLIENT_H |
| 5 | |
| 6 | #include "graph.h" |
| 7 | #include "smooth_time.h" |
| 8 | |
| 9 | #include <base/hash.h> |
| 10 | #include <base/types.h> |
| 11 | |
| 12 | #include <engine/client.h> |
| 13 | #include <engine/client/checksum.h> |
| 14 | #include <engine/client/friends.h> |
| 15 | #include <engine/client/ghost.h> |
| 16 | #include <engine/client/serverbrowser.h> |
| 17 | #include <engine/client/updater.h> |
| 18 | #include <engine/editor.h> |
| 19 | #include <engine/graphics.h> |
| 20 | #include <engine/shared/config.h> |
| 21 | #include <engine/shared/demo.h> |
| 22 | #include <engine/shared/fifo.h> |
| 23 | #include <engine/shared/http.h> |
| 24 | #include <engine/shared/network.h> |
| 25 | #include <engine/textrender.h> |
| 26 | #include <engine/warning.h> |
| 27 | |
| 28 | #include <chrono> |
| 29 | #include <deque> |
| 30 | #include <memory> |
| 31 | #include <mutex> |
| 32 | |
| 33 | class CDemoEdit; |
| 34 | class IDemoRecorder; |
| 35 | class CMsgPacker; |
| 36 | class CUnpacker; |
| 37 | class IConfigManager; |
| 38 | class IDiscord; |
| 39 | class IEngine; |
| 40 | class IEngineInput; |
| 41 | class IEngineMap; |
| 42 | class IEngineSound; |
| 43 | class IFriends; |
| 44 | class ILogger; |
| 45 | class ISteam; |
| 46 | class INotifications; |
| 47 | class IStorage; |
| 48 | class IUpdater; |
| 49 | |
| 50 | class CServerCapabilities |
| 51 | { |
| 52 | public: |
| 53 | bool m_ChatTimeoutCode = false; |
| 54 | bool m_AnyPlayerFlag = false; |
| 55 | bool m_PingEx = false; |
| 56 | bool m_AllowDummy = false; |
| 57 | bool m_SyncWeaponInput = false; |
| 58 | }; |
| 59 | |
| 60 | class CClient : public IClient, public CDemoPlayer::IListener |
| 61 | { |
| 62 | // needed interfaces |
| 63 | IConfigManager *m_pConfigManager = nullptr; |
| 64 | CConfig *m_pConfig = nullptr; |
| 65 | IConsole *m_pConsole = nullptr; |
| 66 | IDiscord *m_pDiscord = nullptr; |
| 67 | IEditor *m_pEditor = nullptr; |
| 68 | IEngine *m_pEngine = nullptr; |
| 69 | IFavorites *m_pFavorites = nullptr; |
| 70 | IGameClient *m_pGameClient = nullptr; |
| 71 | IEngineGraphics *m_pGraphics = nullptr; |
| 72 | IEngineInput *m_pInput = nullptr; |
| 73 | IEngineMap *m_pMap = nullptr; |
| 74 | IEngineSound *m_pSound = nullptr; |
| 75 | ISteam *m_pSteam = nullptr; |
| 76 | INotifications *m_pNotifications = nullptr; |
| 77 | IStorage *m_pStorage = nullptr; |
| 78 | IEngineTextRender *m_pTextRender = nullptr; |
| 79 | IUpdater *m_pUpdater = nullptr; |
| 80 | CHttp m_Http; |
| 81 | |
| 82 | CNetClient m_aNetClient[NUM_CONNS]; |
| 83 | CDemoPlayer m_DemoPlayer; |
| 84 | CDemoRecorder m_aDemoRecorder[RECORDER_MAX]; |
| 85 | CDemoEditor m_DemoEditor; |
| 86 | CGhostRecorder m_GhostRecorder; |
| 87 | CGhostLoader m_GhostLoader; |
| 88 | CServerBrowser m_ServerBrowser; |
| 89 | CUpdater m_Updater; |
| 90 | CFriends m_Friends; |
| 91 | CFriends m_Foes; |
| 92 | |
| 93 | char m_aConnectAddressStr[MAX_SERVER_ADDRESSES * NETADDR_MAXSTRSIZE] = "" ; |
| 94 | |
| 95 | CUuid m_ConnectionId = UUID_ZEROED; |
| 96 | bool m_Sixup; |
| 97 | |
| 98 | bool m_HaveGlobalTcpAddr = false; |
| 99 | NETADDR m_GlobalTcpAddr = NETADDR_ZEROED; |
| 100 | |
| 101 | uint64_t m_aSnapshotParts[NUM_DUMMIES] = {0, 0}; |
| 102 | int64_t m_LocalStartTime = 0; |
| 103 | int64_t m_GlobalStartTime = 0; |
| 104 | |
| 105 | IGraphics::CTextureHandle m_DebugFont; |
| 106 | |
| 107 | int64_t m_LastRenderTime; |
| 108 | |
| 109 | int m_SnapCrcErrors = 0; |
| 110 | bool m_AutoScreenshotRecycle = false; |
| 111 | bool m_AutoStatScreenshotRecycle = false; |
| 112 | bool m_AutoCSVRecycle = false; |
| 113 | bool m_EditorActive = false; |
| 114 | |
| 115 | int m_aAckGameTick[NUM_DUMMIES] = {-1, -1}; |
| 116 | int m_aCurrentRecvTick[NUM_DUMMIES] = {0, 0}; |
| 117 | int m_aRconAuthed[NUM_DUMMIES] = {0, 0}; |
| 118 | char m_aRconUsername[64] = "" ; |
| 119 | char m_aRconPassword[sizeof(g_Config.m_SvRconPassword)] = "" ; |
| 120 | int m_UseTempRconCommands = 0; |
| 121 | int m_ExpectedRconCommands = -1; |
| 122 | int m_GotRconCommands = 0; |
| 123 | char m_aPassword[sizeof(g_Config.m_Password)] = "" ; |
| 124 | bool m_SendPassword = false; |
| 125 | |
| 126 | int m_ExpectedMaplistEntries = -1; |
| 127 | std::vector<std::string> m_vMaplistEntries; |
| 128 | |
| 129 | // version-checking |
| 130 | char m_aVersionStr[10] = "0" ; |
| 131 | |
| 132 | // pinging |
| 133 | int64_t m_PingStartTime = 0; |
| 134 | |
| 135 | char m_aCurrentMap[IO_MAX_PATH_LENGTH] = "" ; |
| 136 | char m_aCurrentMapPath[IO_MAX_PATH_LENGTH] = "" ; |
| 137 | |
| 138 | char m_aTimeoutCodes[NUM_DUMMIES][32] = {"" , "" }; |
| 139 | bool m_aDidPostConnect[NUM_DUMMIES] = {false, false}; |
| 140 | bool m_GenerateTimeoutSeed = true; |
| 141 | |
| 142 | char m_aCmdConnect[256] = "" ; |
| 143 | char m_aCmdPlayDemo[IO_MAX_PATH_LENGTH] = "" ; |
| 144 | char m_aCmdEditMap[IO_MAX_PATH_LENGTH] = "" ; |
| 145 | |
| 146 | // map download |
| 147 | char m_aMapDownloadUrl[256] = "" ; |
| 148 | std::shared_ptr<CHttpRequest> m_pMapdownloadTask = nullptr; |
| 149 | char m_aMapdownloadFilename[256] = "" ; |
| 150 | char m_aMapdownloadFilenameTemp[256] = "" ; |
| 151 | char m_aMapdownloadName[256] = "" ; |
| 152 | IOHANDLE m_MapdownloadFileTemp = nullptr; |
| 153 | int m_MapdownloadChunk = 0; |
| 154 | int m_MapdownloadCrc = 0; |
| 155 | int m_MapdownloadAmount = -1; |
| 156 | int m_MapdownloadTotalsize = -1; |
| 157 | bool m_MapdownloadSha256Present = false; |
| 158 | SHA256_DIGEST m_MapdownloadSha256 = SHA256_ZEROED; |
| 159 | |
| 160 | bool m_MapDetailsPresent = false; |
| 161 | char m_aMapDetailsName[256] = "" ; |
| 162 | int m_MapDetailsCrc = 0; |
| 163 | SHA256_DIGEST m_MapDetailsSha256 = SHA256_ZEROED; |
| 164 | char m_aMapDetailsUrl[256] = "" ; |
| 165 | |
| 166 | EInfoState m_InfoState = EInfoState::ERROR; |
| 167 | std::shared_ptr<CHttpRequest> m_pDDNetInfoTask = nullptr; |
| 168 | |
| 169 | // time |
| 170 | CSmoothTime m_aGameTime[NUM_DUMMIES]; |
| 171 | CSmoothTime m_PredictedTime; |
| 172 | |
| 173 | // input |
| 174 | struct // TODO: handle input better |
| 175 | { |
| 176 | int m_aData[MAX_INPUT_SIZE]; // the input data |
| 177 | int m_Tick; // the tick that the input is for |
| 178 | int64_t m_PredictedTime; // prediction latency when we sent this input |
| 179 | int64_t m_PredictionMargin; // prediction margin when we sent this input |
| 180 | int64_t m_Time; |
| 181 | } m_aInputs[NUM_DUMMIES][200]; |
| 182 | |
| 183 | int m_aCurrentInput[NUM_DUMMIES] = {0, 0}; |
| 184 | bool m_LastDummy = false; |
| 185 | bool m_DummySendConnInfo = false; |
| 186 | bool m_DummyConnecting = false; |
| 187 | bool m_DummyConnected = false; |
| 188 | float m_LastDummyConnectTime = 0.0f; |
| 189 | bool m_DummyReconnectOnReload = false; |
| 190 | bool m_DummyDeactivateOnReconnect = false; |
| 191 | |
| 192 | // graphs |
| 193 | CGraph m_InputtimeMarginGraph; |
| 194 | CGraph m_aGametimeMarginGraphs[NUM_DUMMIES]; |
| 195 | CGraph m_FpsGraph; |
| 196 | |
| 197 | // the game snapshots are modifiable by the game |
| 198 | CSnapshotStorage m_aSnapshotStorage[NUM_DUMMIES]; |
| 199 | CSnapshotStorage::CHolder *m_aapSnapshots[NUM_DUMMIES][NUM_SNAPSHOT_TYPES]; |
| 200 | |
| 201 | int m_aReceivedSnapshots[NUM_DUMMIES] = {0, 0}; |
| 202 | char m_aaSnapshotIncomingData[NUM_DUMMIES][CSnapshot::MAX_SIZE]; |
| 203 | int m_aSnapshotIncomingDataSize[NUM_DUMMIES] = {0, 0}; |
| 204 | |
| 205 | CSnapshotStorage::CHolder m_aDemorecSnapshotHolders[NUM_SNAPSHOT_TYPES]; |
| 206 | char m_aaaDemorecSnapshotData[NUM_SNAPSHOT_TYPES][2][CSnapshot::MAX_SIZE]; |
| 207 | |
| 208 | CSnapshotDelta m_SnapshotDelta; |
| 209 | |
| 210 | std::deque<std::shared_ptr<CDemoEdit>> m_EditJobs; |
| 211 | |
| 212 | // |
| 213 | bool m_CanReceiveServerCapabilities = false; |
| 214 | bool m_ServerSentCapabilities = false; |
| 215 | CServerCapabilities m_ServerCapabilities; |
| 216 | |
| 217 | bool ServerCapAnyPlayerFlag() const override { return m_ServerCapabilities.m_AnyPlayerFlag; } |
| 218 | |
| 219 | CServerInfo m_CurrentServerInfo; |
| 220 | int64_t m_CurrentServerInfoRequestTime = -1; // >= 0 should request, == -1 got info |
| 221 | |
| 222 | int m_CurrentServerPingInfoType = -1; |
| 223 | int m_CurrentServerPingBasicToken = -1; |
| 224 | int m_CurrentServerPingToken = -1; |
| 225 | CUuid m_CurrentServerPingUuid = UUID_ZEROED; |
| 226 | int64_t m_CurrentServerCurrentPingTime = -1; // >= 0 request running |
| 227 | int64_t m_CurrentServerNextPingTime = -1; // >= 0 should request |
| 228 | |
| 229 | // version info |
| 230 | struct CVersionInfo |
| 231 | { |
| 232 | enum |
| 233 | { |
| 234 | STATE_INIT = 0, |
| 235 | STATE_START, |
| 236 | STATE_READY, |
| 237 | }; |
| 238 | |
| 239 | int m_State = STATE_INIT; |
| 240 | } m_VersionInfo; |
| 241 | |
| 242 | std::mutex m_WarningsMutex; |
| 243 | std::vector<SWarning> m_vWarnings; |
| 244 | std::vector<SWarning> m_vQuittingWarnings; |
| 245 | |
| 246 | CFifo m_Fifo; |
| 247 | |
| 248 | IOHANDLE m_BenchmarkFile = nullptr; |
| 249 | int64_t m_BenchmarkStopTime = 0; |
| 250 | |
| 251 | CChecksum m_Checksum; |
| 252 | int64_t m_OwnExecutableSize = 0; |
| 253 | IOHANDLE m_OwnExecutable = nullptr; |
| 254 | |
| 255 | // favorite command handling |
| 256 | bool m_FavoritesGroup = false; |
| 257 | bool m_FavoritesGroupAllowPing = false; |
| 258 | int m_FavoritesGroupNum = 0; |
| 259 | NETADDR m_aFavoritesGroupAddresses[MAX_SERVER_ADDRESSES]; |
| 260 | |
| 261 | void UpdateDemoIntraTimers(); |
| 262 | int MaxLatencyTicks() const; |
| 263 | int PredictionMargin() const; |
| 264 | |
| 265 | std::shared_ptr<ILogger> m_pFileLogger = nullptr; |
| 266 | std::shared_ptr<ILogger> m_pStdoutLogger = nullptr; |
| 267 | |
| 268 | // For RenderDebug function |
| 269 | NETSTATS m_NetstatsPrev = {}; |
| 270 | NETSTATS m_NetstatsCurrent = {}; |
| 271 | std::chrono::nanoseconds m_NetstatsLastUpdate = std::chrono::nanoseconds(0); |
| 272 | |
| 273 | // For DummyName function |
| 274 | char m_aAutomaticDummyName[MAX_NAME_LENGTH]; |
| 275 | |
| 276 | public: |
| 277 | IConfigManager *ConfigManager() { return m_pConfigManager; } |
| 278 | CConfig *Config() { return m_pConfig; } |
| 279 | IDiscord *Discord() { return m_pDiscord; } |
| 280 | IEngine *Engine() { return m_pEngine; } |
| 281 | IGameClient *GameClient() { return m_pGameClient; } |
| 282 | IEngineGraphics *Graphics() { return m_pGraphics; } |
| 283 | IEngineInput *Input() { return m_pInput; } |
| 284 | IEngineSound *Sound() { return m_pSound; } |
| 285 | ISteam *Steam() { return m_pSteam; } |
| 286 | INotifications *Notifications() { return m_pNotifications; } |
| 287 | IStorage *Storage() { return m_pStorage; } |
| 288 | IEngineTextRender *TextRender() { return m_pTextRender; } |
| 289 | IUpdater *Updater() { return m_pUpdater; } |
| 290 | IHttp *Http() { return &m_Http; } |
| 291 | |
| 292 | CClient(); |
| 293 | |
| 294 | // ----- send functions ----- |
| 295 | int SendMsg(int Conn, CMsgPacker *pMsg, int Flags) override; |
| 296 | // Send via the currently active client (main/dummy) |
| 297 | int SendMsgActive(CMsgPacker *pMsg, int Flags) override; |
| 298 | |
| 299 | void SendInfo(int Conn); |
| 300 | void SendEnterGame(int Conn); |
| 301 | void SendReady(int Conn); |
| 302 | void SendMapRequest(); |
| 303 | |
| 304 | bool RconAuthed() const override { return m_aRconAuthed[g_Config.m_ClDummy] != 0; } |
| 305 | bool UseTempRconCommands() const override { return m_UseTempRconCommands != 0; } |
| 306 | void RconAuth(const char *pName, const char *pPassword, bool Dummy = g_Config.m_ClDummy) override; |
| 307 | void Rcon(const char *pCmd) override; |
| 308 | bool ReceivingRconCommands() const override { return m_ExpectedRconCommands > 0; } |
| 309 | float GotRconCommandsPercentage() const override; |
| 310 | bool ReceivingMaplist() const override { return m_ExpectedMaplistEntries > 0; } |
| 311 | float GotMaplistPercentage() const override; |
| 312 | const std::vector<std::string> &MaplistEntries() const override { return m_vMaplistEntries; } |
| 313 | |
| 314 | bool ConnectionProblems() const override; |
| 315 | |
| 316 | IGraphics::CTextureHandle GetDebugFont() const override { return m_DebugFont; } |
| 317 | |
| 318 | void SendInput(); |
| 319 | |
| 320 | // TODO: OPT: do this a lot smarter! |
| 321 | int *GetInput(int Tick, int IsDummy) const override; |
| 322 | |
| 323 | const char *LatestVersion() const override; |
| 324 | |
| 325 | // ------ state handling ----- |
| 326 | void SetState(EClientState State); |
| 327 | |
| 328 | // called when the map is loaded and we should init for a new round |
| 329 | void OnEnterGame(bool Dummy); |
| 330 | void EnterGame(int Conn) override; |
| 331 | |
| 332 | // called once after being ingame for 1 second |
| 333 | void OnPostConnect(int Conn); |
| 334 | |
| 335 | void Connect(const char *pAddress, const char *pPassword = nullptr) override; |
| 336 | void DisconnectWithReason(const char *pReason); |
| 337 | void Disconnect() override; |
| 338 | |
| 339 | void DummyDisconnect(const char *pReason) override; |
| 340 | void DummyConnect() override; |
| 341 | bool DummyConnected() const override; |
| 342 | bool DummyConnecting() const override; |
| 343 | bool DummyConnectingDelayed() const override; |
| 344 | bool DummyAllowed() const override; |
| 345 | |
| 346 | void GetServerInfo(CServerInfo *pServerInfo) const override; |
| 347 | void ServerInfoRequest(); |
| 348 | |
| 349 | void LoadDebugFont(); |
| 350 | |
| 351 | // --- |
| 352 | |
| 353 | int GetPredictionTime() override; |
| 354 | CSnapItem SnapGetItem(int SnapId, int Index) const override; |
| 355 | int GetPredictionTick() override; |
| 356 | const void *SnapFindItem(int SnapId, int Type, int Id) const override; |
| 357 | int SnapNumItems(int SnapId) const override; |
| 358 | void SnapSetStaticsize(int ItemType, int Size) override; |
| 359 | void SnapSetStaticsize7(int ItemType, int Size) override; |
| 360 | |
| 361 | void Render(); |
| 362 | void RenderDebug(); |
| 363 | void RenderGraphs(); |
| 364 | |
| 365 | void Restart() override; |
| 366 | void Quit() override; |
| 367 | void ResetSocket(); |
| 368 | |
| 369 | const char *PlayerName() const override; |
| 370 | const char *DummyName() override; |
| 371 | const char *ErrorString() const override; |
| 372 | |
| 373 | const char *LoadMap(const char *pName, const char *pFilename, SHA256_DIGEST *pWantedSha256, unsigned WantedCrc); |
| 374 | const char *LoadMapSearch(const char *pMapName, SHA256_DIGEST *pWantedSha256, int WantedCrc); |
| 375 | |
| 376 | int TranslateSysMsg(int *pMsgId, bool System, CUnpacker *pUnpacker, CPacker *pPacker, CNetChunk *pPacket, bool *pIsExMsg); |
| 377 | |
| 378 | void PreprocessConnlessPacket7(CNetChunk *pPacket); |
| 379 | void ProcessConnlessPacket(CNetChunk *pPacket); |
| 380 | void ProcessServerInfo(int Type, NETADDR *pFrom, const void *pData, int DataSize); |
| 381 | void ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy); |
| 382 | |
| 383 | int UnpackAndValidateSnapshot(CSnapshot *pFrom, CSnapshot *pTo); |
| 384 | |
| 385 | void ResetMapDownload(bool ResetActive); |
| 386 | void FinishMapDownload(); |
| 387 | |
| 388 | EInfoState InfoState() const override { return m_InfoState; } |
| 389 | void RequestDDNetInfo() override; |
| 390 | void ResetDDNetInfoTask(); |
| 391 | void LoadDDNetInfo(); |
| 392 | |
| 393 | bool IsSixup() const override { return m_Sixup; } |
| 394 | |
| 395 | const NETADDR &ServerAddress() const override { return *m_aNetClient[CONN_MAIN].ServerAddress(); } |
| 396 | int ConnectNetTypes() const override; |
| 397 | const char *ConnectAddressString() const override { return m_aConnectAddressStr; } |
| 398 | const char *MapDownloadName() const override { return m_aMapdownloadName; } |
| 399 | int MapDownloadAmount() const override { return !m_pMapdownloadTask ? m_MapdownloadAmount : (int)m_pMapdownloadTask->Current(); } |
| 400 | int MapDownloadTotalsize() const override { return !m_pMapdownloadTask ? m_MapdownloadTotalsize : (int)m_pMapdownloadTask->Size(); } |
| 401 | |
| 402 | void PumpNetwork(); |
| 403 | |
| 404 | void OnDemoPlayerSnapshot(void *pData, int Size) override; |
| 405 | void OnDemoPlayerMessage(void *pData, int Size) override; |
| 406 | |
| 407 | void Update(); |
| 408 | |
| 409 | void RegisterInterfaces(); |
| 410 | void InitInterfaces(); |
| 411 | |
| 412 | void Run(); |
| 413 | |
| 414 | bool InitNetworkClient(char *pError, size_t ErrorSize); |
| 415 | bool InitNetworkClientImpl(NETADDR BindAddr, int Conn, char *pError, size_t ErrorSize); |
| 416 | bool CtrlShiftKey(int Key, bool &Last); |
| 417 | |
| 418 | static void Con_Connect(IConsole::IResult *pResult, void *pUserData); |
| 419 | static void Con_Disconnect(IConsole::IResult *pResult, void *pUserData); |
| 420 | |
| 421 | static void Con_DummyConnect(IConsole::IResult *pResult, void *pUserData); |
| 422 | static void Con_DummyDisconnect(IConsole::IResult *pResult, void *pUserData); |
| 423 | static void Con_DummyResetInput(IConsole::IResult *pResult, void *pUserData); |
| 424 | |
| 425 | static void Con_Quit(IConsole::IResult *pResult, void *pUserData); |
| 426 | static void Con_Restart(IConsole::IResult *pResult, void *pUserData); |
| 427 | static void Con_DemoPlay(IConsole::IResult *pResult, void *pUserData); |
| 428 | static void Con_DemoSpeed(IConsole::IResult *pResult, void *pUserData); |
| 429 | static void Con_Minimize(IConsole::IResult *pResult, void *pUserData); |
| 430 | static void Con_Ping(IConsole::IResult *pResult, void *pUserData); |
| 431 | static void ConNetReset(IConsole::IResult *pResult, void *pUserData); |
| 432 | static void Con_Screenshot(IConsole::IResult *pResult, void *pUserData); |
| 433 | |
| 434 | #if defined(CONF_VIDEORECORDER) |
| 435 | void StartVideo(const char *pFilename, bool WithTimestamp); |
| 436 | static void Con_StartVideo(IConsole::IResult *pResult, void *pUserData); |
| 437 | static void Con_StopVideo(IConsole::IResult *pResult, void *pUserData); |
| 438 | const char *DemoPlayer_Render(const char *pFilename, int StorageType, const char *pVideoName, int SpeedIndex, bool StartPaused = false) override; |
| 439 | #endif |
| 440 | |
| 441 | static void Con_Rcon(IConsole::IResult *pResult, void *pUserData); |
| 442 | static void Con_RconAuth(IConsole::IResult *pResult, void *pUserData); |
| 443 | static void Con_RconLogin(IConsole::IResult *pResult, void *pUserData); |
| 444 | static void Con_BeginFavoriteGroup(IConsole::IResult *pResult, void *pUserData); |
| 445 | static void Con_EndFavoriteGroup(IConsole::IResult *pResult, void *pUserData); |
| 446 | static void Con_AddFavorite(IConsole::IResult *pResult, void *pUserData); |
| 447 | static void Con_RemoveFavorite(IConsole::IResult *pResult, void *pUserData); |
| 448 | static void Con_Play(IConsole::IResult *pResult, void *pUserData); |
| 449 | static void Con_Record(IConsole::IResult *pResult, void *pUserData); |
| 450 | static void Con_StopRecord(IConsole::IResult *pResult, void *pUserData); |
| 451 | static void Con_AddDemoMarker(IConsole::IResult *pResult, void *pUserData); |
| 452 | static void Con_BenchmarkQuit(IConsole::IResult *pResult, void *pUserData); |
| 453 | static void ConchainServerBrowserUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 454 | static void ConchainFullscreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 455 | static void ConchainWindowBordered(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 456 | static void ConchainWindowScreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 457 | static void ConchainWindowVSync(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 458 | static void ConchainWindowResize(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 459 | static void ConchainTimeoutSeed(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 460 | static void ConchainPassword(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 461 | static void ConchainReplays(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 462 | static void ConchainInputFifo(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 463 | static void ConchainNetReset(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 464 | static void ConchainLoglevel(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 465 | static void ConchainStdoutOutputLevel(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 466 | |
| 467 | static void Con_DemoSlice(IConsole::IResult *pResult, void *pUserData); |
| 468 | static void Con_DemoSliceBegin(IConsole::IResult *pResult, void *pUserData); |
| 469 | static void Con_DemoSliceEnd(IConsole::IResult *pResult, void *pUserData); |
| 470 | static void Con_SaveReplay(IConsole::IResult *pResult, void *pUserData); |
| 471 | |
| 472 | void RegisterCommands(); |
| 473 | |
| 474 | const char *DemoPlayer_Play(const char *pFilename, int StorageType) override; |
| 475 | void DemoRecorder_Start(const char *pFilename, bool WithTimestamp, int Recorder, bool Verbose = false) override; |
| 476 | void DemoRecorder_HandleAutoStart() override; |
| 477 | void DemoRecorder_UpdateReplayRecorder() override; |
| 478 | void DemoRecorder_AddDemoMarker(int Recorder); |
| 479 | IDemoRecorder *DemoRecorder(int Recorder) override; |
| 480 | |
| 481 | void AutoScreenshot_Start() override; |
| 482 | void AutoStatScreenshot_Start() override; |
| 483 | void AutoScreenshot_Cleanup(); |
| 484 | void AutoStatScreenshot_Cleanup(); |
| 485 | |
| 486 | void AutoCSV_Start() override; |
| 487 | void AutoCSV_Cleanup(); |
| 488 | |
| 489 | void ServerBrowserUpdate() override; |
| 490 | |
| 491 | void HandleConnectAddress(const NETADDR *pAddr); |
| 492 | void HandleConnectLink(const char *pLink); |
| 493 | void HandleDemoPath(const char *pPath); |
| 494 | void HandleMapPath(const char *pPath); |
| 495 | |
| 496 | virtual void InitChecksum(); |
| 497 | virtual int HandleChecksum(int Conn, CUuid Uuid, CUnpacker *pUnpacker); |
| 498 | |
| 499 | // gfx |
| 500 | void Notify(const char *pTitle, const char *pMessage) override; |
| 501 | void OnWindowResize() override; |
| 502 | void BenchmarkQuit(int Seconds, const char *pFilename); |
| 503 | |
| 504 | void UpdateAndSwap() override; |
| 505 | |
| 506 | // DDRace |
| 507 | |
| 508 | void GenerateTimeoutSeed() override; |
| 509 | void GenerateTimeoutCodes(const NETADDR *pAddrs, int NumAddrs); |
| 510 | |
| 511 | const char *GetCurrentMap() const override; |
| 512 | const char *GetCurrentMapPath() const override; |
| 513 | SHA256_DIGEST GetCurrentMapSha256() const override; |
| 514 | unsigned GetCurrentMapCrc() const override; |
| 515 | |
| 516 | void RaceRecord_Start(const char *pFilename) override; |
| 517 | void RaceRecord_Stop() override; |
| 518 | bool RaceRecord_IsRecording() override; |
| 519 | |
| 520 | void DemoSliceBegin() override; |
| 521 | void DemoSliceEnd() override; |
| 522 | void DemoSlice(const char *pDstPath, CLIENTFUNC_FILTER pfnFilter, void *pUser) override; |
| 523 | virtual void SaveReplay(int Length, const char *pFilename = "" ); |
| 524 | |
| 525 | bool EditorHasUnsavedData() const override { return m_pEditor->HasUnsavedData(); } |
| 526 | |
| 527 | IFriends *Foes() override { return &m_Foes; } |
| 528 | |
| 529 | void GetSmoothTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) override; |
| 530 | |
| 531 | void AddWarning(const SWarning &Warning) override; |
| 532 | std::optional<SWarning> CurrentWarning() override; |
| 533 | std::vector<SWarning> &&QuittingWarnings() { return std::move(m_vQuittingWarnings); } |
| 534 | |
| 535 | CChecksumData *ChecksumData() override { return &m_Checksum.m_Data; } |
| 536 | int UdpConnectivity(int NetType) override; |
| 537 | |
| 538 | bool ViewLink(const char *pLink) override; |
| 539 | bool ViewFile(const char *pFilename) override; |
| 540 | |
| 541 | #if defined(CONF_FAMILY_WINDOWS) |
| 542 | void ShellRegister() override; |
| 543 | void ShellUnregister() override; |
| 544 | #endif |
| 545 | |
| 546 | std::optional<int> ShowMessageBox(const IGraphics::CMessageBox &MessageBox) override; |
| 547 | void GetGpuInfoString(char (&aGpuInfo)[512]) override; |
| 548 | void SetLoggers(std::shared_ptr<ILogger> &&pFileLogger, std::shared_ptr<ILogger> &&pStdoutLogger); |
| 549 | }; |
| 550 | |
| 551 | #endif |
| 552 | |