inputconfig.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/commando/inputconfig.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 7/18/01 6:09p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "inputconfig.h"
  36. #include "chunkio.h"
  37. #include "debug.h"
  38. ////////////////////////////////////////////////////////////////
  39. // Save/load constants
  40. ////////////////////////////////////////////////////////////////
  41. enum
  42. {
  43. CHUNKID_VARIABLES = 0x07181106,
  44. };
  45. enum
  46. {
  47. VARID_DISPLAY_NAME = 1,
  48. VARID_FILENAME,
  49. VARID_IS_DEFAULT,
  50. VARID_IS_CUSTOM,
  51. };
  52. ////////////////////////////////////////////////////////////////
  53. //
  54. // Save
  55. //
  56. ////////////////////////////////////////////////////////////////
  57. void
  58. InputConfigClass::Save (ChunkSaveClass &csave)
  59. {
  60. //
  61. // Save the variables to their own chunk
  62. //
  63. csave.Begin_Chunk (CHUNKID_VARIABLES);
  64. WRITE_MICRO_CHUNK_WIDESTRING (csave, VARID_DISPLAY_NAME, DisplayName);
  65. WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_FILENAME, Filename);
  66. WRITE_MICRO_CHUNK (csave, VARID_IS_DEFAULT, IsDefault);
  67. WRITE_MICRO_CHUNK (csave, VARID_IS_CUSTOM, IsCustom);
  68. csave.End_Chunk ();
  69. return ;
  70. }
  71. ////////////////////////////////////////////////////////////////
  72. //
  73. // Load
  74. //
  75. ////////////////////////////////////////////////////////////////
  76. void
  77. InputConfigClass::Load (ChunkLoadClass &cload)
  78. {
  79. //
  80. // Read all the sub-chunks
  81. //
  82. while (cload.Open_Chunk ()) {
  83. switch (cload.Cur_Chunk_ID ()) {
  84. case CHUNKID_VARIABLES:
  85. Load_Variables (cload);
  86. break;
  87. default:
  88. Debug_Say (("Unrecognized InputConfigClass::Load Chunk ID\n"));
  89. break;
  90. }
  91. cload.Close_Chunk ();
  92. }
  93. return ;
  94. }
  95. ////////////////////////////////////////////////////////////////
  96. //
  97. // Load_Variables
  98. //
  99. ////////////////////////////////////////////////////////////////
  100. void
  101. InputConfigClass::Load_Variables (ChunkLoadClass &cload)
  102. {
  103. //
  104. // Read all the microchunks
  105. //
  106. while (cload.Open_Micro_Chunk ()) {
  107. switch(cload.Cur_Micro_Chunk_ID ()) {
  108. READ_MICRO_CHUNK_WIDESTRING (cload, VARID_DISPLAY_NAME, DisplayName);
  109. READ_MICRO_CHUNK_WWSTRING (cload, VARID_FILENAME, Filename);
  110. READ_MICRO_CHUNK (cload, VARID_IS_DEFAULT, IsDefault);
  111. READ_MICRO_CHUNK (cload, VARID_IS_CUSTOM, IsCustom);
  112. }
  113. cload.Close_Micro_Chunk ();
  114. }
  115. return ;
  116. }
  117. ////////////////////////////////////////////////////////////////
  118. //
  119. // operator=
  120. //
  121. ////////////////////////////////////////////////////////////////
  122. const InputConfigClass &
  123. InputConfigClass::operator= (const InputConfigClass &src)
  124. {
  125. if (&src != this) {
  126. DisplayName = src.DisplayName;
  127. Filename = src.Filename;
  128. IsDefault = src.IsDefault;
  129. IsCustom = src.IsCustom;
  130. }
  131. return *this;
  132. }