about summary refs log tree commit diff
path: root/src/game/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/server')
-rw-r--r--src/game/server/entities/character.cpp3
-rw-r--r--src/game/server/gamecontext.cpp5
-rw-r--r--src/game/server/gamecontext.hpp1
-rw-r--r--src/game/server/hooks.cpp30
-rw-r--r--src/game/server/player.hpp1
5 files changed, 33 insertions, 7 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index c04be833..df3e7666 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -682,7 +682,8 @@ void CHARACTER::tick_defered()
 		reckoningcore.write(&predicted);
 		core.write(&current);
 		
-		if(mem_comp(&predicted, &current, sizeof(NETOBJ_CHARACTER)) != 0)
+		// only allow dead reackoning for a top of 3 seconds
+		if(reckoning_tick+server_tickspeed()*3 < server_tick() || mem_comp(&predicted, &current, sizeof(NETOBJ_CHARACTER)) != 0)
 		{
 			reckoning_tick = server_tick();
 			sendcore = core;
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index d5e5c19d..258b2994 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -321,8 +321,11 @@ void GAMECONTEXT::tick()
 			console_execute_line(vote_command);
 			end_vote();
 			send_chat(-1, GAMECONTEXT::CHAT_ALL, "Vote passed");
+			
+			if(players[vote_creator])
+				players[vote_creator]->last_votecall = 0;
 		}
-		else if(time_get() > vote_closetime || no >= total/2+1)
+		else if(time_get() > vote_closetime || no >= total/2+1 || yes+no == total)
 		{
 			end_vote();
 			send_chat(-1, GAMECONTEXT::CHAT_ALL, "Vote failed");
diff --git a/src/game/server/gamecontext.hpp b/src/game/server/gamecontext.hpp
index 6ce9f068..124df645 100644
--- a/src/game/server/gamecontext.hpp
+++ b/src/game/server/gamecontext.hpp
@@ -49,6 +49,7 @@ public:
 	void end_vote();
 	void send_vote_set(int cid);
 	void send_vote_status(int cid);
+	int vote_creator;
 	int64 vote_closetime;
 	char vote_description[512];
 	char vote_command[512];
diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp
index 0f3008ce..f7fad64a 100644
--- a/src/game/server/hooks.cpp
+++ b/src/game/server/hooks.cpp
@@ -128,6 +128,22 @@ void mods_message(int msgtype, int client_id)
 	}
 	else if(msgtype == NETMSGTYPE_CL_CALLVOTE)
 	{
+		int64 now = time_get();
+		if(game.vote_closetime)
+		{
+			game.send_chat(-1, client_id, "Wait for current vote to end before calling a new one.");
+			return;
+		}
+		
+		int64 timeleft = p->last_votecall + time_freq()*60 - now;
+		if(timeleft > 0)
+		{
+			char chatmsg[512] = {0};
+			str_format(chatmsg, sizeof(chatmsg), "You must wait %d seconds before making another vote", (timeleft/time_freq())+1);
+			game.send_chat(-1, client_id, chatmsg);
+			return;
+		}
+		
 		char chatmsg[512] = {0};
 		char desc[512] = {0};
 		char cmd[512] = {0};
@@ -144,6 +160,8 @@ void mods_message(int msgtype, int client_id)
 			game.send_chat(-1, GAMECONTEXT::CHAT_ALL, chatmsg);
 			game.start_vote(desc, cmd);
 			p->vote = 1;
+			game.vote_creator = client_id;
+			p->last_votecall = now;
 			game.send_vote_status(-1);
 		}
 	}
@@ -151,11 +169,13 @@ void mods_message(int msgtype, int client_id)
 	{
 		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);
+
+		if(p->vote == 0)
+		{
+			NETMSG_CL_VOTE *msg = (NETMSG_CL_VOTE *)rawmsg;
+			p->vote = msg->vote;
+			game.send_vote_status(-1);
+		}
 	}
 	else if (msgtype == NETMSGTYPE_CL_SETTEAM)
 	{
diff --git a/src/game/server/player.hpp b/src/game/server/player.hpp
index f483ecf9..24713c93 100644
--- a/src/game/server/player.hpp
+++ b/src/game/server/player.hpp
@@ -29,6 +29,7 @@ public:
 	
 	//
 	int vote;
+	int64 last_votecall;
 
 	//
 	int64 last_chat;