From cc441691d8e5b4c6650e279805d7657593436d3f Mon Sep 17 00:00:00 2001 From: kadaverjack Date: Tue, 21 Mar 2006 00:38:46 +0000 Subject: [PATCH] "vcall (map|chmap)" checks now if a map exists and tells the user if it doesn't git-svn-id: svn://svn.icculus.org/nexuiz/trunk@1171 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/gamec/clientcommands.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/data/qcsrc/server/gamec/clientcommands.c b/data/qcsrc/server/gamec/clientcommands.c index b3ec2ba1e..d2e3e8598 100644 --- a/data/qcsrc/server/gamec/clientcommands.c +++ b/data/qcsrc/server/gamec/clientcommands.c @@ -1,4 +1,5 @@ void ReadyCount(); +float ValidateMap(string vote); void SV_ParseClientCommand(string s) { local float index; @@ -80,6 +81,8 @@ void SV_ParseClientCommand(string s) { } else if(time < self.vote_next) { sprint(self, strcat("^1You have to wait ^2", ftos(self.vote_next - time), "^1 seconds before you can again call a vote.\n")); } else if(VoteAllowed(strcat(argv(2)))) { // strcat seems to be necessary + if(!ValidateMap(vote)) + return; votecalled = TRUE; votecalledmaster = FALSE; votecalledvote = strzone(vote); @@ -240,6 +243,27 @@ void SV_ParseClientCommand(string s) { } } +float ValidateMap(string vote) +{ + string ext; + + tokenize(vote); + if(argv(0) == "map") + ext = ".bsp"; + else if(argv(0) == "chmap") + ext = ".mapcfg"; + else + return TRUE; + + if(!TryFile(strcat("maps/", argv(1), ext))) + { + sprint(self, strcat("^1Invalid mapname, \"^3", argv(1), "^1\" does not exist on this server.\n")); + return FALSE; + } + return TRUE; +} + + void VoteThink() { if(votefinished > 0 // a vote was called && time > votefinished) // time is up -- 2.39.2