]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into samual/updatecommands
authorSamual <samual@xonotic.org>
Sat, 26 Nov 2011 19:38:30 +0000 (14:38 -0500)
committerSamual <samual@xonotic.org>
Sat, 26 Nov 2011 19:38:30 +0000 (14:38 -0500)
Conflicts:
qcsrc/client/Main.qc
qcsrc/server/clientcommands.qc

1  2 
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/gamecommand.qc
qcsrc/client/main.qh
qcsrc/client/progs.src
qcsrc/server/clientcommands.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/progs.src

Simple merge
index ea3b5f571e193337c351de32819520fd1d2322b3,90f1fcb334cf55c8813b9e89570e27321f588335..cf696a3228cf2d7b646601b95384442d446e3d95
@@@ -61,14 -82,30 +61,14 @@@ void CSQC_Init(void
                        break;
        maxclients = i;
  
-       //registercmd("hud_configure");
-       //registercmd("hud_save");
-       //registercmd("menu_action");
 -      registercommand("hud_configure");
 -      registercommand("hud_save");
++      //registercommand("hud_configure");
++      //registercommand("hud_save");
+       //registercommand("menu_action");
 +      
 +      ConsoleCommand_macro_init();
  
 -      registercommand("+showscores");registercommand("-showscores");
 -      registercommand("+showaccuracy");registercommand("-showaccuracy");
 -
 -#ifndef CAMERATEST
 -      if(isdemo())
 -      {
 -#endif
 -              registercommand("+forward");registercommand("-forward");
 -              registercommand("+back");registercommand("-back");
 -              registercommand("+moveup");registercommand("-moveup");
 -              registercommand("+movedown");registercommand("-movedown");
 -              registercommand("+moveright");registercommand("-moveright");
 -              registercommand("+moveleft");registercommand("-moveleft");
 -              registercommand("+roll_right");registercommand("-roll_right");
 -              registercommand("+roll_left");registercommand("-roll_left");
 -#ifndef CAMERATEST
 -      }
 -#endif
        registercvar("hud_usecsqc", "1");
-       registercvar("scoreboard_columns", "default", CVAR_SAVE);
+       registercvar("scoreboard_columns", "default");
  
        gametype = 0;
  
index b030cc7a26bf8c0b0e4d5c0ea8bd49b5907eb160,0000000000000000000000000000000000000000..ab6aa359f7c4ffc3a9fafb698a3bf624ff30f65a
mode 100644,000000..100644
--- /dev/null
@@@ -1,509 -1,0 +1,509 @@@
- //  Last updated: November 8th, 2011
 +// ==============================================
 +//  CSQC client commands code, written by Samual
-               { registercmd(name); }
++//  Last updated: November 26th, 2011
 +// ==============================================
 +
 +      /*
 +      if(cmd == "mv_download") {
 +              Cmd_MapVote_MapDownload(argc);
 +      }
 +      else if(cmd == "scoreboard_columns_set") {
 +              Cmd_HUD_SetFields(argc);
 +      }
 +      else if(cmd == "scoreboard_columns_help") {
 +              Cmd_HUD_Help(argc);
 +      }
 +      else if(cmd == "spawn") {
 +              s = argv(1);
 +              e = spawn();
 +              precache_model(s);
 +              setmodel(e, s);
 +              setorigin(e, view_origin);
 +              e.angles = view_angles;
 +              e.draw = DrawDebugModel;
 +              e.classname = "debugmodel";
 +      }
 +    else if(cmd == "vyes")
 +    {
 +        if(uid2name_dialog)
 +        {
 +            vote_active = 0; // force the panel to disappear right as we have selected the value (to prevent it from fading out in the normal vote panel pos)
 +            vote_prev = 0;
 +            localcmd("setreport cl_allow_uid2name 1\n");
 +            vote_change = -9999;
 +                      uid2name_dialog = 0;
 +        }
 +        else
 +        {
 +            localcmd("cmd vote yes\n");
 +        }
 +    }
 +    else if(cmd == "vno")
 +    {
 +        if(uid2name_dialog)
 +        {
 +            vote_active = 0;
 +            vote_prev = 0;
 +            localcmd("setreport cl_allow_uid2name 0\n");
 +            vote_change = -9999;
 +                      uid2name_dialog = 0;
 +        }
 +        else
 +        {
 +            localcmd("cmd vote no\n");
 +        }
 +    }
 +      */
 +
 +
 +#define GC_REQUEST_COMMAND 1
 +#define GC_REQUEST_USAGE 2
 +
 +void Cmd_HUD_SetFields(float);
 +void Cmd_HUD_Help(float);
 +
 +.vector view_ofs;
 +entity debug_shotorg;
 +
 +
 +// ============================
 +//  Misc. Supporting Functions
 +// ============================
 +
 +float cvar_clientsettemp(string tmp_cvar, string value)
 +{
 +      entity e;
 +      
 +      for(e = world; (e = find(e, classname, "saved_cvar_value")); )
 +              if(e.netname == tmp_cvar)
 +                      goto saved;
 +                      
 +      // creating a new entity to keep track of this cvar
 +      e = spawn();
 +      e.classname = "saved_cvar_value";
 +      e.netname = strzone(tmp_cvar);
 +      e.message = strzone(cvar_string(tmp_cvar));
 +      return TRUE;
 +      
 +      // an entity for this cvar already exists, update the value
 +      :saved
 +      cvar_set(tmp_cvar, value);
 +      return FALSE;
 +}
 +
 +float cvar_clientsettemp_restore()
 +{
 +      float i;
 +      entity e;
 +      
 +      for(e = world; (e = find(e, classname, "saved_cvar_value")); )
 +              { cvar_set(e.netname, e.message); ++i; } 
 +              
 +      return i;
 +}
 +
 +void DrawDebugModel()
 +{
 +      if(time - floor(time) > 0.5)
 +      {
 +              PolyDrawModel(self);
 +              self.drawmask = 0;
 +      }
 +      else
 +      {
 +              self.renderflags = 0;
 +              self.drawmask = MASK_NORMAL;
 +      }
 +}
 +
 +
 +// =======================
 +//  Command Sub-Functions
 +// =======================
 +
 +void GameCommand_blurtest(float request)
 +{
 +      // Simple command to work with postprocessing temporarily... possibly completely pointless, the glsl shader is used for a real feature now...
 +      // Anyway, to enable it, just compile the client with -DBLURTEST and then you can use the command.
 +      
 +      #ifdef BLURTEST
 +      switch(request)
 +      {
 +              case GC_REQUEST_COMMAND:
 +              {
 +                      blurtest_time0 = time;
 +                      blurtest_time1 = time + stof(argv(1));
 +                      blurtest_radius = stof(argv(2));
 +                      blurtest_power = stof(argv(3));
 +                      print("Enabled blurtest\n");
 +                      return; 
 +              }
 +                      
 +              default:
 +              case GC_REQUEST_USAGE:
 +              {
 +                      print("\nUsage:^3 cl_cmd blurtest\n");
 +                      print("  No arguments required.\n");
 +                      return;
 +              }
 +      }
 +      #else
 +      if(request)
 +      {
 +              print("Blurtest is not enabled on this client.\n");
 +              return;
 +      }
 +      #endif
 +}
 +
 +void GameCommand_hud(float request, float argc) // TODO: Add aliases in commands.cfg
 +{
 +      switch(request)
 +      {
 +              case GC_REQUEST_COMMAND:
 +              {
 +                      switch(argv(1))
 +                      {
 +                              case "configure":
 +                              {
 +                                      cvar_set("_hud_configure", ftos(!autocvar__hud_configure));
 +                                      return;
 +                              }
 +                              
 +                              case "save":
 +                              {
 +                                      if(argv(2))
 +                                      {
 +                                              HUD_Panel_ExportCfg(argv(2));
 +                                              return;
 +                                      }
 +                                      else
 +                                      {
 +                                              break; // go to usage, we're missing the paramater needed here.
 +                                      }
 +                              }
 +                              
 +                              case "radar":
 +                              {
 +                                      if(argv(2))
 +                                              hud_panel_radar_maximized = (stof(argv(2)) != 0);
 +                                      else
 +                                              hud_panel_radar_maximized = !hud_panel_radar_maximized;
 +                                      
 +                                      return;
 +                              }
 +                              
 +                              case "scoreboard_columns_set":
 +                              {
 +                                      Cmd_HUD_SetFields(argc); // todo update this function
 +                                      
 +                                      return;
 +                              }
 +
 +                              case "scoreboard_columns_help":
 +                              {
 +                                      Cmd_HUD_Help(argc); // todo update this function
 +                                      
 +                                      return;
 +                              }
 +                      }
 +                      return; 
 +              }
 +                      
 +              default:
 +                      print("Incorrect parameters for ^2hud^7\n");
 +              case GC_REQUEST_USAGE:
 +              {
 +                      print("\nUsage:^3 cl_cmd hud action [configname | radartoggle]\n");
 +                      print("  Where 'action' is the command to complete,\n");
 +                      print("  'configname' is the name to save to for \"save\" action,\n");
 +                      print("  and 'radartoggle' is to control hud_panel_radar_maximized for \"radar\" action.\n");
 +                      print("  Full list of commands here: \"configure, save, radar.\"\n");
 +                      return;
 +              }
 +      }
 +}
 +
 +void GameCommand_sendcvar(float request, float argc)
 +{
 +      switch(request)
 +      {
 +              case GC_REQUEST_COMMAND:
 +              {
 +                      // W_FixWeaponOrder will trash argv, so save what we need.
 +                      string thiscvar = strzone(argv(1));
 +                      string s = cvar_string(thiscvar);
 +                      
 +                      if(thiscvar == "cl_weaponpriority")
 +                              s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
 +                      else if(substring(thiscvar, 0, 17) == "cl_weaponpriority" && strlen(thiscvar) == 18)
 +                              s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
 +                              
 +                      localcmd("cmd sentcvar ", thiscvar, " \"", s, "\"\n");
 +                      strunzone(thiscvar);
 +                      
 +                      return; 
 +              }
 +                      
 +              default:
 +              case GC_REQUEST_USAGE:
 +              {
 +                      print("\nUsage:^3 cl_cmd sendcvar <cvar>\n");
 +                      print("  Where 'cvar' is the cvar plus arguments to send to the server.\n");
 +                      return;
 +              }
 +      }
 +}
 +
 +void GameCommand_settemp(float request, float argc)
 +{
 +      switch(request)
 +      {
 +              case GC_REQUEST_COMMAND:
 +              {
 +                      if((argv(1) == "restore") && (argc == 3))
 +                      {
 +                              float i = cvar_clientsettemp_restore();
 +                              
 +                              if(i)
 +                                      print("Restored ", ftos(i), " temporary cvar settings to their original values.\n");
 +                              else
 +                                      print("Nothing to restore.\n");
 +                      }
 +                      else
 +                      {
 +                              if(cvar_clientsettemp(argv(1), argv(2)))
 +                                      print("Creating new settemp tracker for ", argv(1), " and setting it to \"", argv(2), "\" temporarily.\n"); 
 +                              else
 +                                      print("Already had a tracker for ", argv(1), ", updating it to \"", argv(2), "\".\n");
 +                      }
 +                              
 +                      return; 
 +              }
 +                      
 +              default:
 +              case GC_REQUEST_USAGE:
 +              {
 +                      print("\nUsage:^3 cl_cmd settemp <cvar> | [restore]\n");
 +                      print("  Where 'cvar' is the cvar plus arguments to send to the server,\n");
 +                      print("  or 'restore' allows you to restore all of the original temporary cvar values.\n");
 +                      return;
 +              }
 +      }
 +}
 +
 +/* use this when creating a new command, making sure to place it in alphabetical order.
 +void GameCommand_(float request)
 +{
 +      switch(request)
 +      {
 +              case GC_REQUEST_COMMAND:
 +              {
 +                      
 +                      return; 
 +              }
 +                      
 +              default:
 +              case GC_REQUEST_USAGE:
 +              {
 +                      print("\nUsage:^3 cl_cmd \n");
 +                      print("  No arguments required.\n");
 +                      return;
 +              }
 +      }
 +}
 +*/
 +
 +
 +// ==================================
 +//  Macro system for client commands
 +// ==================================
 +
 +// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
 +#define CLIENT_COMMANDS(request,arguments) \
 +      CLIENT_COMMAND("blurtest", GameCommand_blurtest(request), "Feature for testing blur postprocessing") \
 +      CLIENT_COMMAND("hud", GameCommand_hud(request, arguments), "Commands regarding/controlling the HUD system") \
 +      CLIENT_COMMAND("sendcvar", GameCommand_sendcvar(request, arguments), "Send a cvar to the server (like weaponpriority)") \
 +      CLIENT_COMMAND("settemp", GameCommand_settemp(request, arguments), "Temporarily set a value to a cvar which is restored by command or end of each match") \
 +      /* nothing */
 +      
 +void GameCommand_macro_help()
 +{
 +      #define CLIENT_COMMAND(name,function,description) \
 +              { print("  ^2", name, "^7: ", description, "\n"); }
 +              
 +      CLIENT_COMMANDS(0, 0)
 +      #undef CLIENT_COMMAND
 +      
 +      return;
 +}
 +
 +float GameCommand_macro_command(float argc)
 +{
 +      #define CLIENT_COMMAND(name,function,description) \
 +              { if(name == strtolower(argv(0))) { function; return TRUE; } }
 +              
 +      CLIENT_COMMANDS(GC_REQUEST_COMMAND, argc)
 +      #undef CLIENT_COMMAND
 +      
 +      return FALSE;
 +}
 +
 +float GameCommand_macro_usage(float argc)
 +{
 +      #define CLIENT_COMMAND(name,function,description) \
 +              { if(name == strtolower(argv(1))) { function; return TRUE; } }
 +              
 +      CLIENT_COMMANDS(GC_REQUEST_USAGE, argc)
 +      #undef CLIENT_COMMAND
 +      
 +      return FALSE;
 +}
 +
 +
 +// =========================================
 +//  Main Function Called By Engine (cl_cmd)
 +// =========================================
 +// If this function exists, client code handles gamecommand instead of the engine code.
 +
 +void GameCommand(string command)
 +{
 +      float argc = tokenize_console(command);
 +
 +      if(strtolower(argv(0)) == "help") 
 +      {
 +              if(argc == 1) 
 +              {
 +                      print("\nUsage:^3 cl_cmd COMMAND...^7, where possible commands are:\n");
 +                      GameCommand_macro_help();
 +                      GameCommand_Generic("help");
 +                      print("For help about specific commands, type cl_cmd help COMMAND\n");
 +                      return;
 +              } 
 +              else if(GameCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
 +              {
 +                      return;
 +              }
 +      } 
 +      else if(GameCommand_Generic(command)) 
 +      {
 +              return; // handled by common/gamecommand.qc
 +      }
 +      else if(GameCommand_macro_command(argc)) // continue as usual and scan for normal commands
 +      {
 +              return; // handled by one of the above GameCommand_* functions
 +      }
 +      
 +      // nothing above caught the command, must be invalid
 +      print("Unknown client command", ((command != "") ? strcat(" \"", command, "\"") : ""), ". For a list of supported commands, try cl_cmd help.\n");
 +      
 +      return;
 +}
 +
 +
 +// ===================================
 +//  Macro system for console commands
 +// ===================================
 +
 +// These functions are here specifically to add special + - commands to the game, and are not really normal commands.
 +// Please add client commands to the function above this, as this is only for special reasons.
 +#define CONSOLE_COMMANDS_NORMAL \
 +      CONSOLE_COMMAND("+showscores", { scoreboard_showscores = TRUE; }) \
 +      CONSOLE_COMMAND("-showscores", { scoreboard_showscores = FALSE; }) \
 +      CONSOLE_COMMAND("+showaccuracy", { scoreboard_showaccuracy = TRUE; }) \
 +      CONSOLE_COMMAND("-showaccuracy", { scoreboard_showaccuracy = FALSE; }) \
 +      /* nothing */
 +      
 +#define CONSOLE_COMMANDS_MOVEMENT \
 +      CONSOLE_COMMAND("+forward", { ++camera_direction_x; }) \
 +      CONSOLE_COMMAND("-forward", { --camera_direction_x; }) \
 +      CONSOLE_COMMAND("+back", { --camera_direction_x; }) \
 +      CONSOLE_COMMAND("-back", { ++camera_direction_x; }) \
 +      CONSOLE_COMMAND("+moveup", { ++camera_direction_z; }) \
 +      CONSOLE_COMMAND("-moveup", { --camera_direction_z; }) \
 +      CONSOLE_COMMAND("+movedown", { --camera_direction_z; }) \
 +      CONSOLE_COMMAND("-movedown", { ++camera_direction_z; }) \
 +      CONSOLE_COMMAND("+moveright", { --camera_direction_y; }) \
 +      CONSOLE_COMMAND("-moveright", { ++camera_direction_y; }) \
 +      CONSOLE_COMMAND("+moveleft", { ++camera_direction_y; }) \
 +      CONSOLE_COMMAND("-moveleft", { --camera_direction_y; }) \
 +      CONSOLE_COMMAND("+roll_right", { ++camera_roll; }) \
 +      CONSOLE_COMMAND("-roll_right", { --camera_roll; }) \
 +      CONSOLE_COMMAND("+roll_left", { --camera_roll; }) \
 +      CONSOLE_COMMAND("-roll_left", { ++camera_roll; }) \
 +      /* nothing */
 +
 +void ConsoleCommand_macro_init()
 +{
 +      // first init normal commands
 +      #define CONSOLE_COMMAND(name,execution) \
-                       { registercmd(name); }
++              { registercommand(name); }
 +
 +      CONSOLE_COMMANDS_NORMAL
 +      #undef CONSOLE_COMMAND
 +      
 +      // then init movement commands
 +      #ifndef CAMERATEST
 +      if(isdemo())
 +      {
 +      #endif
 +              #define CONSOLE_COMMAND(name,execution) \
- // Used to parse commands in the console that have been registered with the "registercmd" function
++                      { registercommand(name); }
 +
 +              CONSOLE_COMMANDS_MOVEMENT
 +              #undef CONSOLE_COMMAND
 +      #ifndef CAMERATEST
 +      }
 +      #endif
 +      
 +      return;
 +}
 +
 +float ConsoleCommand_macro_normal(float argc)
 +{
 +      #define CONSOLE_COMMAND(name,execution) \
 +              { if(name == strtolower(argv(0))) { { execution } return TRUE; } }
 +              
 +      CONSOLE_COMMANDS_NORMAL
 +      #undef CONSOLE_COMMAND
 +      
 +      return FALSE;
 +}
 +
 +float ConsoleCommand_macro_movement(float argc)
 +{
 +      if(camera_active)
 +      {
 +              #define CONSOLE_COMMAND(name,execution) \
 +                      { if(name == strtolower(argv(0))) { { execution } return TRUE; } }
 +
 +              CONSOLE_COMMANDS_MOVEMENT
 +              #undef CONSOLE_COMMAND
 +      }
 +      
 +      return FALSE;
 +}
 +
 +
 +// ======================================================
 +//  Main Function Called By Engine (registered commands)
 +// ======================================================
++// Used to parse commands in the console that have been registered with the "registercommand" function
 +
 +float CSQC_ConsoleCommand(string command)
 +{
 +      float argc = tokenize_console(command);
 +
 +      if(ConsoleCommand_macro_normal(argc))
 +      {
 +              return TRUE;
 +      }
 +      else if(ConsoleCommand_macro_movement(argc))
 +      {
 +              return TRUE;
 +      }
 +      
 +      // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
 +
 +      return FALSE;
 +}
Simple merge
Simple merge
index 74b501eb57a4dba3bf39f76fc1ed37162071bf48,3deddf80164c92ceb6269ea35f78e5a538d17fd9..fde3fd943e9a442cd1cb27fb38ed486a2d82725b
 -entity nagger;
 -float readycount;
 +// =========================================================
 +//  Server side networked commands code, reworked by Samual
- //  Last updated: November 8th, 2011
++//  Last updated: November 26th, 2011
 +// =========================================================
  
 -float Nagger_SendEntity(entity to, float sendflags)
 -{
 -      float nags, i, f, b;
 -      entity e;
 -      WriteByte(MSG_ENTITY, ENT_CLIENT_NAGGER);
 -
 -      // bits:
 -      //   1 = ready
 -      //   2 = player needs to ready up
 -      //   4 = vote
 -      //   8 = player needs to vote
 -      //  16 = warmup
 -      // sendflags:
 -      //  64 = vote counts
 -      // 128 = vote string
 +#define CC_REQUEST_COMMAND 1
 +#define CC_REQUEST_USAGE 2
  
 -      nags = 0;
 -      if(readycount)
 -      {
 -              nags |= 1;
 -              if(to.ready == 0)
 -                      nags |= 2;
 -      }
 -      if(votecalled)
 -      {
 -              nags |= 4;
 -              if(to.vote_vote == 0)
 -                      nags |= 8;
 -      }
 -      if(inWarmupStage)
 -              nags |= 16;
 -
 -      if(sendflags & 64)
 -              nags |= 64;
 +.float cmd_floodtime;
 +.float cmd_floodcount;
 +.float checkfail;
 +.float lms_spectate_warning;
  
 -      if(sendflags & 128)
 -              nags |= 128;
 +string MapVote_Suggest(string m);
  
 -      if(!(nags & 4)) // no vote called? send no string
 -              nags &~= (64 | 128);
  
 -      WriteByte(MSG_ENTITY, nags);
 +// ============================
 +//  Misc. Supporting Functions
 +// ============================
  
 -      if(nags & 64)
 +float SV_ParseClientCommand_floodcheck()
 +{
 +      if (timeoutStatus != 2) // if the game is not paused... but wait, doesn't that mean it could be dos'd by pausing it? eh? (old code)
        {
 -              WriteByte(MSG_ENTITY, vote_yescount);
 -              WriteByte(MSG_ENTITY, vote_nocount);
 -              WriteByte(MSG_ENTITY, vote_needed_absolute);
 -              WriteChar(MSG_ENTITY, to.vote_vote);
 +              if(time == self.cmd_floodtime) // todo: add buffer time as well, ONLY one second is a short amount of time for someone to be spamming. 
 +              {
 +                      self.cmd_floodcount += 1;
 +                      if(self.cmd_floodcount > 8) // todo: replace constant 8 with a cvar for the server to control
 +                              return FALSE; // too much spam, halt
 +              }
 +              else
 +              {
 +                      self.cmd_floodtime = time;
 +                      self.cmd_floodcount = 1;
 +              }
        }
 +      return TRUE; // continue, as we're not flooding yet
 +}
 +
  
 -      if(nags & 128)
 -              WriteString(MSG_ENTITY, votecalledvote_display);
 +// =======================
 +//  Command Sub-Functions
 +// =======================
  
 -      if(nags & 1)
 +void ClientCommand_autoswitch(float request, float argc)
 +{
 +      switch(request)
        {
 -              for(i = 1; i <= maxclients; i += 8)
 +              case CC_REQUEST_COMMAND:
                {
 -                      for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
 -                              if(clienttype(e) != CLIENTTYPE_REAL || e.ready)
 -                                      f |= b;
 -                      WriteByte(MSG_ENTITY, f);
 +                      self.autoswitch = ("0" != argv(1));
 +                      sprint(self, strcat("^1autoswitch is currently turned ", (self.autoswitch ? "on" : "off"), ".\n"));
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd autoswitch selection\n");
 +                      sprint(self, "  Where 'selection' is 1 or 0 for on or off.\n"); 
 +                      return;
                }
        }
 -
 -      return TRUE;
  }
 -void Nagger_Init()
 +
 +void ClientCommand_checkfail(float request, string command) // used only by client side code
  {
 -      Net_LinkEntity(nagger = spawn(), FALSE, 0, Nagger_SendEntity);
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      print(sprintf("CHECKFAIL: %s (%s) epically failed check %s\n", self.netname, self.netaddress, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))));
 +                      self.checkfail = 1;
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd checkfail message\n");
 +                      sprint(self, "  Where 'message' is the message reported by client about the fail.\n");
 +                      return;
 +              }
 +      }
  }
 -void Nagger_VoteChanged()
 +
 +void ClientCommand_clientversion(float request, float argc) // used only by client side code
  {
 -      if(nagger)
 -              nagger.SendFlags |= 128;
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      if(self.flags & FL_CLIENT)
 +                      {
 +                              self.version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1)));
 +                              
 +                              if(self.version < autocvar_gameversion_min || self.version > autocvar_gameversion_max)
 +                              {
 +                                      self.version_mismatch = 1;
 +                                      ClientKill_TeamChange(-2); // observe
 +                              } 
 +                              else if(autocvar_g_campaign || autocvar_g_balance_teams || autocvar_g_balance_teams_force) 
 +                              {
 +                                      //JoinBestTeam(self, FALSE, TRUE);
 +                              } 
 +                              else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0)) 
 +                              {
 +                                      self.classname = "observer"; // really?
 +                                      stuffcmd(self, "menu_showteamselect\n");
 +                              }
 +                      }
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd clientversion version\n");
 +                      sprint(self, "  Where 'version' is the game version reported by self.\n");
 +                      return;
 +              }
 +      }
  }
 -void Nagger_VoteCountChanged()
 +
 +void ClientCommand_cvar_changes(float request)
  {
 -      if(nagger)
 -              nagger.SendFlags |= 64;
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      sprint(self, cvar_changes);
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 sv_cmd cvar_changes\n");
 +                      sprint(self, "  No arguments required.\n");
 +                      //sprint(self, "See also: ^2cvar_purechanges^7\n");
 +                      return;
 +              }
 +      }
  }
 -void Nagger_ReadyCounted()
 +
 +void ClientCommand_cvar_purechanges(float request)
  {
 -      if(nagger)
 -              nagger.SendFlags |= 1;
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      sprint(self, cvar_purechanges);
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 sv_cmd cvar_purechanges\n");
 +                      sprint(self, "  No arguments required.\n");
 +                      //sprint(self, "See also: ^2cvar_changes^7\n");
 +                      return;
 +              }
 +      }
  }
  
 -void ReadyCount();
 -string MapVote_Suggest(string m);
 +void ClientCommand_info(float request, float argc)
 +{     
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      string command;
 +                      
-                       command = cvar_string_builtin(strcat("sv_info_", argv(1))); 
++                      command = builtin_cvar_string(strcat("sv_info_", argv(1))); 
 +                      if(command)
 +                              wordwrap_sprint(command, 1111); // why 1111?
 +                      else
 +                              sprint(self, "ERROR: unsupported info command\n");
 +                              
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd info request\n");
 +                      sprint(self, "  Where 'request' is the suffixed string appended onto the request for cvar.\n");
 +                      return;
 +              }
 +      }
 +}
  
 -entity GetPlayer(string name)
 +void ClientCommand_join(float request)
  {
 -      float num;
 -      entity e;
 -      string ns;
 -
 -      if(substring(name, 0, 1) == "#") {
 -              num = stof(substring(name, 1, 999));
 -              if(num >= 1 && num <= maxclients) {
 -                      for((e = world); num > 0; --num, (e = nextent(e)))
 -                              ;
 -                      //if(clienttype(e) == CLIENTTYPE_REAL)
 -                      if(e.classname == "player")
 -                              return e;
 -              }
 -      } else {
 -              ns = strdecolorize(name);
 -              FOR_EACH_REALPLAYER(e) {
 -                      if(!strcasecmp(strdecolorize(e.netname), ns)) {
 -                              return e;
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      if(self.flags & FL_CLIENT)
 +                      {
 +                              if(self.classname != "player" && !lockteams && !g_arena)
 +                              {
 +                                      if(nJoinAllowed(1)) 
 +                                      {
 +                                              if(g_ca) { self.caplayer = 1; }
 +                                              if(autocvar_g_campaign) { campaign_bots_may_start = 1; }
 +                                              
 +                                              self.classname = "player";
 +                                              PlayerScore_Clear(self);
 +                                              bprint ("^4", self.netname, "^4 is playing now\n");
 +                                              PutClientInServer();
 +                                      }
 +                                      else 
 +                                      {
 +                                              //player may not join because of g_maxplayers is set
 +                                              centerprint(self, PREVENT_JOIN_TEXT);
 +                                      }
 +                              }
                        }
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd join\n");
 +                      sprint(self, "  No arguments required.\n");
 +                      return;
                }
        }
 -      return world;
  }
  
 -//float ctf_clientcommand();
 -float readyrestart_happened;
 -.float lms_spectate_warning;
 -void spawnfunc_func_breakable();
 -
 -.float cmd_floodtime;
 -.float cmd_floodcount;
 -float cmd_floodcheck()
 +void ClientCommand_ladder(float request)
  {
 -      if (timeoutStatus != 2)
 +      switch(request)
        {
 -              if(time == self.cmd_floodtime)
 +              case CC_REQUEST_COMMAND:
                {
 -                      self.cmd_floodcount += 1;
 -                      if(self.cmd_floodcount > 8)
 -                              return TRUE;
 +                      sprint(self, ladder_reply);
 +                      return; // never fall through to usage
                }
 -              else
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
                {
 -                      self.cmd_floodtime = time;
 -                      self.cmd_floodcount = 1;
 +                      sprint(self, "\nUsage:^3 cmd ladder\n");
 +                      sprint(self, "  No arguments required.\n");
 +                      return;
                }
        }
 -      return FALSE;
  }
  
 -.float checkfail;
 -void SV_ParseClientCommand(string s) {
 -      float i;
 -      entity e;
 -
 -      cmd_argc = tokenize_console(s);
 -      cmd_string = s;
 -      cmd_name = strtolower(argv(0));
 -      if(cmd_name != "reportcvar")
 -      if(cmd_name != "sentcvar")
 -      if(cmd_name != "pause")
 -      if(cmd_name != "prespawn")
 -      if(cmd_name != "spawn")
 -      if(cmd_name != "begin")
 -      {
 -              if(cmd_floodcheck())
 +void ClientCommand_lsmaps(float request)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      sprint(self, lsmaps_reply);
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd lsmaps\n");
 +                      sprint(self, "  No arguments required.\n");
                        return;
 +              }
        }
 +}
  
 -      if(MUTATOR_CALLHOOK(SV_ParseClientCommand))
 -              return; // already handled
 -      
 -      if(GameCommand_Vote(s, self)) {
 -              return;
 -      } else if(GameCommand_MapVote(argv(0))) {
 -              return;
 -      } else if(cmd_name == "checkfail") {
 -              print(sprintf("CHECKFAIL: %s (%s) epically failed check %s\n", self.netname, self.netaddress, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))));
 -              self.checkfail = 1;
 -      } else if(cmd_name == "autoswitch") {
 -              // be backwards compatible with older clients (enabled)
 -              self.autoswitch = ("0" != argv(1));
 -              string autoswitchmsg;
 -              if (self.autoswitch) {
 -                      autoswitchmsg = "on";
 -              } else {
 -                      autoswitchmsg = "off";
 -              }
 -              sprint(self, strcat("^1autoswitch turned ", autoswitchmsg, "\n"));
 -      } else if(cmd_name == "clientversion") {
 -              if not(self.flags & FL_CLIENT)
 -                      return;
 -              if (argv(1) == "$gameversion") {
 -                      //versionmsg = "^1client is too old to get versioninfo.\nUPDATE!!! (http://www.xonotic.com)^8";
 -                      // either that or someone wants to be funny
 -                      self.version = 1;
 -              } else {
 -                      self.version = stof(argv(1));
 -              }
 -              if(self.version < autocvar_gameversion_min || self.version > autocvar_gameversion_max)
 -              {
 -                      self.version_mismatch = 1;
 -                      ClientKill_TeamChange(-2); // observe
 -              } else if(autocvar_g_campaign || autocvar_g_balance_teams || autocvar_g_balance_teams_force) {
 -                      //JoinBestTeam(self, FALSE, TRUE);
 -              } else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0)) {
 -                      self.classname = "observer";
 -                      stuffcmd(self,"menu_showteamselect\n");
 -              }
 -      } else if(cmd_name == "reportcvar") { // old system
 -              if(substring(argv(2), 0, 1) == "$") // undefined cvar: use the default value on the server then
 -              {
 -                      s = strcat(substring(s, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
 -                      cmd_argc = tokenize_console(s);
 -              }
 -              GetCvars(1);
 -      } else if(cmd_name == "sentcvar") { // new system
 -              if(cmd_argc == 2) // undefined cvar: use the default value on the server then
 -              {
 -                      s = strcat(substring(s, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
 -                      cmd_argc = tokenize_console(s);
 -              }
 -              GetCvars(1);
 -      } else if(cmd_name == "spectate") {
 -              if(cmd_floodcheck())
 +void ClientCommand_lsnewmaps(float request)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      sprint(self, lsnewmaps_reply);
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd lsnewmaps\n");
 +                      sprint(self, "  No arguments required.\n");
                        return;
 -              if not(self.flags & FL_CLIENT)
 +              }
 +      }
 +}
 +
 +void ClientCommand_maplist(float request)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      sprint(self, maplist_reply);
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd maplist\n");
 +                      sprint(self, "  No arguments required.\n");
                        return;
 -              if(g_arena)
 +              }
 +      }
 +}
 +
 +void ClientCommand_rankings(float request)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      sprint(self, rankings_reply);
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd rankings\n");
 +                      sprint(self, "  No arguments required.\n");
                        return;
 -              if(g_lms)
 +              }
 +      }
 +}
 +
 +void ClientCommand_ready(float request) 
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
                {
 -                      if(self.lms_spectate_warning)
 +                      if(self.flags & FL_CLIENT)
                        {
 -                              // mark player as spectator
 -                              PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0));
 +                              if(inWarmupStage || autocvar_sv_ready_restart || g_race_qualifying == 2)
 +                              {
 +                                      if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable)
 +                                      {
 +                                              if (self.ready) // toggle
 +                                              {
 +                                                      self.ready = FALSE;
 +                                                      bprint(self.netname, "^2 is ^1NOT^2 ready\n");
 +                                              }
 +                                              else
 +                                              {
 +                                                      self.ready = TRUE;
 +                                                      bprint(self.netname, "^2 is ready\n");
 +                                              }
 +
 +                                              // cannot reset the game while a timeout is active!
 +                                              if(!timeoutStatus)
 +                                                      ReadyCount();
 +                                      } else {
 +                                              sprint(self, "^1Game has already been restarted\n");
 +                                      }
 +                              }
                        }
 -                      else
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd ready\n");
 +                      sprint(self, "  No arguments required.\n");
 +                      return;
 +              }
 +      }
 +}
 +
 +void ClientCommand_records(float request) // TODO: Isn't this flooding with the sprint messages? Old code, but perhaps bad?
 +{     
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      float i;
 +                      
 +                      for(i = 0; i < 10; ++i)
 +                              sprint(self, records_reply[i]);
 +                              
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd records\n");
 +                      sprint(self, "  No arguments required.\n");
 +                      return;
 +              }
 +      }
 +}
 +
 +void ClientCommand_reportcvar(float request, float argc, string command) // TODO: confirm this works
 +{     
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      float tokens;
 +                      string s;
 +                      
 +                      if(substring(argv(2), 0, 1) == "$") // undefined cvar: use the default value on the server then
                        {
 -                              self.lms_spectate_warning = 1;
 -                              sprint(self, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n");
 -                              return;
 +                              s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
 +                              tokens = tokenize_console(s);
                        }
 +                      GetCvars(1);
 +                      return; // never fall through to usage
                }
 -              if(self.classname == "player" && autocvar_sv_spectate == 1) {
 -                      ClientKill_TeamChange(-2); // observe
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd reportcvar <cvar>\n");
 +                      sprint(self, "  Where 'cvar' is the cvar plus arguments to send to the server.\n");
 +                      return;
                }
 -              if(g_ca && self.caplayer && (self.classname == "spectator" || self.classname == "observer")) {
 -                      // in CA, allow a dead player to move to spectatators (without that, caplayer!=0 will be moved back to the player list)
 -                      sprint(self, "WARNING: you will spectate in the next round.\n");
 -                      self.caplayer = 0;
 +      }
 +}
 +
 +void ClientCommand_say(float request, float argc, string command)
 +{
 +      switch(request)
 +      {
 +              case CC_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
                }
 -      } else if(cmd_name == "join") {
 -              if not(self.flags & FL_CLIENT)
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd say <message>\n");
 +                      sprint(self, "  Where 'message' is the string of text to say.\n");
                        return;
 -              if(!g_arena)
 -              if (self.classname != "player" && !lockteams)
 -              {
 -                      if(nJoinAllowed(1)) {
 -                              self.classname = "player";
 -                              if(g_ca)
 -                                      self.caplayer = 1;
 -                              PlayerScore_Clear(self);
 -                              bprint ("^4", self.netname, "^4 is playing now\n");
 -                              PutClientInServer();
 -                              if(autocvar_g_campaign)
 -                                      campaign_bots_may_start = 1;
 -                      }
 -                      else {
 -                              //player may not join because of g_maxplayers is set
 -                              centerprint(self, PREVENT_JOIN_TEXT);
 +              }
 +      }
 +}
 +
 +void ClientCommand_say_team(float request, float argc, string command)
 +{
 +      switch(request)
 +      {
 +              case CC_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
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd say_team <message>\n");
 +                      sprint(self, "  Where 'message' is the string of text to say.\n");
 +                      return;
 +              }
 +      }
 +}
 +
 +void ClientCommand_selectteam(float request, float argc) // TODO: Update the messages for this command
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      float selection;
 +                      
 +                      if (self.flags & FL_CLIENT)
 +                      {
 +                              if(teamplay)
 +                                      if not(self.team_forced > 0) 
 +                                              if not(lockteams) 
 +                                              {
 +                                                      switch(argv(1))
 +                                                      {
 +                                                              case "red": selection = COLOR_TEAM1; break;
 +                                                              case "blue": selection = COLOR_TEAM2; break;
 +                                                              case "yellow": selection = COLOR_TEAM3; break;
 +                                                              case "pink": selection = COLOR_TEAM4; break;
 +                                                              case "auto": selection = (-1); break;
 +                                                              
 +                                                              default: break;
 +                                                      }
 +                                                      
 +                                                      if(selection)
 +                                                      {
 +                                                              if(self.team != selection || self.deadflag != DEAD_NO)
 +                                                                      ClientKill_TeamChange(selection);
 +                                                              else
 +                                                                      sprint(self, "^7You already are on that team.\n");
 +                                                      }
 +                                              }
 +                                              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; // never fall through to usage
                }
 -      } else if( cmd_name == "selectteam" ) {
 -              if not(self.flags & FL_CLIENT)
 +
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      //sprint(self, strcat( "selectteam none/red/blue/yellow/pink/auto - \"", argv(1), "\" not recognised\n" ) );
 +                      sprint(self, "\nUsage:^3 cmd selectteam team\n");
 +                      sprint(self, "  Where 'team' is the prefered team to try and join.\n");
 +                      sprint(self, "  Full list of options here: \"red, blue, yellow, pink, auto\"\n");
                        return;
 -              if( !teamplay ) {
 -                      sprint( self, "selectteam can only be used in teamgames\n");
 -              } else if(autocvar_g_campaign) {
 -                      //JoinBestTeam(self, 0);
 -              } else if(self.team_forced > 0) {
 -                      sprint( self, "selectteam can not be used as your team is forced\n");
 -              } else if(lockteams) {
 -                      sprint( self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
 -              } else if( argv(1) == "red" ) {
 -                      if(self.team != COLOR_TEAM1 || self.deadflag != DEAD_NO)
 -                              ClientKill_TeamChange(COLOR_TEAM1);
 -                      else
 -                              sprint( self, "^7You already are on that team.\n");
 -              } else if( argv(1) == "blue" ) {
 -                      if(self.team != COLOR_TEAM2 || self.deadflag != DEAD_NO)
 -                              ClientKill_TeamChange(COLOR_TEAM2);
 -                      else
 -                              sprint( self, "^7You already are on that team.\n");
 -              } else if( argv(1) == "yellow" ) {
 -                      if(self.team != COLOR_TEAM3 || self.deadflag != DEAD_NO)
 -                              ClientKill_TeamChange(COLOR_TEAM3);
 -                      else
 -                              sprint( self, "^7You already are on that team.\n");
 -              } else if( argv(1) == "pink" ) {
 -                      if(self.team != COLOR_TEAM4 || self.deadflag != DEAD_NO)
 -                              ClientKill_TeamChange(COLOR_TEAM4);
 -                      else
 -                              sprint( self, "^7You already are on that team.\n");
 -              } else if( argv(1) == "auto" ) {
 -                      ClientKill_TeamChange(-1);
 -              } else {
 -                      sprint( self, strcat( "selectteam none/red/blue/yellow/pink/auto - \"", argv(1), "\" not recognised\n" ) );
 -              }
 -      } else if(cmd_name == "ready") {
 -              if not(self.flags & FL_CLIENT)
 +              }
 +      }
 +}
 +
 +void ClientCommand_sentcvar(float request, float argc, string command)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      float tokens;
 +                      string s;
 +                      
 +                      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)), "\"");
 +                              tokens = tokenize_console(s);
 +                      }
 +                      GetCvars(1);
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd sentcvar <cvar>\n");
 +                      sprint(self, "  Where 'cvar' is the cvar plus arguments to send to the server.\n");
                        return;
 +              }
 +      }
 +}
  
 -              if((inWarmupStage)
 -                 || autocvar_sv_ready_restart || g_race_qualifying == 2)
 +void ClientCommand_spectate(float request)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
                {
 -                      if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable)
 +                      if(self.flags & FL_CLIENT)
                        {
 -                              if (self.ready) // toggle
 +                              if(g_arena) { return; } 
 +                              if(g_lms)
                                {
 -                                      self.ready = FALSE;
 -                                      bprint(self.netname, "^2 is ^1NOT^2 ready\n");
 +                                      if(self.lms_spectate_warning)
 +                                      {
 +                                              // mark player as spectator
 +                                              PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0));
 +                                      }
 +                                      else
 +                                      {
 +                                              self.lms_spectate_warning = 1;
 +                                              sprint(self, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n");
 +                                              return;
 +                                      }
                                }
 -                              else
 +                              
 +                              if(self.classname == "player" && autocvar_sv_spectate == 1) 
 +                                      ClientKill_TeamChange(-2); // observe
 +                              
 +                              // in CA, allow a dead player to move to spectatators (without that, caplayer!=0 will be moved back to the player list)
 +                              // note: if arena game mode is ever done properly, this needs to be removed.
 +                              if(g_ca && self.caplayer && (self.classname == "spectator" || self.classname == "observer"))
                                {
 -                                      self.ready = TRUE;
 -                                      bprint(self.netname, "^2 is ready\n");
 +                                      sprint(self, "WARNING: you will spectate in the next round.\n");
 +                                      self.caplayer = 0;
                                }
 -
 -                              // cannot reset the game while a timeout is active!
 -                              if(!timeoutStatus)
 -                                      ReadyCount();
 -                      } else {
 -                              sprint(self, "^1Game has already been restarted\n");
                        }
 +                      return; // never fall through to usage
                }
 -      } else if(cmd_name == "maplist") {
 -              sprint(self, maplist_reply);
 -      } else if(cmd_name == "lsmaps") {
 -              sprint(self, lsmaps_reply);
 -      } else if(cmd_name == "lsnewmaps") {
 -              sprint(self, lsnewmaps_reply);
 -      } else if(cmd_name == "records") {
 -              for(i = 0; i < 10; ++i)
 -                      sprint(self, records_reply[i]);
 -      } else if(cmd_name == "ladder") {
 -              sprint(self, ladder_reply);
 -      } else if(cmd_name == "rankings") {
 -              sprint(self, rankings_reply);
 -      } else if(cmd_name == "voice") {
 -              if(cmd_argc >= 3)
 -                      VoiceMessage(argv(1), substring(s, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
 -              else
 -                      VoiceMessage(argv(1), "");
 -      } else if(cmd_name == "say") {
 -              if(cmd_argc >= 2)
 -                      Say(self, FALSE, world, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1);
 -              //clientcommand(self, formatmessage(s));
 -      } else if(cmd_name == "say_team") {
 -              if(cmd_argc >= 2)
 -                      Say(self, TRUE, world, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1);
 -              //clientcommand(self, formatmessage(s));
 -      } else if(cmd_name == "tell") {
 -              e = GetCommandPlayerSlotTargetFromTokenizedCommand(cmd_argc, 1);
 -              if(e && cmd_argc > ParseCommandPlayerSlotTarget_firsttoken)
 -              {
 -                      Say(self, FALSE, e, substring(s, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)), TRUE);
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd spectate\n");
 +                      sprint(self, "  No arguments required.\n");
 +                      return;
                }
 -              else
 +      }
 +}
 +
 +void ClientCommand_suggestmap(float request, float argc)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
                {
 -                      if(cmd_argc > ParseCommandPlayerSlotTarget_firsttoken)
 -                              trigger_magicear_processmessage_forallears(self, -1, world, substring(s, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)));
 -                      sprint(self, "ERROR: usage: tell # playerid text...\n");
 +                      sprint(self, strcat(MapVote_Suggest(argv(1)), "\n"));
 +                      return; // never fall through to usage
                }
 -              //clientcommand(self, formatmessage(s));
 -      } else if(cmd_name == "info") {
 -              cmd_name = builtin_cvar_string(strcat("sv_info_", argv(1))); // This needed fixed for the cvar check
 -              if(cmd_name == "")
 -                      sprint(self, "ERROR: unsupported info command\n");
 -              else
 -                      wordwrap_sprint(cmd_name, 1111);
 -      } else if(cmd_name == "suggestmap") {
 -              sprint(self, strcat(MapVote_Suggest(argv(1)), "\n"));
 -      } else if(cmd_name == "timeout") {
 -              if not(self.flags & FL_CLIENT)
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd suggestmap map\n");
 +                      sprint(self, "  Where 'map' is the name of the map to suggest.\n");
                        return;
 -              if(autocvar_sv_timeout) {
 -                      if(self.classname == "player") {
 -                              if(votecalled)
 -                                      sprint(self, "^7Error: you can not call a timeout while a vote is active!\n");
 -                              else
 -                                      evaluateTimeout();
 -                      }
 -                      else
 -                              sprint(self, "^7Error: only players can call a timeout!\n");
                }
 -      } else if(cmd_name == "timein") {
 -              if not(self.flags & FL_CLIENT)
 -                      return;
 -              if(autocvar_sv_timeout) {
 -                      evaluateTimein();
 -              }
 -      } else if(cmd_name == "teamstatus") {
 -              Score_NicePrint(self);
 -      } else if(cmd_name == "cvar_changes") {
 -              sprint(self, cvar_changes);
 -      } else if(cmd_name == "cvar_purechanges") {
 -              sprint(self, cvar_purechanges);
 -      } else if(CheatCommand(cmd_argc)) {
 -      } else {
 -#if 0
 -              //if(ctf_clientcommand())
 -              //      return;
 -              // grep for Cmd_AddCommand_WithClientCommand to find them all
 -              if(cmd_name != "status")
 -              //if(cmd_name != "say") // handled above
 -              //if(cmd_name != "say_team") // handled above
 -              if(cmd_name != "kill")
 -              if(cmd_name != "pause")
 -              if(cmd_name != "ping")
 -              if(cmd_name != "name")
 -              if(cmd_name != "color")
 -              if(cmd_name != "rate")
 -              if(cmd_name != "pmodel")
 -              if(cmd_name != "playermodel")
 -              if(cmd_name != "playerskin")
 -              if(cmd_name != "prespawn")
 -              if(cmd_name != "spawn")
 -              if(cmd_name != "begin")
 -              if(cmd_name != "pings")
 -              if(cmd_name != "sv_startdownload")
 -              if(cmd_name != "download")
 -              {
 -                      print("WARNING: Invalid clientcommand by ", self.netname, ": ", s, "\n");
 +      }
 +}
 +
 +void ClientCommand_teamstatus(float request)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
 +              {
 +                      Score_NicePrint(self);
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd teamstatus\n");
 +                      sprint(self, "  No arguments required.\n");
                        return;
                }
 -#endif
 +      }
 +}
  
 -              if(self.jointime > 0 && time > self.jointime + 10 && time > self.nickspamtime) // allow any changes in the first 10 seconds since joining
 -              if(cmd_name == "name" || cmd_name == "playermodel") // TODO also playerskin and color?
 +void ClientCommand_tell(float request, float argc, string command)
 +{
 +      switch(request)
 +      {
 +              case CC_REQUEST_COMMAND:
                {
 -                      if(self.nickspamtime == 0 || time > self.nickspamtime + autocvar_g_nick_flood_timeout)
 -                              // good, no serious flood
 -                              self.nickspamcount = 1;
 +                      entity e = GetCommandPlayerSlotTargetFromTokenizedCommand(argc, 1);
 +                      
 +                      if(e && argc > ParseCommandPlayerSlotTarget_firsttoken)
 +                      {
 +                              Say(self, FALSE, e, substring(command, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)), TRUE);
 +                      }
                        else
 -                              self.nickspamcount += 1;
 -                      self.nickspamtime = time + autocvar_g_nick_flood_penalty;
 -
 -                      if (timeoutStatus == 2) //when game is paused, no flood protection
 -                              self.nickspamcount = self.nickspamtime = 0;
 +                      {
 +                              if(argc > ParseCommandPlayerSlotTarget_firsttoken)
 +                                      trigger_magicear_processmessage_forallears(self, -1, world, substring(command, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)));
 +                      }
 +                      return; // never fall through to usage
 +              }
 +                      
 +              default:
 +              case CC_REQUEST_USAGE:
 +              {
 +                      sprint(self, "\nUsage:^3 cmd tell playerid <message>\n");
 +                      sprint(self, "  Where 'playerid' is the entity number of the player to send the 'message' to.\n");
 +                      return;
                }
 -
 -              clientcommand(self,s);
        }
  }
  
