From db26b7fe7334411667e7f2bb7d702213859f98bf Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 27 Oct 2015 12:15:24 +1100 Subject: [PATCH] Uncrustify server/command/* --- qcsrc/server/command/banning.qc | 119 ++--- qcsrc/server/command/banning.qh | 4 +- qcsrc/server/command/cmd.qc | 374 +++++++------ qcsrc/server/command/common.qc | 385 +++++++------- qcsrc/server/command/common.qh | 44 +- qcsrc/server/command/getreplies.qc | 170 +++--- qcsrc/server/command/getreplies.qh | 4 +- qcsrc/server/command/radarmap.qc | 213 ++++---- qcsrc/server/command/sv_cmd.qc | 819 +++++++++++++++-------------- qcsrc/server/command/sv_cmd.qh | 2 +- qcsrc/server/command/vote.qc | 641 +++++++++++----------- qcsrc/server/command/vote.qh | 28 +- 12 files changed, 1430 insertions(+), 1373 deletions(-) diff --git a/qcsrc/server/command/banning.qc b/qcsrc/server/command/banning.qc index f325dcd72..30d6291f6 100644 --- a/qcsrc/server/command/banning.qc +++ b/qcsrc/server/command/banning.qc @@ -15,11 +15,11 @@ void BanCommand_ban(float request, float argc, string command) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc >= 2) + if (argc >= 2) { string ip = argv(1); float reason_arg, bantime; @@ -51,7 +51,7 @@ void BanCommand_ban(float request, float argc, string command) void BanCommand_banlist(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -72,18 +72,18 @@ void BanCommand_banlist(float request) void BanCommand_kickban(float request, float argc, string command) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc >= 2) + if (argc >= 2) { entity client = GetIndexedEntity(argc, 1); float accepted = VerifyKickableEntity(client); float reason_arg, bantime, masksize; string reason; - if(accepted > 0) + if (accepted > 0) { reason_arg = next_token; @@ -117,18 +117,18 @@ void BanCommand_kickban(float request, float argc, string command) } } -void BanCommand_mute(float request, float argc, string command) // TODO: Add a sort of mute-"ban" which allows players to be muted based on IP/cryptokey +void BanCommand_mute(float request, float argc, string command) // TODO: Add a sort of mute-"ban" which allows players to be muted based on IP/cryptokey { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc >= 2) + if (argc >= 2) { entity client = GetFilteredEntity(argv(1)); float accepted = VerifyClientEntity(client, true, false); - if(accepted > 0) + if (accepted > 0) { client.muted = true; return; @@ -154,39 +154,32 @@ void BanCommand_mute(float request, float argc, string command) // TODO: Add a s void BanCommand_unban(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1)) + if (argv(1)) { float tmp_number = -1; string tmp_string; - if(substring(argv(1), 0, 1) == "#") + if (substring(argv(1), 0, 1) == "#") { tmp_string = substring(argv(1), 1, -1); - if(tmp_string != "") // is it all one token? like #1 - { + if (tmp_string != "") // is it all one token? like #1 tmp_number = stof(tmp_string); - } - else if(argc > 2) // no, it's two tokens? # 1 - { + else if (argc > 2) // no, it's two tokens? # 1 tmp_number = stof(argv(2)); - } - else - tmp_number = -1; + else tmp_number = -1; } - else // maybe it's ONLY a number? + else // maybe it's ONLY a number? { tmp_number = stof(argv(1)); - if((tmp_number == 0) && (argv(1) != "0")) - { tmp_number = -1; } - } + if ((tmp_number == 0) && (argv(1) != "0")) tmp_number = -1; } - if(tmp_number >= 0) + if (tmp_number >= 0) { Ban_Delete(tmp_number); return; @@ -207,16 +200,16 @@ void BanCommand_unban(float request, float argc) void BanCommand_unmute(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc >= 2) + if (argc >= 2) { entity client = GetFilteredEntity(argv(1)); float accepted = VerifyClientEntity(client, true, false); - if(accepted > 0) + if (accepted > 0) { client.muted = false; return; @@ -244,22 +237,22 @@ void BanCommand_unmute(float request, float argc) ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION! void BanCommand_(float request) { - switch(request) - { - case CMD_REQUEST_COMMAND: - { - - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 sv_cmd \n"); - print(" No arguments required.\n"); - return; - } - } + switch(request) + { + case CMD_REQUEST_COMMAND: + { + + return; + } + + default: + case CMD_REQUEST_USAGE: + { + print("\nUsage:^3 sv_cmd \n"); + print(" No arguments required.\n"); + return; + } + } } */ @@ -269,7 +262,7 @@ void BanCommand_(float request) // ================================== // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;) -#define BAN_COMMANDS(request,arguments,command) \ +#define BAN_COMMANDS(request, arguments, command) \ BAN_COMMAND("ban", BanCommand_ban(request, arguments, command), "Ban an IP address or a range of addresses (like 1.2.3)") \ BAN_COMMAND("banlist", BanCommand_banlist(request), "List all existing bans") \ BAN_COMMAND("kickban", BanCommand_kickban(request, arguments, command), "Disconnect a client and ban it at the same time") \ @@ -280,46 +273,42 @@ void BanCommand_(float request) void BanCommand_macro_help() { - #define BAN_COMMAND(name,function,description) \ - { if(strtolower(description) != "") { LOG_INFO(" ^2", name, "^7: ", description, "\n"); } } + #define BAN_COMMAND(name, function, description) \ + { if (strtolower(description) != "") { LOG_INFO(" ^2", name, "^7: ", description, "\n"); } } BAN_COMMANDS(0, 0, ""); - #undef BAN_COMMAND - - return; +#undef BAN_COMMAND } float BanCommand_macro_command(float argc, string command) { - #define BAN_COMMAND(name,function,description) \ - { if(name == strtolower(argv(0))) { function; return true; } } + #define BAN_COMMAND(name, function, description) \ + { if (name == strtolower(argv(0))) { function; return true; } } BAN_COMMANDS(CMD_REQUEST_COMMAND, argc, command); - #undef BAN_COMMAND +#undef BAN_COMMAND return false; } float BanCommand_macro_usage(float argc) { - #define BAN_COMMAND(name,function,description) \ - { if(name == strtolower(argv(1))) { function; return true; } } + #define BAN_COMMAND(name, function, description) \ + { if (name == strtolower(argv(1))) { function; return true; } } BAN_COMMANDS(CMD_REQUEST_USAGE, argc, ""); - #undef BAN_COMMAND +#undef BAN_COMMAND return false; } void BanCommand_macro_write_aliases(float fh) { - #define BAN_COMMAND(name,function,description) \ - { if(strtolower(description) != "") { CMD_Write_Alias("qc_cmd_sv", name, description); } } + #define BAN_COMMAND(name, function, description) \ + { if (strtolower(description) != "") { CMD_Write_Alias("qc_cmd_sv", name, description); } } BAN_COMMANDS(0, 0, ""); - #undef BAN_COMMAND - - return; +#undef BAN_COMMAND } float BanCommand(string command) @@ -331,10 +320,8 @@ float BanCommand(string command) // argv: 0 - 1 - 2 - 3 // cmd vote - master - login - password - if(BanCommand_macro_command(argc, command)) // continue as usual and scan for normal commands - { - return true; // handled by one of the above GenericCommand_* functions - } + if (BanCommand_macro_command(argc, command)) // continue as usual and scan for normal commands + return true; // handled by one of the above GenericCommand_* functions return false; } diff --git a/qcsrc/server/command/banning.qh b/qcsrc/server/command/banning.qh index 17eca95c7..a330ff1b0 100644 --- a/qcsrc/server/command/banning.qh +++ b/qcsrc/server/command/banning.qh @@ -6,8 +6,8 @@ // Last updated: December 29th, 2011 // ===================================== -#define GET_BAN_ARG(v,d) if(argc > reason_arg) { if((v = stof(argv(reason_arg))) != 0) ++reason_arg; else v = d; } else { v = d; } -#define GET_BAN_REASON(v,d) if(argc > reason_arg) v = substring(command, argv_start_index(reason_arg), strlen(command) - argv_start_index(reason_arg)); else v = d; +#define GET_BAN_ARG(v, d) if (argc > reason_arg) { if ((v = stof(argv(reason_arg))) != 0) ++reason_arg; else v = d; } else { v = d; } +#define GET_BAN_REASON(v, d) if (argc > reason_arg) v = substring(command, argv_start_index(reason_arg), strlen(command) - argv_start_index(reason_arg)); else v = d; void Ban_KickBanClient(entity client, float bantime, float masksize, string reason); void Ban_View(); diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 69517738b..ac21bc62d 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -35,7 +35,7 @@ #include "../../lib/warpzone/common.qh" -void ClientKill_TeamChange (float targetteam); // 0 = don't change, -1 = auto, -2 = spec +void ClientKill_TeamChange(float targetteam); // 0 = don't change, -1 = auto, -2 = spec // ========================================================= // Server side networked commands code, reworked by Samual @@ -43,13 +43,14 @@ void ClientKill_TeamChange (float targetteam); // 0 = don't change, -1 = auto, - // ========================================================= float SV_ParseClientCommand_floodcheck() -{SELFPARAM(); - if (!timeout_status) // not while paused +{ + SELFPARAM(); + if (!timeout_status) // not while paused { - if(time <= (self.cmd_floodtime + autocvar_sv_clientcommand_antispam_time)) + if (time <= (self.cmd_floodtime + autocvar_sv_clientcommand_antispam_time)) { self.cmd_floodcount += 1; - if(self.cmd_floodcount > autocvar_sv_clientcommand_antispam_count) { return false; } // too much spam, halt + if (self.cmd_floodcount > autocvar_sv_clientcommand_antispam_count) return false; // too much spam, halt } else { @@ -57,7 +58,7 @@ float SV_ParseClientCommand_floodcheck() self.cmd_floodcount = 1; } } - return true; // continue, as we're not flooding yet + return true; // continue, as we're not flooding yet } @@ -66,12 +67,13 @@ float SV_ParseClientCommand_floodcheck() // ======================= void ClientCommand_autoswitch(float request, float argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { self.autoswitch = InterpretBoolean(argv(1)); sprint(self, strcat("^1autoswitch is currently turned ", (self.autoswitch ? "on" : "off"), ".\n")); @@ -90,30 +92,31 @@ void ClientCommand_autoswitch(float request, float argc) } } -void ClientCommand_clientversion(float request, float argc) // internal command, used only by code -{SELFPARAM(); - switch(request) +void ClientCommand_clientversion(float request, float argc) // internal command, used only by code +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { - if(IS_CLIENT(self)) + if (IS_CLIENT(self)) { self.version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1))); - if(self.version < autocvar_gameversion_min || self.version > autocvar_gameversion_max) + if (self.version < autocvar_gameversion_min || self.version > autocvar_gameversion_max) { self.version_mismatch = 1; - ClientKill_TeamChange(-2); // observe + ClientKill_TeamChange(-2); // observe } - else if(autocvar_g_campaign || autocvar_g_balance_teams) + else if (autocvar_g_campaign || autocvar_g_balance_teams) { - //JoinBestTeam(self, false, true); + // JoinBestTeam(self, false, true); } - else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0)) + else if (teamplay && !autocvar_sv_spectate && !(self.team_forced > 0)) { - self.classname = STR_OBSERVER; // really? + self.classname = STR_OBSERVER; // really? stuffcmd(self, "menu_showteamselect\n"); } } @@ -133,16 +136,16 @@ void ClientCommand_clientversion(float request, float argc) // internal command, } } -void ClientCommand_mv_getpicture(float request, float argc) // internal command, used only by code -{SELFPARAM(); - switch(request) +void ClientCommand_mv_getpicture(float request, float argc) // internal command, used only by code +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { - if(intermission_running) - MapVote_SendPicture(stof(argv(1))); + if (intermission_running) MapVote_SendPicture(stof(argv(1))); return; } @@ -160,21 +163,20 @@ void ClientCommand_mv_getpicture(float request, float argc) // internal command, } void ClientCommand_join(float request) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(IS_CLIENT(self)) + if (IS_CLIENT(self)) { - if(!IS_PLAYER(self) && !lockteams && !gameover) + if (!IS_PLAYER(self) && !lockteams && !gameover) { - if(self.caplayer) - return; - if(nJoinAllowed(self)) + if (self.caplayer) return; + if (nJoinAllowed(self)) { - if(autocvar_g_campaign) { campaign_bots_may_start = 1; } - + if (autocvar_g_campaign) campaign_bots_may_start = 1; self.classname = STR_PLAYER; PlayerScore_Clear(self); Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN); @@ -183,12 +185,12 @@ void ClientCommand_join(float request) } else { - //player may not join because of g_maxplayers is set + // player may not join because of g_maxplayers is set Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_PREVENT); } } } - return; // never fall through to usage + return; // never fall through to usage } default: @@ -202,26 +204,27 @@ void ClientCommand_join(float request) } void ClientCommand_physics(float request, float argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { string command = strtolower(argv(1)); - if(!autocvar_g_physics_clientselect) + if (!autocvar_g_physics_clientselect) { sprint(self, "Client physics selection is currently disabled.\n"); return; } - if(command == "list" || command == "help") + if (command == "list" || command == "help") { sprint(self, strcat("Available physics sets: \n\n", autocvar_g_physics_clientselect_options, " default\n")); return; } - if(Physics_Valid(command) || command == "default") + if (Physics_Valid(command) || command == "default") { stuffcmd(self, strcat("\nseta cl_physics ", command, "\nsendcvar cl_physics\n")); sprint(self, strcat("^2Physics set successfully changed to ^3", command, "\n")); @@ -241,21 +244,22 @@ void ClientCommand_physics(float request, float argc) } } -void ClientCommand_ready(float request) // todo: anti-spam for toggling readyness -{SELFPARAM(); - switch(request) +void ClientCommand_ready(float request) // todo: anti-spam for toggling readyness +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(IS_CLIENT(self)) + if (IS_CLIENT(self)) { - if(warmup_stage || autocvar_sv_ready_restart || g_race_qualifying == 2) + if (warmup_stage || autocvar_sv_ready_restart || g_race_qualifying == 2) { - if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable) + if (!readyrestart_happened || autocvar_sv_ready_restart_repeatable) { - if(time < game_starttime) // game is already restarting + if (time < game_starttime) // game is already restarting return; - if (self.ready) // toggle + if (self.ready) // toggle { self.ready = false; bprint(self.netname, "^2 is ^1NOT^2 ready\n"); @@ -267,14 +271,15 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes } // cannot reset the game while a timeout is active! - if (!timeout_status) - ReadyCount(); - } else { + if (!timeout_status) ReadyCount(); + } + else + { sprint(self, "^1Game has already been restarted\n"); } } } - return; // never fall through to usage + return; // never fall through to usage } default: @@ -288,13 +293,14 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes } void ClientCommand_say(float request, float argc, string command) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc >= 2) { Say(self, false, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); } - return; // never fall through to usage + if (argc >= 2) Say(self, false, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); + return; // never fall through to usage } default: @@ -308,13 +314,14 @@ void ClientCommand_say(float request, float argc, string command) } void ClientCommand_say_team(float request, float argc, string command) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc >= 2) { Say(self, true, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); } - return; // never fall through to usage + if (argc >= 2) Say(self, true, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); + return; // never fall through to usage } default: @@ -328,45 +335,58 @@ void ClientCommand_say_team(float request, float argc, string command) } void ClientCommand_selectteam(float request, float argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { - if(IS_CLIENT(self)) + if (IS_CLIENT(self)) { - if(teamplay) - if(self.team_forced <= 0) + if (teamplay) + { + if (self.team_forced <= 0) + { if (!lockteams) { float selection; - switch(argv(1)) + switch (argv(1)) { - case "red": selection = NUM_TEAM_1; break; - case "blue": selection = NUM_TEAM_2; break; - case "yellow": selection = NUM_TEAM_3; break; - case "pink": selection = NUM_TEAM_4; break; - case "auto": selection = (-1); break; - - default: selection = 0; break; + case "red": selection = NUM_TEAM_1; + break; + case "blue": selection = NUM_TEAM_2; + break; + case "yellow": selection = NUM_TEAM_3; + break; + case "pink": selection = NUM_TEAM_4; + break; + case "auto": selection = (-1); + break; + + default: selection = 0; + break; } - if(selection) + if (selection) { - if(self.team == selection && self.deadflag == DEAD_NO) + if (self.team == selection && self.deadflag == DEAD_NO) + { sprint(self, "^7You already are on that team.\n"); - else if(self.wasplayer && autocvar_g_changeteam_banned) + } + else if (self.wasplayer && autocvar_g_changeteam_banned) + { sprint(self, "^1You cannot change team, forbidden by the server.\n"); + } else { - if(autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance) + if (autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance) { CheckAllowedTeams(self); GetTeamCounts(self); - if(!TeamSmallerEqThanTeam(Team_TeamToNumber(selection), Team_TeamToNumber(self.team), self)) + if (!TeamSmallerEqThanTeam(Team_TeamToNumber(selection), Team_TeamToNumber(self.team), self)) { Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM); return; @@ -377,11 +397,19 @@ void ClientCommand_selectteam(float request, float argc) } } else + { sprint(self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n"); + } + } else + { sprint(self, "^7selectteam can not be used as your team is forced\n"); + } + } else + { sprint(self, "^7selectteam can only be used in teamgames\n"); + } } return; } @@ -400,12 +428,13 @@ void ClientCommand_selectteam(float request, float argc) } void ClientCommand_selfstuff(float request, string command) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { stuffcmd(self, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))); return; @@ -424,17 +453,18 @@ void ClientCommand_selfstuff(float request, string command) } void ClientCommand_sentcvar(float request, float argc, string command) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { - //float tokens; + // float tokens; string s; - if(argc == 2) // undefined cvar: use the default value on the server then + if (argc == 2) // undefined cvar: use the default value on the server then { s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\""); tokenize_console(s); @@ -458,22 +488,21 @@ void ClientCommand_sentcvar(float request, float argc, string command) } void ClientCommand_spectate(float request) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(IS_CLIENT(self)) + if (IS_CLIENT(self)) { int mutator_returnvalue = MUTATOR_CALLHOOK(ClientCommand_Spectate, self); - if(mutator_returnvalue == MUT_SPECCMD_RETURN) - return; + if (mutator_returnvalue == MUT_SPECCMD_RETURN) return; - if((IS_PLAYER(self) || mutator_returnvalue == MUT_SPECCMD_FORCE) && autocvar_sv_spectate == 1) - ClientKill_TeamChange(-2); // observe + if ((IS_PLAYER(self) || mutator_returnvalue == MUT_SPECCMD_FORCE) && autocvar_sv_spectate == 1) ClientKill_TeamChange(-2); // observe } - return; // never fall through to usage + return; // never fall through to usage } default: @@ -487,12 +516,13 @@ void ClientCommand_spectate(float request) } void ClientCommand_suggestmap(float request, float argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { sprint(self, strcat(MapVote_Suggest(argv(1)), "\n")); return; @@ -511,19 +541,20 @@ void ClientCommand_suggestmap(float request, float argc) } void ClientCommand_tell(float request, float argc, string command) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc >= 3) + if (argc >= 3) { entity tell_to = GetIndexedEntity(argc, 1); float tell_accepted = VerifyClientEntity(tell_to, true, false); - if(tell_accepted > 0) // the target is a real client + if (tell_accepted > 0) // the target is a real client { - if(tell_to != self) // and we're allowed to send to them :D + if (tell_to != self) // and we're allowed to send to them :D { // workaround for argv indexes indexing ascii chars instead of utf8 chars // In this case when the player name contains utf8 chars @@ -541,7 +572,7 @@ void ClientCommand_tell(float request, float argc, string command) } else { print_to(self, "You can't ^2tell^7 a message to yourself."); return; } } - else if(argv(1) == "#0") + else if (argv(1) == "#0") { trigger_magicear_processmessage_forallears(self, -1, world, substring(command, argv_start_index(next_token), argv_end_index(-1) - argv_start_index(next_token))); return; @@ -562,17 +593,16 @@ void ClientCommand_tell(float request, float argc, string command) } void ClientCommand_voice(float request, float argc, string command) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { - if(argc >= 3) - VoiceMessage(argv(1), substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2))); - else - VoiceMessage(argv(1), ""); + if (argc >= 3) VoiceMessage(argv(1), substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2))); + else VoiceMessage(argv(1), ""); return; } @@ -594,22 +624,22 @@ void ClientCommand_voice(float request, float argc, string command) ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION! void ClientCommand_(float request) { - switch(request) - { - case CMD_REQUEST_COMMAND: - { - - return; // never fall through to usage - } - - default: - case CMD_REQUEST_USAGE: - { - sprint(self, "\nUsage:^3 cmd \n"); - sprint(self, " No arguments required.\n"); - return; - } - } + switch(request) + { + case CMD_REQUEST_COMMAND: + { + + return; // never fall through to usage + } + + default: + case CMD_REQUEST_USAGE: + { + sprint(self, "\nUsage:^3 cmd \n"); + sprint(self, " No arguments required.\n"); + return; + } + } } */ @@ -619,7 +649,7 @@ void ClientCommand_(float request) // ===================================== // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;) -#define CLIENT_COMMANDS(request,arguments,command) \ +#define CLIENT_COMMANDS(request, arguments, command) \ CLIENT_COMMAND("autoswitch", ClientCommand_autoswitch(request, arguments), "Whether or not to switch automatically when getting a better weapon") \ CLIENT_COMMAND("clientversion", ClientCommand_clientversion(request, arguments), "Release version of the game") \ CLIENT_COMMAND("mv_getpicture", ClientCommand_mv_getpicture(request, arguments), "Retrieve mapshot picture from the server") \ @@ -639,47 +669,44 @@ void ClientCommand_(float request) /* nothing */ void ClientCommand_macro_help() -{SELFPARAM(); - #define CLIENT_COMMAND(name,function,description) \ +{ + SELFPARAM(); + #define CLIENT_COMMAND(name, function, description) \ { sprint(self, " ^2", name, "^7: ", description, "\n"); } CLIENT_COMMANDS(0, 0, ""); - #undef CLIENT_COMMAND - - return; +#undef CLIENT_COMMAND } float ClientCommand_macro_command(float argc, string command) { - #define CLIENT_COMMAND(name,function,description) \ - { if(name == strtolower(argv(0))) { function; return true; } } + #define CLIENT_COMMAND(name, function, description) \ + { if (name == strtolower(argv(0))) { function; return true; } } CLIENT_COMMANDS(CMD_REQUEST_COMMAND, argc, command); - #undef CLIENT_COMMAND +#undef CLIENT_COMMAND return false; } float ClientCommand_macro_usage(float argc) { - #define CLIENT_COMMAND(name,function,description) \ - { if(name == strtolower(argv(1))) { function; return true; } } + #define CLIENT_COMMAND(name, function, description) \ + { if (name == strtolower(argv(1))) { function; return true; } } CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc, ""); - #undef CLIENT_COMMAND +#undef CLIENT_COMMAND return false; } void ClientCommand_macro_write_aliases(float fh) { - #define CLIENT_COMMAND(name,function,description) \ + #define CLIENT_COMMAND(name, function, description) \ { CMD_Write_Alias("qc_cmd_cmd", name, description); } CLIENT_COMMANDS(0, 0, ""); - #undef CLIENT_COMMAND - - return; +#undef CLIENT_COMMAND } // ====================================== @@ -688,19 +715,18 @@ void ClientCommand_macro_write_aliases(float fh) // If this function exists, server game code parses clientcommand before the engine code gets it. void SV_ParseClientCommand(string command) -{SELFPARAM(); +{ + SELFPARAM(); // If invalid UTF-8, don't even parse it string command2 = ""; float len = strlen(command); float i; for (i = 0; i < len; ++i) command2 = strcat(command2, chr2str(str2chr(command, i))); - if (command != command2) - return; + if (command != command2) return; // if we're banned, don't even parse the command - if(Ban_MaybeEnforceBanOnce(self)) - return; + if (Ban_MaybeEnforceBanOnce(self)) return; float argc = tokenize_console(command); @@ -710,28 +736,26 @@ void SV_ParseClientCommand(string command) // cmd vote - master - login - password // for floodcheck - switch(strtolower(argv(0))) + switch (strtolower(argv(0))) { // exempt commands which are not subject to floodcheck - case "begin": break; // handled by engine in host_cmd.c - case "download": break; // handled by engine in cl_parse.c - case "mv_getpicture": 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 "sentcvar": break; // handled by server in this file - case "spawn": break; // handled by engine in host_cmd.c + case "begin": break; // handled by engine in host_cmd.c + case "download": break; // handled by engine in cl_parse.c + case "mv_getpicture": 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 "sentcvar": break; // handled by server in this file + case "spawn": break; // handled by engine in host_cmd.c default: - if(SV_ParseClientCommand_floodcheck()) - break; // "true": continue, as we're not flooding yet - else - return; // "false": not allowed to continue, halt // print("^1ERROR: ^7ANTISPAM CAUGHT: ", command, ".\n"); + if (SV_ParseClientCommand_floodcheck()) break; // "true": continue, as we're not flooding yet + else return; // "false": not allowed to continue, halt // print("^1ERROR: ^7ANTISPAM CAUGHT: ", command, ".\n"); } /* NOTE: should this be disabled? It can be spammy perhaps, but hopefully it's okay for now */ - if(argv(0) == "help") + if (argv(0) == "help") { - if(argc == 1) + if (argc == 1) { sprint(self, "\nClient networked commands:\n"); ClientCommand_macro_help(); @@ -743,31 +767,33 @@ void SV_ParseClientCommand(string command) sprint(self, "For help about a specific command, type cmd help COMMAND\n"); return; } - else if(CommonCommand_macro_usage(argc, self)) // Instead of trying to call a command, we're going to see detailed information about it + else if (CommonCommand_macro_usage(argc, self)) // Instead of trying to call a command, we're going to see detailed information about it { return; } - else if(ClientCommand_macro_usage(argc)) // same, but for normal commands now + else if (ClientCommand_macro_usage(argc)) // same, but for normal commands now { return; } } - else if(MUTATOR_CALLHOOK(SV_ParseClientCommand, strtolower(argv(0)), argc, command)) + else if (MUTATOR_CALLHOOK(SV_ParseClientCommand, strtolower(argv(0)), argc, command)) { - return; // handled by a mutator + return; // handled by a mutator } - else if(CheatCommand(argc)) + else if (CheatCommand(argc)) { - return; // handled by server/cheats.qc + return; // handled by server/cheats.qc } - else if(CommonCommand_macro_command(argc, self, command)) + else if (CommonCommand_macro_command(argc, self, command)) { - return; // handled by server/command/common.qc + return; // handled by server/command/common.qc } - else if(ClientCommand_macro_command(argc, command)) // continue as usual and scan for normal commands + else if (ClientCommand_macro_command(argc, command)) // continue as usual and scan for normal commands { - return; // handled by one of the above ClientCommand_* functions + return; // handled by one of the above ClientCommand_* functions } else + { clientcommand(self, command); + } } diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index 8d8045872..69f0222cb 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -16,38 +16,30 @@ // select the proper prefix for usage and other messages string GetCommandPrefix(entity caller) { - if(caller) - return "cmd"; - else - return "sv_cmd"; + if (caller) return "cmd"; + else return "sv_cmd"; } // if client return player nickname, or if server return admin nickname string GetCallerName(entity caller) { - if(caller) - return caller.netname; - else - return admin_name(); //((autocvar_sv_adminnick != "") ? autocvar_sv_adminnick : autocvar_hostname); + if (caller) return caller.netname; + else return admin_name(); // ((autocvar_sv_adminnick != "") ? autocvar_sv_adminnick : autocvar_hostname); } // verify that the client provided is acceptable for kicking float VerifyKickableEntity(entity client) { - if (!IS_REAL_CLIENT(client)) - return CLIENT_NOT_REAL; + if (!IS_REAL_CLIENT(client)) return CLIENT_NOT_REAL; return CLIENT_ACCEPTABLE; } // verify that the client provided is acceptable for use float VerifyClientEntity(entity client, float must_be_real, float must_be_bots) { - if (!IS_CLIENT(client)) - return CLIENT_DOESNT_EXIST; - else if(must_be_real && !IS_REAL_CLIENT(client)) - return CLIENT_NOT_REAL; - else if(must_be_bots && !IS_BOT_CLIENT(client)) - return CLIENT_NOT_BOT; + if (!IS_CLIENT(client)) return CLIENT_DOESNT_EXIST; + else if (must_be_real && !IS_REAL_CLIENT(client)) return CLIENT_NOT_REAL; + else if (must_be_bots && !IS_BOT_CLIENT(client)) return CLIENT_NOT_BOT; return CLIENT_ACCEPTABLE; } @@ -55,22 +47,28 @@ float VerifyClientEntity(entity client, float must_be_real, float must_be_bots) // if the client is not acceptable, return a string to be used for error messages string GetClientErrorString_color(float clienterror, string original_input, string col) { - switch(clienterror) + switch (clienterror) { - case CLIENT_DOESNT_EXIST: { return strcat(col, "Client '", original_input, col, "' doesn't exist"); } - case CLIENT_NOT_REAL: { return strcat(col, "Client '", original_input, col, "' is not real"); } - case CLIENT_NOT_BOT: { return strcat(col, "Client '", original_input, col, "' is not a bot"); } - default: { return "Incorrect usage of GetClientErrorString"; } + case CLIENT_DOESNT_EXIST: + { return strcat(col, "Client '", original_input, col, "' doesn't exist"); + } + case CLIENT_NOT_REAL: + { return strcat(col, "Client '", original_input, col, "' is not real"); + } + case CLIENT_NOT_BOT: + { return strcat(col, "Client '", original_input, col, "' is not a bot"); + } + default: + { return "Incorrect usage of GetClientErrorString"; + } } } // is this entity number even in the possible range of entities? float VerifyClientNumber(float tmp_number) { - if((tmp_number < 1) || (tmp_number > maxclients)) - return false; - else - return true; + if ((tmp_number < 1) || (tmp_number > maxclients)) return false; + else return true; } entity GetIndexedEntity(float argc, float start_index) @@ -83,47 +81,48 @@ entity GetIndexedEntity(float argc, float start_index) index = start_index; selection = world; - if(argc > start_index) + if (argc > start_index) { - if(substring(argv(index), 0, 1) == "#") + if (substring(argv(index), 0, 1) == "#") { tmp_string = substring(argv(index), 1, -1); ++index; - if(tmp_string != "") // is it all one token? like #1 + if (tmp_string != "") // is it all one token? like #1 { tmp_number = stof(tmp_string); } - else if(argc > index) // no, it's two tokens? # 1 + else if (argc > index) // no, it's two tokens? # 1 { tmp_number = stof(argv(index)); ++index; } else + { tmp_number = 0; + } } - else // maybe it's ONLY a number? + else // maybe it's ONLY a number? { tmp_number = stof(argv(index)); ++index; } - if(VerifyClientNumber(tmp_number)) + if (VerifyClientNumber(tmp_number)) { - selection = edict_num(tmp_number); // yes, it was a number + selection = edict_num(tmp_number); // yes, it was a number } - else // no, maybe it's a name? + else // no, maybe it's a name? { FOR_EACH_CLIENT(tmp_player) - if (strdecolorize(tmp_player.netname) == strdecolorize(argv(start_index))) - selection = tmp_player; + if (strdecolorize(tmp_player.netname) == strdecolorize(argv(start_index))) selection = tmp_player; index = (start_index + 1); } } next_token = index; - //print(strcat("start_index: ", ftos(start_index), ", next_token: ", ftos(next_token), ", edict: ", ftos(num_for_edict(selection)), ".\n")); + // print(strcat("start_index: ", ftos(start_index), ", next_token: ", ftos(next_token), ", edict: ", ftos(num_for_edict(selection)), ".\n")); return selection; } @@ -133,12 +132,10 @@ entity GetFilteredEntity(string input) entity tmp_player, selection; float tmp_number; - if(substring(input, 0, 1) == "#") - tmp_number = stof(substring(input, 1, -1)); - else - tmp_number = stof(input); + if (substring(input, 0, 1) == "#") tmp_number = stof(substring(input, 1, -1)); + else tmp_number = stof(input); - if(VerifyClientNumber(tmp_number)) + if (VerifyClientNumber(tmp_number)) { selection = edict_num(tmp_number); } @@ -146,8 +143,7 @@ entity GetFilteredEntity(string input) { selection = world; FOR_EACH_CLIENT(tmp_player) - if (strdecolorize(tmp_player.netname) == strdecolorize(input)) - selection = tmp_player; + if (strdecolorize(tmp_player.netname) == strdecolorize(input)) selection = tmp_player; } return selection; @@ -167,10 +163,8 @@ float GetFilteredNumber(string input) // switch between sprint and print depending on whether the receiver is the server or a player void print_to(entity to, string input) { - if(to) - sprint(to, strcat(input, "\n")); - else - LOG_INFO(input, "\n"); + if (to) sprint(to, strcat(input, "\n")); + else LOG_INFO(input, "\n"); } // ========================================== @@ -179,7 +173,8 @@ void print_to(entity to, string input) // used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such. void timeout_handler_reset() -{SELFPARAM(); +{ + SELFPARAM(); timeout_caller = world; timeout_time = 0; timeout_leadtime = 0; @@ -188,24 +183,25 @@ void timeout_handler_reset() } void timeout_handler_think() -{SELFPARAM(); +{ + SELFPARAM(); entity tmp_player; - switch(timeout_status) + switch (timeout_status) { case TIMEOUT_ACTIVE: { - if(timeout_time > 0) // countdown is still going + if (timeout_time > 0) // countdown is still going { Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_TIMEOUT_ENDING, timeout_time); - if(timeout_time == autocvar_sv_timeout_resumetime) // play a warning sound when only seconds are left + if (timeout_time == autocvar_sv_timeout_resumetime) // play a warning sound when only seconds are left Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_PREPARE); - self.nextthink = time + TIMEOUT_SLOWMO_VALUE; // think again in one second - timeout_time -= 1; // decrease the time counter + self.nextthink = time + TIMEOUT_SLOWMO_VALUE; // think again in one second + timeout_time -= 1; // decrease the time counter } - else // time to end the timeout + else // time to end the timeout { timeout_status = TIMEOUT_INACTIVE; @@ -214,7 +210,7 @@ void timeout_handler_think() // unlock the view for players so they can move around again FOR_EACH_REALPLAYER(tmp_player) - tmp_player.fixangle = false; + tmp_player.fixangle = false; timeout_handler_reset(); } @@ -224,14 +220,14 @@ void timeout_handler_think() case TIMEOUT_LEADTIME: { - if(timeout_leadtime > 0) // countdown is still going + if (timeout_leadtime > 0) // countdown is still going { Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_TIMEOUT_BEGINNING, timeout_leadtime); self.nextthink = time + 1; // think again in one second - timeout_leadtime -= 1; // decrease the time counter + timeout_leadtime -= 1; // decrease the time counter } - else // time to begin the timeout + else // time to begin the timeout { timeout_status = TIMEOUT_ACTIVE; @@ -240,15 +236,15 @@ void timeout_handler_think() // reset all the flood variables FOR_EACH_CLIENT(tmp_player) - tmp_player.nickspamcount = tmp_player.nickspamtime = tmp_player.floodcontrol_chat = - tmp_player.floodcontrol_chatteam = tmp_player.floodcontrol_chattell = - tmp_player.floodcontrol_voice = tmp_player.floodcontrol_voiceteam = 0; + tmp_player.nickspamcount = tmp_player.nickspamtime = tmp_player.floodcontrol_chat = + tmp_player.floodcontrol_chatteam = tmp_player.floodcontrol_chattell = + tmp_player.floodcontrol_voice = tmp_player.floodcontrol_voiceteam = 0; // copy .v_angle to .lastV_angle for every player in order to fix their view during pause (see PlayerPreThink) FOR_EACH_REALPLAYER(tmp_player) - tmp_player.lastV_angle = tmp_player.v_angle; + tmp_player.lastV_angle = tmp_player.v_angle; - self.nextthink = time; // think again next frame to handle it under TIMEOUT_ACTIVE code + self.nextthink = time; // think again next frame to handle it under TIMEOUT_ACTIVE code } return; @@ -265,19 +261,18 @@ void timeout_handler_think() } - // =================================================== // Common commands used in both sv_cmd.qc and cmd.qc // =================================================== void CommonCommand_cvar_changes(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { print_to(caller, cvar_changes); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -293,12 +288,12 @@ void CommonCommand_cvar_changes(float request, entity caller) void CommonCommand_cvar_purechanges(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { print_to(caller, cvar_purechanges); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -313,15 +308,16 @@ void CommonCommand_cvar_purechanges(float request, entity caller) } void CommonCommand_editmob(int request, entity caller, int argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(autocvar_g_campaign) { print_to(caller, "Monster editing is disabled in singleplayer"); return; } + if (autocvar_g_campaign) { print_to(caller, "Monster editing is disabled in singleplayer"); return; } // no checks for g_monsters here, as it may be toggled mid match which existing monsters - if(caller) + if (caller) { makevectors(self.v_angle); WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self); @@ -331,80 +327,83 @@ void CommonCommand_editmob(int request, entity caller, int argc) bool is_visible = IS_MONSTER(mon); string argument = argv(2); - switch(argv(1)) + switch (argv(1)) { case "name": { - if(!caller) { print_to(caller, "Only players can edit monsters"); return; } - if(!argument) { break; } // escape to usage - if(!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; } - if(mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; } - if(!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; } + if (!caller) { print_to(caller, "Only players can edit monsters"); return; } + if (!argument) break; // escape to usage + if (!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; } + if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; } + if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; } string mon_oldname = mon.monster_name; mon.monster_name = argument; - if(mon.sprite) { WaypointSprite_UpdateSprites(mon.sprite, WP_Monster, WP_Null, WP_Null); } + if (mon.sprite) WaypointSprite_UpdateSprites(mon.sprite, WP_Monster, WP_Null, WP_Null); print_to(caller, sprintf("Your pet '%s' is now known as '%s'", mon_oldname, mon.monster_name)); return; } case "spawn": { - if(!caller) { print_to(caller, "Only players can spawn monsters"); return; } - if(!argv(2)) { break; } // escape to usage + if (!caller) { print_to(caller, "Only players can spawn monsters"); return; } + if (!argv(2)) break; // escape to usage int moveflag, tmp_moncount = 0; string arg_lower = strtolower(argument); - moveflag = (argv(3)) ? stof(argv(3)) : 1; // follow owner if not defined + moveflag = (argv(3)) ? stof(argv(3)) : 1; // follow owner if not defined ret_string = "Monster spawning is currently disabled by a mutator"; - if(arg_lower == "list") { print_to(caller, monsterlist_reply); return; } + if (arg_lower == "list") { print_to(caller, monsterlist_reply); return; } - FOR_EACH_MONSTER(mon) { if(mon.realowner == caller) ++tmp_moncount; } + FOR_EACH_MONSTER(mon) + { + if (mon.realowner == caller) ++tmp_moncount; + } - if(!autocvar_g_monsters) { print_to(caller, "Monsters are disabled"); return; } - if(autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { print_to(caller, "Monster spawning is disabled"); return; } - if(!IS_PLAYER(caller)) { print_to(caller, "You must be playing to spawn a monster"); return; } - if(MUTATOR_CALLHOOK(AllowMobSpawning)) { print_to(caller, ret_string); return; } - if(caller.vehicle) { print_to(caller, "You can't spawn monsters while driving a vehicle"); return; } - if(caller.frozen) { print_to(caller, "You can't spawn monsters while frozen"); return; } - if(caller.deadflag != DEAD_NO) { print_to(caller, "You can't spawn monsters while dead"); return; } - if(tmp_moncount >= autocvar_g_monsters_max) { print_to(caller, "The maximum monster count has been reached"); return; } - if(tmp_moncount >= autocvar_g_monsters_max_perplayer) { print_to(caller, "You can't spawn any more monsters"); return; } + if (!autocvar_g_monsters) { print_to(caller, "Monsters are disabled"); return; } + if (autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { print_to(caller, "Monster spawning is disabled"); return; } + if (!IS_PLAYER(caller)) { print_to(caller, "You must be playing to spawn a monster"); return; } + if (MUTATOR_CALLHOOK(AllowMobSpawning)) { print_to(caller, ret_string); return; } + if (caller.vehicle) { print_to(caller, "You can't spawn monsters while driving a vehicle"); return; } + if (caller.frozen) { print_to(caller, "You can't spawn monsters while frozen"); return; } + if (caller.deadflag != DEAD_NO) { print_to(caller, "You can't spawn monsters while dead"); return; } + if (tmp_moncount >= autocvar_g_monsters_max) { print_to(caller, "The maximum monster count has been reached"); return; } + if (tmp_moncount >= autocvar_g_monsters_max_perplayer) { print_to(caller, "You can't spawn any more monsters"); return; } bool found = false; - for(int i = MON_FIRST; i <= MON_LAST; ++i) + for (int i = MON_FIRST; i <= MON_LAST; ++i) { mon = get_monsterinfo(i); - if(mon.netname == arg_lower) { found = true; break; } + if (mon.netname == arg_lower) { found = true; break; } } - if(!found && arg_lower != "random") { print_to(caller, "Invalid monster"); return; } + if (!found && arg_lower != "random") { print_to(caller, "Invalid monster"); return; } totalspawned += 1; - WarpZone_TraceBox (CENTER_OR_VIEWOFS(caller), caller.mins, caller.maxs, CENTER_OR_VIEWOFS(caller) + v_forward * 150, true, caller); + WarpZone_TraceBox(CENTER_OR_VIEWOFS(caller), caller.mins, caller.maxs, CENTER_OR_VIEWOFS(caller) + v_forward * 150, true, caller); mon = spawnmonster(arg_lower, 0, caller, caller, trace_endpos, false, false, moveflag); print_to(caller, strcat("Spawned ", mon.monster_name)); return; } case "kill": { - if(!caller) { print_to(caller, "Only players can kill monsters"); return; } - if(mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; } - if(!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; } + if (!caller) { print_to(caller, "Only players can kill monsters"); return; } + if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; } + if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; } - Damage (mon, world, world, mon.health + mon.max_health + 200, DEATH_KILL.m_id, mon.origin, '0 0 0'); + Damage(mon, world, world, mon.health + mon.max_health + 200, DEATH_KILL.m_id, mon.origin, '0 0 0'); print_to(caller, strcat("Your pet '", mon.monster_name, "' has been brutally mutilated")); return; } case "skin": { - if(!caller) { print_to(caller, "Only players can edit monsters"); return; } - if(!argument) { break; } // escape to usage - if(!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; } - if(!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; } - if(mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; } - if(mon.monsterid == MON_MAGE.monsterid) { print_to(caller, "Mage skins can't be changed"); return; } // TODO + if (!caller) { print_to(caller, "Only players can edit monsters"); return; } + if (!argument) break; // escape to usage + if (!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; } + if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; } + if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; } + if (mon.monsterid == MON_MAGE.monsterid) { print_to(caller, "Mage skins can't be changed"); return; } // TODO mon.skin = stof(argument); print_to(caller, strcat("Monster skin successfully changed to ", ftos(mon.skin))); @@ -412,11 +411,11 @@ void CommonCommand_editmob(int request, entity caller, int argc) } case "movetarget": { - if(!caller) { print_to(caller, "Only players can edit monsters"); return; } - if(!argument) { break; } // escape to usage - if(!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; } - if(!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; } - if(mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; } + if (!caller) { print_to(caller, "Only players can edit monsters"); return; } + if (!argument) break; // escape to usage + if (!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; } + if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; } + if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; } mon.monster_moveflags = stof(argument); print_to(caller, strcat("Monster move target successfully changed to ", ftos(mon.monster_moveflags))); @@ -424,13 +423,17 @@ void CommonCommand_editmob(int request, entity caller, int argc) } case "butcher": { - if(caller) { print_to(caller, "This command is not available to players"); return; } - if(MUTATOR_CALLHOOK(AllowMobButcher)) { LOG_INFO(ret_string, "\n"); return; } + if (caller) { print_to(caller, "This command is not available to players"); return; } + if (MUTATOR_CALLHOOK(AllowMobButcher)) { LOG_INFO(ret_string, "\n"); return; } int tmp_remcount = 0; entity tmp_entity; - FOR_EACH_MONSTER(tmp_entity) { Monster_Remove(tmp_entity); ++tmp_remcount; } + FOR_EACH_MONSTER(tmp_entity) + { + Monster_Remove(tmp_entity); + ++tmp_remcount; + } monsters_total = monsters_killed = totalspawned = 0; @@ -455,18 +458,16 @@ void CommonCommand_editmob(int request, entity caller, int argc) void CommonCommand_info(float request, entity caller, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { string command = builtin_cvar_string(strcat("sv_info_", argv(1))); - if(command) - wordwrap_sprint(command, 1000); - else - print_to(caller, "ERROR: unsupported info command"); + if (command) wordwrap_sprint(command, 1000); + else print_to(caller, "ERROR: unsupported info command"); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -481,12 +482,12 @@ void CommonCommand_info(float request, entity caller, float argc) void CommonCommand_ladder(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { print_to(caller, ladder_reply); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -501,12 +502,12 @@ void CommonCommand_ladder(float request, entity caller) void CommonCommand_lsmaps(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { print_to(caller, lsmaps_reply); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -521,12 +522,12 @@ void CommonCommand_lsmaps(float request, entity caller) void CommonCommand_printmaplist(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { print_to(caller, maplist_reply); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -541,12 +542,12 @@ void CommonCommand_printmaplist(float request, entity caller) void CommonCommand_rankings(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { print_to(caller, rankings_reply); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -561,15 +562,14 @@ void CommonCommand_rankings(float request, entity caller) void CommonCommand_records(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - for(int i = 0; i < 10; ++i) - if(records_reply[i] != "") - print_to(caller, records_reply[i]); + for (int i = 0; i < 10; ++i) + if (records_reply[i] != "") print_to(caller, records_reply[i]); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -584,12 +584,12 @@ void CommonCommand_records(float request, entity caller) void CommonCommand_teamstatus(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { Score_NicePrint(caller); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -604,7 +604,7 @@ void CommonCommand_teamstatus(float request, entity caller) void CommonCommand_time(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -630,24 +630,27 @@ void CommonCommand_time(float request, entity caller) void CommonCommand_timein(float request, entity caller) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(!caller || autocvar_sv_timeout) + if (!caller || autocvar_sv_timeout) { if (!timeout_status) { print_to(caller, "^7Error: There is no active timeout called."); } - else if(caller && (caller != timeout_caller)) { print_to(caller, "^7Error: You are not allowed to stop the active timeout."); } + else if (caller && (caller != timeout_caller)) + { + print_to(caller, "^7Error: You are not allowed to stop the active timeout."); + } - else // everything should be okay, continue aborting timeout + else // everything should be okay, continue aborting timeout { - switch(timeout_status) + switch (timeout_status) { case TIMEOUT_LEADTIME: { timeout_status = TIMEOUT_INACTIVE; timeout_time = 0; - timeout_handler.nextthink = time; // timeout_handler has to take care of it immediately + timeout_handler.nextthink = time; // timeout_handler has to take care of it immediately bprint(strcat("^7The timeout was aborted by ", GetCallerName(caller), " !\n")); return; } @@ -655,18 +658,19 @@ void CommonCommand_timein(float request, entity caller) case TIMEOUT_ACTIVE: { timeout_time = autocvar_sv_timeout_resumetime; - timeout_handler.nextthink = time; // timeout_handler has to take care of it immediately + timeout_handler.nextthink = time; // timeout_handler has to take care of it immediately bprint(strcat("^1Attention: ^7", GetCallerName(caller), " resumed the game! Prepare for battle!\n")); return; } - default: LOG_TRACE("timeout status was inactive, but this code was executed anyway?"); return; + default: LOG_TRACE("timeout status was inactive, but this code was executed anyway?"); + return; } } } else { print_to(caller, "^1Timeins are not allowed to be called, enable them with sv_timeout 1.\n"); } - return; // never fall through to usage + return; // never fall through to usage } default: @@ -679,28 +683,45 @@ void CommonCommand_timein(float request, entity caller) } } -void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAND IS TERRIBLE. +void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAND IS TERRIBLE. { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(!caller || autocvar_sv_timeout) + if (!caller || autocvar_sv_timeout) { float last_possible_timeout = ((autocvar_timelimit * 60) - autocvar_sv_timeout_leadtime - 1); - if(timeout_status) { print_to(caller, "^7Error: A timeout is already active."); } - else if(vote_called) { print_to(caller, "^7Error: You can not call a timeout while a vote is active."); } - else if(warmup_stage && !g_warmup_allow_timeout) { print_to(caller, "^7Error: You can not call a timeout in warmup-stage."); } - else if(time < game_starttime) { print_to(caller, "^7Error: You can not call a timeout while the map is being restarted."); } - else if(caller && (caller.allowed_timeouts < 1)) { print_to(caller, "^7Error: You already used all your timeout calls for this map."); } - else if(caller && !IS_PLAYER(caller)) { print_to(caller, "^7Error: You must be a player to call a timeout."); } - else if((autocvar_timelimit) && (last_possible_timeout < time - game_starttime)) { print_to(caller, "^7Error: It is too late to call a timeout now!"); } - - else // everything should be okay, proceed with starting the timeout + if (timeout_status) { print_to(caller, "^7Error: A timeout is already active."); } + else if (vote_called) { - if(caller) { caller.allowed_timeouts -= 1; } + print_to(caller, "^7Error: You can not call a timeout while a vote is active."); + } + else if (warmup_stage && !g_warmup_allow_timeout) + { + print_to(caller, "^7Error: You can not call a timeout in warmup-stage."); + } + else if (time < game_starttime) + { + print_to(caller, "^7Error: You can not call a timeout while the map is being restarted."); + } + else if (caller && (caller.allowed_timeouts < 1)) + { + print_to(caller, "^7Error: You already used all your timeout calls for this map."); + } + else if (caller && !IS_PLAYER(caller)) + { + print_to(caller, "^7Error: You must be a player to call a timeout."); + } + else if ((autocvar_timelimit) && (last_possible_timeout < time - game_starttime)) + { + print_to(caller, "^7Error: It is too late to call a timeout now!"); + } + else // everything should be okay, proceed with starting the timeout + { + if (caller) caller.allowed_timeouts -= 1; // write a bprint who started the timeout (and how many they have left) bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : ""), "!\n"); @@ -711,14 +732,14 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAN timeout_handler = spawn(); timeout_handler.think = timeout_handler_think; - timeout_handler.nextthink = time; // always let the entity think asap + timeout_handler.nextthink = time; // always let the entity think asap Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_TIMEOUT); } } else { print_to(caller, "^1Timeouts are not allowed to be called, enable them with sv_timeout 1.\n"); } - return; // never fall through to usage + return; // never fall through to usage } default: @@ -733,7 +754,7 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAN void CommonCommand_who(float request, entity caller, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -753,12 +774,12 @@ void CommonCommand_who(float request, entity caller, float argc) { is_bot = (IS_BOT_CLIENT(tmp_player)); - if(is_bot) + if (is_bot) { tmp_netaddress = "null/botclient"; tmp_crypto_idfp = "null/botclient"; } - else if(privacy) + else if (privacy) { tmp_netaddress = "hidden"; tmp_crypto_idfp = "hidden"; @@ -783,7 +804,7 @@ void CommonCommand_who(float request, entity caller, float argc) print_to(caller, strcat("Finished listing ", ftos(total_listed_players), " client(s) out of ", ftos(maxclients), " slots.")); - return; // never fall through to usage + return; // never fall through to usage } default: @@ -800,21 +821,21 @@ void CommonCommand_who(float request, entity caller, float argc) ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION! void CommonCommand_(float request, entity caller) { - switch(request) - { - case CMD_REQUEST_COMMAND: - { - - return; // never fall through to usage - } - - default: - case CMD_REQUEST_USAGE: - { - print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " ")); - print_to(caller, " No arguments required."); - return; - } - } + switch(request) + { + case CMD_REQUEST_COMMAND: + { + + return; // never fall through to usage + } + + default: + case CMD_REQUEST_USAGE: + { + print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " ")); + print_to(caller, " No arguments required."); + return; + } + } } */ diff --git a/qcsrc/server/command/common.qh b/qcsrc/server/command/common.qh index 9a011fb85..2a1a2b42f 100644 --- a/qcsrc/server/command/common.qh +++ b/qcsrc/server/command/common.qh @@ -27,15 +27,15 @@ const float TIMEOUT_ACTIVE = 2; const float TIMEOUT_SLOWMO_VALUE = 0.0001; // global timeout information declarations -entity timeout_caller; // contains the entity of the player who started the last timeout -entity timeout_handler; // responsible for centerprinting the timeout countdowns and playing sounds -float sys_frametime; // gets initialised in worldspawn, saves the value from autocvar_sys_ticrate -float orig_slowmo; // contains the value of autocvar_slowmo so that, after timeout finished, it isn't set to slowmo 1 necessarily -float timeout_time; // contains the time in seconds that the active timeout has left -float timeout_leadtime; // contains the number of seconds left of the leadtime (before the timeout starts) -float timeout_status; // (values: 0, 1, 2) contains whether a timeout is not active (0), was called but still at leadtime (1) or is active (2) +entity timeout_caller; // contains the entity of the player who started the last timeout +entity timeout_handler; // responsible for centerprinting the timeout countdowns and playing sounds +float sys_frametime; // gets initialised in worldspawn, saves the value from autocvar_sys_ticrate +float orig_slowmo; // contains the value of autocvar_slowmo so that, after timeout finished, it isn't set to slowmo 1 necessarily +float timeout_time; // contains the time in seconds that the active timeout has left +float timeout_leadtime; // contains the number of seconds left of the leadtime (before the timeout starts) +float timeout_status; // (values: 0, 1, 2) contains whether a timeout is not active (0), was called but still at leadtime (1) or is active (2) .float allowed_timeouts; // contains the number of allowed timeouts for each player -.vector lastV_angle; //used when pausing the game in order to force the player to keep his old view angle fixed +.vector lastV_angle; // used when pausing the game in order to force the player to keep his old view angle fixed // allow functions to be used in other code like g_world.qc and teamplay.qc void timeout_handler_think(); @@ -60,7 +60,7 @@ float VerifyClientEntity(entity client, float must_be_real, float must_be_bots); // if the client is not acceptable, return a string to be used for error messages string GetClientErrorString_color(float clienterror, string original_input, string col); -#define GetClientErrorString(clienterror,original_input) GetClientErrorString_color(clienterror,original_input,"^7") +#define GetClientErrorString(clienterror, original_input) GetClientErrorString_color(clienterror, original_input, "^7") // is this entity number even in the possible range of entities? float VerifyClientNumber(float tmp_number); @@ -123,7 +123,7 @@ void CommonCommand_who(float request, entity caller, float argc); // ================================== // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;) -#define COMMON_COMMANDS(request,caller,arguments,command) \ +#define COMMON_COMMANDS(request, caller, arguments, command) \ COMMON_COMMAND("cvar_changes", CommonCommand_cvar_changes(request, caller), "Prints a list of all changed server cvars") \ COMMON_COMMAND("cvar_purechanges", CommonCommand_cvar_purechanges(request, caller), "Prints a list of all changed gameplay cvars") \ COMMON_COMMAND("editmob", CommonCommand_editmob(request, caller, arguments), "Modifies a monster or all monsters") \ @@ -143,46 +143,42 @@ void CommonCommand_who(float request, entity caller, float argc); void CommonCommand_macro_help(entity caller) { - #define COMMON_COMMAND(name,function,description) \ + #define COMMON_COMMAND(name, function, description) \ { print_to(caller, strcat(" ^2", name, "^7: ", description)); } COMMON_COMMANDS(0, caller, 0, ""); - #undef COMMON_COMMAND - - return; +#undef COMMON_COMMAND } float CommonCommand_macro_command(float argc, entity caller, string command) { - #define COMMON_COMMAND(name,function,description) \ - { if(name == strtolower(argv(0))) { function; return true; } } + #define COMMON_COMMAND(name, function, description) \ + { if (name == strtolower(argv(0))) { function; return true; } } COMMON_COMMANDS(CMD_REQUEST_COMMAND, caller, argc, command); - #undef COMMON_COMMAND +#undef COMMON_COMMAND return false; } float CommonCommand_macro_usage(float argc, entity caller) { - #define COMMON_COMMAND(name,function,description) \ - { if(name == strtolower(argv(1))) { function; return true; } } + #define COMMON_COMMAND(name, function, description) \ + { if (name == strtolower(argv(1))) { function; return true; } } COMMON_COMMANDS(CMD_REQUEST_USAGE, caller, argc, ""); - #undef COMMON_COMMAND +#undef COMMON_COMMAND return false; } void CommonCommand_macro_write_aliases(float fh) { - #define COMMON_COMMAND(name,function,description) \ + #define COMMON_COMMAND(name, function, description) \ { CMD_Write_Alias("qc_cmd_svcmd", name, description); } COMMON_COMMANDS(0, world, 0, ""); - #undef COMMON_COMMAND - - return; +#undef COMMON_COMMAND } diff --git a/qcsrc/server/command/getreplies.qc b/qcsrc/server/command/getreplies.qc index fd312bff6..d2233029d 100644 --- a/qcsrc/server/command/getreplies.qc +++ b/qcsrc/server/command/getreplies.qc @@ -21,7 +21,7 @@ // See common.qc for their proper commands -string getrecords(int page) // 50 records per page +string getrecords(int page) // 50 records per page { string s = ""; @@ -30,10 +30,8 @@ string getrecords(int page) // 50 records per page MapInfo_ClearTemps(); - if(s == "" && page == 0) - return "No records are available on this server.\n"; - else - return s; + if (s == "" && page == 0) return "No records are available on this server.\n"; + else return s; } string getrankings() @@ -48,8 +46,7 @@ string getrankings() { t = race_readTime(map, i); - if (t == 0) - continue; + if (t == 0) continue; n = race_readName(map, i); p = count_ordinal(i); @@ -58,10 +55,8 @@ string getrankings() MapInfo_ClearTemps(); - if (s == "") - return strcat("No records are available for the map: ", map, "\n"); - else - return strcat("Records for ", map, ":\n", s); + if (s == "") return strcat("No records are available for the map: ", map, "\n"); + else return strcat("Records for ", map, ":\n", s); } string getladder() @@ -71,23 +66,21 @@ string getladder() rr = (g_cts) ? CTS_RECORD : RACE_RECORD; - for(k = 0; k < MapInfo_count; ++k) + for (k = 0; k < MapInfo_count; ++k) { - if(MapInfo_Get_ByID(k)) + if (MapInfo_Get_ByID(k)) { - for(i = 0; i <= LADDER_CNT; ++i) // i = 0 because it is the speed award + for (i = 0; i <= LADDER_CNT; ++i) // i = 0 because it is the speed award { - if(i == 0) // speed award + if (i == 0) // speed award { - if(stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/speed"))) == 0) - continue; + if (stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/speed"))) == 0) continue; myuid = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/crypto_idfp")); } - else // normal record, if it exists (else break) + else // normal record, if it exists (else break) { - if(race_readTime(MapInfo_Map_bspname, i) == 0) - continue; + if (race_readTime(MapInfo_Map_bspname, i) == 0) continue; myuid = race_readUID(MapInfo_Map_bspname, i); } @@ -101,43 +94,38 @@ string getladder() temp_s = db_get(TemporaryDB, strcat("ladder", myuid)); - if(temp_s == "") + if (temp_s == "") { db_put(TemporaryDB, strcat("uid", ftos(uidcnt)), myuid); ++uidcnt; - for(j = 0; j <= LADDER_CNT + 1; ++j) + for (j = 0; j <= LADDER_CNT + 1; ++j) { - if(j != LADDER_CNT + 1) - temp_s = strcat(temp_s, "0 "); - else - temp_s = strcat(temp_s, "0"); + if (j != LADDER_CNT + 1) temp_s = strcat(temp_s, "0 "); + else temp_s = strcat(temp_s, "0"); } } tokenize_console(temp_s); s = ""; - if(i == 0) // speed award + if (i == 0) // speed award { - for(j = 0; j <= LADDER_CNT; ++j) // loop over each arg in the string + for (j = 0; j <= LADDER_CNT; ++j) // loop over each arg in the string { - if(j == 0) // speed award - s = strcat(s, ftos(stof(argv(j)) +1)); // add 1 to speed rec count and write - else - s = strcat(s, " ", argv(j)); // just copy over everything else + if (j == 0) // speed award + s = strcat(s, ftos(stof(argv(j)) + 1)); // add 1 to speed rec count and write + else s = strcat(s, " ", argv(j)); // just copy over everything else } } - else // record + else // record { - for(j = 0; j <= LADDER_CNT; ++j) // loop over each arg in the string + for (j = 0; j <= LADDER_CNT; ++j) // loop over each arg in the string { - if(j == 0) - s = strcat(s, argv(j)); // speed award, dont prefix with " " - else if(j == i) // wanted rec! - s = strcat(s, " ", ftos(stof(argv(j)) +1)); // update argv(j) - else - s = strcat(s, " ", argv(j)); // just copy over everything else + if (j == 0) s = strcat(s, argv(j)); // speed award, dont prefix with " " + else if (j == i) // wanted rec! + s = strcat(s, " ", ftos(stof(argv(j)) + 1)); // update argv(j) + else s = strcat(s, " ", argv(j)); // just copy over everything else } } @@ -150,33 +138,31 @@ string getladder() // 5th place = floor(100 / 5) = 20 points // ... etc - if(i == 0) - s = strcat(s, " ", ftos(stof(argv(LADDER_CNT+1)) + LADDER_FIRSTPOINT / 10)); // speed award, add LADDER_FIRSTPOINT / 10 points - else - s = strcat(s, " ", ftos(stof(argv(LADDER_CNT+1)) + floor(LADDER_FIRSTPOINT / i))); // record, add LADDER_FIRSTPOINT / i points + if (i == 0) s = strcat(s, " ", ftos(stof(argv(LADDER_CNT + 1)) + LADDER_FIRSTPOINT / 10)); // speed award, add LADDER_FIRSTPOINT / 10 points + else s = strcat(s, " ", ftos(stof(argv(LADDER_CNT + 1)) + floor(LADDER_FIRSTPOINT / i))); // record, add LADDER_FIRSTPOINT / i points db_put(TemporaryDB, strcat("ladder", myuid), s); } } } - for(i = 0; i <= uidcnt; ++i) // for each known uid + for (i = 0; i <= uidcnt; ++i) // for each known uid { thisuid = db_get(TemporaryDB, strcat("uid", ftos(i))); temp_s = db_get(TemporaryDB, strcat("ladder", thisuid)); tokenize_console(temp_s); - thiscnt = stof(argv(LADDER_CNT+1)); + thiscnt = stof(argv(LADDER_CNT + 1)); - if(thiscnt > top_scores[LADDER_SIZE-1]) + if (thiscnt > top_scores[LADDER_SIZE - 1]) { - for(j = 0; j < LADDER_SIZE; ++j) // for each place in ladder + for (j = 0; j < LADDER_SIZE; ++j) // for each place in ladder { - if(thiscnt > top_scores[j]) + if (thiscnt > top_scores[j]) { - for(k = LADDER_SIZE-1; k >= j; --k) + for (k = LADDER_SIZE - 1; k >= j; --k) { - top_uids[k] = top_uids[k-1]; - top_scores[k] = top_scores[k-1]; + top_uids[k] = top_uids[k - 1]; + top_scores[k] = top_scores[k - 1]; } top_uids[j] = thisuid; @@ -192,51 +178,47 @@ string getladder() s = strcat(s, "Pos ^3|"); s = strcat(s, " ^7Total ^3|"); - for(i = 1; i <= LADDER_CNT; ++i) - { s = strcat(s, " ^7", count_ordinal(i), " ^3|"); } - + for (i = 1; i <= LADDER_CNT; ++i) + s = strcat(s, " ^7", count_ordinal(i), " ^3|"); s = strcat(s, " ^7Speed awards ^3| ^7Name"); s = strcat(s, "\n^3----+--------"); - for(i = 1; i <= min(9, LADDER_CNT); ++i) - { s = strcat(s, "+-----"); } - - #if LADDER_CNT > 9 - for(i = 1; i <= LADDER_CNT - 9; ++i) - { s = strcat(s, "+------"); } - #endif + for (i = 1; i <= min(9, LADDER_CNT); ++i) + s = strcat(s, "+-----"); +#if LADDER_CNT > 9 + for (i = 1; i <= LADDER_CNT - 9; ++i) + s = strcat(s, "+------"); +#endif s = strcat(s, "+--------------+--------------------\n"); - for(i = 0; i < LADDER_SIZE; ++i) + for (i = 0; i < LADDER_SIZE; ++i) { temp_s = db_get(TemporaryDB, strcat("ladder", top_uids[i])); tokenize_console(temp_s); - if(argv(LADDER_CNT+1) == "") // total is 0, skip + if (argv(LADDER_CNT + 1) == "") // total is 0, skip continue; - s = strcat(s, strpad(4, count_ordinal(i+1)), "^3| ^7"); // pos - s = strcat(s, strpad(7, argv(LADDER_CNT+1)), "^3| ^7"); // total + s = strcat(s, strpad(4, count_ordinal(i + 1)), "^3| ^7"); // pos + s = strcat(s, strpad(7, argv(LADDER_CNT + 1)), "^3| ^7"); // total - for(j = 1; j <= min(9, LADDER_CNT); ++j) - { s = strcat(s, strpad(4, argv(j)), "^3| ^7"); } // 1st, 2nd, 3rd etc cnt + for (j = 1; j <= min(9, LADDER_CNT); ++j) + s = strcat(s, strpad(4, argv(j)), "^3| ^7"); // 1st, 2nd, 3rd etc cnt - #if LADDER_CNT > 9 - for(j = 10; j <= LADDER_CNT; ++j) - { s = strcat(s, strpad(4, argv(j)), " ^3| ^7"); } // 1st, 2nd, 3rd etc cnt - #endif +#if LADDER_CNT > 9 + for (j = 10; j <= LADDER_CNT; ++j) + s = strcat(s, strpad(4, argv(j)), " ^3| ^7"); // 1st, 2nd, 3rd etc cnt +#endif - s = strcat(s, strpad(13, argv(0)), "^3| ^7"); // speed award cnt - s = strcat(s, uid2name(top_uids[i]), "\n"); // name + s = strcat(s, strpad(13, argv(0)), "^3| ^7"); // speed award cnt + s = strcat(s, uid2name(top_uids[i]), "\n"); // name } MapInfo_ClearTemps(); - if(s == "") - return "No ladder on this server!\n"; - else - return strcat("Top ", ftos(LADDER_SIZE), " ladder rankings:\n", s); + if (s == "") return "No ladder on this server!\n"; + else return strcat("Top ", ftos(LADDER_SIZE), " ladder rankings:\n", s); } string getmaplist() @@ -245,12 +227,11 @@ string getmaplist() int i, argc; argc = tokenize_console(autocvar_g_maplist); - for(i = 0; i < argc; ++i) + for (i = 0; i < argc; ++i) { - if(MapInfo_CheckMap(argv(i))) + if (MapInfo_CheckMap(argv(i))) { - if(i % 2) { col = "^2"; } - else { col = "^3"; } + if (i % 2) col = "^2"; else col = "^3"; maplist = sprintf("%s%s%s ", maplist, col, argv(i)); } } @@ -265,25 +246,23 @@ string getlsmaps() string lsmaps = "", col; float i, newmaps = 0; - for(i = 0; i < MapInfo_count; ++i) + for (i = 0; i < MapInfo_count; ++i) { - if((MapInfo_Get_ByID(i)) && !(MapInfo_Map_flags & MapInfo_ForbiddenFlags())) + if ((MapInfo_Get_ByID(i)) && !(MapInfo_Map_flags & MapInfo_ForbiddenFlags())) { // todo: Check by play count of maps for other game types? - if( - (g_race && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, RACE_RECORD, "time")))) - || - (g_cts && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, CTS_RECORD, "time")))) - ) + if ( + (g_race && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, RACE_RECORD, "time")))) + || + (g_cts && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, CTS_RECORD, "time")))) + ) { newmaps = true; - if(i % 2) { col = "^4*"; } - else { col = "^5*"; } + if (i % 2) col = "^4*"; else col = "^5*"; } else { - if(i % 2) { col = "^2"; } - else { col = "^3"; } + if (i % 2) col = "^2"; else col = "^3"; } lsmaps = sprintf("%s%s%s ", lsmaps, col, MapInfo_Map_bspname); @@ -298,10 +277,9 @@ string getmonsterlist() { string monsterlist = "", col; - for(int i = MON_FIRST; i <= MON_LAST; ++i) + for (int i = MON_FIRST; i <= MON_LAST; ++i) { - if(i % 2) { col = "^2"; } - else { col = "^3"; } + if (i % 2) col = "^2"; else col = "^3"; monsterlist = sprintf("%s%s%s ", monsterlist, col, (get_monsterinfo(i)).netname); } diff --git a/qcsrc/server/command/getreplies.qh b/qcsrc/server/command/getreplies.qh index 0e419fdea..bf37153c4 100644 --- a/qcsrc/server/command/getreplies.qh +++ b/qcsrc/server/command/getreplies.qh @@ -8,8 +8,8 @@ // ladder bullshit todo const int LADDER_FIRSTPOINT = 100; -#define LADDER_CNT 10 // position X still gives LADDER_FIRSTPOINT/X points -const int LADDER_SIZE = 30; // ladder shows the top X players +#define LADDER_CNT 10 // position X still gives LADDER_FIRSTPOINT/X points +const int LADDER_SIZE = 30; // ladder shows the top X players string top_uids[LADDER_SIZE]; float top_scores[LADDER_SIZE]; diff --git a/qcsrc/server/command/radarmap.qc b/qcsrc/server/command/radarmap.qc index 60e6bde62..26d108a1e 100644 --- a/qcsrc/server/command/radarmap.qc +++ b/qcsrc/server/command/radarmap.qc @@ -25,14 +25,14 @@ float FullTraceFraction(vector a, vector mi, vector ma, vector b) float n, m; n = m = 0; - while(vlen(c - b) > 1) + while (vlen(c - b) > 1) { ++m; tracebox(c, mi, ma, b, MOVE_WORLDONLY, world); ++n; - if(!trace_startsolid) + if (!trace_startsolid) { black += vlen(trace_endpos - c); c = trace_endpos; @@ -44,8 +44,7 @@ float FullTraceFraction(vector a, vector mi, vector ma, vector b) c = trace_endpos; } - if(n > 200) - LOG_TRACE("HOLY SHIT! FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n"); + if (n > 200) LOG_TRACE("HOLY SHIT! FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n"); return white / (black + white); } @@ -74,17 +73,13 @@ float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin, ma = '1 0 0' * w + '0 1 0' * h + dz; o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin; - if(x < world.absmin.x - w) - return 0; - if(y < world.absmin.y - h) - return 0; - if(x > world.absmax.x) - return 0; - if(y > world.absmax.y) - return 0; + if (x < world.absmin.x - w) return 0; + if (y < world.absmin.y - h) return 0; + if (x > world.absmax.x) return 0; + if (y > world.absmax.y) return 0; r = 0; - for(i = 0; i < q; ++i) + for (i = 0; i < q; ++i) { vector v1, v2; v1 = v2 = o + dz * i + mi; @@ -95,8 +90,7 @@ float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin, v2_y += random() * (ma.y - mi.y); v2_z += random() * (ma.z - mi.z); traceline(v1, v2, MOVE_WORLDONLY, world); - if(trace_startsolid || trace_fraction < 1) - ++r; + if (trace_startsolid || trace_fraction < 1) ++r; } return r / q; } @@ -114,21 +108,16 @@ float RadarMapAtPoint_Block(float x, float y, float w, float h, float zmin, floa ma = '1 0 0' * w + '0 1 0' * h + dz; o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin; - if(x < world.absmin.x - w) - return 0; - if(y < world.absmin.y - h) - return 0; - if(x > world.absmax.x) - return 0; - if(y > world.absmax.y) - return 0; + if (x < world.absmin.x - w) return 0; + if (y < world.absmin.y - h) return 0; + if (x > world.absmax.x) return 0; + if (y > world.absmax.y) return 0; r = 0; - for(i = 0; i < q; ++i) + for (i = 0; i < q; ++i) { tracebox(o + dz * i, mi, ma, o + dz * i, MOVE_WORLDONLY, world); - if(trace_startsolid) - ++r; + if (trace_startsolid) ++r; } return r / q; } @@ -136,7 +125,7 @@ float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, flo { vector a, b, mi, ma; - q *= 4; // choose q so it matches the regular algorithm in speed + q *= 4; // choose q so it matches the regular algorithm in speed q = 256 * q - 1; // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value @@ -149,15 +138,14 @@ float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, flo float c, i; c = 0; - for(i = 0; i < q; ++i) + for (i = 0; i < q; ++i) { vector v; v.x = a.x + random() * b.x; v.y = a.y + random() * b.y; v.z = a.z + random() * b.z; traceline(v, v, MOVE_WORLDONLY, world); - if(trace_startsolid) - ++c; + if (trace_startsolid) ++c; } return c / q; @@ -168,22 +156,17 @@ void sharpen_set(int x, float v) } float sharpen_getpixel(int x, int y) { - if(x < 0) - return 0; - if(x >= RADAR_WIDTH_MAX) - return 0; - if(y < 0) - return 0; - if(y > 2) - return 0; + if (x < 0) return 0; + if (x >= RADAR_WIDTH_MAX) return 0; + if (y < 0) return 0; + if (y > 2) return 0; return sharpen_buffer[x + y * RADAR_WIDTH_MAX]; } float sharpen_get(float x, float a) { float sum = sharpen_getpixel(x, 1); - if(a == 0) - return sum; - sum *= (8 + 1/a); + if (a == 0) return sum; + sum *= (8 + 1 / a); sum -= sharpen_getpixel(x - 1, 0); sum -= sharpen_getpixel(x - 1, 1); sum -= sharpen_getpixel(x - 1, 2); @@ -196,7 +179,7 @@ float sharpen_get(float x, float a) } void sharpen_shift(int w) { - for(int i = 0; i < w; ++i) + for (int i = 0; i < w; ++i) { sharpen_buffer[i] = sharpen_buffer[i + RADAR_WIDTH_MAX]; sharpen_buffer[i + RADAR_WIDTH_MAX] = sharpen_buffer[i + 2 * RADAR_WIDTH_MAX]; @@ -205,7 +188,7 @@ void sharpen_shift(int w) } void sharpen_init(int w) { - for(int i = 0; i < w; ++i) + for (int i = 0; i < w; ++i) { sharpen_buffer[i] = 0; sharpen_buffer[i + RADAR_WIDTH_MAX] = 0; @@ -214,11 +197,11 @@ void sharpen_init(int w) } void RadarMap_Next() { - if(radarmapper.count & 4) + if (radarmapper.count & 4) { localcmd("quit\n"); } - else if(radarmapper.count & 2) + else if (radarmapper.count & 2) { localcmd(strcat("defer 1 \"sv_cmd radarmap --flags ", ftos(radarmapper.count), strcat(" --res ", ftos(radarmapper.size.x), " ", ftos(radarmapper.size.y), " --sharpen ", ftos(radarmapper.ltime), " --qual ", ftos(radarmapper.size.z)), "\"\n")); GotoNextMap(0); @@ -227,7 +210,8 @@ void RadarMap_Next() radarmapper = world; } void RadarMap_Think() -{SELFPARAM(); +{ + SELFPARAM(); // rough map entity // cnt: current line // size: pixel width/height @@ -237,7 +221,7 @@ void RadarMap_Think() float i, x, l; string si; - if(self.frame == 0) + if (self.frame == 0) { // initialize get_mi_min_max_texcoords(1); @@ -247,22 +231,16 @@ void RadarMap_Think() self.maxs_z = mi_max.z - mi_min.z; LOG_INFO("Picture mins/maxs: ", ftos(self.maxs.x), " and ", ftos(self.maxs.y), " should match\n"); self.netname = strzone(strcat("gfx/", mi_shortname, "_radar.xpm")); - if(!(self.count & 1)) + if (!(self.count & 1)) { self.cnt = fopen(self.netname, FILE_READ); - if(self.cnt < 0) - self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.tga"), FILE_READ); - if(self.cnt < 0) - self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.png"), FILE_READ); - if(self.cnt < 0) - self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.jpg"), FILE_READ); - if(self.cnt < 0) - self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.tga"), FILE_READ); - if(self.cnt < 0) - self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.png"), FILE_READ); - if(self.cnt < 0) - self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.jpg"), FILE_READ); - if(self.cnt >= 0) + if (self.cnt < 0) self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.tga"), FILE_READ); + if (self.cnt < 0) self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.png"), FILE_READ); + if (self.cnt < 0) self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.jpg"), FILE_READ); + if (self.cnt < 0) self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.tga"), FILE_READ); + if (self.cnt < 0) self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.png"), FILE_READ); + if (self.cnt < 0) self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.jpg"), FILE_READ); + if (self.cnt >= 0) { fclose(self.cnt); @@ -272,7 +250,7 @@ void RadarMap_Think() } } self.cnt = fopen(self.netname, FILE_WRITE); - if(self.cnt < 0) + if (self.cnt < 0) { LOG_INFO("Error writing ", self.netname, "\n"); remove(self); @@ -284,47 +262,47 @@ void RadarMap_Think() fputs(self.cnt, "static char *RadarMap[] = {\n"); fputs(self.cnt, "/* columns rows colors chars-per-pixel */\n"); fputs(self.cnt, strcat("\"", ftos(self.size.x), " ", ftos(self.size.y), " 256 2\",\n")); - for(i = 0; i < 256; ++i) + for (i = 0; i < 256; ++i) { - si = substring(doublehex, i*2, 2); + si = substring(doublehex, i * 2, 2); fputs(self.cnt, strcat("\"", si, " c #", si, si, si, "\",\n")); } self.frame += 1; self.nextthink = time; sharpen_init(self.size.x); } - else if(self.frame <= self.size.y) + else if (self.frame <= self.size.y) { // fill the sharpen buffer with this line sharpen_shift(self.size.x); i = self.count & 24; - switch(i) + switch (i) { case 0: default: - for(x = 0; x < self.size.x; ++x) + for (x = 0; x < self.size.x; ++x) { l = RadarMapAtPoint_Block(self.mins.x + x * self.maxs.x, self.mins.y + (self.size.y - self.frame) * self.maxs.y, self.maxs.x, self.maxs.y, self.mins.z, self.maxs.z, self.size.z); sharpen_set(x, l); } break; case 8: - for(x = 0; x < self.size.x; ++x) + for (x = 0; x < self.size.x; ++x) { l = RadarMapAtPoint_Trace(self.mins.x + x * self.maxs.x, self.mins.y + (self.size.y - self.frame) * self.maxs.y, self.maxs.x, self.maxs.y, self.mins.z, self.maxs.z, self.size.z); sharpen_set(x, l); } break; case 16: - for(x = 0; x < self.size.x; ++x) + for (x = 0; x < self.size.x; ++x) { l = RadarMapAtPoint_Sample(self.mins.x + x * self.maxs.x, self.mins.y + (self.size.y - self.frame) * self.maxs.y, self.maxs.x, self.maxs.y, self.mins.z, self.maxs.z, self.size.z); sharpen_set(x, l); } break; case 24: - for(x = 0; x < self.size.x; ++x) + for (x = 0; x < self.size.x; ++x) { l = RadarMapAtPoint_LineBlock(self.mins.x + x * self.maxs.x, self.mins.y + (self.size.y - self.frame) * self.maxs.y, self.maxs.x, self.maxs.y, self.mins.z, self.maxs.z, self.size.z); sharpen_set(x, l); @@ -333,17 +311,19 @@ void RadarMap_Think() } // do we have enough lines? - if(self.frame >= 2) + if (self.frame >= 2) { // write a pixel line fputs(self.cnt, "\""); - for(x = 0; x < self.size.x; ++x) + for (x = 0; x < self.size.x; ++x) { l = sharpen_get(x, self.ltime); fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2)); } - if(self.frame == self.size.y) + if (self.frame == self.size.y) + { fputs(self.cnt, "\"\n"); + } else { fputs(self.cnt, "\",\n"); @@ -352,18 +332,20 @@ void RadarMap_Think() } // is this the last line? then write back the missing line - if(self.frame == self.size.y) + if (self.frame == self.size.y) { sharpen_shift(self.size.x); // write a pixel line fputs(self.cnt, "\""); - for(x = 0; x < self.size.x; ++x) + for (x = 0; x < self.size.x; ++x) { l = sharpen_get(x, self.ltime); fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2)); } - if(self.frame == self.size.y) + if (self.frame == self.size.y) + { fputs(self.cnt, "\"\n"); + } else { fputs(self.cnt, "\",\n"); @@ -388,32 +370,73 @@ float RadarMap_Make(float argc) { float i; - if(!radarmapper) + if (!radarmapper) { radarmapper = spawn(); radarmapper.classname = "radarmapper"; radarmapper.think = RadarMap_Think; radarmapper.nextthink = time; - radarmapper.count = 8; // default to the --trace method, as it is faster now + radarmapper.count = 8; // default to the --trace method, as it is faster now radarmapper.ltime = 1; radarmapper.size = '512 512 1'; - for(i = 1; i < argc; ++i) + for (i = 1; i < argc; ++i) { - switch(argv(i)) + switch (argv(i)) { - case "--force": { radarmapper.count |= 1; break; } - case "--loop": { radarmapper.count |= 2; break; } - case "--quit": { radarmapper.count |= 4; break; } - case "--block": { radarmapper.count &= ~24; break; } - case "--trace": { radarmapper.count &= ~24; radarmapper.count |= 8; break; } - case "--sample": { radarmapper.count &= ~24; radarmapper.count |= 16; break; } - case "--lineblock": { radarmapper.count |= 24; break; } - case "--flags": { ++i; radarmapper.count = stof(argv(i)); break; } // for the recursive call - case "--sharpen": { ++i; radarmapper.ltime = stof(argv(i)); break; } // for the recursive call - case "--res": // minor alias - case "--resolution": { ++i; radarmapper.size_x = stof(argv(i)); ++i; radarmapper.size_y = stof(argv(i)); break; } - case "--qual": // minor alias - case "--quality": { ++i; radarmapper.size_z = stof(argv(i)); break; } + case "--force": + { radarmapper.count |= 1; + break; + } + case "--loop": + { radarmapper.count |= 2; + break; + } + case "--quit": + { radarmapper.count |= 4; + break; + } + case "--block": + { radarmapper.count &= ~24; + break; + } + case "--trace": + { radarmapper.count &= ~24; + radarmapper.count |= 8; + break; + } + case "--sample": + { radarmapper.count &= ~24; + radarmapper.count |= 16; + break; + } + case "--lineblock": + { radarmapper.count |= 24; + break; + } + case "--flags": + { ++i; + radarmapper.count = stof(argv(i)); + break; + } // for the recursive call + case "--sharpen": + { ++i; + radarmapper.ltime = stof(argv(i)); + break; + } // for the recursive call + case "--res": // minor alias + case "--resolution": + { ++i; + radarmapper.size_x = stof(argv(i)); + ++i; + radarmapper.size_y = stof(argv(i)); + break; + } + case "--qual": // minor alias + case "--quality": + { ++i; + radarmapper.size_z = stof(argv(i)); + break; + } default: i = argc; @@ -423,10 +446,10 @@ float RadarMap_Make(float argc) } } - if(radarmapper) // after doing the arguments, see if we successfully went forward. + if (radarmapper) // after doing the arguments, see if we successfully went forward. { LOG_INFO("Radarmap entity spawned.\n"); - return true; // if so, don't print usage. + return true; // if so, don't print usage. } } diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index cde2d6c45..98127d198 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -31,7 +31,7 @@ #include "../../common/monsters/sv_monsters.qh" -void PutObserverInServer (void); +void PutObserverInServer(void); // ===================================================== // Server side game commands code, reworked by Samual @@ -40,8 +40,9 @@ void PutObserverInServer (void); // used by GameCommand_make_mapinfo() void make_mapinfo_Think() -{SELFPARAM(); - if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1)) +{ + SELFPARAM(); + if (MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1)) { LOG_INFO("Done rebuiling mapinfos.\n"); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); @@ -61,35 +62,29 @@ void changematchtime(float delta, float mi, float ma) float update; float lim; - if(delta == 0) - return; - if(autocvar_timelimit < 0) - return; + if (delta == 0) return; + if (autocvar_timelimit < 0) return; - if(mi <= 10) - mi = 10; // at least ten sec in the future + if (mi <= 10) mi = 10; // at least ten sec in the future cur = time - game_starttime; - if(cur > 0) - mi += cur; // from current time! + if (cur > 0) mi += cur; // from current time! lim = autocvar_timelimit * 60; - if(delta > 0) + if (delta > 0) { - if(lim == 0) - return; // cannot increase any further - else if(lim < ma) - update = min(ma, lim + delta); - else // already above maximum: FAIL + if (lim == 0) return; // cannot increase any further + else if (lim < ma) update = min(ma, lim + delta); + else // already above maximum: FAIL return; } else { - if(lim == 0) // infinite: try reducing to max, if we are allowed to + if (lim == 0) // infinite: try reducing to max, if we are allowed to update = max(mi, ma); - else if(lim > mi) // above minimum: decrease + else if (lim > mi) // above minimum: decrease update = max(mi, lim + delta); - else // already below minimum: FAIL + else // already below minimum: FAIL return; } @@ -103,7 +98,7 @@ void changematchtime(float delta, float mi, float ma) void GameCommand_adminmsg(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -118,24 +113,25 @@ void GameCommand_adminmsg(float request, float argc) string successful, t; successful = string_null; - if((targets) && (admin_message)) + if ((targets) && (admin_message)) { - for (;targets;) + for ( ; targets; ) { - t = car(targets); targets = cdr(targets); + t = car(targets); + targets = cdr(targets); // Check to see if the player is a valid target client = GetFilteredEntity(t); accepted = VerifyClientEntity(client, true, false); - if(accepted <= 0) + if (accepted <= 0) { LOG_INFO("adminmsg: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : ".\n")); continue; } // send the centerprint/console print or infomessage - if(infobartime) + if (infobartime) { stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", infobartime, MakeConsoleSafe(admin_message))); } @@ -150,10 +146,8 @@ void GameCommand_adminmsg(float request, float argc) continue; } - if(successful) - bprint("Successfully sent message '", admin_message, "' to ", successful, ".\n"); - else - LOG_INFO("No players given (", original_targets, ") could receive the message.\n"); + if (successful) bprint("Successfully sent message '", admin_message, "' to ", successful, ".\n"); + else LOG_INFO("No players given (", original_targets, ") could receive the message.\n"); return; } @@ -176,7 +170,7 @@ void GameCommand_adminmsg(float request, float argc) void GameCommand_allready(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -195,8 +189,9 @@ void GameCommand_allready(float request) } void GameCommand_allspec(float request, float argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { @@ -206,13 +201,12 @@ void GameCommand_allspec(float request, float argc) FOR_EACH_REALPLAYER(client) { - if (client.caplayer) - client.caplayer = 0; + if (client.caplayer) client.caplayer = 0; WITH(entity, self, client, PutObserverInServer()); ++i; } - if(i) { bprint(strcat("Successfully forced all (", ftos(i), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); } - else { LOG_INFO("No players found to spectate.\n"); } + if (i) bprint(strcat("Successfully forced all (", ftos(i), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); + else LOG_INFO("No players found to spectate.\n"); return; } @@ -228,15 +222,16 @@ void GameCommand_allspec(float request, float argc) } void GameCommand_anticheat(float request, float argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { entity client = GetIndexedEntity(argc, 1); float accepted = VerifyClientEntity(client, false, false); - if(accepted > 0) + if (accepted > 0) { WITH(entity, self, client, anticheat_report()); return; @@ -260,7 +255,7 @@ void GameCommand_anticheat(float request, float argc) void GameCommand_bbox(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -271,70 +266,58 @@ void GameCommand_bbox(float request) LOG_INFO("Solid bounding box size:"); tracebox('1 0 0' * world.absmin.x, - '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z, - '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z, - '1 0 0' * world.absmax.x, - MOVE_WORLDONLY, - world); - if(trace_startsolid) - LOG_INFO(" ", ftos(world.absmin.x)); - else - LOG_INFO(" ", ftos(trace_endpos.x)); + '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z, + '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z, + '1 0 0' * world.absmax.x, + MOVE_WORLDONLY, + world); + if (trace_startsolid) LOG_INFO(" ", ftos(world.absmin.x)); + else LOG_INFO(" ", ftos(trace_endpos.x)); tracebox('0 1 0' * world.absmin.y, - '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z, - '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z, - '0 1 0' * world.absmax.y, - MOVE_WORLDONLY, - world); - if(trace_startsolid) - LOG_INFO(" ", ftos(world.absmin.y)); - else - LOG_INFO(" ", ftos(trace_endpos.y)); + '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z, + '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z, + '0 1 0' * world.absmax.y, + MOVE_WORLDONLY, + world); + if (trace_startsolid) LOG_INFO(" ", ftos(world.absmin.y)); + else LOG_INFO(" ", ftos(trace_endpos.y)); tracebox('0 0 1' * world.absmin.z, - '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y, - '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y, - '0 0 1' * world.absmax.z, - MOVE_WORLDONLY, - world); - if(trace_startsolid) - LOG_INFO(" ", ftos(world.absmin.z)); - else - LOG_INFO(" ", ftos(trace_endpos.z)); + '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y, + '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y, + '0 0 1' * world.absmax.z, + MOVE_WORLDONLY, + world); + if (trace_startsolid) LOG_INFO(" ", ftos(world.absmin.z)); + else LOG_INFO(" ", ftos(trace_endpos.z)); tracebox('1 0 0' * world.absmax.x, - '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z, - '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z, - '1 0 0' * world.absmin.x, - MOVE_WORLDONLY, - world); - if(trace_startsolid) - LOG_INFO(" ", ftos(world.absmax.x)); - else - LOG_INFO(" ", ftos(trace_endpos.x)); + '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z, + '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z, + '1 0 0' * world.absmin.x, + MOVE_WORLDONLY, + world); + if (trace_startsolid) LOG_INFO(" ", ftos(world.absmax.x)); + else LOG_INFO(" ", ftos(trace_endpos.x)); tracebox('0 1 0' * world.absmax.y, - '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z, - '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z, - '0 1 0' * world.absmin.y, - MOVE_WORLDONLY, - world); - if(trace_startsolid) - LOG_INFO(" ", ftos(world.absmax.y)); - else - LOG_INFO(" ", ftos(trace_endpos.y)); + '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z, + '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z, + '0 1 0' * world.absmin.y, + MOVE_WORLDONLY, + world); + if (trace_startsolid) LOG_INFO(" ", ftos(world.absmax.y)); + else LOG_INFO(" ", ftos(trace_endpos.y)); tracebox('0 0 1' * world.absmax.z, - '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y, - '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y, - '0 0 1' * world.absmin.z, - MOVE_WORLDONLY, - world); - if(trace_startsolid) - LOG_INFO(" ", ftos(world.absmax.z)); - else - LOG_INFO(" ", ftos(trace_endpos.z)); + '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y, + '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y, + '0 0 1' * world.absmin.z, + MOVE_WORLDONLY, + world); + if (trace_startsolid) LOG_INFO(" ", ftos(world.absmax.z)); + else LOG_INFO(" ", ftos(trace_endpos.z)); LOG_INFO("\n"); return; @@ -353,72 +336,70 @@ void GameCommand_bbox(float request) void GameCommand_bot_cmd(float request, float argc, string command) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { entity bot; - if(argv(1) == "reset") + if (argv(1) == "reset") { bot_resetqueues(); return; } - else if(argv(1) == "setbots") + else if (argv(1) == "setbots") { cvar_settemp("bot_vs_human", "0"); cvar_settemp("minplayers", "0"); cvar_settemp("bot_number", "0"); bot_fixcount(); cvar_settemp("bot_number", argv(2)); - if(!bot_fixcount()) - LOG_INFO("Sorry, could not set requested bot count\n"); + if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count\n"); return; } - else if(argv(1) == "load" && argc == 3) + else if (argv(1) == "load" && argc == 3) { float fh, i; string s; fh = fopen(argv(2), FILE_READ); - if(fh < 0) + if (fh < 0) { LOG_INFO("cannot open the file\n"); return; } i = 0; - while((s = fgets(fh))) + while ((s = fgets(fh))) { argc = tokenize_console(s); - if(argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd") + if (argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd") { - if(argv(2) == "reset") + if (argv(2) == "reset") { bot_resetqueues(); } - else if(argv(2) == "setbots") + else if (argv(2) == "setbots") { cvar_settemp("bot_vs_human", "0"); cvar_settemp("minplayers", "0"); cvar_settemp("bot_number", "0"); bot_fixcount(); cvar_settemp("bot_number", argv(3)); - if(!bot_fixcount()) - LOG_INFO("Sorry, could not set requested bot count\n"); + if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count\n"); } else { // let's start at token 2 so we can skip sv_cmd bot_cmd bot = find_bot_by_number(stof(argv(2))); - if(bot == world) - bot = find_bot_by_name(argv(2)); - if(bot) - bot_queuecommand(bot, substring(s, argv_start_index(3), -1)); + if (bot == world) bot = find_bot_by_name(argv(2)); + if (bot) bot_queuecommand(bot, substring(s, argv_start_index(3), -1)); } } else + { localcmd(strcat(s, "\n")); + } ++i; } @@ -426,27 +407,26 @@ void GameCommand_bot_cmd(float request, float argc, string command) fclose(fh); return; } - else if(argv(1) == "help") + else if (argv(1) == "help") { - if(argv(2)) - bot_cmdhelp(argv(2)); - else - bot_list_commands(); + if (argv(2)) bot_cmdhelp(argv(2)); + else bot_list_commands(); return; } - else if(argc >= 3) // this comes last + else if (argc >= 3) // this comes last { bot = find_bot_by_number(stof(argv(1))); - if(bot == world) - bot = find_bot_by_name(argv(1)); - if(bot) + if (bot == world) bot = find_bot_by_name(argv(1)); + if (bot) { LOG_INFO(strcat("Command '", substring(command, argv_start_index(2), -1), "' sent to bot ", bot.netname, "\n")); bot_queuecommand(bot, substring(command, argv_start_index(2), -1)); return; } else - LOG_INFO(strcat("Error: Can't find bot with the name or id '", argv(1),"' - Did you mistype the command?\n")); // don't return so that usage is shown + { + LOG_INFO(strcat("Error: Can't find bot with the name or id '", argv(1), "' - Did you mistype the command?\n")); // don't return so that usage is shown + } } } @@ -466,7 +446,7 @@ void GameCommand_bot_cmd(float request, float argc, string command) void GameCommand_cointoss(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -490,25 +470,25 @@ void GameCommand_cointoss(float request, float argc) void GameCommand_database(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc == 3) + if (argc == 3) { - if(argv(1) == "save") + if (argv(1) == "save") { db_save(ServerProgsDB, argv(2)); LOG_INFO(strcat("Copied serverprogs database to '", argv(2), "' in the data directory.\n")); return; } - else if(argv(1) == "dump") + else if (argv(1) == "dump") { db_dump(ServerProgsDB, argv(2)); - LOG_INFO("DB dumped.\n"); // wtf does this do? + LOG_INFO("DB dumped.\n"); // wtf does this do? return; } - else if(argv(1) == "load") + else if (argv(1) == "load") { db_close(ServerProgsDB); ServerProgsDB = db_load(argv(2)); @@ -533,19 +513,19 @@ void GameCommand_database(float request, float argc) void GameCommand_defer_clear(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { entity client; float accepted; - if(argc >= 2) + if (argc >= 2) { client = GetIndexedEntity(argc, 1); accepted = VerifyClientEntity(client, true, false); - if(accepted > 0) + if (accepted > 0) { stuffcmd(client, "defer clear\n"); LOG_INFO("defer clear stuffed to ", client.netname, "\n"); @@ -570,7 +550,7 @@ void GameCommand_defer_clear(float request, float argc) void GameCommand_defer_clear_all(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -584,7 +564,7 @@ void GameCommand_defer_clear_all(float request) GameCommand_defer_clear(CMD_REQUEST_COMMAND, argc); ++i; } - if(i) { LOG_INFO(strcat("Successfully stuffed defer clear to all clients (", ftos(i), ")\n")); } // should a message be added if no players were found? + if (i) LOG_INFO(strcat("Successfully stuffed defer clear to all clients (", ftos(i), ")\n")); // should a message be added if no players were found? return; } @@ -601,16 +581,14 @@ void GameCommand_defer_clear_all(float request) void GameCommand_delrec(float request, float argc) // perhaps merge later with records and printstats and such? { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1)) + if (argv(1)) { - if(argv(2)) - race_deleteTime(argv(2), stof(argv(1))); - else - race_deleteTime(GetMapname(), stof(argv(1))); + if (argv(2)) race_deleteTime(argv(2), stof(argv(1))); + else race_deleteTime(GetMapname(), stof(argv(1))); return; } } @@ -630,7 +608,7 @@ void GameCommand_delrec(float request, float argc) // perhaps merge later with void GameCommand_effectindexdump(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -639,54 +617,89 @@ void GameCommand_effectindexdump(float request) d = db_create(); LOG_INFO("begin of effects list\n"); - db_put(d, "TE_GUNSHOT", "1"); LOG_INFO("effect TE_GUNSHOT is ", ftos(_particleeffectnum("TE_GUNSHOT")), "\n"); - db_put(d, "TE_GUNSHOTQUAD", "1"); LOG_INFO("effect TE_GUNSHOTQUAD is ", ftos(_particleeffectnum("TE_GUNSHOTQUAD")), "\n"); - db_put(d, "TE_SPIKE", "1"); LOG_INFO("effect TE_SPIKE is ", ftos(_particleeffectnum("TE_SPIKE")), "\n"); - db_put(d, "TE_SPIKEQUAD", "1"); LOG_INFO("effect TE_SPIKEQUAD is ", ftos(_particleeffectnum("TE_SPIKEQUAD")), "\n"); - db_put(d, "TE_SUPERSPIKE", "1"); LOG_INFO("effect TE_SUPERSPIKE is ", ftos(_particleeffectnum("TE_SUPERSPIKE")), "\n"); - db_put(d, "TE_SUPERSPIKEQUAD", "1"); LOG_INFO("effect TE_SUPERSPIKEQUAD is ", ftos(_particleeffectnum("TE_SUPERSPIKEQUAD")), "\n"); - db_put(d, "TE_WIZSPIKE", "1"); LOG_INFO("effect TE_WIZSPIKE is ", ftos(_particleeffectnum("TE_WIZSPIKE")), "\n"); - db_put(d, "TE_KNIGHTSPIKE", "1"); LOG_INFO("effect TE_KNIGHTSPIKE is ", ftos(_particleeffectnum("TE_KNIGHTSPIKE")), "\n"); - db_put(d, "TE_EXPLOSION", "1"); LOG_INFO("effect TE_EXPLOSION is ", ftos(_particleeffectnum("TE_EXPLOSION")), "\n"); - db_put(d, "TE_EXPLOSIONQUAD", "1"); LOG_INFO("effect TE_EXPLOSIONQUAD is ", ftos(_particleeffectnum("TE_EXPLOSIONQUAD")), "\n"); - db_put(d, "TE_TAREXPLOSION", "1"); LOG_INFO("effect TE_TAREXPLOSION is ", ftos(_particleeffectnum("TE_TAREXPLOSION")), "\n"); - db_put(d, "TE_TELEPORT", "1"); LOG_INFO("effect TE_TELEPORT is ", ftos(_particleeffectnum("TE_TELEPORT")), "\n"); - db_put(d, "TE_LAVASPLASH", "1"); LOG_INFO("effect TE_LAVASPLASH is ", ftos(_particleeffectnum("TE_LAVASPLASH")), "\n"); - db_put(d, "TE_SMALLFLASH", "1"); LOG_INFO("effect TE_SMALLFLASH is ", ftos(_particleeffectnum("TE_SMALLFLASH")), "\n"); - db_put(d, "TE_FLAMEJET", "1"); LOG_INFO("effect TE_FLAMEJET is ", ftos(_particleeffectnum("TE_FLAMEJET")), "\n"); - db_put(d, "EF_FLAME", "1"); LOG_INFO("effect EF_FLAME is ", ftos(_particleeffectnum("EF_FLAME")), "\n"); - db_put(d, "TE_BLOOD", "1"); LOG_INFO("effect TE_BLOOD is ", ftos(_particleeffectnum("TE_BLOOD")), "\n"); - db_put(d, "TE_SPARK", "1"); LOG_INFO("effect TE_SPARK is ", ftos(_particleeffectnum("TE_SPARK")), "\n"); - db_put(d, "TE_PLASMABURN", "1"); LOG_INFO("effect TE_PLASMABURN is ", ftos(_particleeffectnum("TE_PLASMABURN")), "\n"); - db_put(d, "TE_TEI_G3", "1"); LOG_INFO("effect TE_TEI_G3 is ", ftos(_particleeffectnum("TE_TEI_G3")), "\n"); - db_put(d, "TE_TEI_SMOKE", "1"); LOG_INFO("effect TE_TEI_SMOKE is ", ftos(_particleeffectnum("TE_TEI_SMOKE")), "\n"); - db_put(d, "TE_TEI_BIGEXPLOSION", "1"); LOG_INFO("effect TE_TEI_BIGEXPLOSION is ", ftos(_particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n"); - db_put(d, "TE_TEI_PLASMAHIT", "1"); LOG_INFO("effect TE_TEI_PLASMAHIT is ", ftos(_particleeffectnum("TE_TEI_PLASMAHIT")), "\n"); - db_put(d, "EF_STARDUST", "1"); LOG_INFO("effect EF_STARDUST is ", ftos(_particleeffectnum("EF_STARDUST")), "\n"); - db_put(d, "TR_ROCKET", "1"); LOG_INFO("effect TR_ROCKET is ", ftos(_particleeffectnum("TR_ROCKET")), "\n"); - db_put(d, "TR_GRENADE", "1"); LOG_INFO("effect TR_GRENADE is ", ftos(_particleeffectnum("TR_GRENADE")), "\n"); - db_put(d, "TR_BLOOD", "1"); LOG_INFO("effect TR_BLOOD is ", ftos(_particleeffectnum("TR_BLOOD")), "\n"); - db_put(d, "TR_WIZSPIKE", "1"); LOG_INFO("effect TR_WIZSPIKE is ", ftos(_particleeffectnum("TR_WIZSPIKE")), "\n"); - db_put(d, "TR_SLIGHTBLOOD", "1"); LOG_INFO("effect TR_SLIGHTBLOOD is ", ftos(_particleeffectnum("TR_SLIGHTBLOOD")), "\n"); - db_put(d, "TR_KNIGHTSPIKE", "1"); LOG_INFO("effect TR_KNIGHTSPIKE is ", ftos(_particleeffectnum("TR_KNIGHTSPIKE")), "\n"); - db_put(d, "TR_VORESPIKE", "1"); LOG_INFO("effect TR_VORESPIKE is ", ftos(_particleeffectnum("TR_VORESPIKE")), "\n"); - db_put(d, "TR_NEHAHRASMOKE", "1"); LOG_INFO("effect TR_NEHAHRASMOKE is ", ftos(_particleeffectnum("TR_NEHAHRASMOKE")), "\n"); - db_put(d, "TR_NEXUIZPLASMA", "1"); LOG_INFO("effect TR_NEXUIZPLASMA is ", ftos(_particleeffectnum("TR_NEXUIZPLASMA")), "\n"); - db_put(d, "TR_GLOWTRAIL", "1"); LOG_INFO("effect TR_GLOWTRAIL is ", ftos(_particleeffectnum("TR_GLOWTRAIL")), "\n"); - db_put(d, "TR_SEEKER", "1"); LOG_INFO("effect TR_SEEKER is ", ftos(_particleeffectnum("TR_SEEKER")), "\n"); - db_put(d, "SVC_PARTICLE", "1"); LOG_INFO("effect SVC_PARTICLE is ", ftos(_particleeffectnum("SVC_PARTICLE")), "\n"); + db_put(d, "TE_GUNSHOT", "1"); + LOG_INFO("effect TE_GUNSHOT is ", ftos(_particleeffectnum("TE_GUNSHOT")), "\n"); + db_put(d, "TE_GUNSHOTQUAD", "1"); + LOG_INFO("effect TE_GUNSHOTQUAD is ", ftos(_particleeffectnum("TE_GUNSHOTQUAD")), "\n"); + db_put(d, "TE_SPIKE", "1"); + LOG_INFO("effect TE_SPIKE is ", ftos(_particleeffectnum("TE_SPIKE")), "\n"); + db_put(d, "TE_SPIKEQUAD", "1"); + LOG_INFO("effect TE_SPIKEQUAD is ", ftos(_particleeffectnum("TE_SPIKEQUAD")), "\n"); + db_put(d, "TE_SUPERSPIKE", "1"); + LOG_INFO("effect TE_SUPERSPIKE is ", ftos(_particleeffectnum("TE_SUPERSPIKE")), "\n"); + db_put(d, "TE_SUPERSPIKEQUAD", "1"); + LOG_INFO("effect TE_SUPERSPIKEQUAD is ", ftos(_particleeffectnum("TE_SUPERSPIKEQUAD")), "\n"); + db_put(d, "TE_WIZSPIKE", "1"); + LOG_INFO("effect TE_WIZSPIKE is ", ftos(_particleeffectnum("TE_WIZSPIKE")), "\n"); + db_put(d, "TE_KNIGHTSPIKE", "1"); + LOG_INFO("effect TE_KNIGHTSPIKE is ", ftos(_particleeffectnum("TE_KNIGHTSPIKE")), "\n"); + db_put(d, "TE_EXPLOSION", "1"); + LOG_INFO("effect TE_EXPLOSION is ", ftos(_particleeffectnum("TE_EXPLOSION")), "\n"); + db_put(d, "TE_EXPLOSIONQUAD", "1"); + LOG_INFO("effect TE_EXPLOSIONQUAD is ", ftos(_particleeffectnum("TE_EXPLOSIONQUAD")), "\n"); + db_put(d, "TE_TAREXPLOSION", "1"); + LOG_INFO("effect TE_TAREXPLOSION is ", ftos(_particleeffectnum("TE_TAREXPLOSION")), "\n"); + db_put(d, "TE_TELEPORT", "1"); + LOG_INFO("effect TE_TELEPORT is ", ftos(_particleeffectnum("TE_TELEPORT")), "\n"); + db_put(d, "TE_LAVASPLASH", "1"); + LOG_INFO("effect TE_LAVASPLASH is ", ftos(_particleeffectnum("TE_LAVASPLASH")), "\n"); + db_put(d, "TE_SMALLFLASH", "1"); + LOG_INFO("effect TE_SMALLFLASH is ", ftos(_particleeffectnum("TE_SMALLFLASH")), "\n"); + db_put(d, "TE_FLAMEJET", "1"); + LOG_INFO("effect TE_FLAMEJET is ", ftos(_particleeffectnum("TE_FLAMEJET")), "\n"); + db_put(d, "EF_FLAME", "1"); + LOG_INFO("effect EF_FLAME is ", ftos(_particleeffectnum("EF_FLAME")), "\n"); + db_put(d, "TE_BLOOD", "1"); + LOG_INFO("effect TE_BLOOD is ", ftos(_particleeffectnum("TE_BLOOD")), "\n"); + db_put(d, "TE_SPARK", "1"); + LOG_INFO("effect TE_SPARK is ", ftos(_particleeffectnum("TE_SPARK")), "\n"); + db_put(d, "TE_PLASMABURN", "1"); + LOG_INFO("effect TE_PLASMABURN is ", ftos(_particleeffectnum("TE_PLASMABURN")), "\n"); + db_put(d, "TE_TEI_G3", "1"); + LOG_INFO("effect TE_TEI_G3 is ", ftos(_particleeffectnum("TE_TEI_G3")), "\n"); + db_put(d, "TE_TEI_SMOKE", "1"); + LOG_INFO("effect TE_TEI_SMOKE is ", ftos(_particleeffectnum("TE_TEI_SMOKE")), "\n"); + db_put(d, "TE_TEI_BIGEXPLOSION", "1"); + LOG_INFO("effect TE_TEI_BIGEXPLOSION is ", ftos(_particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n"); + db_put(d, "TE_TEI_PLASMAHIT", "1"); + LOG_INFO("effect TE_TEI_PLASMAHIT is ", ftos(_particleeffectnum("TE_TEI_PLASMAHIT")), "\n"); + db_put(d, "EF_STARDUST", "1"); + LOG_INFO("effect EF_STARDUST is ", ftos(_particleeffectnum("EF_STARDUST")), "\n"); + db_put(d, "TR_ROCKET", "1"); + LOG_INFO("effect TR_ROCKET is ", ftos(_particleeffectnum("TR_ROCKET")), "\n"); + db_put(d, "TR_GRENADE", "1"); + LOG_INFO("effect TR_GRENADE is ", ftos(_particleeffectnum("TR_GRENADE")), "\n"); + db_put(d, "TR_BLOOD", "1"); + LOG_INFO("effect TR_BLOOD is ", ftos(_particleeffectnum("TR_BLOOD")), "\n"); + db_put(d, "TR_WIZSPIKE", "1"); + LOG_INFO("effect TR_WIZSPIKE is ", ftos(_particleeffectnum("TR_WIZSPIKE")), "\n"); + db_put(d, "TR_SLIGHTBLOOD", "1"); + LOG_INFO("effect TR_SLIGHTBLOOD is ", ftos(_particleeffectnum("TR_SLIGHTBLOOD")), "\n"); + db_put(d, "TR_KNIGHTSPIKE", "1"); + LOG_INFO("effect TR_KNIGHTSPIKE is ", ftos(_particleeffectnum("TR_KNIGHTSPIKE")), "\n"); + db_put(d, "TR_VORESPIKE", "1"); + LOG_INFO("effect TR_VORESPIKE is ", ftos(_particleeffectnum("TR_VORESPIKE")), "\n"); + db_put(d, "TR_NEHAHRASMOKE", "1"); + LOG_INFO("effect TR_NEHAHRASMOKE is ", ftos(_particleeffectnum("TR_NEHAHRASMOKE")), "\n"); + db_put(d, "TR_NEXUIZPLASMA", "1"); + LOG_INFO("effect TR_NEXUIZPLASMA is ", ftos(_particleeffectnum("TR_NEXUIZPLASMA")), "\n"); + db_put(d, "TR_GLOWTRAIL", "1"); + LOG_INFO("effect TR_GLOWTRAIL is ", ftos(_particleeffectnum("TR_GLOWTRAIL")), "\n"); + db_put(d, "TR_SEEKER", "1"); + LOG_INFO("effect TR_SEEKER is ", ftos(_particleeffectnum("TR_SEEKER")), "\n"); + db_put(d, "SVC_PARTICLE", "1"); + LOG_INFO("effect SVC_PARTICLE is ", ftos(_particleeffectnum("SVC_PARTICLE")), "\n"); fh = fopen("effectinfo.txt", FILE_READ); - while((s = fgets(fh))) + while ((s = fgets(fh))) { tokenize_console(s); - if(argv(0) == "effect") + if (argv(0) == "effect") { - if(db_get(d, argv(1)) != "1") + if (db_get(d, argv(1)) != "1") { int i = _particleeffectnum(argv(1)); - if(i >= 0) - LOG_INFO("effect ", argv(1), " is ", ftos(i), "\n"); + if (i >= 0) LOG_INFO("effect ", argv(1), " is ", ftos(i), "\n"); db_put(d, argv(1), "1"); } } @@ -709,7 +722,7 @@ void GameCommand_effectindexdump(float request) void GameCommand_extendmatchtime(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -730,13 +743,13 @@ void GameCommand_extendmatchtime(float request) void GameCommand_find(float request, float argc) // is this even needed? We have prvm_edicts command and such ANYWAY { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { entity client; - for(client = world; (client = find(client, classname, argv(1))); ) + for (client = world; (client = find(client, classname, argv(1))); ) LOG_INFO(etos(client), "\n"); return; @@ -755,23 +768,23 @@ void GameCommand_find(float request, float argc) // is this even needed? We hav void GameCommand_gametype(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1) != "") + if (argv(1) != "") { string s = argv(1); float t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype(); - if(t) + if (t) { MapInfo_SwitchGameType(t); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); - if(MapInfo_count > 0) + if (MapInfo_count > 0) { // update lsmaps in case the gametype changed, this way people can easily list maps for it - if(lsmaps_reply != "") { strunzone(lsmaps_reply); } + if (lsmaps_reply != "") strunzone(lsmaps_reply); lsmaps_reply = strzone(getlsmaps()); bprint("Game type successfully switched to ", s, "\n"); } @@ -783,7 +796,9 @@ void GameCommand_gametype(float request, float argc) } } else + { bprint("Game type switch to ", s, " failed: this type does not exist!\n"); + } return; } @@ -803,7 +818,7 @@ void GameCommand_gametype(float request, float argc) void GameCommand_gettaginfo(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -811,22 +826,22 @@ void GameCommand_gettaginfo(float request, float argc) float i; vector v; - if(argc >= 4) + if (argc >= 4) { tmp_entity = spawn(); - if(argv(1) == "w") + if (argv(1) == "w") + { _setmodel(tmp_entity, (nextent(world)).weaponentity.model); + } else { precache_model(argv(1)); _setmodel(tmp_entity, argv(1)); } tmp_entity.frame = stof(argv(2)); - if(substring(argv(3), 0, 1) == "#") - i = stof(substring(argv(3), 1, -1)); - else - i = gettagindex(tmp_entity, argv(3)); - if(i) + if (substring(argv(3), 0, 1) == "#") i = stof(substring(argv(3), 1, -1)); + else i = gettagindex(tmp_entity, argv(3)); + if (i) { v = gettaginfo(tmp_entity, i); LOG_INFO("model ", tmp_entity.model, " frame ", ftos(tmp_entity.frame), " tag ", gettaginfo_name); @@ -836,14 +851,16 @@ void GameCommand_gettaginfo(float request, float argc) LOG_INFO(" forward = ", ftos(gettaginfo_forward.x), " ", ftos(gettaginfo_forward.y), " ", ftos(gettaginfo_forward.z), "\n"); LOG_INFO(" right = ", ftos(gettaginfo_right.x), " ", ftos(gettaginfo_right.y), " ", ftos(gettaginfo_right.z), "\n"); LOG_INFO(" up = ", ftos(gettaginfo_up.x), " ", ftos(gettaginfo_up.y), " ", ftos(gettaginfo_up.z), "\n"); - if(argc >= 6) + if (argc >= 6) { v.y = -v.y; localcmd(strcat(argv(4), vtos(v), argv(5), "\n")); } } else + { LOG_INFO("bone not found\n"); + } remove(tmp_entity); return; @@ -863,17 +880,19 @@ void GameCommand_gettaginfo(float request, float argc) void GameCommand_animbench(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { entity tmp_entity; - if(argc >= 4) + if (argc >= 4) { tmp_entity = spawn(); - if(argv(1) == "w") + if (argv(1) == "w") + { _setmodel(tmp_entity, (nextent(world)).weaponentity.model); + } else { precache_model(argv(1)); @@ -886,7 +905,7 @@ void GameCommand_animbench(float request, float argc) float t2 = 0; float n = 0; - while(t1 + t2 < 1) + while (t1 + t2 < 1) { tmp_entity.frame = f1; t0 = gettime(GETTIME_HIRES); @@ -919,11 +938,11 @@ void GameCommand_animbench(float request, float argc) void GameCommand_gotomap(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(1)) + if (argv(1)) { LOG_INFO(GotoMap(argv(1)), "\n"); return; @@ -944,11 +963,11 @@ void GameCommand_gotomap(float request, float argc) void GameCommand_lockteams(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(teamplay) + if (teamplay) { lockteams = 1; bprint("^1The teams are now locked.\n"); @@ -973,7 +992,7 @@ void GameCommand_lockteams(float request) void GameCommand_make_mapinfo(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -999,8 +1018,9 @@ void GameCommand_make_mapinfo(float request) } void GameCommand_moveplayer(float request, float argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { @@ -1015,29 +1035,29 @@ void GameCommand_moveplayer(float request, float argc) successful = string_null; // lets see if the target(s) even actually exist. - if((targets) && (destination)) + if ((targets) && (destination)) { - for (;targets;) + for ( ; targets; ) { - t = car(targets); targets = cdr(targets); + t = car(targets); + targets = cdr(targets); // Check to see if the player is a valid target client = GetFilteredEntity(t); accepted = VerifyClientEntity(client, false, false); - if(accepted <= 0) + if (accepted <= 0) { LOG_INFO("moveplayer: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : ".\n")); continue; } // Where are we putting this player? - if(destination == "spec" || destination == "spectator") + if (destination == "spec" || destination == "spectator") { - if(!IS_SPEC(client) && !IS_OBSERVER(client)) + if (!IS_SPEC(client) && !IS_OBSERVER(client)) { - if (client.caplayer) - client.caplayer = 0; + if (client.caplayer) client.caplayer = 0; WITH(entity, self, client, PutObserverInServer()); successful = strcat(successful, (successful ? ", " : ""), client.netname); @@ -1050,9 +1070,9 @@ void GameCommand_moveplayer(float request, float argc) } else { - if(!IS_SPEC(client) && !IS_OBSERVER(client)) + if (!IS_SPEC(client) && !IS_OBSERVER(client)) { - if(teamplay) + if (teamplay) { // set up float team_id; @@ -1061,13 +1081,13 @@ void GameCommand_moveplayer(float request, float argc) // find the team to move the player to team_id = Team_ColorToTeam(destination); - if(team_id == client.team) // already on the destination team + if (team_id == client.team) // already on the destination team { // keep the forcing undone LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already on the ", Team_ColoredFullName(client.team), (targets ? "^7, skipping to next player.\n" : "^7.\n")); continue; } - else if(team_id == 0) // auto team + else if (team_id == 0) // auto team { CheckAllowedTeams(client); team_id = Team_NumberToTeam(FindSmallestTeam(client, false)); @@ -1079,14 +1099,15 @@ void GameCommand_moveplayer(float request, float argc) client.team_forced = save; // Check to see if the destination team is even available - switch(team_id) + switch (team_id) { - case NUM_TEAM_1: if(c1 == -1) { LOG_INFO("Sorry, can't move player to red team if it doesn't exist.\n"); return; } break; - case NUM_TEAM_2: if(c2 == -1) { LOG_INFO("Sorry, can't move player to blue team if it doesn't exist.\n"); return; } break; - case NUM_TEAM_3: if(c3 == -1) { LOG_INFO("Sorry, can't move player to yellow team if it doesn't exist.\n"); return; } break; - case NUM_TEAM_4: if(c4 == -1) { LOG_INFO("Sorry, can't move player to pink team if it doesn't exist.\n"); return; } break; + case NUM_TEAM_1: if (c1 == -1) { LOG_INFO("Sorry, can't move player to red team if it doesn't exist.\n"); return; } break; + case NUM_TEAM_2: if (c2 == -1) { LOG_INFO("Sorry, can't move player to blue team if it doesn't exist.\n"); return; } break; + case NUM_TEAM_3: if (c3 == -1) { LOG_INFO("Sorry, can't move player to yellow team if it doesn't exist.\n"); return; } break; + case NUM_TEAM_4: if (c4 == -1) { LOG_INFO("Sorry, can't move player to pink team if it doesn't exist.\n"); return; } break; - default: LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist.\n"); return; + default: LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist.\n"); + return; } // If so, lets continue and finally move the player @@ -1104,18 +1125,16 @@ void GameCommand_moveplayer(float request, float argc) } else { - LOG_INFO("Can't change teams if the player isn't in the game.\n"); // well technically we could, but should we allow that? :P + LOG_INFO("Can't change teams if the player isn't in the game.\n"); // well technically we could, but should we allow that? :P return; } } } - if(successful) - bprint("Successfully moved players ", successful, " to destination ", destination, ".\n"); - else - LOG_INFO("No players given (", original_targets, ") are able to move.\n"); + if (successful) bprint("Successfully moved players ", successful, " to destination ", destination, ".\n"); + else LOG_INFO("No players given (", original_targets, ") are able to move.\n"); - return; // still correct parameters so return to avoid usage print + return; // still correct parameters so return to avoid usage print } } @@ -1137,19 +1156,21 @@ void GameCommand_moveplayer(float request, float argc) void GameCommand_nospectators(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { blockSpectators = 1; entity plr; - FOR_EACH_REALCLIENT(plr) //give every spectator seconds time to become a player + FOR_EACH_REALCLIENT(plr) // give every spectator seconds time to become a player { - if(IS_SPEC(plr) || IS_OBSERVER(plr)) - if(!plr.caplayer) + if (IS_SPEC(plr) || IS_OBSERVER(plr)) { - plr.spectatortime = time; - Send_Notification(NOTIF_ONE_ONLY, plr, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime); + if (!plr.caplayer) + { + plr.spectatortime = time; + Send_Notification(NOTIF_ONE_ONLY, plr, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime); + } } } bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n")); @@ -1167,24 +1188,25 @@ void GameCommand_nospectators(float request) } void GameCommand_playerdemo(float request, float argc) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(argv(2) && argv(3)) + if (argv(2) && argv(3)) { entity client; float i, n, accepted; - switch(argv(1)) + switch (argv(1)) { case "read": { client = GetIndexedEntity(argc, 2); accepted = VerifyClientEntity(client, false, true); - if(accepted <= 0) + if (accepted <= 0) { LOG_INFO("playerdemo: read: ", GetClientErrorString(accepted, argv(2)), ".\n"); return; @@ -1199,7 +1221,7 @@ void GameCommand_playerdemo(float request, float argc) client = GetIndexedEntity(argc, 2); accepted = VerifyClientEntity(client, false, false); - if(accepted <= 0) + if (accepted <= 0) { LOG_INFO("playerdemo: write: ", GetClientErrorString(accepted, argv(2)), ".\n"); return; @@ -1215,9 +1237,9 @@ void GameCommand_playerdemo(float request, float argc) cvar_set("bot_number", ftos(n)); localcmd("wait; wait; wait\n"); - for(i = 0; i < n; ++i) { localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", argv(2), ftos(i+1), "\n"); } - - localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n"); + for (i = 0; i < n; ++i) + localcmd("sv_cmd playerdemo read ", ftos(i + 2), " ", argv(2), ftos(i + 1), "\n"); + localcmd("sv_cmd playerdemo write 1 ", ftos(n + 1), "\n"); return; } @@ -1227,7 +1249,8 @@ void GameCommand_playerdemo(float request, float argc) cvar_set("bot_number", ftos(n)); localcmd("wait; wait; wait\n"); - for(i = 0; i < n; ++i) { localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", argv(2), ftos(i+1), "\n"); } + for (i = 0; i < n; ++i) + localcmd("sv_cmd playerdemo read ", ftos(i + 2), " ", argv(2), ftos(i + 1), "\n"); return; } } @@ -1247,7 +1270,7 @@ void GameCommand_playerdemo(float request, float argc) void GameCommand_printstats(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -1268,12 +1291,11 @@ void GameCommand_printstats(float request) void GameCommand_radarmap(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(RadarMap_Make(argc)) - return; + if (RadarMap_Make(argc)) return; } default: @@ -1291,11 +1313,11 @@ void GameCommand_radarmap(float request, float argc) void GameCommand_reducematchtime(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - changematchtime(autocvar_timelimit_decrement *-60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60); + changematchtime(autocvar_timelimit_decrement * -60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60); return; } @@ -1312,11 +1334,11 @@ void GameCommand_reducematchtime(float request) void GameCommand_setbots(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(argc >= 2) + if (argc >= 2) { cvar_settemp("minplayers", "0"); cvar_settemp("bot_number", argv(1)); @@ -1338,12 +1360,13 @@ void GameCommand_setbots(float request, float argc) } void GameCommand_shuffleteams(float request) -{SELFPARAM(); - switch(request) +{ + SELFPARAM(); + switch (request) { case CMD_REQUEST_COMMAND: { - if(teamplay) + if (teamplay) { entity tmp_player; int i; @@ -1353,29 +1376,29 @@ void GameCommand_shuffleteams(float request) t_players = 0; t_teams = 0; FOR_EACH_CLIENT(tmp_player) - if(IS_PLAYER(tmp_player) || tmp_player.caplayer) + if (IS_PLAYER(tmp_player) || tmp_player.caplayer) { CheckAllowedTeams(tmp_player); - if(c1 >= 0) t_teams = max(1, t_teams); - if(c2 >= 0) t_teams = max(2, t_teams); - if(c3 >= 0) t_teams = max(3, t_teams); - if(c4 >= 0) t_teams = max(4, t_teams); + if (c1 >= 0) t_teams = max(1, t_teams); + if (c2 >= 0) t_teams = max(2, t_teams); + if (c3 >= 0) t_teams = max(3, t_teams); + if (c4 >= 0) t_teams = max(4, t_teams); ++t_players; } // build a list of the players in a random order FOR_EACH_CLIENT(tmp_player) - if(IS_PLAYER(tmp_player) || tmp_player.caplayer) + if (IS_PLAYER(tmp_player) || tmp_player.caplayer) { - for (;;) + for ( ; ; ) { i = bound(1, floor(random() * maxclients) + 1, maxclients); - if(shuffleteams_players[i]) + if (shuffleteams_players[i]) { - continue; // a player is already assigned to this slot + continue; // a player is already assigned to this slot } else { @@ -1399,21 +1422,18 @@ void GameCommand_shuffleteams(float request) { if (!(shuffleteams_teams[i] >= x)) { - if (!(shuffleteams_players[z])) - continue; // not a player, move on to next random slot + if (!(shuffleteams_players[z])) continue; // not a player, move on to next random slot - if(VerifyClientNumber(shuffleteams_players[z])) - setself(edict_num(shuffleteams_players[z])); + if (VerifyClientNumber(shuffleteams_players[z])) setself(edict_num(shuffleteams_players[z])); - if(self.team != team_color) - MoveToTeam(self, team_color, 6); + if (self.team != team_color) MoveToTeam(self, team_color, 6); shuffleteams_players[z] = 0; shuffleteams_teams[i] = shuffleteams_teams[i] + 1; } else { - break; // move on to next team + break; // move on to next team } } } @@ -1421,10 +1441,10 @@ void GameCommand_shuffleteams(float request) bprint("Successfully shuffled the players around randomly.\n"); // clear the buffers now - for (i=0; i 0) + if (argv(2)) { - stuffcmd(client, strcat("\n", argv(next_token), "\n")); - LOG_INFO(strcat("Command: \"", argv(next_token), "\" sent to ", GetCallerName(client), " (", argv(1) ,").\n")); + entity client = GetIndexedEntity(argc, 1); + float accepted = VerifyClientEntity(client, true, false); + + if (accepted > 0) + { + stuffcmd(client, strcat("\n", argv(next_token), "\n")); + LOG_INFO(strcat("Command: \"", argv(next_token), "\" sent to ", GetCallerName(client), " (", argv(1), ").\n")); + } + else + { + LOG_INFO("stuffto: ", GetClientErrorString(accepted, argv(1)), ".\n"); + } + + return; } - else - LOG_INFO("stuffto: ", GetClientErrorString(accepted, argv(1)), ".\n"); + } + default: + LOG_INFO("Incorrect parameters for ^2stuffto^7\n"); + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 sv_cmd stuffto client \"command\"\n"); + LOG_INFO(" 'client' is the entity number or name of the player,\n"); + LOG_INFO(" and 'command' is the command to be sent to that player.\n"); return; } } - - default: - LOG_INFO("Incorrect parameters for ^2stuffto^7\n"); - case CMD_REQUEST_USAGE: +#else + if (request) { - LOG_INFO("\nUsage:^3 sv_cmd stuffto client \"command\"\n"); - LOG_INFO(" 'client' is the entity number or name of the player,\n"); - LOG_INFO(" and 'command' is the command to be sent to that player.\n"); + LOG_INFO("stuffto command is not enabled on this server.\n"); return; } - } - #else - if(request) - { - LOG_INFO("stuffto command is not enabled on this server.\n"); - return; - } - #endif +#endif } void GameCommand_trace(float request, float argc) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { @@ -1504,14 +1526,14 @@ void GameCommand_trace(float request, float argc) vector org, delta, start, end, p, q, q0, pos, vv, dv; float i, f, safe, unsafe, dq, dqf; - switch(argv(1)) + switch (argv(1)) { case "debug": { float hitcount = 0; LOG_INFO("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.\n"); float worst_endpos_bug = 0; - for (;;) + for ( ; ; ) { org = world.mins; delta = world.maxs - world.mins; @@ -1528,32 +1550,30 @@ void GameCommand_trace(float request, float argc) end = stov(vtos(end)); tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world); - if(!trace_startsolid && trace_fraction < 1) + if (!trace_startsolid && trace_fraction < 1) { p = trace_endpos; tracebox(p, PL_MIN, PL_MAX, p, MOVE_NOMONSTERS, world); - if(trace_startsolid) + if (trace_startsolid) { - rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid + rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world); // how much do we need to back off? safe = 1; unsafe = 0; - for (;;) + for ( ; ; ) { pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5); tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world); - if(trace_startsolid) + if (trace_startsolid) { - if((safe + unsafe) * 0.5 == unsafe) - break; + if ((safe + unsafe) * 0.5 == unsafe) break; unsafe = (safe + unsafe) * 0.5; } else { - if((safe + unsafe) * 0.5 == safe) - break; + if ((safe + unsafe) * 0.5 == safe) break; safe = (safe + unsafe) * 0.5; } } @@ -1562,38 +1582,31 @@ void GameCommand_trace(float request, float argc) LOG_INFO("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n"); tracebox(p, PL_MIN + '0.1 0.1 0.1', PL_MAX - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world); - if(trace_startsolid) - LOG_INFO("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n"); - else - LOG_INFO("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n"); - if (++hitcount >= 10) - break; + if (trace_startsolid) LOG_INFO("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n"); + else LOG_INFO("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n"); + if (++hitcount >= 10) break; } else { q0 = p; dq = 0; dqf = 1; - for (;;) + for ( ; ; ) { q = p + normalize(end - p) * (dq + dqf); - if(q == q0) - break; + if (q == q0) break; tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world); - if(trace_startsolid) - error("THIS ONE cannot happen"); - if(trace_fraction > 0) - dq += dqf * trace_fraction; + if (trace_startsolid) error("THIS ONE cannot happen"); + if (trace_fraction > 0) dq += dqf * trace_fraction; dqf *= 0.5; q0 = q; } - if(dq > worst_endpos_bug) + if (dq > worst_endpos_bug) { worst_endpos_bug = dq; LOG_INFO("trace_endpos still before solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n"); LOG_INFO("could go ", ftos(dq), " units further to ", vtos(q), "\n"); - if (++hitcount >= 10) - break; + if (++hitcount >= 10) break; } } } @@ -1606,26 +1619,26 @@ void GameCommand_trace(float request, float argc) e = nextent(world); tracebox(e.origin + '0 0 32', e.mins, e.maxs, e.origin + '0 0 -1024', MOVE_NORMAL, e); vv = trace_endpos; - if(trace_fraction == 1) + if (trace_fraction == 1) { LOG_INFO("not above ground, aborting\n"); return; } f = 0; - for(i = 0; i < 100000; ++i) + for (i = 0; i < 100000; ++i) { dv = randomvec(); - if(dv.z > 0) - dv = -1 * dv; + if (dv.z > 0) dv = -1 * dv; tracebox(vv, e.mins, e.maxs, vv + dv, MOVE_NORMAL, e); - if(trace_startsolid) - LOG_INFO("bug 1\n"); - if(trace_fraction == 1) - if(dv.z < f) + if (trace_startsolid) LOG_INFO("bug 1\n"); + if (trace_fraction == 1) { - LOG_INFO("bug 2: ", ftos(dv.x), " ", ftos(dv.y), " ", ftos(dv.z)); - LOG_INFO(" (", ftos(asin(dv.z / vlen(dv)) * 180 / M_PI), " degrees)\n"); - f = dv.z; + if (dv.z < f) + { + LOG_INFO("bug 2: ", ftos(dv.x), " ", ftos(dv.y), " ", ftos(dv.z)); + LOG_INFO(" (", ftos(asin(dv.z / vlen(dv)) * 180 / M_PI), " degrees)\n"); + f = dv.z; + } } } LOG_INFO("highest possible dist: ", ftos(f), "\n"); @@ -1634,20 +1647,18 @@ void GameCommand_trace(float request, float argc) case "walk": { - if(argc == 4) + if (argc == 4) { e = nextent(world); - if(tracewalk(e, stov(argv(2)), e.mins, e.maxs, stov(argv(3)), MOVE_NORMAL)) - LOG_INFO("can walk\n"); - else - LOG_INFO("cannot walk\n"); + if (tracewalk(e, stov(argv(2)), e.mins, e.maxs, stov(argv(3)), MOVE_NORMAL)) LOG_INFO("can walk\n"); + else LOG_INFO("cannot walk\n"); return; } } case "showline": { - if(argc == 4) + if (argc == 4) { vv = stov(argv(2)); dv = stov(argv(3)); @@ -1658,7 +1669,7 @@ void GameCommand_trace(float request, float argc) } } - // no default case, just go straight to invalid + // no default case, just go straight to invalid } } @@ -1676,11 +1687,11 @@ void GameCommand_trace(float request, float argc) void GameCommand_unlockteams(float request) { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(teamplay) + if (teamplay) { lockteams = 0; bprint("^1The teams are now unlocked.\n"); @@ -1709,9 +1720,9 @@ void GameCommand_warp(float request, float argc) { case CMD_REQUEST_COMMAND: { - if(autocvar_g_campaign) + if (autocvar_g_campaign) { - if(argc >= 2) + if (argc >= 2) { CampaignLevelWarp(stof(argv(1))); LOG_INFO("Successfully warped to campaign level ", stof(argv(1)), ".\n"); @@ -1723,7 +1734,9 @@ void GameCommand_warp(float request, float argc) } } else + { LOG_INFO("Not in campaign, can't level warp\n"); + } return; } @@ -1742,22 +1755,22 @@ void GameCommand_warp(float request, float argc) ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION! void GameCommand_(float request) { - switch(request) - { - case CMD_REQUEST_COMMAND: - { - - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 sv_cmd \n"); - print(" No arguments required.\n"); - return; - } - } + switch(request) + { + case CMD_REQUEST_COMMAND: + { + + return; + } + + default: + case CMD_REQUEST_USAGE: + { + print("\nUsage:^3 sv_cmd \n"); + print(" No arguments required.\n"); + return; + } + } } */ @@ -1767,7 +1780,7 @@ void GameCommand_(float request) // ================================== // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;) -#define SERVER_COMMANDS(request,arguments,command) \ +#define SERVER_COMMANDS(request, arguments, command) \ SERVER_COMMAND("adminmsg", GameCommand_adminmsg(request, arguments), "Send an admin message to a client directly") \ SERVER_COMMAND("allready", GameCommand_allready(request), "Restart the server and reset the players") \ SERVER_COMMAND("allspec", GameCommand_allspec(request, arguments), "Force all players to spectate") \ @@ -1804,46 +1817,42 @@ void GameCommand_(float request) void GameCommand_macro_help() { - #define SERVER_COMMAND(name,function,description) \ + #define SERVER_COMMAND(name, function, description) \ { LOG_INFO(" ^2", name, "^7: ", description, "\n"); } SERVER_COMMANDS(0, 0, ""); - #undef SERVER_COMMAND - - return; +#undef SERVER_COMMAND } float GameCommand_macro_command(float argc, string command) { - #define SERVER_COMMAND(name,function,description) \ - { if(name == strtolower(argv(0))) { function; return true; } } + #define SERVER_COMMAND(name, function, description) \ + { if (name == strtolower(argv(0))) { function; return true; } } SERVER_COMMANDS(CMD_REQUEST_COMMAND, argc, command); - #undef SERVER_COMMAND +#undef SERVER_COMMAND return false; } float GameCommand_macro_usage(float argc) { - #define SERVER_COMMAND(name,function,description) \ - { if(name == strtolower(argv(1))) { function; return true; } } + #define SERVER_COMMAND(name, function, description) \ + { if (name == strtolower(argv(1))) { function; return true; } } SERVER_COMMANDS(CMD_REQUEST_USAGE, argc, ""); - #undef SERVER_COMMAND +#undef SERVER_COMMAND return false; } void GameCommand_macro_write_aliases(float fh) { - #define SERVER_COMMAND(name,function,description) \ + #define SERVER_COMMAND(name, function, description) \ { CMD_Write_Alias("qc_cmd_sv", name, description); } SERVER_COMMANDS(0, 0, ""); - #undef SERVER_COMMAND - - return; +#undef SERVER_COMMAND } @@ -1861,9 +1870,9 @@ void GameCommand(string command) // argv: 0 - 1 - 2 - 3 // cmd vote - master - login - password - if(strtolower(argv(0)) == "help") + if (strtolower(argv(0)) == "help") { - if(argc == 1) + if (argc == 1) { LOG_INFO("\nServer console commands:\n"); GameCommand_macro_help(); @@ -1882,46 +1891,44 @@ void GameCommand(string command) return; } - else if(BanCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it + else if (BanCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it { return; } - else if(CommonCommand_macro_usage(argc, world)) // same here, but for common commands instead + else if (CommonCommand_macro_usage(argc, world)) // same here, but for common commands instead { return; } - else if(GenericCommand_macro_usage(argc)) // same here, but for generic commands instead + else if (GenericCommand_macro_usage(argc)) // same here, but for generic commands instead { return; } - else if(GameCommand_macro_usage(argc)) // finally try for normal commands too + else if (GameCommand_macro_usage(argc)) // finally try for normal commands too { return; } } - else if(MUTATOR_CALLHOOK(SV_ParseServerCommand, strtolower(argv(0)), argc, command)) + else if (MUTATOR_CALLHOOK(SV_ParseServerCommand, strtolower(argv(0)), argc, command)) { - return; // handled by a mutator + return; // handled by a mutator } - else if(BanCommand(command)) + else if (BanCommand(command)) { - return; // handled by server/command/ipban.qc + return; // handled by server/command/ipban.qc } - else if(CommonCommand_macro_command(argc, world, command)) + else if (CommonCommand_macro_command(argc, world, command)) { - return; // handled by server/command/common.qc + return; // handled by server/command/common.qc } - else if(GenericCommand(command)) + else if (GenericCommand(command)) { - return; // handled by common/command/generic.qc + return; // handled by common/command/generic.qc } - else if(GameCommand_macro_command(argc, command)) // continue as usual and scan for normal commands + else if (GameCommand_macro_command(argc, command)) // continue as usual and scan for normal commands { - return; // handled by one of the above GameCommand_* functions + return; // handled by one of the above GameCommand_* functions } // nothing above caught the command, must be invalid LOG_INFO(((command != "") ? strcat("Unknown server command \"", command, "\"") : "No command provided"), ". For a list of supported commands, try sv_cmd help.\n"); - - return; } diff --git a/qcsrc/server/command/sv_cmd.qh b/qcsrc/server/command/sv_cmd.qh index 0cc520c2e..8fa66dac4 100644 --- a/qcsrc/server/command/sv_cmd.qh +++ b/qcsrc/server/command/sv_cmd.qh @@ -13,7 +13,7 @@ void race_deleteTime(string map, float pos); const float SHUFFLETEAMS_MAX_PLAYERS = 255; const float SHUFFLETEAMS_MAX_TEAMS = 4; float shuffleteams_players[SHUFFLETEAMS_MAX_PLAYERS]; // maximum of 255 player slots -float shuffleteams_teams[SHUFFLETEAMS_MAX_TEAMS]; // maximum of 4 teams +float shuffleteams_teams[SHUFFLETEAMS_MAX_TEAMS]; // maximum of 4 teams // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file void GameCommand_macro_write_aliases(float fh); diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index da9be11ff..1e60cd0a8 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -40,33 +40,28 @@ bool Nagger_SendEntity(entity this, entity to, float sendflags) // 128 = vote string nags = 0; - if(readycount) + if (readycount) { nags |= BIT(0); - if(to.ready == 0) - nags |= BIT(1); + if (to.ready == 0) nags |= BIT(1); } - if(vote_called) + if (vote_called) { nags |= BIT(2); - if(to.vote_selection == 0) - nags |= BIT(3); + if (to.vote_selection == 0) nags |= BIT(3); } - if(warmup_stage) - nags |= BIT(4); + if (warmup_stage) nags |= BIT(4); - if(sendflags & BIT(6)) - nags |= BIT(6); + if (sendflags & BIT(6)) nags |= BIT(6); - if(sendflags & BIT(7)) - nags |= BIT(7); + if (sendflags & BIT(7)) nags |= BIT(7); - if(!(nags & 4)) // no vote called? send no string + if (!(nags & 4)) // no vote called? send no string nags &= ~(BIT(6) | BIT(7)); WriteByte(MSG_ENTITY, nags); - if(nags & BIT(6)) + if (nags & BIT(6)) { WriteByte(MSG_ENTITY, vote_accept_count); WriteByte(MSG_ENTITY, vote_reject_count); @@ -74,16 +69,14 @@ bool Nagger_SendEntity(entity this, entity to, float sendflags) WriteChar(MSG_ENTITY, to.vote_selection); } - if(nags & BIT(7)) - WriteString(MSG_ENTITY, vote_called_display); + if (nags & BIT(7)) WriteString(MSG_ENTITY, vote_called_display); - if(nags & 1) + if (nags & 1) { - for(i = 1; i <= maxclients; i += 8) + for (i = 1; i <= maxclients; i += 8) { - for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e)) - if(!IS_REAL_CLIENT(e) || e.ready) - f |= b; + for (f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e)) + if (!IS_REAL_CLIENT(e) || e.ready) f |= b; WriteByte(MSG_ENTITY, f); } } @@ -98,27 +91,23 @@ void Nagger_Init() void Nagger_VoteChanged() { - if(nagger) - nagger.SendFlags |= BIT(7); + if (nagger) nagger.SendFlags |= BIT(7); } void Nagger_VoteCountChanged() { - if(nagger) - nagger.SendFlags |= BIT(6); + if (nagger) nagger.SendFlags |= BIT(6); } void Nagger_ReadyCounted() { - if(nagger) - nagger.SendFlags |= BIT(0); + if (nagger) nagger.SendFlags |= BIT(0); } // If the vote_caller is still here, return their name, otherwise vote_caller_name string OriginalCallerName() { - if (IS_REAL_CLIENT(vote_caller)) - return vote_caller.netname; + if (IS_REAL_CLIENT(vote_caller)) return vote_caller.netname; return vote_caller_name; } @@ -130,9 +119,12 @@ void VoteReset() { entity tmp_player; - FOR_EACH_CLIENT(tmp_player) { tmp_player.vote_selection = 0; } + FOR_EACH_CLIENT(tmp_player) + { + tmp_player.vote_selection = 0; + } - if(vote_called) + if (vote_called) { strunzone(vote_called_command); strunzone(vote_called_display); @@ -156,11 +148,9 @@ void VoteReset() void VoteStop(entity stopper) { bprint("\{1}^2* ^3", GetCallerName(stopper), "^2 stopped ^3", OriginalCallerName(), "^2's vote\n"); - if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vstop:", ftos(stopper.playerid))); } - + if (autocvar_sv_eventlog) GameLogEcho(strcat(":vote:vstop:", ftos(stopper.playerid))); // Don't force them to wait for next vote, this way they can e.g. correct their vote. - if((vote_caller) && (stopper == vote_caller)) { vote_caller.vote_waittime = time + autocvar_sv_vote_stop; } - + if ((vote_caller) && (stopper == vote_caller)) vote_caller.vote_waittime = time + autocvar_sv_vote_stop; VoteReset(); } @@ -168,12 +158,10 @@ void VoteAccept() { bprint("\{1}^2* ^3", OriginalCallerName(), "^2's vote for ^1", vote_called_display, "^2 was accepted\n"); - if((vote_called == VOTE_MASTER) && vote_caller) - vote_caller.vote_master = 1; - else - localcmd(strcat(vote_called_command, "\n")); + if ((vote_called == VOTE_MASTER) && vote_caller) vote_caller.vote_master = 1; + else localcmd(strcat(vote_called_command, "\n")); - if(vote_caller) { vote_caller.vote_waittime = 0; } // people like your votes, you don't need to wait to vote again + if (vote_caller) vote_caller.vote_waittime = 0; // people like your votes, you don't need to wait to vote again VoteReset(); Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_VOTE_ACCEPT); @@ -202,7 +190,7 @@ void VoteSpam(float notvoters, float mincount, string result) strcat(", ^1", ftos(vote_abstain_count), "^2 didn't care"), strcat(", ^1", ftos(notvoters), strcat("^2 didn't ", ((mincount >= 0) ? "" : "have to "), "vote\n")))); - if(autocvar_sv_eventlog) + if (autocvar_sv_eventlog) { GameLogEcho(strcat( strcat(":vote:v", result, ":", ftos(vote_accept_count)), @@ -219,8 +207,8 @@ void VoteCount(float first_count) vote_accept_count = vote_reject_count = vote_abstain_count = 0; float spectators_allowed = ((autocvar_sv_vote_nospectators != 2) - || ((autocvar_sv_vote_nospectators == 1) && (warmup_stage || gameover)) - || (autocvar_sv_vote_nospectators == 0)); + || ((autocvar_sv_vote_nospectators == 1) && (warmup_stage || gameover)) + || (autocvar_sv_vote_nospectators == 0)); float vote_player_count = 0, notvoters = 0; float vote_real_player_count = 0, vote_real_accept_count = 0; @@ -236,28 +224,36 @@ void VoteCount(float first_count) FOR_EACH_REALCLIENT(tmp_player) { ++vote_player_count; - if(IS_PLAYER(tmp_player)) { ++vote_real_player_count; } - - switch(tmp_player.vote_selection) + if (IS_PLAYER(tmp_player)) ++vote_real_player_count; + switch (tmp_player.vote_selection) { - case VOTE_SELECT_REJECT: { ++vote_reject_count; { if(IS_PLAYER(tmp_player)) ++vote_real_reject_count; } break; } - case VOTE_SELECT_ACCEPT: { ++vote_accept_count; { if(IS_PLAYER(tmp_player)) ++vote_real_accept_count; } break; } - case VOTE_SELECT_ABSTAIN: { ++vote_abstain_count; { if(IS_PLAYER(tmp_player)) ++vote_real_abstain_count; } break; } + case VOTE_SELECT_REJECT: + { ++vote_reject_count; + { if (IS_PLAYER(tmp_player)) ++vote_real_reject_count; } break; + } + case VOTE_SELECT_ACCEPT: + { ++vote_accept_count; + { if (IS_PLAYER(tmp_player)) ++vote_real_accept_count; } break; + } + case VOTE_SELECT_ABSTAIN: + { ++vote_abstain_count; + { if (IS_PLAYER(tmp_player)) ++vote_real_abstain_count; } break; + } default: break; } } // Check to see if there are enough players on the server to allow master voting... otherwise, vote master could be used for evil. - if((vote_called == VOTE_MASTER) && autocvar_sv_vote_master_playerlimit > vote_player_count) + if ((vote_called == VOTE_MASTER) && autocvar_sv_vote_master_playerlimit > vote_player_count) { - if(vote_caller) { vote_caller.vote_waittime = 0; } + if (vote_caller) vote_caller.vote_waittime = 0; print_to(vote_caller, "^1There are not enough players on this server to allow you to become vote master."); VoteReset(); return; } // if spectators aren't allowed to vote and there are players in a match, then only count the players in the vote and ignore spectators. - if(!spectators_allowed && (vote_real_player_count > 0)) + if (!spectators_allowed && (vote_real_player_count > 0)) { vote_accept_count = vote_real_accept_count; vote_reject_count = vote_real_reject_count; @@ -277,43 +273,43 @@ void VoteCount(float first_count) vote_needed_of_voted = floor((vote_accept_count + vote_reject_count) * vote_factor_of_voted) + 1; // are there any players at all on the server? it could be an admin vote - if(vote_player_count == 0 && first_count) + if (vote_player_count == 0 && first_count) { - VoteSpam(0, -1, "yes"); // no players at all, just accept it + VoteSpam(0, -1, "yes"); // no players at all, just accept it VoteAccept(); return; } // since there ARE players, finally calculate the result of the vote - if(vote_accept_count >= vote_needed_overall) + if (vote_accept_count >= vote_needed_overall) { - VoteSpam(notvoters, -1, "yes"); // there is enough acceptions to pass the vote + VoteSpam(notvoters, -1, "yes"); // there is enough acceptions to pass the vote VoteAccept(); return; } - if(vote_reject_count > vote_player_count - vote_abstain_count - vote_needed_overall) + if (vote_reject_count > vote_player_count - vote_abstain_count - vote_needed_overall) { - VoteSpam(notvoters, -1, "no"); // there is enough rejections to deny the vote + VoteSpam(notvoters, -1, "no"); // there is enough rejections to deny the vote VoteReject(); return; } // there is not enough votes in either direction, now lets just calculate what the voters have said - if(time > vote_endtime) + if (time > vote_endtime) { final_needed_votes = vote_needed_overall; - if(autocvar_sv_vote_majority_factor_of_voted) + if (autocvar_sv_vote_majority_factor_of_voted) { - if(vote_accept_count >= vote_needed_of_voted) + if (vote_accept_count >= vote_needed_of_voted) { VoteSpam(notvoters, min(vote_needed_overall, vote_needed_of_voted), "yes"); VoteAccept(); return; } - if(vote_accept_count + vote_reject_count > 0) + if (vote_accept_count + vote_reject_count > 0) { VoteSpam(notvoters, min(vote_needed_overall, vote_needed_of_voted), "no"); VoteReject(); @@ -331,13 +327,11 @@ void VoteCount(float first_count) void VoteThink() { - if(vote_endtime > 0) // a vote was called - if(time > vote_endtime) // time is up + if (vote_endtime > 0) // a vote was called { - VoteCount(false); + if (time > vote_endtime) // time is up + VoteCount(false); } - - return; } @@ -347,39 +341,38 @@ void VoteThink() // Resets the state of all clients, items, weapons, waypoints, ... of the map. void reset_map(float dorespawn) -{SELFPARAM(); +{ + SELFPARAM(); - if(time <= game_starttime && round_handler_IsActive()) - round_handler_Reset(game_starttime); + if (time <= game_starttime && round_handler_IsActive()) round_handler_Reset(game_starttime); MUTATOR_CALLHOOK(reset_map_global); - for(entity e = world; (e = nextent(e)); ) + for (entity e = world; (e = nextent(e)); ) { setself(e); - if(IS_NOT_A_CLIENT(self)) + if (IS_NOT_A_CLIENT(self)) { - if(self.reset) + if (self.reset) { self.reset(); continue; } - if(self.team_saved) - self.team = self.team_saved; + if (self.team_saved) self.team = self.team_saved; - if(self.flags & FL_PROJECTILE) // remove any projectiles left + if (self.flags & FL_PROJECTILE) // remove any projectiles left remove(self); } } // Waypoints and assault start come LAST - for(entity e = world; (e = nextent(e)); ) + for (entity e = world; (e = nextent(e)); ) { setself(e); - if(IS_NOT_A_CLIENT(self)) + if (IS_NOT_A_CLIENT(self)) { - if(self.reset2) + if (self.reset2) { self.reset2(); continue; @@ -389,51 +382,52 @@ void reset_map(float dorespawn) entity e; FOR_EACH_PLAYER(e) - if(e.frozen) - { - WITH(entity, self, e, Unfreeze(self)); - } + if (e.frozen) WITH(entity, self, e, Unfreeze(self)); // Moving the player reset code here since the player-reset depends // on spawnpoint entities which have to be reset first --blub - if(dorespawn) - if(!MUTATOR_CALLHOOK(reset_map_players)) - FOR_EACH_CLIENT(e) // reset all players + if (dorespawn) { - setself(e); - /* - only reset players if a restart countdown is active - this can either be due to cvar sv_ready_restart_after_countdown having set - restart_mapalreadyrestarted to 1 after the countdown ended or when - sv_ready_restart_after_countdown is not used and countdown is still running - */ - if (restart_mapalreadyrestarted || (time < game_starttime)) + if (!MUTATOR_CALLHOOK(reset_map_players)) { - //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players - if (IS_PLAYER(self)) { - //PlayerScore_Clear(self); - self.killcount = 0; - //stop the player from moving so that he stands still once he gets respawned - self.velocity = '0 0 0'; - self.avelocity = '0 0 0'; - self.movement = '0 0 0'; - PutClientInServer(); + FOR_EACH_CLIENT(e) // reset all players + { + setself(e); + /* + only reset players if a restart countdown is active + this can either be due to cvar sv_ready_restart_after_countdown having set + restart_mapalreadyrestarted to 1 after the countdown ended or when + sv_ready_restart_after_countdown is not used and countdown is still running + */ + if (restart_mapalreadyrestarted || (time < game_starttime)) + { + // NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players + if (IS_PLAYER(self)) + { + // PlayerScore_Clear(self); + self.killcount = 0; + // stop the player from moving so that he stands still once he gets respawned + self.velocity = '0 0 0'; + self.avelocity = '0 0 0'; + self.movement = '0 0 0'; + PutClientInServer(); + } + } } + + setself(this); } } - - setself(this); } // Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown is set) void ReadyRestart_think() -{SELFPARAM(); +{ + SELFPARAM(); restart_mapalreadyrestarted = 1; reset_map(true); Score_ClearAll(); remove(self); - - return; } // Forces a restart of the game without actually reloading the map // this is a mess... @@ -446,8 +440,7 @@ void ReadyRestart_force() VoteReset(); // clear overtime, we have to decrease timelimit to its original value again. - if (checkrules_overtimesadded > 0 && g_race_qualifying != 2) { cvar_set("timelimit", ftos(autocvar_timelimit - (checkrules_overtimesadded * autocvar_timelimit_overtime))); } - + if (checkrules_overtimesadded > 0 && g_race_qualifying != 2) cvar_set("timelimit", ftos(autocvar_timelimit - (checkrules_overtimesadded * autocvar_timelimit_overtime))); checkrules_suddendeathend = checkrules_overtimesadded = checkrules_suddendeathwarning = 0; readyrestart_happened = 1; @@ -464,22 +457,25 @@ void ReadyRestart_force() restart_mapalreadyrestarted = 0; // reset this var, needed when cvar sv_ready_restart_repeatable is in use // disable the warmup global for the server - warmup_stage = 0; // once the game is restarted the game is in match stage + warmup_stage = 0; // once the game is restarted the game is in match stage // reset the .ready status of all players (also spectators) - FOR_EACH_REALCLIENT(tmp_player) { tmp_player.ready = 0; } + FOR_EACH_REALCLIENT(tmp_player) + { + tmp_player.ready = 0; + } readycount = 0; - Nagger_ReadyCounted(); // NOTE: this causes a resend of that entity, and will also turn off warmup state on the client + Nagger_ReadyCounted(); // NOTE: this causes a resend of that entity, and will also turn off warmup state on the client // lock teams with lockonrestart - if(autocvar_teamplay_lockonrestart && teamplay) + if (autocvar_teamplay_lockonrestart && teamplay) { lockteams = 1; bprint("^1The teams are now locked.\n"); } - //initiate the restart-countdown-announcer entity - if(autocvar_sv_ready_restart_after_countdown) + // initiate the restart-countdown-announcer entity + if (autocvar_sv_ready_restart_after_countdown) { restart_timer = spawn(); restart_timer.think = ReadyRestart_think; @@ -487,29 +483,26 @@ void ReadyRestart_force() } // after a restart every players number of allowed timeouts gets reset, too - 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_eventlog) { GameLogEcho(":restart"); } -} + 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_eventlog) GameLogEcho(":restart"); } void ReadyRestart() { // no assault support yet... - if(g_assault | gameover | intermission_running | race_completing) - localcmd("restart\n"); - else - localcmd("\nsv_hook_gamerestart\n"); + if (g_assault | gameover | intermission_running | race_completing) localcmd("restart\n"); + else localcmd("\nsv_hook_gamerestart\n"); // Reset ALL scores, but only do that at the beginning of the countdown if sv_ready_restart_after_countdown is off! // Otherwise scores could be manipulated during the countdown. - if (!autocvar_sv_ready_restart_after_countdown) { Score_ClearAll(); } - + if (!autocvar_sv_ready_restart_after_countdown) Score_ClearAll(); ReadyRestart_force(); - - return; } // Count the players who are ready and determine whether or not to restart the match @@ -521,11 +514,10 @@ void ReadyCount() FOR_EACH_REALCLIENT(tmp_player) { - if(IS_PLAYER(tmp_player) || tmp_player.caplayer == 1) + if (IS_PLAYER(tmp_player) || tmp_player.caplayer == 1) { ++t_players; - if(tmp_player.ready) { ++t_ready; } - } + if (tmp_player.ready) ++t_ready; } } readycount = t_ready; @@ -535,12 +527,7 @@ void ReadyCount() ready_needed_factor = bound(0.5, cvar("g_warmup_majority_factor"), 0.999); ready_needed_count = floor(t_players * ready_needed_factor) + 1; - if(readycount >= ready_needed_count) - { - ReadyRestart(); - } - - return; + if (readycount >= ready_needed_count) ReadyRestart(); } @@ -552,12 +539,9 @@ float Votecommand_check_assignment(entity caller, float assignment) { float from_server = (!caller); - if((assignment == VC_ASGNMNT_BOTH) - || ((!from_server && assignment == VC_ASGNMNT_CLIENTONLY) - || (from_server && assignment == VC_ASGNMNT_SERVERONLY))) - { - return true; - } + if ((assignment == VC_ASGNMNT_BOTH) + || ((!from_server && assignment == VC_ASGNMNT_CLIENTONLY) + || (from_server && assignment == VC_ASGNMNT_SERVERONLY))) return true; return false; } @@ -566,21 +550,18 @@ string VoteCommand_extractcommand(string input, float startpos, float argc) { string output; - if((argc - 1) < startpos) - output = ""; - else - output = substring(input, argv_start_index(startpos), argv_end_index(-1) - argv_start_index(startpos)); + if ((argc - 1) < startpos) output = ""; + else output = substring(input, argv_start_index(startpos), argv_end_index(-1) - argv_start_index(startpos)); return output; } float VoteCommand_checknasty(string vote_command) { - if((strstrofs(vote_command, ";", 0) >= 0) - || (strstrofs(vote_command, "\n", 0) >= 0) - || (strstrofs(vote_command, "\r", 0) >= 0) - || (strstrofs(vote_command, "$", 0) >= 0)) - return false; + if ((strstrofs(vote_command, ";", 0) >= 0) + || (strstrofs(vote_command, "\n", 0) >= 0) + || (strstrofs(vote_command, "\r", 0) >= 0) + || (strstrofs(vote_command, "$", 0) >= 0)) return false; return true; } @@ -589,8 +570,7 @@ float VoteCommand_checkinlist(string vote_command, string list) { string l = strcat(" ", list, " "); - if(strstrofs(l, strcat(" ", vote_command, " "), 0) >= 0) - return true; + if (strstrofs(l, strcat(" ", vote_command, " "), 0) >= 0) return true; return false; } @@ -605,16 +585,16 @@ string ValidateMap(string validated_map, entity caller) return string_null; } - if(!autocvar_sv_vote_override_mostrecent && caller) + if (!autocvar_sv_vote_override_mostrecent && caller) { - if(Map_IsRecent(validated_map)) + if (Map_IsRecent(validated_map)) { print_to(caller, "This server does not allow for recent maps to be played again. Please be patient for some rounds."); return string_null; } } - if(!MapInfo_CheckMap(validated_map)) + if (!MapInfo_CheckMap(validated_map)) { print_to(caller, strcat("^1Invalid mapname, \"^3", validated_map, "^1\" does not support the current game mode.")); return string_null; @@ -627,14 +607,13 @@ float VoteCommand_checkargs(float startpos, float argc) { float p, q, check, minargs; string cvarname = strcat("sv_vote_command_restriction_", argv(startpos)); - string cmdrestriction = cvar_string(cvarname); // note: this warns on undefined cvar. We want that. + string cmdrestriction = cvar_string(cvarname); // note: this warns on undefined cvar. We want that. string charlist, arg; float checkmate; - if(cmdrestriction == "") - return true; + if (cmdrestriction == "") return true; - ++startpos; // skip command name + ++startpos; // skip command name // check minimum arg count @@ -643,49 +622,45 @@ float VoteCommand_checkargs(float startpos, float argc) // ... minargs = stof(cmdrestriction); - if(argc - startpos < minargs) - return false; + if (argc - startpos < minargs) return false; - p = strstrofs(cmdrestriction, ";", 0); // find first semicolon + 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 // argc-minargs >= argc, thus minargs <= 0, thus all minargs // have been seen already - if(startpos >= argc) // all args checked? GOOD + if (startpos >= argc) // all args checked? GOOD break; - if(p < 0) // no more args? FAIL + if (p < 0) // no more args? FAIL { // exception: exactly minargs left, this one included - if(argc - startpos == minargs) - break; + if (argc - startpos == minargs) break; // otherwise fail return false; } // cut to next semicolon - q = strstrofs(cmdrestriction, ";", p+1); // find next semicolon - if(q < 0) - charlist = substring(cmdrestriction, p+1, -1); - else - charlist = substring(cmdrestriction, p+1, q - (p+1)); + q = strstrofs(cmdrestriction, ";", p + 1); // find next semicolon + if (q < 0) charlist = substring(cmdrestriction, p + 1, -1); + else charlist = substring(cmdrestriction, p + 1, q - (p + 1)); // in case we ever want to allow semicolons in VoteCommand_checknasty // charlist = strreplace("^^", ";", charlist); - if(charlist != "") + if (charlist != "") { // verify the arg only contains allowed chars arg = argv(startpos); checkmate = strlen(arg); - for(check = 0; check < checkmate; ++check) - if(strstrofs(charlist, substring(arg, check, 1), 0) < 0) - return false; // not allowed character + for (check = 0; check < checkmate; ++check) + if (strstrofs(charlist, substring(arg, check, 1), 0) < 0) return false; + // not allowed character // all characters are allowed. FINE. } @@ -704,40 +679,35 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl first_command = argv(startpos); /*printf("VoteCommand_parse(): Command: '%s', Length: %f.\n", - substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos)), - strlen(substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos))) + substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos)), + strlen(substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos))) );*/ - if( - (autocvar_sv_vote_limit > 0) - && - (strlen(substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos))) > autocvar_sv_vote_limit) - ) - return false; + if ( + (autocvar_sv_vote_limit > 0) + && + (strlen(substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos))) > autocvar_sv_vote_limit) + ) return false; - if (!VoteCommand_checkinlist(first_command, vote_list)) - return false; + if (!VoteCommand_checkinlist(first_command, vote_list)) return false; - if (!VoteCommand_checkargs(startpos, argc)) - return false; + if (!VoteCommand_checkargs(startpos, argc)) return false; - switch(first_command) // now go through and parse the proper commands to adjust as needed. + switch (first_command) // now go through and parse the proper commands to adjust as needed. { case "kick": - case "kickban": // catch all kick/kickban commands + case "kickban": // catch all kick/kickban commands { entity victim = GetIndexedEntity(argc, (startpos + 1)); float accepted = VerifyClientEntity(victim, true, false); - if(accepted > 0) + if (accepted > 0) { string reason = ((argc > next_token) ? substring(vote_command, argv_start_index(next_token), strlen(vote_command) - argv_start_index(next_token)) : "No reason provided"); string command_arguments; - if(first_command == "kickban") - command_arguments = strcat(ftos(autocvar_g_ban_default_bantime), " ", ftos(autocvar_g_ban_default_masksize), " ~"); - else - command_arguments = reason; + if (first_command == "kickban") command_arguments = strcat(ftos(autocvar_g_ban_default_bantime), " ", ftos(autocvar_g_ban_default_masksize), " ~"); + else command_arguments = reason; 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); @@ -749,10 +719,10 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl case "map": case "chmap": - case "gotomap": // re-direct all map selection commands to gotomap + 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)); @@ -776,22 +746,24 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl // Command Sub-Functions // ======================= -void VoteCommand_abstain(float request, entity caller) // CLIENT ONLY +void VoteCommand_abstain(float request, entity caller) // CLIENT ONLY { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { if (!vote_called) { print_to(caller, "^1No vote called."); } - else if(caller.vote_selection != VOTE_SELECT_NULL && !autocvar_sv_vote_change) { print_to(caller, "^1You have already voted."); } + else if (caller.vote_selection != VOTE_SELECT_NULL && !autocvar_sv_vote_change) + { + print_to(caller, "^1You have already voted."); + } - else // everything went okay, continue changing vote + else // everything went okay, continue changing vote { 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; } @@ -806,54 +778,81 @@ void VoteCommand_abstain(float request, entity caller) // CLIENT ONLY } } -void VoteCommand_call(float request, entity caller, float argc, string vote_command) // BOTH +void VoteCommand_call(float request, entity caller, float argc, string vote_command) // BOTH { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { float spectators_allowed = ((autocvar_sv_vote_nospectators != 2) - || ((autocvar_sv_vote_nospectators == 1) && warmup_stage) - || (autocvar_sv_vote_nospectators == 0)); + || ((autocvar_sv_vote_nospectators == 1) && warmup_stage) + || (autocvar_sv_vote_nospectators == 0)); float tmp_playercount = 0; entity tmp_player; vote_command = VoteCommand_extractcommand(vote_command, 2, argc); - if(!autocvar_sv_vote_call && caller) { print_to(caller, "^1Vote calling is not allowed."); } - else if(!autocvar_sv_vote_gamestart && time < game_starttime) { print_to(caller, "^1Vote calling is not allowed before the match has started."); } - else if(vote_called) { print_to(caller, "^1There is already a vote called."); } - else if(!spectators_allowed && (caller && !IS_PLAYER(caller))) { print_to(caller, "^1Only players can call a vote."); } - else if(caller && !IS_CLIENT(caller)) { print_to(caller, "^1Only connected clients can vote."); } - else if(timeout_status) { print_to(caller, "^1You can not call a vote while a timeout is active."); } - else if(caller && (time < caller.vote_waittime)) { print_to(caller, strcat("^1You have to wait ^2", ftos(ceil(caller.vote_waittime - time)), "^1 seconds before you can again call a vote.")); } - else if (!VoteCommand_checknasty(vote_command)) { print_to(caller, "^1Syntax error in command, see 'vhelp' for more info."); } - else if (!VoteCommand_parse(caller, vote_command, autocvar_sv_vote_commands, 2, argc)) { print_to(caller, "^1This command is not acceptable, see 'vhelp' for more info."); } - - else // everything went okay, continue with calling the vote + if (!autocvar_sv_vote_call && caller) { print_to(caller, "^1Vote calling is not allowed."); } + else if (!autocvar_sv_vote_gamestart && time < game_starttime) { - vote_caller = caller; // remember who called the vote + print_to(caller, "^1Vote calling is not allowed before the match has started."); + } + else if (vote_called) + { + print_to(caller, "^1There is already a vote called."); + } + else if (!spectators_allowed && (caller && !IS_PLAYER(caller))) + { + print_to(caller, "^1Only players can call a vote."); + } + else if (caller && !IS_CLIENT(caller)) + { + print_to(caller, "^1Only connected clients can vote."); + } + else if (timeout_status) + { + print_to(caller, "^1You can not call a vote while a timeout is active."); + } + else if (caller && (time < caller.vote_waittime)) + { + print_to(caller, strcat("^1You have to wait ^2", ftos(ceil(caller.vote_waittime - time)), "^1 seconds before you can again call a vote.")); + } + else if (!VoteCommand_checknasty(vote_command)) + { + print_to(caller, "^1Syntax error in command, see 'vhelp' for more info."); + } + else if (!VoteCommand_parse(caller, vote_command, autocvar_sv_vote_commands, 2, argc)) + { + print_to(caller, "^1This command is not acceptable, see 'vhelp' for more info."); + } + + else // everything went okay, continue with calling the vote + { + vote_caller = caller; // remember who called the vote vote_caller_name = strzone(GetCallerName(vote_caller)); vote_called = VOTE_NORMAL; vote_called_command = strzone(vote_parsed_command); vote_called_display = strzone(vote_parsed_display); vote_endtime = time + autocvar_sv_vote_timeout; - if(caller) + if (caller) { caller.vote_selection = VOTE_SELECT_ACCEPT; caller.vote_waittime = time + autocvar_sv_vote_wait; msg_entity = caller; } - FOR_EACH_REALCLIENT(tmp_player) { ++tmp_playercount; } - if(tmp_playercount > 1) { Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_VOTE_CALL); } // don't announce a "vote now" sound if player is alone + FOR_EACH_REALCLIENT(tmp_player) + { + ++tmp_playercount; + } + if (tmp_playercount > 1) Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_VOTE_CALL); // don't announce a "vote now" sound if player is alone bprint("\{1}^2* ^3", OriginalCallerName(), "^2 calls a vote for ", vote_called_display, "\n"); - if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vcall:", ftos(vote_caller.playerid), ":", vote_called_display)); } + 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; @@ -871,64 +870,83 @@ void VoteCommand_call(float request, entity caller, float argc, string vote_comm } } -void VoteCommand_master(float request, entity caller, float argc, string vote_command) // CLIENT ONLY +void VoteCommand_master(float request, entity caller, float argc, string vote_command) // CLIENT ONLY { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(autocvar_sv_vote_master) + if (autocvar_sv_vote_master) { - switch(strtolower(argv(2))) + switch (strtolower(argv(2))) { case "do": { vote_command = VoteCommand_extractcommand(vote_command, 3, argc); if (!caller.vote_master) { print_to(caller, "^1You do not have vote master privelages."); } - else if (!VoteCommand_checknasty(vote_command)) { print_to(caller, "^1Syntax error in command, see 'vhelp' for more info."); } - else if (!VoteCommand_parse(caller, vote_command, strcat(autocvar_sv_vote_commands, " ", autocvar_sv_vote_master_commands), 3, argc)) { print_to(caller, "^1This command is not acceptable, see 'vhelp' for more info."); } + else if (!VoteCommand_checknasty(vote_command)) + { + print_to(caller, "^1Syntax error in command, see 'vhelp' for more info."); + } + else if (!VoteCommand_parse(caller, vote_command, strcat(autocvar_sv_vote_commands, " ", autocvar_sv_vote_master_commands), 3, argc)) + { + print_to(caller, "^1This command is not acceptable, see 'vhelp' for more info."); + } - else // everything went okay, proceed with command + else // everything went okay, proceed with command { localcmd(strcat(vote_parsed_command, "\n")); print_to(caller, strcat("Executing command '", vote_parsed_display, "' on server.")); bprint("\{1}^2* ^3", GetCallerName(caller), "^2 used their ^3master^2 status to do \"^2", vote_parsed_display, "^2\".\n"); - if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vdo:", ftos(caller.playerid), ":", vote_parsed_display)); } - } + if (autocvar_sv_eventlog) GameLogEcho(strcat(":vote:vdo:", ftos(caller.playerid), ":", vote_parsed_display)); } return; } case "login": { - if(autocvar_sv_vote_master_password == "") { print_to(caller, "^1Login to vote master is not allowed."); } - else if(caller.vote_master) { print_to(caller, "^1You are already logged in as vote master."); } - else if(autocvar_sv_vote_master_password != argv(3)) { print_to(caller, strcat("Rejected vote master login from ", GetCallerName(caller))); } + if (autocvar_sv_vote_master_password == "") { print_to(caller, "^1Login to vote master is not allowed."); } + else if (caller.vote_master) + { + print_to(caller, "^1You are already logged in as vote master."); + } + else if (autocvar_sv_vote_master_password != argv(3)) + { + print_to(caller, strcat("Rejected vote master login from ", GetCallerName(caller))); + } - else // everything went okay, proceed with giving this player master privilages + else // everything went okay, proceed with giving this player master privilages { 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))); } - } + if (autocvar_sv_eventlog) GameLogEcho(strcat(":vote:vlogin:", ftos(caller.playerid))); } return; } - default: // calling a vote for master + default: // calling a vote for master { float spectators_allowed = ((autocvar_sv_vote_nospectators != 2) - || ((autocvar_sv_vote_nospectators == 1) && warmup_stage) - || (autocvar_sv_vote_nospectators == 0)); + || ((autocvar_sv_vote_nospectators == 1) && warmup_stage) + || (autocvar_sv_vote_nospectators == 0)); if (!autocvar_sv_vote_master_callable) { print_to(caller, "^1Vote to become vote master is not allowed."); } - else if(vote_called) { print_to(caller, "^1There is already a vote called."); } - else if(!spectators_allowed && (caller && !IS_PLAYER(caller))) { print_to(caller, "^1Only players can call a vote."); } - else if(timeout_status) { print_to(caller, "^1You can not call a vote while a timeout is active."); } + else if (vote_called) + { + print_to(caller, "^1There is already a vote called."); + } + else if (!spectators_allowed && (caller && !IS_PLAYER(caller))) + { + print_to(caller, "^1Only players can call a vote."); + } + else if (timeout_status) + { + print_to(caller, "^1You can not call a vote while a timeout is active."); + } - else // everything went okay, continue with creating vote + else // everything went okay, continue with creating vote { vote_caller = caller; vote_caller_name = strzone(GetCallerName(vote_caller)); @@ -941,9 +959,9 @@ void VoteCommand_master(float request, entity caller, float argc, string vote_co caller.vote_waittime = time + autocvar_sv_vote_wait; bprint("\{1}^2* ^3", OriginalCallerName(), "^2 calls a vote to become ^3master^2.\n"); - if(autocvar_sv_eventlog) { GameLogEcho(strcat(":vote:vcall:", ftos(vote_caller.playerid), ":", vote_called_display)); } + 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; @@ -966,23 +984,28 @@ void VoteCommand_master(float request, entity caller, float argc, string vote_co } } -void VoteCommand_no(float request, entity caller) // CLIENT ONLY +void VoteCommand_no(float request, entity caller) // CLIENT ONLY { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { if (!vote_called) { print_to(caller, "^1No vote called."); } - else if(caller.vote_selection != VOTE_SELECT_NULL && !autocvar_sv_vote_change) { print_to(caller, "^1You have already voted."); } - else if(((caller == vote_caller) || caller.vote_master) && autocvar_sv_vote_no_stops_vote) { VoteStop(caller); } + else if (caller.vote_selection != VOTE_SELECT_NULL && !autocvar_sv_vote_change) + { + print_to(caller, "^1You have already voted."); + } + else if (((caller == vote_caller) || caller.vote_master) && autocvar_sv_vote_no_stops_vote) + { + VoteStop(caller); + } - else // everything went okay, continue changing vote + else // everything went okay, continue changing vote { 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; } @@ -997,16 +1020,14 @@ void VoteCommand_no(float request, entity caller) // CLIENT ONLY } } -void VoteCommand_status(float request, entity caller) // BOTH +void VoteCommand_status(float request, entity caller) // BOTH { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(vote_called) - print_to(caller, strcat("^7Vote for ", vote_called_display, "^7 called by ^7", OriginalCallerName(), "^7.")); - else - print_to(caller, "^1No vote called."); + if (vote_called) print_to(caller, strcat("^7Vote for ", vote_called_display, "^7 called by ^7", OriginalCallerName(), "^7.")); + else print_to(caller, "^1No vote called."); return; } @@ -1021,16 +1042,15 @@ void VoteCommand_status(float request, entity caller) // BOTH } } -void VoteCommand_stop(float request, entity caller) // BOTH +void VoteCommand_stop(float request, entity caller) // BOTH { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if (!vote_called) { print_to(caller, "^1No vote called."); } - else if((caller == vote_caller) || !caller || caller.vote_master) { VoteStop(caller); } - else { print_to(caller, "^1You are not allowed to stop that vote."); } - + if (!vote_called) print_to(caller, "^1No vote called."); + else if ((caller == vote_caller) || !caller || caller.vote_master) VoteStop(caller); + else print_to(caller, "^1You are not allowed to stop that vote."); return; } @@ -1044,22 +1064,24 @@ void VoteCommand_stop(float request, entity caller) // BOTH } } -void VoteCommand_yes(float request, entity caller) // CLIENT ONLY +void VoteCommand_yes(float request, entity caller) // CLIENT ONLY { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { if (!vote_called) { print_to(caller, "^1No vote called."); } - else if(caller.vote_selection != VOTE_SELECT_NULL && !autocvar_sv_vote_change) { print_to(caller, "^1You have already voted."); } + else if (caller.vote_selection != VOTE_SELECT_NULL && !autocvar_sv_vote_change) + { + print_to(caller, "^1You have already voted."); + } - else // everything went okay, continue changing vote + else // everything went okay, continue changing vote { 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; } @@ -1078,22 +1100,22 @@ void VoteCommand_yes(float request, entity caller) // CLIENT ONLY ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION! void VoteCommand_(float request) { - switch(request) - { - case CMD_REQUEST_COMMAND: - { - - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " vote "); - print_to(caller, " No arguments required."); - return; - } - } + switch(request) + { + case CMD_REQUEST_COMMAND: + { + + return; + } + + default: + case CMD_REQUEST_USAGE: + { + print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " vote "); + print_to(caller, " No arguments required."); + return; + } + } } */ @@ -1103,7 +1125,7 @@ void VoteCommand_(float request) // ================================ // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;) -#define VOTE_COMMANDS(request,caller,arguments,command) \ +#define VOTE_COMMANDS(request, caller, arguments, command) \ VOTE_COMMAND("abstain", VoteCommand_abstain(request, caller), "Abstain your vote in current vote", VC_ASGNMNT_CLIENTONLY) \ VOTE_COMMAND("call", VoteCommand_call(request, caller, arguments, command), "Create a new vote for players to decide on", VC_ASGNMNT_BOTH) \ VOTE_COMMAND("help", VoteCommand_macro_help(caller, arguments), "Shows this information", VC_ASGNMNT_BOTH) \ @@ -1118,38 +1140,36 @@ void VoteCommand_macro_help(entity caller, float argc) { string command_origin = GetCommandPrefix(caller); - if(argc == 2 || argv(2) == "help") // help display listing all commands + if (argc == 2 || argv(2) == "help") // help display listing all commands { print_to(caller, "\nVoting commands:\n"); - #define VOTE_COMMAND(name,function,description,assignment) \ - { if(Votecommand_check_assignment(caller, assignment)) { print_to(caller, strcat(" ^2", name, "^7: ", description)); } } + #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, ""); - #undef VOTE_COMMAND +#undef VOTE_COMMAND print_to(caller, strcat("\nUsage:^3 ", command_origin, " vote COMMAND...^7, where possible commands are listed above.\n")); print_to(caller, strcat("For help about a specific command, type ", command_origin, " vote help COMMAND")); print_to(caller, strcat("\n^7You can call a vote for or execute these commands: ^3", autocvar_sv_vote_commands, "^7 and maybe further ^3arguments^7")); } - else // usage for individual command + else // usage for individual command { - #define VOTE_COMMAND(name,function,description,assignment) \ - { if(Votecommand_check_assignment(caller, assignment)) { if(name == strtolower(argv(2))) { function; return; } } } + #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, ""); - #undef VOTE_COMMAND +#undef VOTE_COMMAND } - - return; } 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; } } } + #define VOTE_COMMAND(name, function, description, assignment) \ + { if (Votecommand_check_assignment(caller, assignment)) { if (name == strtolower(argv(1))) { function; return true; } } } VOTE_COMMANDS(CMD_REQUEST_COMMAND, caller, argc, vote_command); - #undef VOTE_COMMAND +#undef VOTE_COMMAND return false; } @@ -1166,12 +1186,11 @@ void VoteCommand(float request, entity caller, float argc, string vote_command) // argv: 0 - 1 - 2 - 3 // cmd vote - master - login - password - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { - if(VoteCommand_macro_command(caller, argc, vote_command)) - return; + if (VoteCommand_macro_command(caller, argc, vote_command)) return; } default: diff --git a/qcsrc/server/command/vote.qh b/qcsrc/server/command/vote.qh index f80785e2a..98b000e75 100644 --- a/qcsrc/server/command/vote.qh +++ b/qcsrc/server/command/vote.qh @@ -23,17 +23,17 @@ const float VOTE_NORMAL = 1; const float VOTE_MASTER = 2; // global vote information declarations -entity vote_caller; // original caller of the current vote -string vote_caller_name; // name of the vote caller -float vote_called; // stores status of current vote (See VOTE_*) -float vote_endtime; // time when the vote is finished -float vote_accept_count; // total amount of players who accept the vote (counted by VoteCount() function) -float vote_reject_count; // same as above, but rejected -float vote_abstain_count; // same as above, but abstained -float vote_needed_overall; // total amount of players NEEDED for a vote to pass (based on sv_vote_majority_factor) -.float vote_master; // flag for if the player has vote master privelages -.float vote_waittime; // flag for how long the player must wait before they can vote again -.float vote_selection; // flag for which vote selection the player has made (See VOTE_SELECT_*) +entity vote_caller; // original caller of the current vote +string vote_caller_name; // name of the vote caller +float vote_called; // stores status of current vote (See VOTE_*) +float vote_endtime; // time when the vote is finished +float vote_accept_count; // total amount of players who accept the vote (counted by VoteCount() function) +float vote_reject_count; // same as above, but rejected +float vote_abstain_count; // same as above, but abstained +float vote_needed_overall; // total amount of players NEEDED for a vote to pass (based on sv_vote_majority_factor) +.float vote_master; // flag for if the player has vote master privelages +.float vote_waittime; // flag for how long the player must wait before they can vote again +.float vote_selection; // flag for which vote selection the player has made (See VOTE_SELECT_*) string vote_called_command; // command sent by client string vote_called_display; // visual string of command sent by client string vote_parsed_command; // command which is fixed after being parsed @@ -47,10 +47,10 @@ void VoteCommand(float request, entity caller, float argc, string vote_command); // warmup and nagger stuff const float RESTART_COUNTDOWN = 10; entity nagger; -float readycount; // amount of players who are ready -float readyrestart_happened; // keeps track of whether a restart has already happened +float readycount; // amount of players who are ready +float readyrestart_happened; // keeps track of whether a restart has already happened float restart_mapalreadyrestarted; // bool, indicates whether reset_map() was already executed -.float ready; // flag for if a player is ready +.float ready; // flag for if a player is ready void reset_map(float dorespawn); void ReadyCount(); void ReadyRestart_force(); -- 2.39.2