mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
parent
3887eea18d
commit
f3a686bc62
|
@ -208,6 +208,7 @@ public:
|
|||
virtual bool UseTempRconCommands() const = 0;
|
||||
virtual void Rcon(const char *pLine) = 0;
|
||||
virtual bool ReceivingRconCommands() const = 0;
|
||||
virtual float GotRconCommandsPercentage() const = 0;
|
||||
|
||||
// server info
|
||||
virtual void GetServerInfo(class CServerInfo *pServerInfo) const = 0;
|
||||
|
|
|
@ -217,6 +217,16 @@ void CClient::Rcon(const char *pCmd)
|
|||
SendMsgActive(&Msg, MSGFLAG_VITAL);
|
||||
}
|
||||
|
||||
float CClient::GotRconCommandsPercentage() const
|
||||
{
|
||||
if(m_ExpectedRconCommands < 1)
|
||||
return -1.0f;
|
||||
if(m_GotRconCommands > m_ExpectedRconCommands)
|
||||
return -1.0f;
|
||||
|
||||
return (float)m_GotRconCommands / (float)m_ExpectedRconCommands;
|
||||
}
|
||||
|
||||
bool CClient::ConnectionProblems() const
|
||||
{
|
||||
return m_aNetClient[g_Config.m_ClDummy].GotProblems(MaxLatencyTicks() * time_freq() / GameTickSpeed()) != 0;
|
||||
|
@ -552,7 +562,8 @@ void CClient::DisconnectWithReason(const char *pReason)
|
|||
mem_zero(m_aRconPassword, sizeof(m_aRconPassword));
|
||||
m_ServerSentCapabilities = false;
|
||||
m_UseTempRconCommands = 0;
|
||||
m_ReceivingRconCommands = false;
|
||||
m_ExpectedRconCommands = -1;
|
||||
m_GotRconCommands = 0;
|
||||
m_pConsole->DeregisterTempAll();
|
||||
m_aNetClient[CONN_MAIN].Disconnect(pReason);
|
||||
SetState(IClient::STATE_OFFLINE);
|
||||
|
@ -1594,6 +1605,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
|||
{
|
||||
m_pConsole->RegisterTemp(pName, pParams, CFGFLAG_SERVER, pHelp);
|
||||
}
|
||||
m_GotRconCommands++;
|
||||
}
|
||||
else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_REM)
|
||||
{
|
||||
|
@ -1621,7 +1633,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
|||
if(Old != 0 && m_UseTempRconCommands == 0)
|
||||
{
|
||||
m_pConsole->DeregisterTempAll();
|
||||
m_ReceivingRconCommands = false;
|
||||
m_ExpectedRconCommands = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1953,11 +1965,16 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
|||
}
|
||||
else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_GROUP_START)
|
||||
{
|
||||
m_ReceivingRconCommands = true;
|
||||
int ExpectedRconCommands = Unpacker.GetInt();
|
||||
if(Unpacker.Error())
|
||||
return;
|
||||
|
||||
m_ExpectedRconCommands = ExpectedRconCommands;
|
||||
m_GotRconCommands = 0;
|
||||
}
|
||||
else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_GROUP_END)
|
||||
{
|
||||
m_ReceivingRconCommands = false;
|
||||
m_ExpectedRconCommands = -1;
|
||||
}
|
||||
}
|
||||
else if((pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0)
|
||||
|
|
|
@ -117,7 +117,8 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
char m_aRconUsername[32] = "";
|
||||
char m_aRconPassword[sizeof(g_Config.m_SvRconPassword)] = "";
|
||||
int m_UseTempRconCommands = 0;
|
||||
bool m_ReceivingRconCommands = false;
|
||||
int m_ExpectedRconCommands = -1;
|
||||
int m_GotRconCommands = 0;
|
||||
char m_aPassword[sizeof(g_Config.m_Password)] = "";
|
||||
bool m_SendPassword = false;
|
||||
|
||||
|
@ -285,7 +286,8 @@ public:
|
|||
bool UseTempRconCommands() const override { return m_UseTempRconCommands != 0; }
|
||||
void RconAuth(const char *pName, const char *pPassword) override;
|
||||
void Rcon(const char *pCmd) override;
|
||||
bool ReceivingRconCommands() const override { return m_ReceivingRconCommands; }
|
||||
bool ReceivingRconCommands() const override { return m_ExpectedRconCommands > 0; }
|
||||
float GotRconCommandsPercentage() const override;
|
||||
|
||||
bool ConnectionProblems() const override;
|
||||
|
||||
|
|
|
@ -1341,13 +1341,30 @@ void CServer::SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int Cli
|
|||
SendMsg(&Msg, MSGFLAG_VITAL, ClientId);
|
||||
}
|
||||
|
||||
int CServer::GetConsoleAccessLevel(int ClientId)
|
||||
{
|
||||
return m_aClients[ClientId].m_Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : m_aClients[ClientId].m_Authed == AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : IConsole::ACCESS_LEVEL_HELPER;
|
||||
}
|
||||
|
||||
int CServer::NumRconCommands(int ClientId)
|
||||
{
|
||||
int Num = 0;
|
||||
int ConsoleAccessLevel = GetConsoleAccessLevel(ClientId);
|
||||
for(const IConsole::CCommandInfo *pCmd = Console()->FirstCommandInfo(ConsoleAccessLevel, CFGFLAG_SERVER);
|
||||
pCmd; pCmd = pCmd->NextCommandInfo(ConsoleAccessLevel, CFGFLAG_SERVER))
|
||||
{
|
||||
Num++;
|
||||
}
|
||||
return Num;
|
||||
}
|
||||
|
||||
void CServer::UpdateClientRconCommands()
|
||||
{
|
||||
int ClientId = Tick() % MAX_CLIENTS;
|
||||
|
||||
if(m_aClients[ClientId].m_State != CClient::STATE_EMPTY && m_aClients[ClientId].m_Authed)
|
||||
{
|
||||
int ConsoleAccessLevel = m_aClients[ClientId].m_Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : m_aClients[ClientId].m_Authed == AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : IConsole::ACCESS_LEVEL_HELPER;
|
||||
int ConsoleAccessLevel = GetConsoleAccessLevel(ClientId);
|
||||
for(int i = 0; i < MAX_RCONCMD_SEND && m_aClients[ClientId].m_pRconCmdToSend; ++i)
|
||||
{
|
||||
SendRconCmdAdd(m_aClients[ClientId].m_pRconCmdToSend, ClientId);
|
||||
|
@ -1759,6 +1776,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
|||
// AUTHED_ADMIN - AuthLevel gets the proper IConsole::ACCESS_LEVEL_<x>
|
||||
m_aClients[ClientId].m_pRconCmdToSend = Console()->FirstCommandInfo(AUTHED_ADMIN - AuthLevel, CFGFLAG_SERVER);
|
||||
CMsgPacker MsgStart(NETMSG_RCON_CMD_GROUP_START, true);
|
||||
MsgStart.AddInt(NumRconCommands(ClientId));
|
||||
SendMsg(&MsgStart, MSGFLAG_VITAL, ClientId);
|
||||
if(m_aClients[ClientId].m_pRconCmdToSend == nullptr)
|
||||
{
|
||||
|
|
|
@ -331,6 +331,8 @@ public:
|
|||
|
||||
void SendRconCmdAdd(const IConsole::CCommandInfo *pCommandInfo, int ClientId);
|
||||
void SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int ClientId);
|
||||
int GetConsoleAccessLevel(int ClientId);
|
||||
int NumRconCommands(int ClientId);
|
||||
void UpdateClientRconCommands();
|
||||
|
||||
bool CheckReservedSlotAuth(int ClientId, const char *pPassword);
|
||||
|
|
|
@ -1307,8 +1307,20 @@ void CGameConsole::OnRender()
|
|||
|
||||
if(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->ReceivingRconCommands())
|
||||
{
|
||||
float Percentage = Client()->GotRconCommandsPercentage();
|
||||
SProgressSpinnerProperties ProgressProps;
|
||||
ProgressProps.m_Progress = Percentage;
|
||||
Ui()->RenderProgressSpinner(vec2(Screen.w / 4.0f + FONT_SIZE / 2.f, FONT_SIZE), FONT_SIZE / 2.f);
|
||||
TextRender()->Text(Screen.w / 4.0f + FONT_SIZE + 2.0f, FONT_SIZE / 2.f, FONT_SIZE, Localize("Loading commands…"));
|
||||
|
||||
char aLoading[128];
|
||||
str_copy(aLoading, Localize("Loading commands…"));
|
||||
if(Percentage > 0)
|
||||
{
|
||||
char aPercentage[8];
|
||||
str_format(aPercentage, sizeof(aPercentage), " %d%%", (int)(Percentage * 100));
|
||||
str_append(aLoading, aPercentage);
|
||||
}
|
||||
TextRender()->Text(Screen.w / 4.0f + FONT_SIZE + 2.0f, FONT_SIZE / 2.f, FONT_SIZE, aLoading);
|
||||
}
|
||||
|
||||
// render version
|
||||
|
|
Loading…
Reference in a new issue