-
Notifications
You must be signed in to change notification settings - Fork 210
Fix #2452: Per-object cooldown for under-attack radar alarm #2845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,7 @@ | |
| m_object = nullptr; | ||
| m_next = nullptr; | ||
| m_color = GameMakeColor( 255, 255, 255, 255 ); | ||
| m_lastUnderAttackAlarmFrame = 0xFFFFFFFF; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason for this init value? |
||
|
|
||
| } | ||
|
|
||
|
|
@@ -1046,9 +1047,21 @@ | |
| if( obj == nullptr ) | ||
| return; | ||
|
|
||
| // Per-object cooldown: each unit can alarm at most once per suppression window. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Contribution Guidelines give comment format. Needs comment prefix. |
||
| // 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(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const |
||
| RadarObject *radarData = obj->friend_getRadarData(); | ||
|
Check failure on line 1055 in Core/GameEngine/Source/Common/System/Radar.cpp
|
||
| if( radarData && currentFrame - radarData->m_lastUnderAttackAlarmFrame < framesBetweenAlarms ) | ||
|
Check failure on line 1056 in Core/GameEngine/Source/Common/System/Radar.cpp
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it even compile? |
||
| return; | ||
|
|
||
| // try to create the event | ||
| Bool eventCreated = tryEvent( RADAR_EVENT_UNDER_ATTACK, obj->getPosition() ); | ||
|
|
||
| if( eventCreated && radarData ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests eventCreated twice which can be avoided. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests radarData twice. Can second test be avoided? |
||
| radarData->m_lastUnderAttackAlarmFrame = currentFrame; | ||
|
Check failure on line 1063 in Core/GameEngine/Source/Common/System/Radar.cpp
|
||
|
|
||
| // if event created, do some more feedback | ||
| if( eventCreated ) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
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)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this fix avoids the under attack audio spam, then PRESERVE_RADAR_WARNING_SUPPRESSION can be removed?