about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
authorChoupom <andycootlapin@hotmail.fr>2010-10-09 20:34:17 +0200
committeroy <Tom_Adams@web.de>2010-10-11 00:31:21 +0200
commit61201fea1311b62bd5390a3f1684695073315290 (patch)
tree88cf384c78c01ceb7fbd2218148e3fce2f701d2b /src/game
parent7aefbca742c20206ce18a64bc83322331ee67b39 (diff)
downloadzcatch-61201fea1311b62bd5390a3f1684695073315290.tar.gz
zcatch-61201fea1311b62bd5390a3f1684695073315290.zip
added reason to kick a player in the callvote tab
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/components/menus.cpp1
-rw-r--r--src/game/client/components/menus.h1
-rw-r--r--src/game/client/components/menus_ingame.cpp20
-rw-r--r--src/game/client/components/voting.cpp11
-rw-r--r--src/game/client/components/voting.h2
-rw-r--r--src/game/server/gamecontext.cpp13
6 files changed, 38 insertions, 10 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index caad5a80..05eb975b 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -99,6 +99,7 @@ CMenus::CMenus()
 	m_LastInput = time_get();
 	
 	str_copy(m_aCurrentDemoFolder, "demos", sizeof(m_aCurrentDemoFolder));
+	m_aCallvoteReason[0] = 0;
 }
 
 vec4 CMenus::ButtonColorMul(const void *pID)
diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h
index 3d11cf91..1a63f5e5 100644
--- a/src/game/client/components/menus.h
+++ b/src/game/client/components/menus.h
@@ -152,6 +152,7 @@ class CMenus : public CComponent
 	// for call vote
 	int m_CallvoteSelectedOption;
 	int m_CallvoteSelectedPlayer;
+	char m_aCallvoteReason[16];
 	
 	// demo
 	struct CDemoItem
diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp
index f1a4b0dd..972b1f59 100644
--- a/src/game/client/components/menus_ingame.cpp
+++ b/src/game/client/components/menus_ingame.cpp
@@ -414,12 +414,28 @@ void CMenus::RenderServerControl(CUIRect MainView)
 				if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
 					m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer])
 				{
-					m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer);
+					m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason);
+					m_aCallvoteReason[0] = 0;
 					SetActive(false);
 				}
 			}
 		}
-
+		
+		// render kick reason
+		if(s_ControlPage == 1)
+		{
+			CUIRect Reason;
+			Bottom.VSplitRight(140.0f, &Bottom, &Reason);
+			Bottom.VSplitRight(200.0f, &Bottom, &Reason);
+			const char *pLabel = Localize("Reason:");
+			UI()->DoLabel(&Reason, pLabel, 14.0f, -1);
+			float w = TextRender()->TextWidth(0, 14.0f, pLabel, -1);
+			Reason.VSplitLeft(w, 0, &Reason);
+			Reason.VSplitLeft(10.0f, 0, &Reason);
+			static float s_Offset = 0.0f;
+			DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL);
+		}
+		
 		// force vote button (only available when authed in rcon)
 		if(Client()->RconAuthed())
 		{
diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp
index 17c0fe31..c5e6a56c 100644
--- a/src/game/client/components/voting.cpp
+++ b/src/game/client/components/voting.cpp
@@ -29,11 +29,14 @@ void CVoting::Callvote(const char *pType, const char *pValue)
 	Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
 }
 
-void CVoting::CallvoteKick(int ClientId)
+void CVoting::CallvoteKick(int ClientId, char *pReason)
 {
-	char Buf[32];
-	str_format(Buf, sizeof(Buf), "%d", ClientId);
-	Callvote("kick", Buf);
+	char aBuf[32];
+	if(pReason[0])
+		str_format(aBuf, sizeof(aBuf), "%d %s", ClientId, pReason);
+	else
+		str_format(aBuf, sizeof(aBuf), "%d", ClientId);
+	Callvote("kick", aBuf);
 }
 
 void CVoting::CallvoteOption(int OptionId)
diff --git a/src/game/client/components/voting.h b/src/game/client/components/voting.h
index 1f5d2fc5..1fc2aa53 100644
--- a/src/game/client/components/voting.h
+++ b/src/game/client/components/voting.h
@@ -39,7 +39,7 @@ public:
 	
 	void RenderBars(CUIRect Bars, bool Text);
 	
-	void CallvoteKick(int ClientId);
+	void CallvoteKick(int ClientId, char *pReason);
 	void CallvoteOption(int Option);
 	void ForcevoteKick(int ClientId);
 	void ForcevoteOption(int Option);
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index 4300bc2e..95a7e558 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -669,15 +669,22 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
 				return;
 			}
 			
-			str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s'", Server()->ClientName(ClientId), Server()->ClientName(KickId));
+			const char *pReason = "No reason given";
+			for(int i = 0; i < str_length(pMsg->m_Value)-1; i++)
+			{
+				if(pMsg->m_Value[i] == ' ')
+					pReason = &pMsg->m_Value[i+1];
+			}
+			
+			str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientId), Server()->ClientName(KickId), pReason);
 			str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId));
 			if (!g_Config.m_SvVoteKickBantime)
-				str_format(aCmd, sizeof(aCmd), "kick %d", KickId);
+				str_format(aCmd, sizeof(aCmd), "kick %d %s", KickId, pReason);
 			else
 			{
 				char aBuf[64] = {0};
 				Server()->GetClientIP(KickId, aBuf, sizeof(aBuf));
-				str_format(aCmd, sizeof(aCmd), "ban %s %d", aBuf, g_Config.m_SvVoteKickBantime);
+				str_format(aCmd, sizeof(aCmd), "ban %s %d %s", aBuf, g_Config.m_SvVoteKickBantime, pReason);
 			}
 		}