about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/game/client/components/menus.cpp3
-rw-r--r--src/game/server/gamecontext.cpp13
-rw-r--r--src/game/server/gamecontext.hpp1
-rw-r--r--src/game/server/hooks.cpp4
4 files changed, 18 insertions, 3 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index 7cac8bcd..8cfd211b 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -749,7 +749,8 @@ void MENUS::render_game(RECT main_view)
 				pass_area.x += yes_area.w;
 				pass_area.w -= yes_area.w;
 			}
-			else if(gameclient.voting->no)
+			
+			if(gameclient.voting->no)
 			{
 				RECT no_area = bars;
 				no_area.w *= gameclient.voting->no/(float)gameclient.voting->total;
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index ca335896..0a79004d 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -235,6 +235,13 @@ void GAMECONTEXT::start_vote(const char *desc, const char *command)
 	send_vote_status(-1);
 }
 
+
+void GAMECONTEXT::end_vote()
+{
+	vote_closetime = 0;
+	send_vote_set(-1);
+}
+
 void GAMECONTEXT::send_vote_set(int cid)
 {
 	NETMSG_SV_VOTE_SET msg;
@@ -261,6 +268,7 @@ void GAMECONTEXT::send_vote_status(int cid)
 	{
 		if(players[i])
 		{
+			dbg_msg("", "%d %d", i, players[i]->vote);
 			msg.total++;
 			if(players[i]->vote > 0)
 				msg.yes++;
@@ -271,6 +279,7 @@ void GAMECONTEXT::send_vote_status(int cid)
 		}
 	}	
 
+	dbg_msg("", "%d %d %d %d", msg.yes, msg.no, msg.pass, msg.total);
 	msg.pack(MSGFLAG_VITAL);
 	server_send_msg(cid);
 	
@@ -310,13 +319,13 @@ void GAMECONTEXT::tick()
 		if(yes >= (total+1)/2)
 		{
 			console_execute_line(vote_command);
-			vote_closetime = 0;
+			end_vote();
 			send_chat(-1, GAMECONTEXT::CHAT_ALL, "Vote passed");
 		}
 		else if(time_get() > vote_closetime || no >= (total+1)/2)
 		{
+			end_vote();
 			send_chat(-1, GAMECONTEXT::CHAT_ALL, "Vote failed");
-			vote_closetime = 0;
 		}
 	}
 }
diff --git a/src/game/server/gamecontext.hpp b/src/game/server/gamecontext.hpp
index 83ada09f..6ce9f068 100644
--- a/src/game/server/gamecontext.hpp
+++ b/src/game/server/gamecontext.hpp
@@ -46,6 +46,7 @@ public:
 	
 	// voting
 	void start_vote(const char *desc, const char *command);
+	void end_vote();
 	void send_vote_set(int cid);
 	void send_vote_status(int cid);
 	int64 vote_closetime;
diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp
index 3a034a97..0f3008ce 100644
--- a/src/game/server/hooks.cpp
+++ b/src/game/server/hooks.cpp
@@ -149,8 +149,12 @@ void mods_message(int msgtype, int client_id)
 	}
 	else if(msgtype == NETMSGTYPE_CL_VOTE)
 	{
+		if(!game.vote_closetime)
+			return;
+			
 		NETMSG_CL_VOTE *msg = (NETMSG_CL_VOTE *)rawmsg;
 		p->vote = msg->vote;
+		dbg_msg("", "%d voted %d", client_id, msg->vote);
 		game.send_vote_status(-1);
 	}
 	else if (msgtype == NETMSGTYPE_CL_SETTEAM)