mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-19 17:14:18 +00:00
Compare commits
2 commits
0520fdcade
...
bd13ee8c7a
Author | SHA1 | Date | |
---|---|---|---|
bd13ee8c7a | |||
ed7d4d4f66 |
|
@ -163,7 +163,7 @@ public:
|
||||||
|
|
||||||
// dummy
|
// dummy
|
||||||
virtual void DummyDisconnect(const char *pReason) = 0;
|
virtual void DummyDisconnect(const char *pReason) = 0;
|
||||||
virtual void DummyConnect(bool Force = false) = 0;
|
virtual void DummyConnect() = 0;
|
||||||
virtual bool DummyConnected() const = 0;
|
virtual bool DummyConnected() const = 0;
|
||||||
virtual bool DummyConnecting() const = 0;
|
virtual bool DummyConnecting() const = 0;
|
||||||
virtual bool DummyConnectingDelayed() const = 0;
|
virtual bool DummyConnectingDelayed() const = 0;
|
||||||
|
|
|
@ -707,7 +707,7 @@ bool CClient::DummyConnectingDelayed() const
|
||||||
return !DummyConnected() && !DummyConnecting() && m_LastDummyConnectTime > 0.0f && m_LastDummyConnectTime + 5.0f > GlobalTime();
|
return !DummyConnected() && !DummyConnecting() && m_LastDummyConnectTime > 0.0f && m_LastDummyConnectTime + 5.0f > GlobalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::DummyConnect(bool Force)
|
void CClient::DummyConnect()
|
||||||
{
|
{
|
||||||
if(m_aNetClient[CONN_MAIN].State() != NETSTATE_ONLINE)
|
if(m_aNetClient[CONN_MAIN].State() != NETSTATE_ONLINE)
|
||||||
{
|
{
|
||||||
|
@ -720,20 +720,23 @@ void CClient::DummyConnect(bool Force)
|
||||||
log_info("client", "Dummy is not allowed on this server.");
|
log_info("client", "Dummy is not allowed on this server.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(DummyConnected() || DummyConnecting())
|
if((DummyConnected() || DummyConnecting()) && !m_DummyReconnectOnReload)
|
||||||
{
|
{
|
||||||
log_info("client", "Dummy is already connected/connecting.");
|
log_info("client", "Dummy is already connected/connecting.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!Force && DummyConnectingDelayed())
|
if(DummyConnectingDelayed() && !m_DummyReconnectOnReload)
|
||||||
{
|
{
|
||||||
log_info("client", "Wait before connecting dummy again.");
|
log_info("client", "Wait before connecting dummy again.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_DummySendConnInfo = true;
|
||||||
|
|
||||||
|
if(!m_DummyReconnectOnReload)
|
||||||
|
{
|
||||||
m_LastDummyConnectTime = GlobalTime();
|
m_LastDummyConnectTime = GlobalTime();
|
||||||
m_aRconAuthed[1] = 0;
|
m_aRconAuthed[1] = 0;
|
||||||
m_DummySendConnInfo = true;
|
|
||||||
|
|
||||||
g_Config.m_ClDummyCopyMoves = 0;
|
g_Config.m_ClDummyCopyMoves = 0;
|
||||||
g_Config.m_ClDummyHammer = 0;
|
g_Config.m_ClDummyHammer = 0;
|
||||||
|
@ -744,6 +747,7 @@ void CClient::DummyConnect(bool Force)
|
||||||
m_aNetClient[CONN_DUMMY].Connect7(m_aNetClient[CONN_MAIN].ServerAddress(), 1);
|
m_aNetClient[CONN_DUMMY].Connect7(m_aNetClient[CONN_MAIN].ServerAddress(), 1);
|
||||||
else
|
else
|
||||||
m_aNetClient[CONN_DUMMY].Connect(m_aNetClient[CONN_MAIN].ServerAddress(), 1);
|
m_aNetClient[CONN_DUMMY].Connect(m_aNetClient[CONN_MAIN].ServerAddress(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::DummyDisconnect(const char *pReason)
|
void CClient::DummyDisconnect(const char *pReason)
|
||||||
|
@ -1520,7 +1524,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_DummyConnected)
|
if(m_DummyConnected && !m_DummyReconnectOnReload)
|
||||||
{
|
{
|
||||||
DummyDisconnect(0);
|
DummyDisconnect(0);
|
||||||
}
|
}
|
||||||
|
@ -1653,8 +1657,9 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
||||||
{
|
{
|
||||||
if(m_DummyConnected)
|
if(m_DummyConnected)
|
||||||
{
|
{
|
||||||
m_DummyReconnectOnLoad = true;
|
m_DummyReconnectOnReload = true;
|
||||||
m_DummySwapOnReconnect = g_Config.m_ClDummy == 1 ? false : true;
|
m_DummySwapOnReconnect = g_Config.m_ClDummy == 1 ? false : true;
|
||||||
|
g_Config.m_ClDummy = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_DummySwapOnReconnect = false;
|
m_DummySwapOnReconnect = false;
|
||||||
|
@ -1662,10 +1667,10 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
||||||
else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_CON_READY)
|
else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_CON_READY)
|
||||||
{
|
{
|
||||||
GameClient()->OnConnected();
|
GameClient()->OnConnected();
|
||||||
if(m_DummyReconnectOnLoad)
|
if(m_DummyReconnectOnReload)
|
||||||
{
|
{
|
||||||
m_DummyReconnectOnLoad = false;
|
DummyConnect();
|
||||||
DummyConnect(true);
|
m_DummyReconnectOnReload = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Conn == CONN_DUMMY && Msg == NETMSG_CON_READY)
|
else if(Conn == CONN_DUMMY && Msg == NETMSG_CON_READY)
|
||||||
|
@ -1674,7 +1679,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
||||||
m_DummyConnecting = false;
|
m_DummyConnecting = false;
|
||||||
g_Config.m_ClDummy = 1;
|
g_Config.m_ClDummy = 1;
|
||||||
Rcon("crashmeplx");
|
Rcon("crashmeplx");
|
||||||
if(m_aRconAuthed[0])
|
if(m_aRconAuthed[0] && !m_aRconAuthed[1])
|
||||||
RconAuth(m_aRconUsername, m_aRconPassword);
|
RconAuth(m_aRconUsername, m_aRconPassword);
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_PING)
|
else if(Msg == NETMSG_PING)
|
||||||
|
|
|
@ -182,7 +182,7 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
||||||
bool m_DummyConnecting = false;
|
bool m_DummyConnecting = false;
|
||||||
bool m_DummyConnected = false;
|
bool m_DummyConnected = false;
|
||||||
float m_LastDummyConnectTime = 0.0f;
|
float m_LastDummyConnectTime = 0.0f;
|
||||||
bool m_DummyReconnectOnLoad = false;
|
bool m_DummyReconnectOnReload = false;
|
||||||
bool m_DummySwapOnReconnect = false;
|
bool m_DummySwapOnReconnect = false;
|
||||||
|
|
||||||
// graphs
|
// graphs
|
||||||
|
@ -321,7 +321,7 @@ public:
|
||||||
void Disconnect() override;
|
void Disconnect() override;
|
||||||
|
|
||||||
void DummyDisconnect(const char *pReason) override;
|
void DummyDisconnect(const char *pReason) override;
|
||||||
void DummyConnect(bool Force = false) override;
|
void DummyConnect() override;
|
||||||
bool DummyConnected() const override;
|
bool DummyConnected() const override;
|
||||||
bool DummyConnecting() const override;
|
bool DummyConnecting() const override;
|
||||||
bool DummyConnectingDelayed() const override;
|
bool DummyConnectingDelayed() const override;
|
||||||
|
|
|
@ -243,6 +243,7 @@ CServer::CServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_MapReload = false;
|
m_MapReload = false;
|
||||||
|
m_SameMapReload = false;
|
||||||
m_ReloadedWhenEmpty = false;
|
m_ReloadedWhenEmpty = false;
|
||||||
m_aCurrentMap[0] = '\0';
|
m_aCurrentMap[0] = '\0';
|
||||||
|
|
||||||
|
@ -1269,6 +1270,12 @@ void CServer::SendMapData(int ClientId, int Chunk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CServer::SendMapReload(int ClientId)
|
||||||
|
{
|
||||||
|
CMsgPacker Msg(NETMSG_MAP_RELOAD, true);
|
||||||
|
SendMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_FLUSH, ClientId);
|
||||||
|
}
|
||||||
|
|
||||||
void CServer::SendConnectionReady(int ClientId)
|
void CServer::SendConnectionReady(int ClientId)
|
||||||
{
|
{
|
||||||
CMsgPacker Msg(NETMSG_CON_READY, true);
|
CMsgPacker Msg(NETMSG_CON_READY, true);
|
||||||
|
@ -2553,7 +2560,7 @@ void CServer::ChangeMap(const char *pMap)
|
||||||
|
|
||||||
void CServer::ReloadMap()
|
void CServer::ReloadMap()
|
||||||
{
|
{
|
||||||
m_MapReload = true;
|
m_SameMapReload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CServer::LoadMap(const char *pMapName)
|
int CServer::LoadMap(const char *pMapName)
|
||||||
|
@ -2805,7 +2812,7 @@ int CServer::Run()
|
||||||
int NewTicks = 0;
|
int NewTicks = 0;
|
||||||
|
|
||||||
// load new map
|
// load new map
|
||||||
if(m_MapReload || m_CurrentGameTick >= MAX_TICK) // force reload to make sure the ticks stay within a valid range
|
if(m_MapReload || m_SameMapReload || m_CurrentGameTick >= MAX_TICK) // force reload to make sure the ticks stay within a valid range
|
||||||
{
|
{
|
||||||
// load map
|
// load map
|
||||||
if(LoadMap(Config()->m_SvMap))
|
if(LoadMap(Config()->m_SvMap))
|
||||||
|
@ -2831,12 +2838,16 @@ int CServer::Run()
|
||||||
if(m_aClients[ClientId].m_State <= CClient::STATE_AUTH)
|
if(m_aClients[ClientId].m_State <= CClient::STATE_AUTH)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(m_SameMapReload)
|
||||||
|
SendMapReload(ClientId);
|
||||||
|
|
||||||
SendMap(ClientId);
|
SendMap(ClientId);
|
||||||
bool HasPersistentData = m_aClients[ClientId].m_HasPersistentData;
|
bool HasPersistentData = m_aClients[ClientId].m_HasPersistentData;
|
||||||
m_aClients[ClientId].Reset();
|
m_aClients[ClientId].Reset();
|
||||||
m_aClients[ClientId].m_HasPersistentData = HasPersistentData;
|
m_aClients[ClientId].m_HasPersistentData = HasPersistentData;
|
||||||
m_aClients[ClientId].m_State = CClient::STATE_CONNECTING;
|
m_aClients[ClientId].m_State = CClient::STATE_CONNECTING;
|
||||||
}
|
}
|
||||||
|
m_SameMapReload = false;
|
||||||
|
|
||||||
m_GameStartTime = time_get();
|
m_GameStartTime = time_get();
|
||||||
m_CurrentGameTick = MIN_TICK;
|
m_CurrentGameTick = MIN_TICK;
|
||||||
|
@ -3509,9 +3520,7 @@ void CServer::ConStopRecord(IConsole::IResult *pResult, void *pUser)
|
||||||
|
|
||||||
void CServer::ConMapReload(IConsole::IResult *pResult, void *pUser)
|
void CServer::ConMapReload(IConsole::IResult *pResult, void *pUser)
|
||||||
{
|
{
|
||||||
((CServer *)pUser)->m_MapReload = true;
|
((CServer *)pUser)->ReloadMap();
|
||||||
CMsgPacker Msg(NETMSG_MAP_RELOAD, true);
|
|
||||||
((CServer *)pUser)->SendMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_FLUSH, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServer::ConLogout(IConsole::IResult *pResult, void *pUser)
|
void CServer::ConLogout(IConsole::IResult *pResult, void *pUser)
|
||||||
|
|
|
@ -219,6 +219,7 @@ public:
|
||||||
int m_RunServer;
|
int m_RunServer;
|
||||||
|
|
||||||
bool m_MapReload;
|
bool m_MapReload;
|
||||||
|
bool m_SameMapReload;
|
||||||
bool m_ReloadedWhenEmpty;
|
bool m_ReloadedWhenEmpty;
|
||||||
int m_RconClientId;
|
int m_RconClientId;
|
||||||
int m_RconAuthLevel;
|
int m_RconAuthLevel;
|
||||||
|
@ -324,6 +325,7 @@ public:
|
||||||
void SendCapabilities(int ClientId);
|
void SendCapabilities(int ClientId);
|
||||||
void SendMap(int ClientId);
|
void SendMap(int ClientId);
|
||||||
void SendMapData(int ClientId, int Chunk);
|
void SendMapData(int ClientId, int Chunk);
|
||||||
|
void SendMapReload(int ClientId);
|
||||||
void SendConnectionReady(int ClientId);
|
void SendConnectionReady(int ClientId);
|
||||||
void SendRconLine(int ClientId, const char *pLine);
|
void SendRconLine(int ClientId, const char *pLine);
|
||||||
// Accepts -1 as ClientId to mean "all clients with at least auth level admin"
|
// Accepts -1 as ClientId to mean "all clients with at least auth level admin"
|
||||||
|
|
|
@ -3237,8 +3237,6 @@ void CGameContext::ConHotReload(IConsole::IResult *pResult, void *pUserData)
|
||||||
pSelf->m_apSavedTeams[pSelf->m_aTeamMapping[i]]->Save(pSelf, pSelf->m_aTeamMapping[i], true, true);
|
pSelf->m_apSavedTeams[pSelf->m_aTeamMapping[i]]->Save(pSelf, pSelf->m_aTeamMapping[i], true, true);
|
||||||
}
|
}
|
||||||
pSelf->Server()->ReloadMap();
|
pSelf->Server()->ReloadMap();
|
||||||
CMsgPacker Msg(NETMSG_MAP_RELOAD, true);
|
|
||||||
pSelf->Server()->SendMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_FLUSH, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData)
|
void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
|
Loading…
Reference in a new issue