W3DScienceModelDraw.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. // FILE: W3DScienceModelDraw.cpp ////////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, NOVEMBER 2002
  25. // Desc: Draw module just like Model, except it only draws if the local player has the specified science
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #include "W3DDevice/GameClient/Module/W3DScienceModelDraw.h"
  28. #include "Common/Player.h"
  29. #include "Common/PlayerList.h"
  30. #include "Common/Science.h"
  31. #include "Common/Xfer.h"
  32. //-------------------------------------------------------------------------------------------------
  33. W3DScienceModelDrawModuleData::W3DScienceModelDrawModuleData()
  34. {
  35. m_requiredScience = SCIENCE_INVALID;
  36. }
  37. //-------------------------------------------------------------------------------------------------
  38. W3DScienceModelDrawModuleData::~W3DScienceModelDrawModuleData()
  39. {
  40. }
  41. //-------------------------------------------------------------------------------------------------
  42. void W3DScienceModelDrawModuleData::buildFieldParse(MultiIniFieldParse& p)
  43. {
  44. W3DModelDrawModuleData::buildFieldParse(p);
  45. static const FieldParse dataFieldParse[] =
  46. {
  47. { "RequiredScience", INI::parseScience, NULL, offsetof(W3DScienceModelDrawModuleData, m_requiredScience) },
  48. { 0, 0, 0, 0 }
  49. };
  50. p.add(dataFieldParse);
  51. }
  52. //-------------------------------------------------------------------------------------------------
  53. //-------------------------------------------------------------------------------------------------
  54. W3DScienceModelDraw::W3DScienceModelDraw( Thing *thing, const ModuleData* moduleData ) : W3DModelDraw( thing, moduleData )
  55. {
  56. }
  57. //-------------------------------------------------------------------------------------------------
  58. W3DScienceModelDraw::~W3DScienceModelDraw()
  59. {
  60. }
  61. //-------------------------------------------------------------------------------------------------
  62. // All this does is stop the call path if we haven't been cleared to draw yet
  63. void W3DScienceModelDraw::doDrawModule(const Matrix3D* transformMtx)
  64. {
  65. ScienceType science = getW3DScienceModelDrawModuleData()->m_requiredScience;
  66. if( science == SCIENCE_INVALID )
  67. {
  68. DEBUG_ASSERTCRASH(science != SCIENCE_INVALID, ("ScienceModelDraw has invalid science as condition.") );
  69. setHidden( TRUE );
  70. return;
  71. }
  72. if( !ThePlayerList->getLocalPlayer()->hasScience(science)
  73. && ThePlayerList->getLocalPlayer()->isPlayerActive()
  74. )
  75. {
  76. // We just don't draw for people without our science except for Observers
  77. setHidden( TRUE );
  78. return;
  79. }
  80. W3DModelDraw::doDrawModule(transformMtx);
  81. }
  82. // ------------------------------------------------------------------------------------------------
  83. /** CRC */
  84. // ------------------------------------------------------------------------------------------------
  85. void W3DScienceModelDraw::crc( Xfer *xfer )
  86. {
  87. // extend base class
  88. W3DModelDraw::crc( xfer );
  89. } // end crc
  90. // ------------------------------------------------------------------------------------------------
  91. /** Xfer method
  92. * Version Info:
  93. * 1: Initial version */
  94. // ------------------------------------------------------------------------------------------------
  95. void W3DScienceModelDraw::xfer( Xfer *xfer )
  96. {
  97. // version
  98. XferVersion currentVersion = 1;
  99. XferVersion version = currentVersion;
  100. xfer->xferVersion( &version, currentVersion );
  101. // extend base class
  102. W3DModelDraw::xfer( xfer );
  103. } // end xfer
  104. // ------------------------------------------------------------------------------------------------
  105. /** Load post process */
  106. // ------------------------------------------------------------------------------------------------
  107. void W3DScienceModelDraw::loadPostProcess( void )
  108. {
  109. // extend base class
  110. W3DModelDraw::loadPostProcess();
  111. } // end loadPostProcess