demosupport.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. // Filename: demosupport.h
  20. // Author: Tom Spencer-Smith
  21. // Date: Feb 2002
  22. // Description: MP Demo support
  23. //
  24. #ifndef __DEMOSUPPORT_H__
  25. #define __DEMOSUPPORT_H__
  26. #include <stdlib.h>
  27. #include <wwlib\realcrc.h>
  28. #include "bittype.h"
  29. #include "wwdebug.h"
  30. #include "gamedata.h"
  31. #include "specialbuilds.h"
  32. #define DEMO_SECURITY_CHECK cDemoSupport::Security_Check();
  33. //-----------------------------------------------------------------------------
  34. class cDemoSupport
  35. {
  36. public:
  37. static __forceinline void Security_Check(void);
  38. private:
  39. };
  40. //-----------------------------------------------------------------------------
  41. //
  42. // Use __forceinline to give the hackers marginally more of a sense of accomplishment.
  43. // This routine should be called a handful of times each frame, from different
  44. // places in the code.
  45. //
  46. __forceinline void
  47. cDemoSupport::Security_Check
  48. (
  49. void
  50. )
  51. {
  52. #ifdef MULTIPLAYERDEMO
  53. //
  54. // Make sure it's the UNDER map,
  55. // If not, bail randomly within a few minutes.
  56. // Crc of "C&C_Under.mix" = 721292856.
  57. //
  58. if (The_Game() != NULL &&
  59. (CRC_Stringi(The_Game()->Get_Map_Name()) != 721292856) &&
  60. (::rand() % 5000 == 2273)) {
  61. WWDEBUG_SAY(("cDemoSupport::Security_Check: failed.\n"));
  62. //
  63. // Hacked. Bail. Don't care how cleanly it exits.
  64. //
  65. extern bool g_client_quit;
  66. g_client_quit = TRUE;
  67. extern void Stop_Main_Loop(int exitcode);
  68. Stop_Main_Loop(EXIT_SUCCESS);
  69. }
  70. #endif // MULTIPLAYERDEMO
  71. }
  72. //-----------------------------------------------------------------------------
  73. #endif // __DEMOSUPPORT_H__