@@ -3984,13 +3984,7 @@ DrawModule** Drawable::getDrawModules()
39843984 }
39853985 else
39863986 {
3987- for (DrawModule** dm2 = dm; *dm2; ++dm2)
3988- {
3989- ObjectDrawInterface* di = (*dm2)->getObjectDrawInterface ();
3990- if (di)
3991- di->replaceModelConditionState ( m_conditionState );
3992- }
3993- m_isModelDirty = false ;
3987+ replaceModelConditionStateInDrawable ();
39943988 }
39953989 }
39963990#endif
@@ -4016,14 +4010,7 @@ DrawModule const** Drawable::getDrawModules() const
40164010 }
40174011 else
40184012 {
4019- // yeah, yeah, yeah... I know (srj)
4020- for (DrawModule** dm2 = (DrawModule**)dm; *dm2; ++dm2)
4021- {
4022- ObjectDrawInterface* di = (*dm2)->getObjectDrawInterface ();
4023- if (di)
4024- di->replaceModelConditionState ( m_conditionState );
4025- }
4026- m_isModelDirty = false ;
4013+ const_cast <Drawable*>(this )->replaceModelConditionStateInDrawable ();
40274014 }
40284015 }
40294016#endif
@@ -4046,12 +4033,7 @@ void Drawable::clearAndSetModelConditionFlags(const ModelConditionFlags& clr, co
40464033#ifdef DIRTY_CONDITION_FLAGS
40474034 m_isModelDirty = true ;
40484035#else
4049- for (DrawModule** dm = getDrawModules (); *dm; ++dm)
4050- {
4051- ObjectDrawInterface* di = (*dm)->getObjectDrawInterface ();
4052- if (di)
4053- di->replaceModelConditionState ( m_conditionState );
4054- }
4036+ replaceModelConditionStateInDrawable ();
40554037#endif
40564038}
40574039
@@ -4073,24 +4055,37 @@ void Drawable::replaceModelConditionFlags( const ModelConditionFlags &flags, Boo
40734055 // when forcing a replace we won't use dirty flags, we will immediately do an update now
40744056 if ( forceReplace == TRUE )
40754057 {
4076- for (DrawModule** dm = getDrawModules (); *dm; ++dm)
4077- {
4078- ObjectDrawInterface* di = (*dm)->getObjectDrawInterface ();
4079- if (di)
4080- di->replaceModelConditionState ( m_conditionState );
4081- }
4082- m_isModelDirty = false ;
4058+ replaceModelConditionStateInDrawable ();
40834059 }
40844060 else
4061+ {
40854062 m_isModelDirty = true ;
4063+ }
40864064#else
4065+ replaceModelConditionStateInDrawable ();
4066+ #endif
4067+ }
4068+
4069+ // -------------------------------------------------------------------------------------------------
4070+ void Drawable::replaceModelConditionStateInDrawable ()
4071+ {
4072+ // TheSuperHackers @info Set not dirty early to avoid recursive calls from within getDrawModules().
4073+ m_isModelDirty = false ;
4074+
4075+ // TheSuperHackers @bugfix Remove and re-add the terrain decal before processing the individual draw
4076+ // modules, because the terrain decal is applied to the first draw module only, and the new first
4077+ // draw module may be different than before.
4078+ const TerrainDecalType terrainDecalType = getTerrainDecalType ();
4079+ setTerrainDecal (TERRAIN_DECAL_NONE);
4080+
40874081 for (DrawModule** dm = getDrawModules (); *dm; ++dm)
40884082 {
40894083 ObjectDrawInterface* di = (*dm)->getObjectDrawInterface ();
40904084 if (di)
40914085 di->replaceModelConditionState ( m_conditionState );
40924086 }
4093- #endif
4087+
4088+ setTerrainDecal (terrainDecalType);
40944089}
40954090
40964091// -------------------------------------------------------------------------------------------------
0 commit comments