Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/GameEngine/Include/Common/GameDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#endif

#ifndef PRESERVE_RADAR_WARNING_SUPPRESSION
#define PRESERVE_RADAR_WARNING_SUPPRESSION (1)
#define PRESERVE_RADAR_WARNING_SUPPRESSION (0) // Per-object cooldown in tryUnderAttackEvent supersedes this map-wide suppression.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling another fix is not a proper solution. If this fix superseeds the previous fix and not backwards compatibility is needed, than the old fix needs to be removed. If it needs to be backwards compatible, than this macro should not be changed and your fix should be in the same macro tags (#if !PRESERVE_RADAR_WARNING_SUPPRESSION)

#endif

#ifndef PRESERVE_STRUCTURE_STEALTH_DURING_REPAIR
Expand Down
1 change: 1 addition & 0 deletions Core/GameEngine/Include/Common/Radar.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class RadarObject : public MemoryPoolObject,
Object *m_object; ///< the object
RadarObject *m_next; ///< next radar object
Color m_color; ///< color to draw for this object on the radar
UnsignedInt m_lastUnderAttackAlarmFrame; ///< last logic frame this object's under-attack alarm fired

};

Expand Down
13 changes: 13 additions & 0 deletions Core/GameEngine/Source/Common/System/Radar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ RadarObject::RadarObject()
m_object = nullptr;
m_next = nullptr;
m_color = GameMakeColor( 255, 255, 255, 255 );
m_lastUnderAttackAlarmFrame = 0xFFFFFFFF;

}

Expand Down Expand Up @@ -1046,9 +1047,21 @@ void Radar::tryUnderAttackEvent( const Object *obj )
if( obj == nullptr )
return;

// Per-object cooldown: each unit can alarm at most once per suppression window.
// This prevents a single object (e.g. a supply plane) from re-triggering the alarm
// every time the global event window expires.
const UnsignedInt framesBetweenAlarms = LOGICFRAMES_PER_SECOND * 10;
UnsignedInt currentFrame = TheGameLogic->getFrame();
RadarObject *radarData = obj->friend_getRadarData();
if( radarData && currentFrame - radarData->m_lastUnderAttackAlarmFrame < framesBetweenAlarms )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_lastUnderAttackAlarmFrame has the maximum value assigned (line 103). This if statement is therefore always true. Therefore line 1063 will never fire and m_lastUnderAttackAlarmFrame will never be reset.

return;

// try to create the event
Bool eventCreated = tryEvent( RADAR_EVENT_UNDER_ATTACK, obj->getPosition() );

if( eventCreated && radarData )
radarData->m_lastUnderAttackAlarmFrame = currentFrame;

// if event created, do some more feedback
if( eventCreated )
{
Expand Down