NetCommandRef.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. #pragma once
  24. #ifndef __NETCOMMANDREF_H
  25. #define __NETCOMMANDREF_H
  26. #include "GameNetwork/NetCommandMsg.h"
  27. #include "Common/GameMemory.h"
  28. #if defined(_INTERNAL) || defined(_DEBUG)
  29. // #define DEBUG_NETCOMMANDREF
  30. #endif
  31. #ifdef DEBUG_NETCOMMANDREF
  32. #define NEW_NETCOMMANDREF(msg) newInstance(NetCommandRef)(msg, __FILE__, __LINE__)
  33. #else
  34. #define NEW_NETCOMMANDREF(msg) newInstance(NetCommandRef)(msg)
  35. #endif
  36. class NetCommandRef : public MemoryPoolObject
  37. {
  38. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetCommandRef, "NetCommandRef")
  39. public:
  40. #ifdef DEBUG_NETCOMMANDREF
  41. NetCommandRef(NetCommandMsg *msg, char *filename, int line);
  42. #else
  43. NetCommandRef(NetCommandMsg *msg);
  44. #endif
  45. //~NetCommandRef();
  46. NetCommandMsg *getCommand();
  47. NetCommandRef *getNext();
  48. NetCommandRef *getPrev();
  49. void setNext(NetCommandRef *next);
  50. void setPrev(NetCommandRef *prev);
  51. void setRelay(UnsignedByte relay);
  52. UnsignedByte getRelay() const;
  53. time_t getTimeLastSent() const;
  54. void setTimeLastSent(time_t timeLastSent);
  55. protected:
  56. NetCommandMsg *m_msg;
  57. NetCommandRef *m_next;
  58. NetCommandRef *m_prev;
  59. UnsignedByte m_relay; ///< Need this in the command reference since the relay value will be different depending on where this particular reference is being sent.
  60. time_t m_timeLastSent;
  61. #ifdef DEBUG_NETCOMMANDREF
  62. UnsignedInt m_id;
  63. #endif
  64. };
  65. /**
  66. * Return the command message.
  67. */
  68. inline NetCommandMsg * NetCommandRef::getCommand()
  69. {
  70. return m_msg;
  71. }
  72. /**
  73. * Return the next command ref in the list.
  74. */
  75. inline NetCommandRef * NetCommandRef::getNext()
  76. {
  77. return m_next;
  78. }
  79. /**
  80. * Return the previous command ref in the list.
  81. */
  82. inline NetCommandRef * NetCommandRef::getPrev()
  83. {
  84. return m_prev;
  85. }
  86. /**
  87. * Set the next command ref in the list.
  88. */
  89. inline void NetCommandRef::setNext(NetCommandRef *next)
  90. {
  91. m_next = next;
  92. }
  93. /**
  94. * Set the previous command ref in the list.
  95. */
  96. inline void NetCommandRef::setPrev(NetCommandRef *prev)
  97. {
  98. m_prev = prev;
  99. }
  100. /**
  101. * Return the time for the last time this command was sent from this reference.
  102. */
  103. inline time_t NetCommandRef::getTimeLastSent() const
  104. {
  105. return m_timeLastSent;
  106. }
  107. /**
  108. * Set the time for the last time this command was sent from this reference.
  109. */
  110. inline void NetCommandRef::setTimeLastSent(time_t timeLastSent)
  111. {
  112. m_timeLastSent = timeLastSent;
  113. }
  114. /**
  115. * Set the send relay for this reference of the command.
  116. */
  117. inline void NetCommandRef::setRelay(UnsignedByte relay)
  118. {
  119. m_relay = relay;
  120. }
  121. /**
  122. * Return the send relay for this refreence of the command.
  123. */
  124. inline UnsignedByte NetCommandRef::getRelay() const
  125. {
  126. return m_relay;
  127. }
  128. #endif // #ifndef __NETCOMMANDREF_H