DisplayStringManager.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. ** Command & Conquer Generals(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. // FILE: DisplayStringManager.cpp /////////////////////////////////////////////////////////////////
  24. // Created: Colin Day, July 2001
  25. // Desc: Access for creating game managed display strings
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  28. #include "GameClient/DisplayStringManager.h"
  29. // PUBLIC DATA ////////////////////////////////////////////////////////////////////////////////////
  30. DisplayStringManager *TheDisplayStringManager = NULL;
  31. ///////////////////////////////////////////////////////////////////////////////////////////////////
  32. // PUBLIC FUNCTIONS
  33. ///////////////////////////////////////////////////////////////////////////////////////////////////
  34. //-------------------------------------------------------------------------------------------------
  35. //-------------------------------------------------------------------------------------------------
  36. DisplayStringManager::DisplayStringManager( void )
  37. {
  38. m_stringList = NULL;
  39. m_currentCheckpoint = NULL;
  40. } // end DisplayStringManager
  41. //-------------------------------------------------------------------------------------------------
  42. //-------------------------------------------------------------------------------------------------
  43. DisplayStringManager::~DisplayStringManager( void )
  44. {
  45. //
  46. // we only keep track of the strings, we do NOT de-allocate them, our
  47. // list better be cleaned out before we destroy ourselves
  48. //
  49. assert( m_stringList == NULL );
  50. } // end ~DisplayStringManager
  51. //-------------------------------------------------------------------------------------------------
  52. /** Link a display string to the master list */
  53. //-------------------------------------------------------------------------------------------------
  54. void DisplayStringManager::link( DisplayString *string )
  55. {
  56. assert( string );
  57. assert( string->m_next == NULL );
  58. assert( string->m_prev == NULL );
  59. string->m_next = m_stringList;
  60. if( m_stringList )
  61. m_stringList->m_prev = string;
  62. m_stringList = string;
  63. } // end link
  64. //-------------------------------------------------------------------------------------------------
  65. /** Unlink a display string from the master list */
  66. //-------------------------------------------------------------------------------------------------
  67. void DisplayStringManager::unLink( DisplayString *string )
  68. {
  69. assert( string );
  70. assert( m_stringList );
  71. if( string->m_next )
  72. string->m_next->m_prev = string->m_prev;
  73. if( string->m_prev )
  74. string->m_prev->m_next = string->m_next;
  75. else
  76. {
  77. assert( string == m_stringList );
  78. m_stringList = string->m_next;
  79. } // end else
  80. } // end unLink