slavemaster.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/slavemaster.h $*
  25. * *
  26. * Author:: Steve Tall *
  27. * *
  28. * $Modtime:: 1/07/02 2:58p $*
  29. * *
  30. * $Revision:: 8 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #pragma once
  36. #ifndef _SLAVEMASTER_H
  37. #define _SLAVEMASTER_H
  38. #include <winbase.h>
  39. #define MAX_SLAVES 7
  40. class SlaveMasterClass;
  41. /*
  42. **
  43. ** One of these classes for each slave server.
  44. **
  45. */
  46. class SlaveServerClass
  47. {
  48. friend SlaveMasterClass;
  49. public:
  50. SlaveServerClass(void);
  51. ~SlaveServerClass(void);
  52. void Set(bool enable, char *nick, char *serial, unsigned short port, char *settings_file, int bandwidth, char *password);
  53. void Get(bool &enable, char *nick, char *serial, unsigned short &port, char *settings_file, int &bandwidth, char *password);
  54. private:
  55. char NickName[32];
  56. char Serial[64];
  57. char Password[64];
  58. unsigned short Port;
  59. char SettingsFileName[MAX_PATH];
  60. bool Enable;
  61. bool IsRunning;
  62. unsigned short ControlPort;
  63. int Bandwidth;
  64. PROCESS_INFORMATION ProcessInfo;
  65. };
  66. /*
  67. **
  68. ** Master server uses this class to manage slave servers.
  69. **
  70. **
  71. */
  72. class SlaveMasterClass
  73. {
  74. public:
  75. SlaveMasterClass(void);
  76. ~SlaveMasterClass(void);
  77. void Startup_Slaves(void);
  78. void Shutdown_Slaves(void);
  79. bool Shutdown_Slave(char *slave_login);
  80. char *Get_Slave_Info(char *buffer, int buflen);
  81. void Load(void);
  82. void Save(void);
  83. void Reset(void);
  84. int Get_Num_Slaves(void) {return(NumSlaveServers);}
  85. int Get_Num_Enabled_Slaves(void);
  86. void Add_Slave(bool enable, char *nick, char *serial, unsigned short port, char *settings_file, int bandwidth, char *password);
  87. SlaveServerClass *Get_Slave(int index);
  88. void Set_Slave_Mode(bool mode) {SlaveMode = mode;}
  89. bool Am_I_Slave(void) {return(SlaveMode);}
  90. private:
  91. void Delete_Registry_Copies(void);
  92. void Create_Registry_Copies(void);
  93. bool Aquire_Slave(int index);
  94. void Wait_For_Slave_Shutdown(void);
  95. SlaveServerClass SlaveServers[MAX_SLAVES];
  96. int NumSlaveServers;
  97. bool SlaveMode; // false = master, true = slave
  98. };
  99. extern SlaveMasterClass SlaveMaster;
  100. #endif //_SLAVEMASTER_H