AutoStart.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/AutoStart.h $*
  25. * *
  26. * $Author:: Steve_t $*
  27. * *
  28. * $Modtime:: 8/13/02 4:57p $*
  29. * *
  30. * $Revision:: 6 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #pragma once
  36. #ifndef _AUTOSTART_H
  37. #define _AUTOSTART_H
  38. #include "WOLLogonMgr.h"
  39. #include <wwlib\signaler.h>
  40. #include "wolgmode.h"
  41. #include "menudialog.h"
  42. #include "resource.h"
  43. #include <wwonline\refptr.h>
  44. #include <wwonline\wolsession.h>
  45. namespace WOL {
  46. class WOLSession;
  47. class ServerError;
  48. }
  49. /*
  50. **
  51. ** This class handles restarting a server after a crash or system reboot.
  52. **
  53. **
  54. */
  55. class AutoRestartClass : public Observer<WOLLogonAction>, public Observer<WWOnline::ServerError>, protected Signaler<WolGameModeClass>
  56. {
  57. public:
  58. /*
  59. ** Constructor, destructor.
  60. */
  61. AutoRestartClass(void);
  62. /*
  63. ** Misc public functions.
  64. */
  65. void Restart_Game(void);
  66. void Think(void);
  67. bool Is_Active(void) {return((bool)(RestartState != STATE_DONE));}
  68. void Set_Restart_Flag(bool enable);
  69. bool Get_Restart_Flag(void);
  70. void Cancel(void);
  71. /*
  72. ** Callbacks.
  73. */
  74. void HandleNotification(WOLLogonAction&);
  75. void HandleNotification(WWOnline::ServerError& server_error);
  76. void ReceiveSignal(WolGameModeClass&);
  77. /*
  78. ** Enum of steps to go through to restart a game.
  79. */
  80. typedef enum {
  81. STATE_FIRST,
  82. STATE_GAME_MODE_WAIT,
  83. STATE_LOGIN,
  84. STATE_CREATE_GAME,
  85. STATE_CREATE_CHANNEL,
  86. STATE_WAIT_CHANNEL_CREATE,
  87. STATE_WAIT_CHANNEL_CREATE_RETRY,
  88. STATE_START_GAME,
  89. STATE_CANCELLED,
  90. STATE_DONE,
  91. } RestartStateType;
  92. static const char *REG_VALUE_AUTO_RESTART_FLAG;
  93. static const char *REG_VALUE_AUTO_RESTART_TYPE;
  94. private:
  95. /*
  96. ** WOL Login state.
  97. */
  98. WOLLogonAction LogonAction;
  99. /*
  100. ** Restart state.
  101. */
  102. RestartStateType RestartState;
  103. /*
  104. ** Cancel request flag.
  105. */
  106. bool CancelRequest;
  107. /*
  108. ** Game mode. 0 = LAN, 1 = internet.
  109. */
  110. int GameMode;
  111. /*
  112. ** Reference pointer to WOLSession.
  113. */
  114. RefPtr<WWOnline::Session> WOLSession;
  115. /*
  116. ** Time we last tried to create the game channel.
  117. */
  118. unsigned long LastChannelCreateTime;
  119. /*
  120. ** Number of times we tried to create the channel.
  121. */
  122. int NumChannelCreateTries;
  123. };
  124. extern AutoRestartClass AutoRestart;
  125. #endif //_AUTOSTART_H