Loading

rcon3.diff

  1. Index: src/console_cmds.cpp
  2. ===================================================================
  3. --- src/console_cmds.cpp    (Revision 20473)
  4. +++ src/console_cmds.cpp    (Arbeitskopie)
  5. @@ -18,6 +18,7 @@
  6.  #include "network/network.h"
  7.  #include "network/network_func.h"
  8.  #include "network/network_base.h"
  9. +#include "network/core/config.h"
  10.  #include "command_func.h"
  11.  #include "settings_func.h"
  12.  #include "fios.h"
  13. @@ -570,16 +571,35 @@
  14.  {
  15.     if (argc == 0) {
  16.         IConsoleHelp("Remote control the server from another client. Usage: 'rcon <password> <command>'");
  17. -       IConsoleHelp("Remember to enclose the command in quotes, otherwise only the first parameter is sent");
  18.         return true;
  19.     }
  20.  
  21.     if (argc < 3) return false;
  22.  
  23. +   char buf[NETWORK_RCONCOMMAND_LENGTH];
  24. +   char* end = buf;
  25. +
  26. +   if (argc == 3) {
  27. +       end = strecat(buf, argv[2], lastof(buf));
  28. +   } else {
  29. +       strecat(buf, "\"", lastof(buf));
  30. +       strecat(buf, argv[2], lastof(buf));
  31. +       for (int i=3; i<argc; i++) {
  32. +           strecat(buf, "\" \"", lastof(buf));
  33. +           strecat(buf, argv[i], lastof(buf));
  34. +       }
  35. +       end = strecat(buf, "\"", lastof(buf));
  36. +   }
  37. +
  38. +   if (end == lastof(buf)) {
  39. +       IConsoleError("Command string too long");
  40. +       return false;
  41. +   }
  42. +
  43.     if (_network_server) {
  44. -       IConsoleCmdExec(argv[2]);
  45. +       IConsoleCmdExec(buf);
  46.     } else {
  47. -       NetworkClientSendRcon(argv[1], argv[2]);
  48. +       NetworkClientSendRcon(argv[1], buf);
  49.     }
  50.     return true;
  51.  }

Comments