Skip to content

Commit 7ac7a41

Browse files
committed
bugfix(drawable): Fix locked color in Drawable::colorTint, EMPUpdate::update (#1579)
1 parent 792d17d commit 7ac7a41

File tree

6 files changed

+12
-36
lines changed

6 files changed

+12
-36
lines changed

Generals/Code/GameEngine/Include/GameClient/Drawable.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class TintEnvelope : public MemoryPoolObject, public Snapshot
168168
TintEnvelope(void);
169169
void update(void); ///< does all the work
170170
void play(const RGBColor *peak,
171-
UnsignedInt atackFrames = DEF_ATTACK_FRAMES,
171+
UnsignedInt attackFrames = DEF_ATTACK_FRAMES,
172172
UnsignedInt decayFrames = DEF_DECAY_FRAMES,
173173
UnsignedInt sustainAtPeak = DEF_SUSTAIN_FRAMES ); // ask MLorenzen
174174
void sustain(void) { m_envState = ENVELOPE_STATE_SUSTAIN; }
@@ -231,7 +231,6 @@ enum DrawableStatus CPP_11(: DrawableStatusBits)
231231
DRAWABLE_STATUS_NONE = 0x00000000, ///< no status
232232
DRAWABLE_STATUS_DRAWS_IN_MIRROR = 0x00000001, ///< drawable can reflect
233233
DRAWABLE_STATUS_SHADOWS = 0x00000002, ///< use setShadowsEnabled() access method
234-
DRAWABLE_STATUS_TINT_COLOR_LOCKED = 0x00000004, ///< drawable tint color is "locked" and won't fade to normal
235234
DRAWABLE_STATUS_NO_STATE_PARTICLES = 0x00000008, ///< do *not* auto-create particle systems based on model condition
236235
DRAWABLE_STATUS_NO_SAVE = 0x00000010, ///< do *not* save this drawable (UI fluff only). ignored (error, actually) if attached to an object
237236

@@ -372,7 +371,7 @@ class Drawable : public Thing,
372371

373372
Bool getDrawsInMirror() const { return BitIsSet(m_status, DRAWABLE_STATUS_DRAWS_IN_MIRROR) || isKindOf(KINDOF_CAN_CAST_REFLECTIONS); }
374373

375-
void colorFlash( const RGBColor *color, UnsignedInt decayFrames = DEF_DECAY_FRAMES, UnsignedInt attackFrames = 0, UnsignedInt sustainAtPeak = FALSE ); ///< flash a drawable in the color specified for a short time
374+
void colorFlash( const RGBColor *color, UnsignedInt decayFrames = DEF_DECAY_FRAMES, UnsignedInt attackFrames = 0, UnsignedInt sustainAtPeak = 0 ); ///< flash a drawable in the color specified for a short time
376375
void colorTint( const RGBColor *color ); ///< tint this drawable the color specified
377376
void setTintEnvelope( const RGBColor *color, Real attack, Real decay ); ///< how to transition color
378377
void flashAsSelected( const RGBColor *color = NULL ); ///< drawable takes care of the details if you spec no color

Generals/Code/GameEngine/Source/GameClient/Drawable.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,6 @@ void Drawable::colorFlash( const RGBColor* color, UnsignedInt decayFrames, Unsig
922922
white.setFromInt(0xffffffff);
923923
m_colorTintEnvelope->play( &white );
924924
}
925-
926-
// make sure the tint color is unlocked so we "fade back down" to normal
927-
clearDrawableStatus( DRAWABLE_STATUS_TINT_COLOR_LOCKED );
928925
}
929926

930927
// ------------------------------------------------------------------------------------------------
@@ -935,11 +932,7 @@ void Drawable::colorTint( const RGBColor* color )
935932
if( color )
936933
{
937934
// set the color via color flash
938-
colorFlash( color, 0, 0, TRUE );
939-
940-
// lock the tint color so the flash never "fades back down"
941-
setDrawableStatus( DRAWABLE_STATUS_TINT_COLOR_LOCKED );
942-
935+
colorFlash( color, 0, 0, ~0u );
943936
}
944937
else
945938
{
@@ -948,10 +941,6 @@ void Drawable::colorTint( const RGBColor* color )
948941

949942
// remove the tint applied to the object
950943
m_colorTintEnvelope->rest();
951-
952-
// set the tint as unlocked so we can flash and stuff again
953-
clearDrawableStatus( DRAWABLE_STATUS_TINT_COLOR_LOCKED );
954-
955944
}
956945

957946
}
@@ -4756,11 +4745,11 @@ TintEnvelope::TintEnvelope(void)
47564745
const Real FADE_RATE_EPSILON = (0.001f);
47574746

