radio.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //******************************************************************************************
  2. //
  3. // Radio.h -- File contains the Radio Definition
  4. //
  5. // MechCommander 2
  6. //
  7. //---------------------------------------------------------------------------//
  8. // Copyright (C) Microsoft Corporation. All rights reserved. //
  9. //===========================================================================//
  10. #ifndef RADIO_H
  11. #define RADIO_H
  12. //------------------------------------------------------------------------------------------
  13. // Include Files
  14. #ifndef MCLIB_H
  15. #include "mclib.h"
  16. #endif
  17. #ifndef DRADIO_H
  18. #include "dradio.h"
  19. #endif
  20. #ifndef DWARRIOR_H
  21. #include "dwarrior.h"
  22. #endif
  23. #ifndef DGAMEOBJ_H
  24. #include "dgameobj.h"
  25. #endif
  26. //------------------------------------------------------------------------------------------
  27. #define MAX_FRAGMENTS 16
  28. #define MAX_RADIOS 256
  29. struct RadioData
  30. {
  31. unsigned long msgId;
  32. unsigned long msgType;
  33. unsigned long noiseId;
  34. long numFragments;
  35. MemoryPtr data[MAX_FRAGMENTS];
  36. long dataSize[MAX_FRAGMENTS];
  37. MemoryPtr noise[MAX_FRAGMENTS];
  38. long noiseSize[MAX_FRAGMENTS];
  39. UserHeapPtr msgHeap;
  40. unsigned long turnQueued;
  41. byte priority;
  42. byte movieCode;
  43. float expirationDate;
  44. MechWarriorPtr pilot;
  45. };
  46. struct RadioMessageInfo
  47. {
  48. byte priority;
  49. float shelfLife;
  50. char movieCode;
  51. byte styleCount;
  52. byte styleChance[3];
  53. DWORD messageMapping;
  54. bool pilotIdentifiesSelf;
  55. bool kludgeStyle;
  56. };
  57. //------------------------------------------------------------------------------------------
  58. class Radio
  59. {
  60. //Data Members
  61. //-------------
  62. protected:
  63. MechWarriorPtr owner;
  64. bool enabled;
  65. bool ammoOutPlayed;
  66. long radioID;
  67. public:
  68. static PacketFilePtr noiseFile;
  69. static RadioPtr radioList[MAX_RADIOS]; //Warriors no longer delete their radios. We do when the
  70. //SoundSystem Shutdown occurs.
  71. static PacketFilePtr messagesFile[MAX_RADIOS]; //Do these when the shutdown occurs too to avoid leaks
  72. static bool messageInfoLoaded;
  73. static bool radioListGo;
  74. static long currentRadio;
  75. static UserHeapPtr radioHeap; //Only one Heap Per Game!!!
  76. //Member Functions
  77. //-----------------
  78. public:
  79. void * operator new (size_t mySize);
  80. void operator delete (void * us);
  81. void init (void)
  82. {
  83. enabled = TRUE;
  84. ammoOutPlayed = false;
  85. radioID = -1;
  86. }
  87. void destroy (void)
  88. {
  89. }
  90. Radio (void)
  91. {
  92. init();
  93. }
  94. ~Radio (void)
  95. {
  96. destroy();
  97. }
  98. long init (char *fileName, unsigned long heapSize, char *movie);
  99. void setOwner (MechWarriorPtr _owner)
  100. {
  101. owner = _owner;
  102. }
  103. long playMessage (RadioMessageType msgId);
  104. void cancelMessage (RadioMessageType msgId);
  105. void turnOn (void) {
  106. enabled = TRUE;
  107. }
  108. void turnOff (void) {
  109. enabled = FALSE;
  110. }
  111. long loadMessageInfo(void);
  112. void resetAmmoMessage (void)
  113. {
  114. ammoOutPlayed = false;
  115. }
  116. };
  117. //------------------------------------------------------------------------------------------
  118. #endif