------ state handling -----
| 399 | |
| 400 | // ------ state handling ----- |
| 401 | void CClient::SetState(EClientState State) |
| 402 | { |
| 403 | if(m_State == IClient::STATE_QUITTING || m_State == IClient::STATE_RESTARTING) |
| 404 | return; |
| 405 | if(m_State == State) |
| 406 | return; |
| 407 | |
| 408 | if(g_Config.m_Debug) |
| 409 | { |
| 410 | char aBuf[64]; |
| 411 | str_format(aBuf, sizeof(aBuf), "state change. last=%d current=%d", m_State, State); |
| 412 | m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf); |
| 413 | } |
| 414 | |
| 415 | const EClientState OldState = m_State; |
| 416 | m_State = State; |
| 417 | |
| 418 | m_StateStartTime = time_get(); |
| 419 | GameClient()->OnStateChange(m_State, OldState); |
| 420 | |
| 421 | if(State == IClient::STATE_OFFLINE && m_ReconnectTime == 0) |
| 422 | { |
| 423 | if(g_Config.m_ClReconnectFull > 0 && (str_find_nocase(ErrorString(), "full") || str_find_nocase(ErrorString(), "reserved"))) |
| 424 | m_ReconnectTime = time_get() + time_freq() * g_Config.m_ClReconnectFull; |
| 425 | else if(g_Config.m_ClReconnectTimeout > 0 && (str_find_nocase(ErrorString(), "Timeout") || str_find_nocase(ErrorString(), "Too weak connection"))) |
| 426 | m_ReconnectTime = time_get() + time_freq() * g_Config.m_ClReconnectTimeout; |
| 427 | } |
| 428 | |
| 429 | if(State == IClient::STATE_ONLINE) |
| 430 | { |
| 431 | const bool Registered = m_ServerBrowser.IsRegistered(ServerAddress()); |
| 432 | CServerInfo CurrentServerInfo; |
| 433 | GetServerInfo(&CurrentServerInfo); |
| 434 | |
| 435 | Discord()->SetGameInfo(CurrentServerInfo, GameClient()->Map()->BaseName(), Registered); |
| 436 | Steam()->SetGameInfo(ServerAddress(), GameClient()->Map()->BaseName(), Registered); |
| 437 | } |
| 438 | else if(OldState == IClient::STATE_ONLINE) |
| 439 | { |
| 440 | Discord()->ClearGameInfo(); |
| 441 | Steam()->ClearGameInfo(); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | // called when the map is loaded and we should init for a new round |
| 446 | void CClient::OnEnterGame(bool Dummy) |
nothing calls this directly
no test coverage detected