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

Method RedirectClient

src/engine/server/server.cpp:545–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543}
544
545void 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
576int64_t CServer::TickStartTime(int Tick)
577{

Callers

nothing calls this directly

Calls 6

PortMethod · 0.95
str_formatFunction · 0.85
time_getFunction · 0.85
time_freqFunction · 0.85
AddIntMethod · 0.80
OnClientDropMethod · 0.80

Tested by

no test coverage detected