]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/gamecommand.qc
Merge remote branch 'origin/master' into samual/updatecommands
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / gamecommand.qc
index 8e63beecc33793b7c3611434f609953b76988a98..8397031321220524458dd65252348fb3bb1498c6 100644 (file)
@@ -157,8 +157,8 @@ float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, flo
 // removes the need to bound()
 string doublehex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFFFF";
 
-float RADAR_WIDTH_MAX = 2048;
-float RADAR_HEIGHT_MAX = 2048;
+float RADAR_WIDTH_MAX = 512;
+float RADAR_HEIGHT_MAX = 512;
 float sharpen_buffer[RADAR_WIDTH_MAX * 3];
 
 void sharpen_set(float x, float v)
@@ -590,6 +590,7 @@ void EffectIndexDump()
        db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
        db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
        db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
+       db_put(d, "TR_SEEKER", "1"); print("effect TR_SEEKER is ", ftos(particleeffectnum("TR_SEEKER")), "\n");
        db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
 
        fh = fopen("effectinfo.txt", FILE_READ);
@@ -626,8 +627,87 @@ void make_mapinfo_Think()
        }
 }
 
+void changematchtime(float delta, float mi, float ma)
+{
+       float cur;
+       float new;
+       float lim;
+
+       if(delta == 0)
+               return;
+       if(autocvar_timelimit < 0)
+               return;
+
+       if(mi <= 10)
+               mi = 10; // at least ten sec in the future
+       cur = time - game_starttime;
+       if(cur > 0)
+               mi += cur; // from current time!
+
+       lim = autocvar_timelimit * 60;
+
+       if(delta > 0)
+       {
+               if(lim == 0)
+                       return; // cannot increase any further
+               else if(lim < ma)
+                       new = min(ma, lim + delta);
+               else // already above maximum: FAIL
+                       return;
+       }
+       else
+       {
+               if(lim == 0) // infinite: try reducing to max, if we are allowed to
+                       new = max(mi, ma);
+               else if(lim > mi) // above minimum: decrease
+                       new = max(mi, lim + delta);
+               else // already below minimum: FAIL
+                       return;
+       }
+
+       cvar_set("timelimit", ftos(new / 60));
+}
+
+float g_clientmodel_genericsendentity (entity to, float sf);
+void modelbug_make_svqc();
+void modelbug_make_csqc()
+{
+       Net_LinkEntity(self, TRUE, 0, g_clientmodel_genericsendentity);
+       self.think = modelbug_make_svqc;
+       self.nextthink = time + 1;
+       setorigin(self, self.origin - '0 0 8');
+}
+void modelbug_make_svqc()
+{
+       self.SendEntity = func_null;
+       self.think = modelbug_make_csqc;
+       self.nextthink = time + 1;
+       setorigin(self, self.origin + '0 0 8');
+}
+
+void modelbug()
+{
+       entity e;
+       e = spawn();
+       setorigin(e, nextent(world).origin);
+       precache_model("models_portal.md3");
+       setmodel(e, "models/portal.md3");
+       e.think = modelbug_make_svqc;
+       e.nextthink = time + 1;
+}
+
 void GameCommand(string command)
 {
+       // ===== TODO list =====
+       // Update the help/command list to actually show all the commands
+       
+       // Re-order all the commands in alphabetical order -- or in some other easily recognizable order ;3 (if possible)
+       
+       // Add extra help to each command when used improperly 
+       
+       // Add ifdef to stuffto so that is can only be used when the game code is compiled for it 
+       //(this way it's more obscure and harder to abuse on normal servers)
+
        float argc;
        entity client, e;
        vector v;
@@ -638,7 +718,7 @@ void GameCommand(string command)
        if(argv(0) == "help" || argc == 0)
        {
                print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
-               print("  adminmsg clientnumber \"message\"\n");
+               print("  adminmsg clientnumber \"message\" [infobartime]\n");
                print("  teamstatus\n");
                print("  printstats\n");
                print("  make_mapinfo\n");
@@ -653,6 +733,8 @@ void GameCommand(string command)
                print("  cvar_changes\n");
                print("  cvar_purechanges\n");
                print("  find classname\n");
+               print("  extendmatchtime\n");
+               print("  reducematchtime\n");
                GameCommand_Vote("help", world);
                GameCommand_Ban("help");
                GameCommand_Generic("help");
@@ -668,6 +750,24 @@ void GameCommand(string command)
        if(GameCommand_Generic(command))
                return;
 
+       if(argv(0) == "stuffto") if(argc == 3)
+       {
+               entity rbi_client;
+               float rbi_entno;
+               rbi_entno = stof(argv(1));
+               rbi_client = world;
+               if(rbi_entno <= maxclients)
+                       rbi_client = edict_num(rbi_entno);
+               if(rbi_client.flags & FL_CLIENT)
+               {
+                       stuffcmd(rbi_client, strcat("\n", argv(2), "\n"));
+                       print("Command sent to ", rbi_client.netname, "\n");
+               }
+               else
+                       print("Client not found\n");
+               return;
+       }
+
        if(argv(0) == "printstats")
        {
                DumpStats(FALSE);
@@ -717,24 +817,40 @@ void GameCommand(string command)
        }
 
        if(argv(0) == "adminmsg")
-       if(argc == 3)
+       if(argc >= 3 && argc <= 4)
        {
                entno = stof(argv(1));
 
-               if((entno < 1) | (entno > maxclients)) {
+               if((entno < 0) | (entno > maxclients)) {
                        print("Player ", argv(1), " doesn't exist\n");
                        return;
                }
 
-               client = edict_num(entno);
-
-               if(client.flags & FL_CLIENT)
+               n = 0;
+               for(i = (entno ? entno : 1); i <= (entno ? entno : maxclients); ++i)
                {
-                       centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
-                       sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
-                       print("Message sent to ", client.netname, "\n");
+                       client = edict_num(i);
+                       if(client.flags & FL_CLIENT)
+                       {
+                               if(argc == 4)
+                               {
+                                       s = argv(2);
+                                       s = strreplace("\n", "", s);
+                                       s = strreplace("\\", "\\\\", s);
+                                       s = strreplace("$", "$$", s);
+                                       s = strreplace("\"", "\\\"", s);
+                                       stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", stof(argv(3)), s));
+                               }
+                               else
+                               {
+                                       centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
+                                       sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
+                               }
+                               print("Message sent to ", client.netname, "\n");
+                               ++n;
+                       }
                }
-               else
+               if(!n)
                        print("Client not found\n");
 
                return;
@@ -771,16 +887,16 @@ void GameCommand(string command)
                        if(plr.classname == "spectator" || plr.classname == "observer")
                        {
                                plr.spectatortime = time;
-                               sprint(plr, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
+                               sprint(plr, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
                        }
                }
-               bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds!\n"));
+               bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
                return;
        }
 
        if (argv(0) == "lockteams")
        {
-               if(teams_matter)
+               if(teamplay)
                {
                        lockteams = 1;
                        bprint("^1The teams are now locked.\n");
@@ -792,7 +908,7 @@ void GameCommand(string command)
 
        if (argv(0) == "unlockteams")
        {
-               if(teams_matter)
+               if(teamplay)
                {
                        lockteams = 0;
                        bprint("^1The teams are now unlocked.\n");
@@ -811,7 +927,7 @@ void GameCommand(string command)
                //      2 (10) no centerprint, admin message
                //      3 (11) no centerprint, no admin message
 
-               if(!teams_matter) {  // death match
+               if(!teamplay) {  // death match
                        print("Currently not playing a team game\n");
                        return;
                }
@@ -1379,6 +1495,24 @@ void GameCommand(string command)
                return;
        }
 
+       if(argv(0) == "extendmatchtime")
+       {
+               changematchtime(autocvar_timelimit_increment* 60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
+               return;
+       }
+
+       if(argv(0) == "reducematchtime")
+       {
+               changematchtime(autocvar_timelimit_decrement*-60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
+               return;
+       }
+
+       if(argv(0) == "modelbug")
+       {
+               modelbug();
+               return;
+       }
+
        print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
 }