Simple merge
Simple merge
index 4e43f17fdae175842b88c3ba33d120b783339d10,5a575dd0e3dcb0a3833ebef50a0ed6d88fa83695..965c2743b590878c0e0e4c7bc8f2eef42e82c760
@@@ -3135,29 -3135,3 +3135,29 @@@ float isPushable(entity e
                return TRUE;
        return FALSE;
  }
- }
 +
 +// used by gamecommand/clientcommand/votecommand/bancommand system
 +float GetFilteredNumber(string input)
 +{
 +      entity tmp_player, selection;
 +      float output, matches;
 +      
 +      // check and see if we can get a number from input like "#3" or "3" 
 +      if(substring(input, 0, 1) == "#")
 +              output = stof(substring(input, 1, -1));
 +      else
 +              output = stof(input);
 +              
 +      // if we can't, check and see if we can match the input to the netname of any player in the game
 +      if not(output) 
 +      {
 +              FOR_EACH_CLIENT(tmp_player)
 +                      if (strdecolorize(tmp_player.netname) == strdecolorize(input))
 +                              selection = tmp_player;
 +
 +              if (selection) { output = num_for_edict(selection); }
 +      }
 +              
 +      print(strcat("input: ", input, ", output: ", ftos(output), ",\n"));
 +      return output;
++}
Simple merge