| 543 | } |
| 544 | |
| 545 | void CServer::RedirectClient(int ClientId, int Port) |
| 546 | { |
| 547 | dbg_assert(0 <= ClientId && ClientId < MAX_CLIENTS, "Invalid ClientId: %d", ClientId); |
| 548 | dbg_assert(m_aClients[ClientId].m_State != CClient::STATE_EMPTY, "Client slot empty: %d", ClientId); |
| 549 | |
| 550 | bool SupportsRedirect = GetClientVersion(ClientId) >= VERSION_DDNET_REDIRECT; |
| 551 | |
| 552 | log_info("server", "redirecting client, cid=%d port=%d supported=%d", ClientId, Port, SupportsRedirect); |
| 553 | |
| 554 | if(!SupportsRedirect) |
| 555 | { |
| 556 | char aBuf[128]; |
| 557 | bool SamePort = Port == this->Port(); |
| 558 | str_format(aBuf, sizeof(aBuf), "Redirect unsupported: please connect to port %d", Port); |
| 559 | Kick(ClientId, SamePort ? "Redirect unsupported: please reconnect" : aBuf); |
| 560 | return; |
| 561 | } |
| 562 | |
| 563 | CMsgPacker Msg(NETMSG_REDIRECT, true); |
| 564 | Msg.AddInt(Port); |
| 565 | SendMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_FLUSH, ClientId); |
| 566 | |
| 567 | if(m_aClients[ClientId].m_State >= CClient::STATE_READY) |
| 568 | { |
| 569 | GameServer()->OnClientDrop(ClientId, "redirect"); |
| 570 | } |
| 571 | |
| 572 | m_aClients[ClientId].m_RedirectDropTime = time_get() + time_freq() * 10; |
| 573 | m_aClients[ClientId].m_State = CClient::STATE_REDIRECTED; |
| 574 | } |
| 575 | |
| 576 | int64_t CServer::TickStartTime(int Tick) |
| 577 | { |
nothing calls this directly
no test coverage detected