r4746 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Oct 14 05:00:46 EDT 2008


Author: div0
Date: 2008-10-14 05:00:38 -0400 (Tue, 14 Oct 2008)
New Revision: 4746

Modified:
   trunk/data/qcsrc/server/clientcommands.qc
   trunk/data/qcsrc/server/vote.qc
   trunk/data/qcsrc/server/vote.qh
Log:
ignore empty "say" commands, make all argv_start_index calls check if the index is in range


Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc	2008-10-14 08:53:07 UTC (rev 4745)
+++ trunk/data/qcsrc/server/clientcommands.qc	2008-10-14 09:00:38 UTC (rev 4746)
@@ -223,9 +223,9 @@
 //float ctf_clientcommand();
 void SV_ParseClientCommand(string s) {
 	local string cmd;
-	local float i;
+	local float i, tokens;
 
-	tokenize_sane(s);
+	tokens = tokenize_sane(s);
 
 	if(GameCommand_Vote(s, self)) {
 		return;
@@ -371,10 +371,12 @@
 	} else if(argv(0) == "voice") {
 		VoiceMessage(argv(1));
 	} else if(argv(0) == "say") {
-		Say(self, FALSE, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
+		if(tokens >= 2)
+			Say(self, FALSE, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
 		//clientcommand(self, formatmessage(s));
 	} else if(argv(0) == "say_team") {
-		Say(self, TRUE, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
+		if(tokens >= 2)
+			Say(self, TRUE, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
 		//clientcommand(self, formatmessage(s));
 	} else if(argv(0) == "info") {
 		cmd = cvar_string(strcat("sv_info_", argv(1)));

Modified: trunk/data/qcsrc/server/vote.qc
===================================================================
--- trunk/data/qcsrc/server/vote.qc	2008-10-14 08:53:07 UTC (rev 4745)
+++ trunk/data/qcsrc/server/vote.qc	2008-10-14 09:00:38 UTC (rev 4746)
@@ -37,7 +37,10 @@
 
 	if(ns != "")
 	{
-		GetKickVoteVictim_reason = substring(vote, argv_start_index(t), argv_end_index(-1) - argv_start_index(t));
+		if(t < tokens)
+			GetKickVoteVictim_reason = substring(vote, argv_start_index(t), argv_end_index(-1) - argv_start_index(t));
+		else
+			GetKickVoteVictim_reason = "";
 
 		n = stof(ns);
 		if(ns == ftos(n)) if(n >= 1) if(n <= maxclients)
@@ -108,7 +111,8 @@
 }
 
 float GameCommand_Vote(string s, entity e) {
-	tokenize_sane(s);
+	float argc;
+	argc = tokenize_sane(s);
 	if(argv(0) == "help") {
 		print_to(e, "  vote COMMANDS ARGUMENTS. See 'vote help' for more info.");
 		return TRUE;
@@ -135,7 +139,7 @@
 					print_to(e, "^1There is already a vote called.");
 				} else {
 					local string vote;
-					vote = VoteParse(s);
+					vote = VoteParse(s, argc);
 					if(vote == "") {
 						print_to(e, "^1Your vote is empty. See help for more info.");
 					} else if(e
@@ -205,7 +209,7 @@
 		} else if(argv(1) == "do") {
 			if(!e || e.vote_master) {
 				local string dovote;
-				dovote = VoteParse(s);
+				dovote = VoteParse(s, argc);
 				if(dovote == "") {
 					print_to(e, "^1Your command was empty. See help for more info.");
 				} else if(VoteCheckNasty(dovote)) {
@@ -375,7 +379,9 @@
 	}
 }
 
-string VoteParse(string all) {
+string VoteParse(string all, float argc) {
+	if(argc < 3)
+		return "";
 	return substring(all, argv_start_index(2), argv_end_index(-1) - argv_start_index(2));
 }
 

Modified: trunk/data/qcsrc/server/vote.qh
===================================================================
--- trunk/data/qcsrc/server/vote.qh	2008-10-14 08:53:07 UTC (rev 4745)
+++ trunk/data/qcsrc/server/vote.qh	2008-10-14 09:00:38 UTC (rev 4746)
@@ -8,7 +8,7 @@
 string VoteNetname(entity e);
 string ValidateMap(string m, entity e);
 void VoteThink();
-string VoteParse(string s);
+string VoteParse(string s, float tokens);
 float VoteAllowed(string votecommand);
 void VoteReset();
 void VoteAccept();




More information about the nexuiz-commits mailing list