mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix style and imporve performance
This commit is contained in:
parent
32189f8485
commit
d6be41d7ab
|
@ -42,7 +42,7 @@ CONSOLE_COMMAND("showall", "?i['0'|'1']", CFGFLAG_CHAT, ConShowAll, this, "Wheth
|
|||
CONSOLE_COMMAND("list", "?s[filter]", CFGFLAG_CHAT, ConList, this, "List connected players with optional case-insensitive substring matching filter")
|
||||
CONSOLE_COMMAND("set_team_ddr", "v[id] ?i[team]", CFGFLAG_SERVER, ConSetDDRTeam, this, "Set ddrace team of a player")
|
||||
|
||||
CONSOLE_COMMAND("vote_mute", "v[id] i[seconds]", CFGFLAG_SERVER, ConVoteMute, this, "")
|
||||
CONSOLE_COMMAND("vote_mute", "v[id] i[seconds]", CFGFLAG_SERVER, ConVoteMute, this, "Remove v's right to vote for i seconds")
|
||||
CONSOLE_COMMAND("mute", "", CFGFLAG_SERVER, ConMute, this, "")
|
||||
CONSOLE_COMMAND("muteid", "v[id] i[seconds]", CFGFLAG_SERVER, ConMuteID, this, "")
|
||||
CONSOLE_COMMAND("muteip", "s[ip] i[seconds]", CFGFLAG_SERVER, ConMuteIP, this, "")
|
||||
|
|
|
@ -349,7 +349,7 @@ void CGameContext::VoteMute(IConsole::IResult *pResult, NETADDR *pAddr, int Secs
|
|||
const char *pDisplayName, int AuthedID)
|
||||
{
|
||||
char aBuf[128];
|
||||
int Found = 0;
|
||||
bool Found = 0;
|
||||
|
||||
pAddr->port = 0; // ignore port number for vote mutes
|
||||
|
||||
|
@ -361,12 +361,13 @@ void CGameContext::VoteMute(IConsole::IResult *pResult, NETADDR *pAddr, int Secs
|
|||
m_aVoteMutes[i].m_Expire = Server()->Tick()
|
||||
+ Secs * Server()->TickSpeed();
|
||||
Found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!Found) // nothing found so far, find a free slot..
|
||||
{
|
||||
if (m_NumVoteMutes < MAX_VOTE_BANS)
|
||||
if(m_NumVoteMutes < MAX_VOTE_BANS)
|
||||
{
|
||||
m_aVoteMutes[m_NumVoteMutes].m_Addr = *pAddr;
|
||||
m_aVoteMutes[m_NumVoteMutes].m_Expire = Server()->Tick()
|
||||
|
@ -436,9 +437,9 @@ void CGameContext::ConVoteMute(IConsole::IResult *pResult, void *pUserData)
|
|||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
int Victim = pResult->GetVictim();
|
||||
|
||||
if (Victim < 0 || Victim > MAX_CLIENTS || !pSelf->m_apPlayers[Victim])
|
||||
if(Victim < 0 || Victim > MAX_CLIENTS || !pSelf->m_apPlayers[Victim])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemute", "Client id not found.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemute", "Client ID not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -744,11 +744,16 @@ void CGameContext::OnTick()
|
|||
NETADDR Addr;
|
||||
Server()->GetClientAddr(i, &Addr);
|
||||
Addr.port = 0; // ignore port number
|
||||
int VoteMuted = 0;
|
||||
bool VoteMuted = 0;
|
||||
for(int j = 0; j < m_NumVoteMutes && !VoteMuted; j++)
|
||||
{
|
||||
if(!net_addr_comp(&Addr, &m_aVoteMutes[j].m_Addr))
|
||||
{
|
||||
VoteMuted = (m_aVoteMutes[j].m_Expire - Server()->Tick()) / Server()->TickSpeed();
|
||||
if(VoteMuted > 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(VoteMuted)
|
||||
continue;
|
||||
|
||||
int ActVote = m_apPlayers[i]->m_Vote;
|
||||
|
@ -1645,13 +1650,18 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
Server()->GetClientAddr(ClientID, &Addr);
|
||||
Addr.port = 0; // ignore port number
|
||||
int VoteMuted = 0;
|
||||
for (int i = 0; i < m_NumVoteMutes && !VoteMuted; i++)
|
||||
if (!net_addr_comp(&Addr, &m_aVoteMutes[i].m_Addr))
|
||||
for(int i = 0; i < m_NumVoteMutes && !VoteMuted; i++)
|
||||
{
|
||||
if(!net_addr_comp(&Addr, &m_aVoteMutes[i].m_Addr))
|
||||
{
|
||||
VoteMuted = (m_aVoteMutes[i].m_Expire - Server()->Tick()) / Server()->TickSpeed();
|
||||
if (VoteMuted > 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(VoteMuted > 0)
|
||||
{
|
||||
char aChatmsg[64];
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "You are not permitted to vote for the next %d seconds.", VoteMuted);
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "You are not permitted to vote for the next %d seconds", VoteMuted);
|
||||
SendChatTarget(ClientID, aChatmsg);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue