From: Samual Date: Mon, 28 Nov 2011 07:31:06 +0000 (-0500) Subject: Working on map vote picture selection, plus some other edits X-Git-Tag: xonotic-v0.6.0~188^2~28^2~202 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e534789ccef413961784c355d2fbab923614d41d;p=xonotic%2Fxonotic-data.pk3dir.git Working on map vote picture selection, plus some other edits --- diff --git a/qcsrc/server/clientcommands.qc b/qcsrc/server/clientcommands.qc index 64ea6b7ac..552dc2ff3 100644 --- a/qcsrc/server/clientcommands.qc +++ b/qcsrc/server/clientcommands.qc @@ -1,6 +1,6 @@ // ========================================================= // Server side networked commands code, reworked by Samual -// Last updated: November 26th, 2011 +// Last updated: November 27th, 2011 // ========================================================= #define CC_REQUEST_COMMAND 1 @@ -12,6 +12,7 @@ .float lms_spectate_warning; string MapVote_Suggest(string m); +//void MapVote_SendPicture(float id) // ============================ @@ -164,6 +165,28 @@ void ClientCommand_cvar_purechanges(float request) } } +void ClientCommand_getmapvotepic(float request, float argc) +{ + switch(request) + { + case CC_REQUEST_COMMAND: + { + if(intermission_running) + MapVote_SendPicture(stof(argv(1))); + + return; // never fall through to usage + } + + default: + case CC_REQUEST_USAGE: + { + sprint(self, "\nUsage:^3 cmd getmapvotepic mapid\n"); + sprint(self, " Where 'mapid' is the id number of the map to request an image of on the map vote selection menu.\n"); + return; + } + } +} + void ClientCommand_info(float request, float argc) { switch(request) @@ -816,7 +839,7 @@ void ClientCommand_voice(float request, float argc, string command) } /* use this when creating a new command, making sure to place it in alphabetical order. -void ClientCommand_(float request) +void ClientCommand_(float request)ClientCommand_getmapvotepic(request, arguments) { switch(request) { @@ -849,6 +872,7 @@ void ClientCommand_(float request) CLIENT_COMMAND("clientversion", ClientCommand_clientversion(request, arguments), "Release version of the game") \ CLIENT_COMMAND("cvar_changes", ClientCommand_cvar_changes(request), "Prints a list of all changed server cvars") \ CLIENT_COMMAND("cvar_purechanges", ClientCommand_cvar_purechanges(request), "Prints a list of all changed gameplay cvars") \ + CLIENT_COMMAND("getmapvotepic", ClientCommand_getmapvotepic(request, arguments), "Retrieve mapshot picture from the server") \ CLIENT_COMMAND("info", ClientCommand_info(request, arguments), "Request for unique server information set up by admin") \ CLIENT_COMMAND("join", ClientCommand_join(request), "Become a player in the game") \ CLIENT_COMMAND("ladder", ClientCommand_ladder(request), "Get information about top players if supported") \ @@ -920,6 +944,7 @@ void SV_ParseClientCommand(string command) { // exempt commands which are not subject to floodcheck case "begin": break; // handled by engine in host_cmd.c + case "getmapvotepic": break; // handled by server in this file case "pause": break; // handled by engine in host_cmd.c case "prespawn": break; // handled by engine in host_cmd.c case "reportcvar": break; // handled by server in this file @@ -956,10 +981,6 @@ void SV_ParseClientCommand(string command) { return; // handled by server/vote.qc } - else if(GameCommand_MapVote(argv(0))) - { - return; // handled by server/g_world.qc - } else if(CheatCommand(argc)) { return; // handled by server/cheats.qc diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 7fcd14612..c9ce4e75f 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -2463,20 +2463,6 @@ void MapVote_SendPicture(float id) WritePicture(MSG_ONE, strcat(mapvote_screenshot_dirs[mapvote_maps_screenshot_dir[id]], "/", mapvote_maps[id]), 3072); } -float GameCommand_MapVote(string cmd) -{ - if(!intermission_running) - return FALSE; - - if(cmd == "mv_getpic") - { - MapVote_SendPicture(stof(argv(1))); - return TRUE; - } - - return FALSE; -} - float MapVote_GetMapMask() { float mask, i, power; diff --git a/qcsrc/server/vote.qc b/qcsrc/server/vote.qc index f5bf7727a..dcc2da1b1 100644 --- a/qcsrc/server/vote.qc +++ b/qcsrc/server/vote.qc @@ -433,7 +433,200 @@ float VoteCommand_macro_usage(float argc) return FALSE; } - +/* + } else if(argv(0) == "vote") { + if(argv(1) == "") { + print_to(e, "^1You have to supply a vote command. See 'vhelp' for more info."); + } else if(argv(1) == "help") { + VoteHelp(e); + } else if(argv(1) == "status") { + if(votecalled) { + print_to(e, strcat("^7Vote for ", votecalledvote_display, "^7 called by ^7", VoteNetname(votecaller), "^7.")); + } else { + print_to(e, "^1No vote called."); + } + } else if(argv(1) == "call") { + if(!e || autocvar_sv_vote_call) { + if(autocvar_sv_vote_nospectators && e && e.classname != "player") { + print_to(e, "^1Error: Only players can call a vote."); // TODO invent a cvar name for allowing votes by spectators during warmup anyway + } + else if(timeoutStatus) { //don't allow a vote call during a timeout + print_to(e, "^1Error: You can not call a vote while a timeout is active."); + } + else if(votecalled) { + print_to(e, "^1There is already a vote called."); + } else { + string vote; + vote = VoteParse(s, argc); + if(vote == "") { + print_to(e, "^1Your vote is empty. See 'vhelp' for more info."); + } else if(e + && time < e.vote_next) { + print_to(e, strcat("^1You have to wait ^2", ftos(ceil(e.vote_next - time)), "^1 seconds before you can again call a vote.")); + } else if(VoteCheckNasty(vote)) { + print_to(e, "Syntax error in command. See 'vhelp' for more info."); + } else if(RemapVote(vote, "vcall", e)) { + votecalledvote = strzone(RemapVote_vote); + votecalledvote_display = strzone(RemapVote_display); + votecalled = TRUE; + votecalledmaster = FALSE; + votefinished = time + autocvar_sv_vote_timeout; + votecaller = e; // remember who called the vote + if(e) { + e.vote_vote = 1; // of course you vote yes + e.vote_next = time + autocvar_sv_vote_wait; + } + bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2 calls a vote for ", votecalledvote_display, "\n"); + if(autocvar_sv_eventlog) + GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display)); + Nagger_VoteChanged(); + VoteCount(); // needed if you are the only one + msg_entity = e; + + entity player; + FOR_EACH_REALCLIENT(player) + { + ++playercount; + } + if(playercount > 1) // don't announce a "vote now" sound if player is alone + Announce("votecall"); + } else { + print_to(e, "^1This vote is not ok. See 'vhelp' for more info."); + } + } + } else { + print_to(e, "^1Vote calling is NOT allowed."); + } + } else if(argv(1) == "stop") { + if(!votecalled) { + print_to(e, "^1No vote called."); + } else if(e == votecaller) { // the votecaller can stop a vote + VoteStop(e); + } else if(!e) { // server admin / console can too + VoteStop(e); + } else if(e.vote_master) { // masters can too + VoteStop(e); + } else { + print_to(e, "^1You are not allowed to stop that Vote."); + } + } else if(argv(1) == "master") { + if(autocvar_sv_vote_master) { + if(votecalled) { + print_to(e, "^1There is already a vote called."); + } else { + votecalled = TRUE; + votecalledmaster = TRUE; + votecalledvote = strzone("XXX"); + votecalledvote_display = strzone("^3master"); + votefinished = time + autocvar_sv_vote_timeout; + votecaller = e; // remember who called the vote + if(e) { + e.vote_vote = 1; // of course you vote yes + e.vote_next = time + autocvar_sv_vote_wait; + } + bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2 calls a vote to become ^3master^2.\n"); + if(autocvar_sv_eventlog) + GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display)); + Nagger_VoteChanged(); + VoteCount(); // needed if you are the only one + } + } else { + print_to(e, "^1Vote to become master is NOT allowed."); + } + } else if(argv(1) == "do") { + if(!e || e.vote_master) { + string dovote; + dovote = VoteParse(s, argc); + if(dovote == "") { + print_to(e, "^1Your command was empty. See 'vhelp' for more info."); + } else if(VoteCheckNasty(dovote)) { + print_to(e, "Syntax error in command. See 'vhelp' for more info."); + } else if(RemapVote(dovote, "vdo", e)) { // strcat seems to be necessary + bprint("\{1}^2* ^3", VoteNetname(e), "^2 used their ^3master^2 status to do \"^2", RemapVote_display, "^2\".\n"); + if(autocvar_sv_eventlog) + GameLogEcho(strcat(":vote:vdo:", ftos(e.playerid), ":", RemapVote_display)); + localcmd(strcat(RemapVote_vote, "\n")); + } else { + print_to(e, "^1This command is not ok. See 'vhelp' for more info."); + } + } else { + print_to(e, "^1You are NOT a master. You might need to login or vote to become master first. See 'vhelp' for more info."); + } + } else if(argv(1) == "login") { + string masterpwd; + masterpwd = autocvar_sv_vote_master_password; + if(masterpwd != "") { + float granted; + granted = (masterpwd == argv(2)); + if (e) + e.vote_master = granted; + if(granted) { + print("Accepted master login from ", VoteNetname(e), "\n"); + bprint("\{1}^2* ^3", VoteNetname(e), "^2 logged in as ^3master^2\n"); + if(autocvar_sv_eventlog) + GameLogEcho(strcat(":vote:vlogin:", ftos(e.playerid))); + } + else + print("REJECTED master login from ", VoteNetname(e), "\n"); + } + else + print_to(e, "^1Login to become master is NOT allowed."); + } else if(argv(1) == "yes") { + if(!votecalled) { + print_to(e, "^1No vote called."); + } else if (!e) { + print_to(e, "^1You can't vote from the server console."); + } else if(e.vote_vote == 0 + || autocvar_sv_vote_change) { + msg_entity = e; + print_to(e, "^1You accepted the vote."); + e.vote_vote = 1; + if(!autocvar_sv_vote_singlecount) { + VoteCount(); + } + } else { + print_to(e, "^1You have already voted."); + } + } else if(argv(1) == "no") { + if(!votecalled) { + print_to(e, "^1No vote called."); + } else if (!e) { + print_to(e, "^1You can't vote from the server console."); + } else if(e.vote_vote == 0 + || autocvar_sv_vote_change) { + msg_entity = e; + print_to(e, "^1You rejected the vote."); + e.vote_vote = -1; + if(!autocvar_sv_vote_singlecount) { + VoteCount(); + } + } else { + print_to(e, "^1You have already voted."); + } + } else if(argv(1) == "abstain" || argv(1) == "dontcare") { + if(!votecalled) { + print_to(e, "^1No vote called."); + } else if (!e) { + print_to(e, "^1You can't vote from the server console."); + } else if(e.vote_vote == 0 + || autocvar_sv_vote_change) { + msg_entity = e; + print_to(e, "^1You abstained from your vote."); + e.vote_vote = -2; + if(!autocvar_sv_vote_singlecount) { + VoteCount(); + } + } else { + print_to(e, "^1You have already voted."); + } + } else { + // ignore this? + print_to(e, "^1Unknown vote command."); + } + return TRUE; + } + return FALSE; +*/ // ====================================== // Main function handling vote commands // ======================================