Skip to content

Commit b1bde99

Browse files
committed
Merge branch 'main' of https://github.com/Andreas-W/GeneralsGameCode_Modding into merge_SH
2 parents 34bdf15 + ae53b8c commit b1bde99

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DieModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class DieMuxData // does NOT inherit from ModuleData.
5454
VeterancyLevelFlags m_veterancyLevels;
5555
ObjectStatusMaskType m_exemptStatus; ///< die module is ignored if any of these status bits are set
5656
ObjectStatusMaskType m_requiredStatus; ///< die module is ignored if any of these status bits are clear
57+
Real m_minWaterDepth;
58+
Real m_maxWaterDepth;
5759

5860
DieMuxData();
5961
static const FieldParse* getFieldParse();

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/DieModule.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include "GameLogic/GameLogic.h"
3838
#include "GameLogic/Module/DieModule.h"
3939
#include "GameLogic/Object.h"
40+
#include <GameLogic/TerrainLogic.h>
41+
4042

4143

4244

@@ -50,6 +52,8 @@ DieMuxData::DieMuxData() {
5052
if (TheGlobalData) {
5153
m_deathTypes &= ~TheGlobalData->m_defaultExcludedDeathTypes;
5254
}
55+
m_minWaterDepth = 0.0f;
56+
m_maxWaterDepth = std::numeric_limits<Real>::infinity();
5357
}
5458

5559
//-------------------------------------------------------------------------------------------------
@@ -61,7 +65,9 @@ const FieldParse* DieMuxData::getFieldParse()
6165
{ "VeterancyLevels", INI::parseVeterancyLevelFlags, nullptr, offsetof( DieMuxData, m_veterancyLevels ) },
6266
{ "ExemptStatus", ObjectStatusMaskType::parseFromINI, nullptr, offsetof( DieMuxData, m_exemptStatus ) },
6367
{ "RequiredStatus", ObjectStatusMaskType::parseFromINI, nullptr, offsetof( DieMuxData, m_requiredStatus ) },
64-
{ nullptr, nullptr, nullptr, 0 }
68+
{ "MinWaterDepth", INI::parseReal, nullptr, offsetof(DieMuxData, m_minWaterDepth )},
69+
{ "MaxWaterDepth", INI::parseReal, nullptr, offsetof(DieMuxData, m_maxWaterDepth )},
70+
{ nullptr, nullptr, nullptr, 0 }
6571
};
6672
return dataFieldParse;
6773
}
@@ -86,6 +92,27 @@ Bool DieMuxData::isDieApplicable(const Object* obj, const DamageInfo *damageInfo
8692
if( m_requiredStatus.any() && !obj->getStatusBits().testForAll( m_requiredStatus ) )
8793
return false;
8894

95+
if ((m_minWaterDepth > 0.0f || m_maxWaterDepth < std::numeric_limits<Short>::infinity()) && obj != nullptr) {
96+
97+
// if on bride and we need water -> not applicable
98+
if (obj->getLayer() > LAYER_GROUND && m_minWaterDepth > 0.0f) {
99+
return false;
100+
}
101+
102+
// Water level restriction
103+
const Coord3D* pos = obj->getPosition();
104+
Real waterZ{ 0 }, terrainZ{ 0 };
105+
106+
if (TheTerrainLogic->isUnderwater(pos->x, pos->y, &waterZ, &terrainZ)) {
107+
Real depth = waterZ - terrainZ;
108+
return depth >= m_minWaterDepth && depth < m_maxWaterDepth;
109+
}
110+
else {
111+
// we are over land
112+
if (m_minWaterDepth > 0.0f) return false;
113+
}
114+
}
115+
89116
return true;
90117
}
91118

0 commit comments

Comments
 (0)