mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #409 from heinrich5991/pr_ddnet_limit_vote_reason
Fix length of vote reason display in chat
This commit is contained in:
commit
4f1d38a769
|
@ -255,7 +255,7 @@ void CGameContext::CreateSoundGlobal(int Sound, int Target)
|
|||
}
|
||||
}
|
||||
|
||||
void CGameContext::CallVote(int ClientID, const char *aDesc, const char *aCmd, const char *pReason, const char *aChatmsg)
|
||||
void CGameContext::CallVote(int ClientID, const char *pDesc, const char *pCmd, const char *pReason, const char *pChatmsg)
|
||||
{
|
||||
// check if a vote is already running
|
||||
if(m_VoteCloseTime)
|
||||
|
@ -267,8 +267,8 @@ void CGameContext::CallVote(int ClientID, const char *aDesc, const char *aCmd, c
|
|||
if(!pPlayer)
|
||||
return;
|
||||
|
||||
SendChat(-1, CGameContext::CHAT_ALL, aChatmsg);
|
||||
StartVote(aDesc, aCmd, pReason);
|
||||
SendChat(-1, CGameContext::CHAT_ALL, pChatmsg);
|
||||
StartVote(pDesc, pCmd, pReason);
|
||||
pPlayer->m_Vote = 1;
|
||||
pPlayer->m_VotePos = m_VotePos = 1;
|
||||
m_VoteCreator = ClientID;
|
||||
|
@ -1147,8 +1147,12 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
char aChatmsg[512] = {0};
|
||||
char aDesc[VOTE_DESC_LENGTH] = {0};
|
||||
char aCmd[VOTE_CMD_LENGTH] = {0};
|
||||
char aReason[VOTE_REASON_LENGTH] = "No reason given";
|
||||
CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)pRawMsg;
|
||||
const char *pReason = pMsg->m_Reason[0] ? pMsg->m_Reason : "No reason given";
|
||||
if(pMsg->m_Reason[0])
|
||||
{
|
||||
str_copy(aReason, pMsg->m_Reason, sizeof(aReason));
|
||||
}
|
||||
|
||||
if(str_comp_nocase(pMsg->m_Type, "option") == 0)
|
||||
{
|
||||
|
@ -1162,7 +1166,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
SendChatTarget(ClientID, "Invalid option");
|
||||
return;
|
||||
}
|
||||
if(!m_apPlayers[ClientID]->m_Authed && (strncmp(pOption->m_aCommand, "sv_map ", 7) == 0 || strncmp(pOption->m_aCommand, "change_map ", 11) == 0 || strncmp(pOption->m_aCommand, "random_map", 10) == 0 || strncmp(pOption->m_aCommand, "random_unfinished_map", 21) == 0) && time_get() < m_LastMapVote + (time_freq() * g_Config.m_SvVoteMapTimeDelay))
|
||||
if(!m_apPlayers[ClientID]->m_Authed && (str_comp_num(pOption->m_aCommand, "sv_map ", 7) == 0 || str_comp_num(pOption->m_aCommand, "change_map ", 11) == 0 || str_comp_num(pOption->m_aCommand, "random_map", 10) == 0 || str_comp_num(pOption->m_aCommand, "random_unfinished_map", 21) == 0) && time_get() < m_LastMapVote + (time_freq() * g_Config.m_SvVoteMapTimeDelay))
|
||||
{
|
||||
char chatmsg[512] = {0};
|
||||
str_format(chatmsg, sizeof(chatmsg), "There's a %d second delay between map-votes, please wait %d seconds.", g_Config.m_SvVoteMapTimeDelay,((m_LastMapVote+(g_Config.m_SvVoteMapTimeDelay * time_freq()))/time_freq())-(time_get()/time_freq()));
|
||||
|
@ -1172,12 +1176,12 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
}
|
||||
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s' (%s)", Server()->ClientName(ClientID),
|
||||
pOption->m_aDescription, pReason);
|
||||
pOption->m_aDescription, aReason);
|
||||
str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aDescription);
|
||||
|
||||
if((strncmp(pOption->m_aCommand, "random_map", 10) == 0 || strncmp(pOption->m_aCommand, "random_unfinished_map", 21) == 0) && str_length(pReason) == 1 && pReason[0] >= '1' && pReason[0] <= '5')
|
||||
if((str_comp_num(pOption->m_aCommand, "random_map", 10) == 0 || str_comp_num(pOption->m_aCommand, "random_unfinished_map", 21) == 0) && str_length(aReason) == 1 && aReason[0] >= '1' && aReason[0] <= '5')
|
||||
{
|
||||
int stars = pReason[0] - '0';
|
||||
int stars = aReason[0] - '0';
|
||||
str_format(aCmd, sizeof(aCmd), "%s %d", pOption->m_aCommand, stars);
|
||||
}
|
||||
else
|
||||
|
@ -1285,7 +1289,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
return;
|
||||
}
|
||||
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), pReason);
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), aReason);
|
||||
str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID));
|
||||
if (!g_Config.m_SvVoteKickBantime)
|
||||
str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID);
|
||||
|
@ -1332,13 +1336,13 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
|
||||
if(g_Config.m_SvPauseable && g_Config.m_SvVotePause)
|
||||
{
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to pause '%s' for %d seconds (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), g_Config.m_SvVotePauseTime, pReason);
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to pause '%s' for %d seconds (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), g_Config.m_SvVotePauseTime, aReason);
|
||||
str_format(aDesc, sizeof(aDesc), "Pause '%s' (%ds)", Server()->ClientName(SpectateID), g_Config.m_SvVotePauseTime);
|
||||
str_format(aCmd, sizeof(aCmd), "force_pause %d %d", SpectateID, g_Config.m_SvVotePauseTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to move '%s' to spectators (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), pReason);
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to move '%s' to spectators (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), aReason);
|
||||
str_format(aDesc, sizeof(aDesc), "move '%s' to spectators", Server()->ClientName(SpectateID));
|
||||
str_format(aCmd, sizeof(aCmd), "set_team %d -1 %d", SpectateID, g_Config.m_SvVoteSpectateRejoindelay);
|
||||
}
|
||||
|
@ -1346,8 +1350,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
m_VoteSpec = true;
|
||||
}
|
||||
|
||||
if(aCmd[0] && str_comp(aCmd,"info"))
|
||||
CallVote(ClientID, aDesc, aCmd, pReason, aChatmsg);
|
||||
if(aCmd[0] && str_comp(aCmd, "info") != 0)
|
||||
CallVote(ClientID, aDesc, aCmd, aReason, aChatmsg);
|
||||
}
|
||||
else if(MsgID == NETMSGTYPE_CL_VOTE)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue