MultiplayerSettings.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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: MultiplayerSettings.cpp ///////////////////////////////////////////////////////////////////////////
  24. // The MultiplayerSettings object
  25. // Author: Matthew D. Campbell, January 2002
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #define DEFINE_TERRAIN_LOD_NAMES
  30. #define DEFINE_TIME_OF_DAY_NAMES
  31. #include "Common/MultiplayerSettings.h"
  32. #include "Common/INI.h"
  33. #include "GameNetwork/GameInfo.h" // for PLAYERTEMPLATE_*
  34. // PUBLIC DATA ////////////////////////////////////////////////////////////////////////////////////
  35. MultiplayerSettings *TheMultiplayerSettings = NULL; ///< The MultiplayerSettings singleton
  36. ///////////////////////////////////////////////////////////////////////////////////////////////////
  37. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  38. ///////////////////////////////////////////////////////////////////////////////////////////////////
  39. const FieldParse MultiplayerColorDefinition::m_colorFieldParseTable[] =
  40. {
  41. { "TooltipName", INI::parseAsciiString, NULL, offsetof( MultiplayerColorDefinition, m_tooltipName ) },
  42. { "RGBColor", INI::parseRGBColor, NULL, offsetof( MultiplayerColorDefinition, m_rgbValue ) },
  43. { "RGBNightColor", INI::parseRGBColor, NULL, offsetof( MultiplayerColorDefinition, m_rgbValueNight ) },
  44. { NULL, NULL, NULL, 0 } // keep this last
  45. };
  46. const FieldParse MultiplayerSettings::m_multiplayerSettingsFieldParseTable[] =
  47. {
  48. { "InitialCreditsMin", INI::parseInt, NULL, offsetof( MultiplayerSettings, m_initialCreditsMin ) },
  49. { "InitialCreditsMax", INI::parseInt, NULL, offsetof( MultiplayerSettings, m_initialCreditsMax ) },
  50. { "StartCountdownTimer", INI::parseInt, NULL, offsetof( MultiplayerSettings, m_startCountdownTimerSeconds ) },
  51. { "MaxBeaconsPerPlayer", INI::parseInt, NULL, offsetof( MultiplayerSettings, m_maxBeaconsPerPlayer ) },
  52. { "UseShroud", INI::parseBool, NULL, offsetof( MultiplayerSettings, m_isShroudInMultiplayer ) },
  53. { "ShowRandomPlayerTemplate", INI::parseBool, NULL, offsetof( MultiplayerSettings, m_showRandomPlayerTemplate ) },
  54. { "ShowRandomStartPos", INI::parseBool, NULL, offsetof( MultiplayerSettings, m_showRandomStartPos ) },
  55. { "ShowRandomColor", INI::parseBool, NULL, offsetof( MultiplayerSettings, m_showRandomColor ) },
  56. { NULL, NULL, NULL, 0 } // keep this last
  57. };
  58. //-------------------------------------------------------------------------------------------------
  59. //-------------------------------------------------------------------------------------------------
  60. MultiplayerSettings::MultiplayerSettings()
  61. {
  62. m_initialCreditsMin = 5000;
  63. //Fixed And Added Code By Sadullah Nader
  64. //DID U MEAN m_initialCreditsMax = 10000;?
  65. //Initializations inserted
  66. m_initialCreditsMax = 10000;
  67. m_maxBeaconsPerPlayer = 3;
  68. //
  69. m_startCountdownTimerSeconds = 0;
  70. m_numColors = 0;
  71. m_isShroudInMultiplayer = TRUE;
  72. m_showRandomPlayerTemplate = TRUE;
  73. m_showRandomStartPos = TRUE;
  74. m_showRandomColor = TRUE;
  75. m_observerColor;
  76. m_randomColor;
  77. } // end MultiplayerSettings
  78. MultiplayerColorDefinition::MultiplayerColorDefinition()
  79. {
  80. m_tooltipName.clear();
  81. m_rgbValue.setFromInt(0xFFFFFFFF);
  82. m_rgbValueNight=m_rgbValue;
  83. m_color = 0xFFFFFFFF;
  84. m_colorNight = m_color;
  85. }
  86. MultiplayerColorDefinition * MultiplayerSettings::getColor(Int which)
  87. {
  88. if (which == PLAYERTEMPLATE_RANDOM)
  89. {
  90. return &m_randomColor;
  91. }
  92. else if (which == PLAYERTEMPLATE_OBSERVER)
  93. {
  94. return &m_observerColor;
  95. }
  96. else if (which < 0 || which >= getNumColors())
  97. {
  98. return NULL;
  99. }
  100. return &m_colorList[which];
  101. }
  102. MultiplayerColorDefinition * MultiplayerSettings::findMultiplayerColorDefinitionByName(AsciiString name)
  103. {
  104. MultiplayerColorIter iter = m_colorList.begin();
  105. while (iter != m_colorList.end())
  106. {
  107. if (iter->second.getTooltipName() == name)
  108. return &(iter->second);
  109. ++iter;
  110. }
  111. return NULL;
  112. }
  113. MultiplayerColorDefinition * MultiplayerSettings::newMultiplayerColorDefinition(AsciiString name)
  114. {
  115. MultiplayerColorDefinition tmp;
  116. Int numColors = getNumColors();
  117. m_colorList[numColors] = tmp;
  118. m_numColors = m_colorList.size();
  119. return &m_colorList[numColors];
  120. }
  121. MultiplayerColorDefinition * MultiplayerColorDefinition::operator =(const MultiplayerColorDefinition& other)
  122. {
  123. m_tooltipName = other.getTooltipName();
  124. m_rgbValue = other.getRGBValue();
  125. m_color = other.getColor();
  126. m_rgbValueNight = other.getRGBNightValue();
  127. m_colorNight = other.getNightColor();
  128. return this;
  129. }
  130. void MultiplayerColorDefinition::setColor( RGBColor rgb )
  131. {
  132. m_color = rgb.getAsInt() | 0xFF << 24;
  133. }
  134. void MultiplayerColorDefinition::setNightColor( RGBColor rgb )
  135. {
  136. m_colorNight = rgb.getAsInt() | 0xFF << 24;
  137. }