X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fvote.qc;h=6edccafb156f8a48a40a325ff67438b533c88282;hp=522ef4b7a4d5f2cda5960f3e3dffd0ee18273e8e;hb=4dd3c23aa51dd6fe855d8c5d97126a12a372eb3b;hpb=76fc4a57414acf55e252fd3d44a28a9c6f79aa50;ds=sidebyside diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 522ef4b7a..6edccafb1 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -1,3 +1,25 @@ +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include "../../dpdefs/progsdefs.qh" + #include "../../dpdefs/dpextensions.qh" + #include "../../common/constants.qh" + #include "../../common/util.qh" + #include "../../common/command/shared_defs.qh" + #include "../autocvars.qh" + #include "../constants.qh" + #include "../defs.qh" + #include "../../common/notifications.qh" + #include "../mutators/mutators_include.qh" + #include "../../common/mapinfo.qh" + #include "common.qh" + #include "vote.qh" + #include "../../common/playerstats.qh" + #include "../scores.qh" + #include "../race.qh" + #include "../round_handler.qh" +#endif + // ============================================= // Server side voting code, reworked by Samual // Last updated: December 27th, 2011 @@ -6,7 +28,7 @@ // Nagger for players to know status of voting float Nagger_SendEntity(entity to, float sendflags) { - float nags, i, f, b; + int nags, i, f, b; entity e; WriteByte(MSG_ENTITY, ENT_CLIENT_NAGGER); @@ -69,12 +91,12 @@ float Nagger_SendEntity(entity to, float sendflags) } } - return TRUE; + return true; } void Nagger_Init() { - Net_LinkEntity(nagger = spawn(), FALSE, 0, Nagger_SendEntity); + Net_LinkEntity(nagger = spawn(), false, 0, Nagger_SendEntity); } void Nagger_VoteChanged() @@ -306,7 +328,7 @@ void VoteThink() if(vote_endtime > 0) // a vote was called if(time > vote_endtime) // time is up { - VoteCount(FALSE); + VoteCount(false); } return; @@ -396,7 +418,7 @@ void reset_map(float dorespawn) void ReadyRestart_think() { restart_mapalreadyrestarted = 1; - reset_map(TRUE); + reset_map(true); Score_ClearAll(); remove(self); @@ -457,7 +479,7 @@ void ReadyRestart_force() if(autocvar_sv_timeout) { FOR_EACH_REALPLAYER(tmp_player) { tmp_player.allowed_timeouts = autocvar_sv_timeout_number; } } //reset map immediately if this cvar is not set - if (!autocvar_sv_ready_restart_after_countdown) { reset_map(TRUE); } + if (!autocvar_sv_ready_restart_after_countdown) { reset_map(true); } if(autocvar_sv_eventlog) { GameLogEcho(":restart"); } } @@ -523,10 +545,10 @@ float Votecommand_check_assignment(entity caller, float assignment) || ((!from_server && assignment == VC_ASGNMNT_CLIENTONLY) || (from_server && assignment == VC_ASGNMNT_SERVERONLY))) { - return TRUE; + return true; } - return FALSE; + return false; } string VoteCommand_extractcommand(string input, float startpos, float argc) @@ -547,9 +569,9 @@ float VoteCommand_checknasty(string vote_command) || (strstrofs(vote_command, "\n", 0) >= 0) || (strstrofs(vote_command, "\r", 0) >= 0) || (strstrofs(vote_command, "$", 0) >= 0)) - return FALSE; + return false; - return TRUE; + return true; } float VoteCommand_checkinlist(string vote_command, string list) @@ -557,9 +579,9 @@ float VoteCommand_checkinlist(string vote_command, string list) string l = strcat(" ", list, " "); if(strstrofs(l, strcat(" ", vote_command, " "), 0) >= 0) - return TRUE; + return true; - return FALSE; + return false; } string ValidateMap(string validated_map, entity caller) @@ -599,7 +621,7 @@ float VoteCommand_checkargs(float startpos, float argc) float checkmate; if(cmdrestriction == "") - return TRUE; + return true; ++startpos; // skip command name @@ -611,11 +633,11 @@ float VoteCommand_checkargs(float startpos, float argc) minargs = stof(cmdrestriction); if(argc - startpos < minargs) - return FALSE; + return false; p = strstrofs(cmdrestriction, ";", 0); // find first semicolon - for(;;) + for (;;) { // we know that at any time, startpos <= argc - minargs // so this means: argc-minargs >= startpos >= argc, thus @@ -632,7 +654,7 @@ float VoteCommand_checkargs(float startpos, float argc) break; // otherwise fail - return FALSE; + return false; } // cut to next semicolon @@ -652,7 +674,7 @@ float VoteCommand_checkargs(float startpos, float argc) checkmate = strlen(arg); for(check = 0; check < checkmate; ++check) if(strstrofs(charlist, substring(arg, check, 1), 0) < 0) - return FALSE; // not allowed character + return false; // not allowed character // all characters are allowed. FINE. } @@ -661,7 +683,7 @@ float VoteCommand_checkargs(float startpos, float argc) p = q; } - return TRUE; + return true; } float VoteCommand_parse(entity caller, string vote_command, string vote_list, float startpos, float argc) @@ -680,13 +702,13 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl && (strlen(substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos))) > autocvar_sv_vote_limit) ) - return FALSE; + return false; if (!VoteCommand_checkinlist(first_command, vote_list)) - return FALSE; + return false; if (!VoteCommand_checkargs(startpos, argc)) - return FALSE; + return false; switch(first_command) // now go through and parse the proper commands to adjust as needed. { @@ -694,7 +716,7 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl case "kickban": // catch all kick/kickban commands { entity victim = GetIndexedEntity(argc, (startpos + 1)); - float accepted = VerifyClientEntity(victim, TRUE, FALSE); + float accepted = VerifyClientEntity(victim, true, false); if(accepted > 0) { @@ -709,7 +731,7 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl vote_parsed_command = strcat(first_command, " # ", ftos(num_for_edict(victim)), " ", command_arguments); vote_parsed_display = strcat("^1", vote_command, " (^7", victim.netname, "^1): ", reason); } - else { print_to(caller, strcat("vcall: ", GetClientErrorString(accepted, argv(startpos + 1)), ".\n")); return FALSE; } + else { print_to(caller, strcat("vcall: ", GetClientErrorString(accepted, argv(startpos + 1)), ".\n")); return false; } break; } @@ -719,7 +741,7 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl case "gotomap": // re-direct all map selection commands to gotomap { vote_command = ValidateMap(argv(startpos + 1), caller); - if (!vote_command) { return FALSE; } + if (!vote_command) { return false; } vote_parsed_command = strcat("gotomap ", vote_command); vote_parsed_display = strzone(strcat("^1", vote_parsed_command)); @@ -735,7 +757,7 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl } } - return TRUE; + return true; } @@ -757,7 +779,7 @@ void VoteCommand_abstain(float request, entity caller) // CLIENT ONLY print_to(caller, "^1You abstained from your vote."); caller.vote_selection = VOTE_SELECT_ABSTAIN; msg_entity = caller; - if(!autocvar_sv_vote_singlecount) { VoteCount(FALSE); } + if(!autocvar_sv_vote_singlecount) { VoteCount(false); } } return; @@ -819,7 +841,7 @@ void VoteCommand_call(float request, entity caller, float argc, string vote_comm bprint("\{1}^2* ^3", GetCallerName(vote_caller), "^2 calls a vote for ", vote_called_display, "\n"); if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vcall:", ftos(vote_caller.playerid), ":", vote_called_display)); } Nagger_VoteChanged(); - VoteCount(TRUE); // needed if you are the only one + VoteCount(true); // needed if you are the only one } return; @@ -874,7 +896,7 @@ void VoteCommand_master(float request, entity caller, float argc, string vote_co else // everything went okay, proceed with giving this player master privilages { - caller.vote_master = TRUE; + caller.vote_master = true; print_to(caller, strcat("Accepted vote master login from ", GetCallerName(caller))); bprint("\{1}^2* ^3", GetCallerName(caller), "^2 logged in as ^3master^2\n"); if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vlogin:", ftos(caller.playerid))); } @@ -908,7 +930,7 @@ void VoteCommand_master(float request, entity caller, float argc, string vote_co bprint("\{1}^2* ^3", GetCallerName(vote_caller), "^2 calls a vote to become ^3master^2.\n"); if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vcall:", ftos(vote_caller.playerid), ":", vote_called_display)); } Nagger_VoteChanged(); - VoteCount(TRUE); // needed if you are the only one + VoteCount(true); // needed if you are the only one } return; @@ -946,7 +968,7 @@ void VoteCommand_no(float request, entity caller) // CLIENT ONLY print_to(caller, "^1You rejected the vote."); caller.vote_selection = VOTE_SELECT_REJECT; msg_entity = caller; - if(!autocvar_sv_vote_singlecount) { VoteCount(FALSE); } + if(!autocvar_sv_vote_singlecount) { VoteCount(false); } } return; @@ -1023,7 +1045,7 @@ void VoteCommand_yes(float request, entity caller) // CLIENT ONLY print_to(caller, "^1You accepted the vote."); caller.vote_selection = VOTE_SELECT_ACCEPT; msg_entity = caller; - if(!autocvar_sv_vote_singlecount) { VoteCount(FALSE); } + if(!autocvar_sv_vote_singlecount) { VoteCount(false); } } return; @@ -1089,7 +1111,7 @@ void VoteCommand_macro_help(entity caller, float argc) #define VOTE_COMMAND(name,function,description,assignment) \ { if(Votecommand_check_assignment(caller, assignment)) { print_to(caller, strcat(" ^2", name, "^7: ", description)); } } - VOTE_COMMANDS(0, caller, 0, "") + VOTE_COMMANDS(0, caller, 0, ""); #undef VOTE_COMMAND print_to(caller, strcat("\nUsage:^3 ", command_origin, " vote COMMAND...^7, where possible commands are listed above.\n")); @@ -1101,7 +1123,7 @@ void VoteCommand_macro_help(entity caller, float argc) #define VOTE_COMMAND(name,function,description,assignment) \ { if(Votecommand_check_assignment(caller, assignment)) { if(name == strtolower(argv(2))) { function; return; } } } - VOTE_COMMANDS(CMD_REQUEST_USAGE, caller, argc, "") + VOTE_COMMANDS(CMD_REQUEST_USAGE, caller, argc, ""); #undef VOTE_COMMAND } @@ -1111,12 +1133,12 @@ void VoteCommand_macro_help(entity caller, float argc) float VoteCommand_macro_command(entity caller, float argc, string vote_command) { #define VOTE_COMMAND(name,function,description,assignment) \ - { if(Votecommand_check_assignment(caller, assignment)) { if(name == strtolower(argv(1))) { function; return TRUE; } } } + { if(Votecommand_check_assignment(caller, assignment)) { if(name == strtolower(argv(1))) { function; return true; } } } - VOTE_COMMANDS(CMD_REQUEST_COMMAND, caller, argc, vote_command) + VOTE_COMMANDS(CMD_REQUEST_COMMAND, caller, argc, vote_command); #undef VOTE_COMMAND - return FALSE; + return false; }