X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fcmd.qc;h=cc8e19673a4760e257894d768ced8c11d8aad771;hb=c14f2b067c9ab0b4fb8a5b7805c8679be61f1fe0;hp=898e7db18faf59a78afe5988320a8a21baa02ccb;hpb=4a82dec0e0b84e3ab88f8dc64abbb0af55e86d75;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 898e7db18..cc8e19673 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -1,3 +1,39 @@ +#include "../../common/command/command.qh" +#include "cmd.qh" +#include "../_all.qh" + +#include "common.qh" +#include "vote.qh" + +#include "../campaign.qh" +#include "../cheats.qh" +#include "../cl_player.qh" +#include "../ipban.qh" +#include "../mapvoting.qh" +#include "../scores.qh" +#include "../teamplay.qh" + +#include "../mutators/mutators_include.qh" + +#ifdef SVQC + #include "../vehicles/vehicle.qh" +#endif + +#include "../../common/constants.qh" +#include "../../common/deathtypes.qh" +#include "../../common/mapinfo.qh" +#include "../../common/notifications.qh" +#include "../../common/teams.qh" +#include "../../common/util.qh" + +#include "../../common/monsters/all.qc" +#include "../../common/monsters/spawn.qh" +#include "../../common/monsters/sv_monsters.qh" + +#include "../../warpzonelib/common.qh" + +void ClientKill_TeamChange (float targetteam); // 0 = don't change, -1 = auto, -2 = spec + // ========================================================= // Server side networked commands code, reworked by Samual // Last updated: December 28th, 2011 @@ -10,7 +46,7 @@ float SV_ParseClientCommand_floodcheck() 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 { @@ -18,7 +54,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 } @@ -92,7 +128,7 @@ void ClientCommand_clientversion(float request, float argc) // internal command, } 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)) { @@ -194,7 +230,7 @@ void ClientCommand_mobedit(float request, float argc) { makevectors(self.v_angle); WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self); - + if(!autocvar_g_monsters_edit) { sprint(self, "Monster property editing is not enabled.\n"); return; } if(trace_ent.flags & FL_MONSTER) { @@ -203,7 +239,7 @@ void ClientCommand_mobedit(float request, float argc) { case "skin": { - if(trace_ent.monsterid != MON_MAGE) + if(trace_ent.monsterid != MON_MAGE.monsterid) trace_ent.skin = stof(argv(2)); return; } @@ -236,7 +272,7 @@ void ClientCommand_mobkill(float request) { makevectors(self.v_angle); WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self); - + if(trace_ent.flags & FL_MONSTER) { if(trace_ent.realowner != self) @@ -249,7 +285,7 @@ void ClientCommand_mobkill(float request) return; } } - + default: sprint(self, "Incorrect parameters for ^2mobkill^7\n"); case CMD_REQUEST_USAGE: @@ -270,22 +306,22 @@ void ClientCommand_mobspawn(float request, float argc) entity e; string tospawn; float moveflag, monstercount = 0; - + moveflag = (argv(2) ? stof(argv(2)) : 1); // follow owner if not defined tospawn = strtolower(argv(1)); - + if(tospawn == "list") { sprint(self, monsterlist_reply); return; } - + FOR_EACH_MONSTER(e) { if(e.realowner == self) ++monstercount; } - + if(autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { sprint(self, "Monster spawning is disabled.\n"); return; } else if(!IS_PLAYER(self)) { sprint(self, "You can't spawn monsters while spectating.\n"); return; } else if(MUTATOR_CALLHOOK(AllowMobSpawning)) { sprint(self, "Monster spawning is currently disabled by a mutator.\n"); return; } @@ -300,13 +336,13 @@ void ClientCommand_mobspawn(float request, float argc) { float found = 0, i; entity mon; - + for(i = MON_FIRST; i <= MON_LAST; ++i) { mon = get_monsterinfo(i); if(mon.netname == tospawn) { - found = TRUE; + found = true; break; } } @@ -314,20 +350,20 @@ void ClientCommand_mobspawn(float request, float argc) if(found || tospawn == "random") { totalspawned += 1; - + makevectors(self.v_angle); - WarpZone_TraceBox (CENTER_OR_VIEWOFS(self), PL_MIN, PL_MAX, CENTER_OR_VIEWOFS(self) + v_forward * 150, TRUE, self); + WarpZone_TraceBox (CENTER_OR_VIEWOFS(self), PL_MIN, PL_MAX, CENTER_OR_VIEWOFS(self) + v_forward * 150, true, self); //WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 150, MOVE_NORMAL, self); - - e = spawnmonster(tospawn, 0, self, self, trace_endpos, FALSE, FALSE, moveflag); - + + e = spawnmonster(tospawn, 0, self, self, trace_endpos, false, false, moveflag); + sprint(self, strcat("Spawned ", e.monster_name, "\n")); - + return; } } } - + default: sprint(self, "Incorrect parameters for ^2mobspawn^7\n"); case CMD_REQUEST_USAGE: @@ -341,6 +377,46 @@ void ClientCommand_mobspawn(float request, float argc) } } +void ClientCommand_physics(float request, float argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + string command = strtolower(argv(1)); + + if(!autocvar_g_physics_clientselect) + { + sprint(self, "Client physics selection is currently disabled.\n"); + return; + } + + 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") + { + stuffcmd(self, strcat("\nseta cl_physics ", command, "\nsendcvar cl_physics\n")); + sprint(self, strcat("^2Physics set successfully changed to ^3", command, "\n")); + return; + } + } + + default: + sprint(self, strcat("Current physics set: ^3", self.cvar_cl_physics, "\n")); + case CMD_REQUEST_USAGE: + { + sprint(self, "\nUsage:^3 cmd physics \n"); + sprint(self, " See 'cmd physics list' for available physics sets.\n"); + sprint(self, " Argument 'default' resets to standard physics.\n"); + return; + } + } +} + void ClientCommand_ready(float request) // todo: anti-spam for toggling readyness { switch(request) @@ -357,12 +433,12 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes return; if (self.ready) // toggle { - self.ready = FALSE; + self.ready = false; bprint(self.netname, "^2 is ^1NOT^2 ready\n"); } else { - self.ready = TRUE; + self.ready = true; bprint(self.netname, "^2 is ready\n"); } @@ -393,7 +469,7 @@ void ClientCommand_say(float request, float argc, string command) { 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); } + 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 } @@ -413,7 +489,7 @@ void ClientCommand_say_team(float request, float argc, string command) { 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); } + 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 } @@ -635,13 +711,13 @@ void ClientCommand_tell(float request, float argc, string command) if(argc >= 3) { entity tell_to = GetIndexedEntity(argc, 1); - float tell_accepted = VerifyClientEntity(tell_to, TRUE, FALSE); + float tell_accepted = VerifyClientEntity(tell_to, true, false); if(tell_accepted > 0) // the target is a real client { if(tell_to != self) // and we're allowed to send to them :D { - Say(self, FALSE, tell_to, substring(command, argv_start_index(next_token), argv_end_index(-1) - argv_start_index(next_token)), TRUE); + Say(self, false, tell_to, substring(command, argv_start_index(next_token), argv_end_index(-1) - argv_start_index(next_token)), true); return; } else { print_to(self, "You can't ^2tell^7 a message to yourself."); return; } @@ -733,6 +809,7 @@ void ClientCommand_(float request) CLIENT_COMMAND("mobedit", ClientCommand_mobedit(request, arguments), "Edit your monster's properties") \ CLIENT_COMMAND("mobkill", ClientCommand_mobkill(request), "Kills your monster") \ CLIENT_COMMAND("mobspawn", ClientCommand_mobspawn(request, arguments), "Spawn monsters infront of yourself") \ + CLIENT_COMMAND("physics", ClientCommand_physics(request, arguments), "Change physics set") \ CLIENT_COMMAND("ready", ClientCommand_ready(request), "Qualify as ready to end warmup stage (or restart server if allowed)") \ CLIENT_COMMAND("say", ClientCommand_say(request, arguments, command), "Print a message to chat to all players") \ CLIENT_COMMAND("say_team", ClientCommand_say_team(request, arguments, command), "Print a message to chat to all team mates") \ @@ -750,7 +827,7 @@ void ClientCommand_macro_help() #define CLIENT_COMMAND(name,function,description) \ { sprint(self, " ^2", name, "^7: ", description, "\n"); } - CLIENT_COMMANDS(0, 0, "") + CLIENT_COMMANDS(0, 0, ""); #undef CLIENT_COMMAND return; @@ -759,23 +836,23 @@ void ClientCommand_macro_help() float ClientCommand_macro_command(float argc, string command) { #define CLIENT_COMMAND(name,function,description) \ - { if(name == strtolower(argv(0))) { function; return TRUE; } } + { if(name == strtolower(argv(0))) { function; return true; } } - CLIENT_COMMANDS(CMD_REQUEST_COMMAND, argc, command) + CLIENT_COMMANDS(CMD_REQUEST_COMMAND, argc, command); #undef CLIENT_COMMAND - return FALSE; + return false; } float ClientCommand_macro_usage(float argc) { #define CLIENT_COMMAND(name,function,description) \ - { if(name == strtolower(argv(1))) { function; return TRUE; } } + { if(name == strtolower(argv(1))) { function; return true; } } - CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc, "") + CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc, ""); #undef CLIENT_COMMAND - return FALSE; + return false; } void ClientCommand_macro_write_aliases(float fh) @@ -783,7 +860,7 @@ void ClientCommand_macro_write_aliases(float fh) #define CLIENT_COMMAND(name,function,description) \ { CMD_Write_Alias("qc_cmd_cmd", name, description); } - CLIENT_COMMANDS(0, 0, "") + CLIENT_COMMANDS(0, 0, ""); #undef CLIENT_COMMAND return; @@ -796,17 +873,21 @@ void ClientCommand_macro_write_aliases(float fh) void SV_ParseClientCommand(string command) { + // 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 we're banned, don't even parse the command if(Ban_MaybeEnforceBanOnce(self)) return; float argc = tokenize_console(command); - // for the mutator hook system - cmd_name = strtolower(argv(0)); - cmd_argc = argc; - cmd_string = command; - // Guide for working with argc arguments by example: // argc: 1 - 2 - 3 - 4 // argv: 0 - 1 - 2 - 3 @@ -826,9 +907,9 @@ void SV_ParseClientCommand(string command) default: if(SV_ParseClientCommand_floodcheck()) - break; // "TRUE": continue, as we're not flooding yet + break; // "true": continue, as we're not flooding yet else - return; // "FALSE": not allowed to continue, halt // print("^1ERROR: ^7ANTISPAM CAUGHT: ", command, ".\n"); + 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 */ @@ -855,7 +936,7 @@ void SV_ParseClientCommand(string command) return; } } - else if(MUTATOR_CALLHOOK(SV_ParseClientCommand)) + else if(MUTATOR_CALLHOOK(SV_ParseClientCommand, strtolower(argv(0)), argc, command)) { return; // handled by a mutator }