about summary refs log tree commit diff
path: root/src/game/server/hooks.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-29 11:34:49 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-29 11:34:49 +0000
commiteac9658b7395a45d0b48cad340fd9ccf7bec0fde (patch)
treed5bd824038a9b095dd8ea5d9ab4cca88ce1afb0f /src/game/server/hooks.cpp
parent6d44adb7114a0be6ecb1b0fabc6fe69d308cad1c (diff)
downloadzcatch-eac9658b7395a45d0b48cad340fd9ccf7bec0fde.tar.gz
zcatch-eac9658b7395a45d0b48cad340fd9ccf7bec0fde.zip
added voting gui and a lot of other minor changes
Diffstat (limited to 'src/game/server/hooks.cpp')
-rw-r--r--src/game/server/hooks.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp
index f7fad64a..200e2c86 100644
--- a/src/game/server/hooks.cpp
+++ b/src/game/server/hooks.cpp
@@ -97,6 +97,7 @@ void mods_client_drop(int client_id)
 	game.players[client_id]->on_disconnect();
 	(void) game.controller->check_team_balance();
 	delete game.players[client_id];
+	game.players[client_id] = 0;
 }
 
 void mods_message(int msgtype, int client_id)
@@ -150,11 +151,36 @@ void mods_message(int msgtype, int client_id)
 		NETMSG_CL_CALLVOTE *msg = (NETMSG_CL_CALLVOTE *)rawmsg;
 		if(str_comp_nocase(msg->type, "map") == 0)
 		{
+			if(!config.sv_vote_map)
+			{
+				game.send_chat(-1, client_id, "Server does not allow voting on map");
+				return;
+			}
+			
 			str_format(chatmsg, sizeof(chatmsg), "Vote called to change map to '%s'", msg->value);
 			str_format(desc, sizeof(desc), "Change map to '%s'", msg->value);
 			str_format(cmd, sizeof(cmd), "sv_map %s", msg->value);
 		}
-
+		else if(str_comp_nocase(msg->type, "kick") == 0)
+		{
+			if(!config.sv_vote_kick)
+			{
+				game.send_chat(-1, client_id, "Server does not allow voting to kick players");
+				return;
+			}
+			
+			int kick_id = atoi(msg->value);
+			if(kick_id < 0 || kick_id >= MAX_CLIENTS || !game.players[kick_id])
+			{
+				game.send_chat(-1, client_id, "Invalid client id to kick");
+				return;
+			}
+			
+			str_format(chatmsg, sizeof(chatmsg), "Vote called to kick '%s'", server_clientname(kick_id));
+			str_format(desc, sizeof(desc), "Kick '%s'", server_clientname(kick_id));
+			str_format(cmd, sizeof(cmd), "kick %d", kick_id);
+		}
+		
 		if(cmd[0])
 		{
 			game.send_chat(-1, GAMECONTEXT::CHAT_ALL, chatmsg);
@@ -257,10 +283,18 @@ void mods_message(int msgtype, int client_id)
 			// send tuning parameters to client
 			send_tuning_params(client_id);
 			
+			// send maps to the client
+			{
+				NETMSG_SV_MAPLIST m;
+				m.names = config.sv_maplist;
+				m.pack(MSGFLAG_VITAL);
+				server_send_msg(client_id);
+			}
+			
 			//
 			NETMSG_SV_READYTOENTER m;
 			m.pack(MSGFLAG_VITAL|MSGFLAG_FLUSH);
-			server_send_msg(client_id);			
+			server_send_msg(client_id);
 		}
 		
 		game.send_info(client_id, -1);