47584747
//-------------------------------------------------------------------------------------------------
4759-
void TintEnvelope::play(const RGBColor *peak, UnsignedInt atackFrames, UnsignedInt decayFrames, UnsignedInt sustainAtPeak )
4748+
void TintEnvelope::play(const RGBColor *peak, UnsignedInt attackFrames, UnsignedInt decayFrames, UnsignedInt sustainAtPeak )
47604749
{
47614750
setPeakColor( peak );
47624751

4763-
setAttackFrames( atackFrames );
4752+
setAttackFrames( attackFrames );
47644753
setDecayFrames( decayFrames );
47654754

47664755
m_envState = ENVELOPE_STATE_ATTACK;

Generals/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ UpdateSleepTime EMPUpdate::update( void )
147147
{
148148
RGBColor end = data->m_endColor;
149149
saturateRGB( end, 5 );
150-
dr->colorFlash( &end, 9999, m_tintEnvFadeFrames, TRUE );
150+
dr->colorFlash( &end, 0, m_tintEnvFadeFrames, ~0u );
151151
doDisableAttack();
152152
}
153153

GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class TintEnvelope : public MemoryPoolObject, public Snapshot
171171
TintEnvelope(void);
172172
void update(void); ///< does all the work
173173
void play(const RGBColor *peak,
174-
UnsignedInt atackFrames = DEF_ATTACK_FRAMES,
174+
UnsignedInt attackFrames = DEF_ATTACK_FRAMES,
175175
UnsignedInt decayFrames = DEF_DECAY_FRAMES,
176176
UnsignedInt sustainAtPeak = DEF_SUSTAIN_FRAMES ); // ask MLorenzen
177177
void sustain(void) { m_envState = ENVELOPE_STATE_SUSTAIN; }
@@ -234,7 +234,6 @@ enum DrawableStatus CPP_11(: DrawableStatusBits)
234234
DRAWABLE_STATUS_NONE = 0x00000000, ///< no status
235235
DRAWABLE_STATUS_DRAWS_IN_MIRROR = 0x00000001, ///< drawable can reflect
236236
DRAWABLE_STATUS_SHADOWS = 0x00000002, ///< use setShadowsEnabled() access method
237-
DRAWABLE_STATUS_TINT_COLOR_LOCKED = 0x00000004, ///< drawable tint color is "locked" and won't fade to normal
238237
DRAWABLE_STATUS_NO_STATE_PARTICLES = 0x00000008, ///< do *not* auto-create particle systems based on model condition
239238
DRAWABLE_STATUS_NO_SAVE = 0x00000010, ///< do *not* save this drawable (UI fluff only). ignored (error, actually) if attached to an object
240239

@@ -388,7 +387,7 @@ class Drawable : public Thing,
388387

389388
Bool getDrawsInMirror() const { return BitIsSet(m_status, DRAWABLE_STATUS_DRAWS_IN_MIRROR) || isKindOf(KINDOF_CAN_CAST_REFLECTIONS); }
390389

391-
void colorFlash( const RGBColor *color, UnsignedInt decayFrames = DEF_DECAY_FRAMES, UnsignedInt attackFrames = 0, UnsignedInt sustainAtPeak = FALSE ); ///< flash a drawable in the color specified for a short time
390+
void colorFlash( const RGBColor *color, UnsignedInt decayFrames = DEF_DECAY_FRAMES, UnsignedInt attackFrames = 0, UnsignedInt sustainAtPeak = 0 ); ///< flash a drawable in the color specified for a short time
392391
void colorTint( const RGBColor *color ); ///< tint this drawable the color specified
393392
void setTintEnvelope( const RGBColor *color, Real attack, Real decay ); ///< how to transition color
394393
void flashAsSelected( const RGBColor *color = NULL ); ///< drawable takes care of the details if you spec no color

GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,6 @@ void Drawable::colorFlash( const RGBColor* color, UnsignedInt decayFrames, Unsig
971971
white.setFromInt(0xffffffff);
972972
m_colorTintEnvelope->play( &white );
973973
}
974-
975-
// make sure the tint color is unlocked so we "fade back down" to normal
976-
clearDrawableStatus( DRAWABLE_STATUS_TINT_COLOR_LOCKED );
977974
}
978975

979976
// ------------------------------------------------------------------------------------------------
@@ -984,11 +981,7 @@ void Drawable::colorTint( const RGBColor* color )
984981
if( color )
985982
{
986983
// set the color via color flash
987-
colorFlash( color, 0, 0, TRUE );
988-
989-
// lock the tint color so the flash never "fades back down"
990-
setDrawableStatus( DRAWABLE_STATUS_TINT_COLOR_LOCKED );
991-
984+
colorFlash( color, 0, 0, ~0u );
992985
}
993986
else
994987
{
@@ -997,10 +990,6 @@ void Drawable::colorTint( const RGBColor* color )
997990

998991
// remove the tint applied to the object
999992
m_colorTintEnvelope->rest();
1000-
1001-
// set the tint as unlocked so we can flash and stuff again
1002-
clearDrawableStatus( DRAWABLE_STATUS_TINT_COLOR_LOCKED );
1003-
1004993
}
1005994

1006995
}
@@ -5513,11 +5502,11 @@ TintEnvelope::TintEnvelope(void)
55135502
const Real FADE_RATE_EPSILON = (0.001f);
55145503

55155504
//-------------------------------------------------------------------------------------------------
5516-
void TintEnvelope::play(const RGBColor *peak, UnsignedInt atackFrames, UnsignedInt decayFrames, UnsignedInt sustainAtPeak )
5505+
void TintEnvelope::play(const RGBColor *peak, UnsignedInt attackFrames, UnsignedInt decayFrames, UnsignedInt sustainAtPeak )
55175506
{
55185507
setPeakColor( peak );
55195508

5520-
setAttackFrames( atackFrames );
5509+
setAttackFrames( attackFrames );
55215510
setDecayFrames( decayFrames );
55225511

55235512
m_envState = ENVELOPE_STATE_ATTACK;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ UpdateSleepTime EMPUpdate::update( void )
149149
{
150150
RGBColor end = data->m_endColor;
151151
saturateRGB( end, 5 );
152-
dr->colorFlash( &end, 9999, m_tintEnvFadeFrames, TRUE );
152+
dr->colorFlash( &end, 0, m_tintEnvFadeFrames, ~0u );
153153
doDisableAttack();
154154
}
155155

0 commit comments

Comments
 (0)