NetCommandRef.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  24. #include "GameNetwork/NetCommandRef.h"
  25. #ifdef DEBUG_NETCOMMANDREF
  26. static UnsignedInt refNum = 0;
  27. #endif
  28. /**
  29. * Constructor. Attach to the given network command.
  30. */
  31. #ifdef DEBUG_NETCOMMANDREF
  32. NetCommandRef::NetCommandRef(NetCommandMsg *msg, char *filename, int line)
  33. #else
  34. NetCommandRef::NetCommandRef(NetCommandMsg *msg)
  35. #endif
  36. {
  37. m_msg = msg;
  38. m_next = NULL;
  39. m_prev = NULL;
  40. m_msg->attach();
  41. m_timeLastSent = -1;
  42. #ifdef DEBUG_NETCOMMANDREF
  43. m_id = ++refNum;
  44. DEBUG_LOG(("NetCommandRef %d allocated in file %s line %d\n", m_id, filename, line));
  45. #endif
  46. }
  47. /**
  48. * Destructor. Detach from the network command.
  49. */
  50. NetCommandRef::~NetCommandRef()
  51. {
  52. if (m_msg != NULL)
  53. {
  54. m_msg->detach();
  55. }
  56. DEBUG_ASSERTCRASH(m_next == NULL, ("NetCommandRef::~NetCommandRef - m_next != NULL"));
  57. DEBUG_ASSERTCRASH(m_prev == NULL, ("NetCommandRef::~NetCommandRef - m_prev != NULL"));
  58. #ifdef DEBUG_NETCOMMANDREF
  59. DEBUG_LOG(("NetCommandRef %d deleted\n", m_id));
  60. #endif
  61. }