]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/cmd.qc
Merge branch 'master' into Mario/vehicles
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / cmd.qc
index fed7088ad8474ad83f2e901652c9a59810b2c632..8672c3a292ac324fcf1f81c03a150a3e58149099 100644 (file)
@@ -1,32 +1,39 @@
-#if defined(CSQC)
-#elif defined(MENUQC)
-#elif defined(SVQC)
-       #include "../../dpdefs/progsdefs.qc"
-    #include "../../dpdefs/dpextensions.qc"
-    #include "../../warpzonelib/common.qh"
-    #include "../../common/constants.qh"
-    #include "../../common/teams.qh"
-    #include "../../common/util.qh"
-    #include "../../common/command/shared_defs.qh"
-    #include "../../common/monsters/monsters.qh"
-    #include "../../common/monsters/sv_monsters.qh"
-    #include "../../common/monsters/spawn.qh"
-    #include "../autocvars.qh"
-    #include "../defs.qh"
-    #include "../../common/notifications.qh"
-    #include "../../common/deathtypes.qh"
-    #include "../mutators/mutators_include.qh"
-    #include "../vehicles/vehicles_def.qh"
-    #include "../campaign.qh"
-    #include "../../common/mapinfo.qh"
-    #include "common.qh"
-    #include "vote.qh"
-    #include "cmd.qh"
-    #include "../cheats.qh"
-    #include "../scores.qh"
-    #include "../ipban.qh"
+#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 "../../common/vehicles/sv_vehicles.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
@@ -223,16 +230,16 @@ 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)
+                               if(IS_MONSTER(trace_ent))
                                {
                                        if(trace_ent.realowner != self) { sprint(self, "That monster does not belong to you.\n"); return; }
                                        switch(argv(1))
                                        {
                                                case "skin":
                                                {
-                                                       if(trace_ent.monsterid != MON_MAGE)
+                                                       if(trace_ent.monsterid != MON_MAGE.monsterid)
                                                                trace_ent.skin = stof(argv(2));
                                                        return;
                                                }
@@ -265,8 +272,8 @@ 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(IS_MONSTER(trace_ent))
                        {
                                if(trace_ent.realowner != self)
                                {
@@ -278,7 +285,7 @@ void ClientCommand_mobkill(float request)
                                return;
                        }
                }
-       
+
                default:
                        sprint(self, "Incorrect parameters for ^2mobkill^7\n");
                case CMD_REQUEST_USAGE:
@@ -299,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; }
@@ -329,7 +336,7 @@ 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);
@@ -343,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_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);
-                                       
+
                                        sprint(self, strcat("Spawned ", e.monster_name, "\n"));
-                                       
+
                                        return;
                                }
                        }
                }
-       
+
                default:
                        sprint(self, "Incorrect parameters for ^2mobspawn^7\n");
                case CMD_REQUEST_USAGE:
@@ -370,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 <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)
@@ -762,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") \
@@ -825,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
@@ -884,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
        }