Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameengine): turkiye radars track moving enemies under fog

Olcay Seyganab7cc84a57a2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f443ffc3..08fe14220 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -362,7 +362,8 @@ found and fixed, EA's own, not port damage.**
- Turkiye is a fourth side in the skirmish and multiplayer lobbies, listed as Turkiye (Experimental), Türkiye (Deneysel) in Turkish. The label is there because the side is not finished: its powers and abilities are still being worked on and will change. It has an army of its own: Mehmetcik riflemen, Sungur missile teams and Maroon Berets from the Barracks; the Altay tank, the Kirpi carrier, Korkut air defense, Firtina howitzers and Sakarya rocket launchers from the Factory; Bayraktar and Akinci drones, the Gokbey helicopter and the Kizilelma fighter from the Airfield. Every name and tooltip reads in English and in Turkish.
- Turkiye kills from range and cannot see for itself. The Firtina throws a shell 600 and sees 100, so it waits until a spotter team, a Bayraktar or a Radar Tower finds the target, then fires on its own. Extended Range at the Factory pushes the guns further.
-- Turkiye's rockets fly on radar. Every rocket and missile the side fires, from the Firtina, the Sakarya, the Bayraktar, the Sungur team, the Kizilelma and the Patriot Battery, hits as aimed when the target stands inside the radar circle of a Command Center (300), a Radar Tower (600), a Koral (350) or an Akinci (400), yours or an ally's. Past every circle only one shot in five keeps its lock; the other four come down on the ground beside the target and miss, and against aircraft that means they miss altogether. A radar under construction, out of power or knocked out by an EMP covers nothing. Inertial Guidance at the Factory, which replaces Precision Guidance, makes it two shots in five. The old blind spread is gone, and so is the Sakarya's fixed spread of 25. Replays recorded before this change play out differently.
+- Turkiye's rockets fly on radar. Every rocket and missile the side fires, from the Firtina, the Sakarya, the Bayraktar, the Sungur team, the Kizilelma and the Patriot Battery, hits as aimed when the target stands inside the radar circle of a Command Center (600), a Radar Tower (1000), a Koral (650) or an Akinci (750), yours or an ally's. Past every circle only one shot in five keeps its lock; the other four come down on the ground beside the target and miss, and against aircraft that means they miss altogether. A radar under construction, out of power or knocked out by an EMP covers nothing. Inertial Guidance at the Factory, which replaces Precision Guidance, makes it two shots in five. The old blind spread is gone, and so is the Sakarya's fixed spread of 25. Replays recorded before this change play out differently.
+- Turkiye's radars now see what moves under fog. Every sweep of a Command Center, Radar Tower, Koral or Akinci marks the enemy units walking inside its circle that nobody can see, as a red ring on the ground and a mark on the minimap. A unit that stands still draws nothing. A Firtina or other gun with long sight fires on a ringed target without waiting for a spotter, and a right-click on a ring sends your selected units to attack it. The rings never name the unit, so neither the cursor nor the unit's voice gives away what is under one. The circles grew with it: Command Center 600, Radar Tower 1000, Koral 650, Akinci 750.
- Once something sees for it, the artillery is what kills. A Firtina shell does 200 where it lands and 60 out to 35, every 7 seconds, where it did 150 inside 10, less than an Altay. A Sakarya salvo is six rockets of 70 each with a 30 blast, every 14 seconds. The Sakarya never hit anything before: its rockets left the launcher level and went nowhere, and it now aims them up the way the Firtina does. Four Battlemasters or sixteen Rangers marching straight at two Firtinas and their spotter, the same 3500 in money, die before they get there. Crusaders and Scorpions get through with one to three tanks left. Come at the guns from the side with that money in tanks and the tanks win seven fights in eight, so a raid on the flank or a dead spotter is how a gun line falls.
- Sight is what Turkiye pays for. The Bayraktar is the artillery's real eye, 550 from the air, and costs 900 instead of 500. The Cobra sees 250 instead of 400 and is a fast car with five seats, no longer the cheapest spotter. The Radar Tower costs 800 instead of 400 and draws 3 power. The spotter team sees 500, has 200 health and moves faster. It no longer hides: the Pathfinder's camouflage made it an eye nobody could find for guns that hit from 600, and left the enemy nothing to shoot back at but the guns. The free Spy Satellite Scan is gone, and the Sungur gunner sees 200 instead of 300.
- Combat Engineers build the base in place of a dozer. They are infantry, so they can be shot and run over. The Barracks' Mine Kit lets them bury mines, and the Factory's Reinforced Hull, which used to be called the Armor Pack, gives the Kirpi and the Altay 20% more health.
diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifest
index ede5759c3..8a704994f 100644
--- a/GeneralsMD/Code/BuildFingerprint.manifest
+++ b/GeneralsMD/Code/BuildFingerprint.manifest
@@ -39,6 +39,8 @@ Data/Art/Textures/ReforgedMineGlowBlue.tga
Data/Art/Textures/ReforgedMineGlowRed.tga
Data/Art/Textures/ReforgedMineLedBlue.tga
Data/Art/Textures/ReforgedMineLedRed.tga
+Data/Art/Textures/ReforgedRadarContact.tga
+Data/Art/Textures/ReforgedRadarRing.tga
Data/Art/Textures/ReforgedSignalAttack.tga
Data/Art/Textures/ReforgedSignalDefend.tga
Data/Art/Textures/ReforgedSignalLook.tga
@@ -825,6 +827,7 @@ GameEngine/Include/GameClient/ParticleSys.h
GameEngine/Include/GameClient/PlaceEventTranslator.h
GameEngine/Include/GameClient/PlayerColorScheme.h
GameEngine/Include/GameClient/ProcessAnimateWindow.h
+GameEngine/Include/GameClient/RadarContactMarks.h
GameEngine/Include/GameClient/RadiusDecal.h
GameEngine/Include/GameClient/RayEffect.h
GameEngine/Include/GameClient/ReachOverlay.h
@@ -1478,6 +1481,7 @@ GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp
GameEngine/Source/GameClient/ObserverCamera.cpp
GameEngine/Source/GameClient/ParabolicEase.cpp
GameEngine/Source/GameClient/PlayerColorScheme.cpp
+GameEngine/Source/GameClient/RadarContactMarks.cpp
GameEngine/Source/GameClient/RadiusDecal.cpp
GameEngine/Source/GameClient/ReachOverlay.cpp
GameEngine/Source/GameClient/SelectionInfo.cpp
@@ -4323,6 +4327,7 @@ Tools/package-common.sh
Tools/packaging-resolution-check.sh
Tools/peacetime_layout.py
Tools/pink_laser.py
+Tools/radar_marks.py
Tools/record-dx11-shaders.ps1
Tools/replay-check.sh
Tools/root-readonly-check.sh
diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRadarContact.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRadarContact.tga
new file mode 100644
index 000000000..7ab330aed
Binary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRadarContact.tga differ
diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRadarRing.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRadarRing.tga
new file mode 100644
index 000000000..7ef136512
Binary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRadarRing.tga differ
diff --git a/GeneralsMD/Code/Data/INI/TurkiyeReforged.ini b/GeneralsMD/Code/Data/INI/TurkiyeReforged.ini
index 0320bf83a..ae636c7c4 100644
--- a/GeneralsMD/Code/Data/INI/TurkiyeReforged.ini
+++ b/GeneralsMD/Code/Data/INI/TurkiyeReforged.ini
@@ -34,7 +34,7 @@ Object TurkiyeCommandCenter
; the radar circle the faction's rockets keep their lock in (TurkiyeWeaponReforged.ini)
AddModule
Behavior = RadarCoverageBehavior ModuleTag_TurkiyeRadarCoverage
- Radius = 300
+ Radius = 600
End
End
; the Rank 1 minefield (ScienceReforged.ini, SpecialPowerReforged.ini)
@@ -760,7 +760,7 @@ Object TurkiyeRadarTower
; the widest radar circle, while it has power
AddModule
Behavior = RadarCoverageBehavior ModuleTag_TurkiyeRadarCoverage
- Radius = 600
+ Radius = 1000
End
End
ReplaceModule ModuleTag_05
@@ -1959,7 +1959,7 @@ Object TurkiyeTankKoral
; and a radar that drives with the army
AddModule
Behavior = RadarCoverageBehavior ModuleTag_TurkiyeRadarCoverage
- Radius = 350
+ Radius = 650
End
End
End
@@ -2137,7 +2137,7 @@ Object TurkiyeJetAkinci
; a radar in the air over the fight
AddModule
Behavior = RadarCoverageBehavior ModuleTag_TurkiyeRadarCoverage
- Radius = 400
+ Radius = 750
End
End
End
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/RadarContactMarks.h b/GeneralsMD/Code/GameEngine/Include/GameClient/RadarContactMarks.h
new file mode 100644
index 000000000..a268e6e15
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/RadarContactMarks.h
@@ -0,0 +1,59 @@
+// The Turkiye radar's contacts: moving enemies hidden in the fog inside a player's radar coverage,
+// published by the logic once a sweep and drawn on the ground (RadarContactMarks.cpp) and on the
+// minimap. The units themselves stay hidden and the fog stays down; only the paint shows. Nothing
+// here goes back into the logic.
+// Distributed under the repository's GPL-3.0 terms; see LICENSE.md.
+#pragma once
+
+#ifndef __RADARCONTACTMARKS_H__
+#define __RADARCONTACTMARKS_H__
+
+#include "Lib/BaseType.h"
+#include "Common/GameType.h"
+#include <vector>
+
+/** One painted contact: whose radar saw it, what it is (for a pick, never drawn) and where it stood. */
+struct RadarContact
+{
+ Int player; ///< the player index whose radar painted it
+ ObjectID id;
+ Coord3D pos;
+};
+
+/** A sweep's contacts for every player. Main thread: the logic calls it through callAfterTick. */
+void RadarContactMarks_publish( UnsignedInt sweepFrame, const std::vector<RadarContact> &all );
+/// InGameUI::update: reads the logic (outside the logic thread's window), refills the lists below and
+/// lays and animates the ground marks. The three getters after reset only read what it left, so a
+/// draw beside the tick may call them
+void RadarContactMarks_update( void );
+void RadarContactMarks_reset( void ); ///< InGameUI::reset: forgets both sweeps, releases the decals
+/// the shown player's contacts (TheObserverCamera.getShroudPlayerIndex()), this sweep, less any
+/// unit that has since come into his sight
+const std::vector<RadarContact> &RadarContactMarks_fresh( void );
+/// the shown player's contacts, the sweep before, less the same
+const std::vector<RadarContact> &RadarContactMarks_echoes( void );
+/// 0 at a publish, rising to 1 by the next sweep is due
+Real RadarContactMarks_sweepAge( void );
+/// the local player's fresh contact nearest pos within RadarContactLook::PickRadius, else INVALID_ID
+ObjectID RadarContactMarks_pick( const Coord3D &pos );
+
+/** The look, in world units, seconds, alphas and minimap pixels. */
+namespace RadarContactLook
+{
+ const Real SweepSeconds = 2.0f; ///< the logic's sweep period, what sweepAge counts to
+ const Real RingSize = 20.0f; ///< across, the contact's ring with its centre pip
+ const Real RingAlpha = 0.95f;
+ const Real RippleFrom = 20.0f; ///< across, a ping ripple as it leaves the ring (RingSize)
+ const Real RippleTo = 42.0f; ///< across, as it is gone: about twice the ring, as in the approved still
+ const Real RippleSeconds = 0.9f; ///< one ripple's run
+ const Real RippleGap = 0.25f; ///< the second ripple leaves this long after the first
+ const Real RippleAlpha = 0.7f; ///< at its start, fading as the square root of what is left of the run
+ const Real EchoAlpha = 0.35f; ///< the previous sweep's ring, fading over the sweep
+ const Real PickRadius = 40.0f; ///< world units from a click to a contact it picks
+ const UnsignedInt Colour = 0xFFF04024; ///< hostile red, the attack cursor's
+ const Int MinimapPip = 3; ///< pixels across, the fresh contact's square
+ const Int MinimapRing = 9; ///< pixels across, the faint ring round it
+ const Int MinimapEcho = 2; ///< pixels across, the previous sweep's square
+}
+
+#endif
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadarCoverageBehavior.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadarCoverageBehavior.h
index 138d81d27..b337426e4 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadarCoverageBehavior.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadarCoverageBehavior.h
@@ -19,7 +19,8 @@
// FILE: RadarCoverageBehavior.h /////////////////////////////////////////////////////////////////
//
// Turkiye's radar: a circle of Radius in which its own and its allies' radar-guided rockets keep
-// their lock (WeaponTemplate RadarBlindHitChance, Weapon.cpp).
+// their lock (WeaponTemplate RadarBlindHitChance, Weapon.cpp), and in which moving enemies hidden in
+// the fog are tracked: painted on the ground for the player, open to beyond-vision artillery.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -59,6 +60,15 @@ public:
/// a working radar of this player or an ally covers this point
static Bool isCovered( const Player *player, const Coord3D *pos );
+ /** The radar holds this unit for this player: it moves, stealth does not hide it, and it stands
+ * in the player's or an ally's coverage. Says nothing of the fog or of whose side it is on;
+ * the caller asks those. */
+ static Bool isTracked( const Player *player, const Object *obj );
+
+ /** GameLogic::update, after the partition manager: every RADAR_SWEEP_FRAMES, hands the client
+ * each player's tracked enemies standing in fog (GameClient/RadarContactMarks.h). Keeps nothing. */
+ static void sweep( void );
+
private:
/* Every radar in the game, in no order that matters: isCovered only asks whether any of them
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h
index 98d8c50e3..7caaea3d6 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h
@@ -1066,15 +1066,17 @@ protected:
//=====================================
/**
- * Accept if they are at least partly clear, not wholly fogged or shrouded
+ * Accept if they are at least partly clear, not wholly fogged or shrouded, or, given a radar
+ * player, if that player's radar tracks them in the fog (RadarCoverageBehavior::isTracked)
*/
class PartitionFilterFreeOfFog : public PartitionFilter
{
private:
Int m_comparisonIndex;
+ const Player *m_radar;
public:
- PartitionFilterFreeOfFog(Int toWhom) :
- m_comparisonIndex(toWhom){}
+ PartitionFilterFreeOfFog(Int toWhom, const Player *radar = NULL) :
+ m_comparisonIndex(toWhom), m_radar(radar){}
protected:
virtual Bool allow( Object *other );
#if defined(_DEBUG) || defined(_INTERNAL)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 8f9fe2838..86e597653 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -101,6 +101,7 @@
#include "GameClient/WindowLayout.h"
#include "GameClient/LookAtXlat.h"
#include "GameClient/ParticleSys.h"
+#include "GameClient/RadarContactMarks.h"
#include "GameClient/ReachOverlay.h"
#include "GameClient/SelectionXlat.h"
#include "GameClient/Shadow.h"
@@ -3323,6 +3324,7 @@ void InGameUI::update( void )
if( TheGameLogic->isInGame() && !TheGameLogic->isInShellGame() )
watchDozers();
updateSignalMarks();
+ RadarContactMarks_update(); // what a Turkiye radar paints in the fog, on the ground
ReachOverlay_update(); // the ground a selected or sited defence hits, drawn on the terrain
UnsignedByte r, g, b, a;
Int amount;
@@ -3668,6 +3670,7 @@ void InGameUI::reset( void )
TheObserverCamera.reset();
CinemaDirector_forgetHudHidden();
clearSignalMarks();
+ RadarContactMarks_reset();
m_armedSignal = SIGNAL_KIND_COUNT;
m_dozerCheckFrame = 0;
for( Int index = 0; index < MAX_PLAYER_COUNT; index++ )
@@ -4275,8 +4278,9 @@ Bool InGameUI::getHeldAircraftOrder( const Object *obj, OrderHintKind& kind, Coo
onObject = ( targetID != INVALID_ID );
if( onObject )
{
+ // a target under the shroud draws nothing, as in getQueuedOrderHint
const Object *target = TheGameLogic->findObjectByID( targetID );
- if( target == NULL )
+ if( target == NULL || isHiddenByShroud( target ) )
return FALSE;
to = orderTargetSpot( target );
}
@@ -4569,6 +4573,7 @@ void InGameUI::collectOrderHints( void )
const Int pathSize = ai->friend_getWaypointGoalPathSize();
const Int pathIndex = ai->friend_getCurrentGoalPathIndex();
hint.onObject = FALSE;
+ Bool goalHidden = FALSE;
if( goalResolved )
{
hint.to = resolvedGoal;
@@ -4594,7 +4599,9 @@ void InGameUI::collectOrderHints( void )
Object *goalObj = ai->getGoalObject();
Path *path = ai->getPath();
hint.onObject = ( goalObj != NULL );
- if( goalObj )
+ if( goalObj && isHiddenByShroud( goalObj ) )
+ goalHidden = TRUE;
+ else if( goalObj )
hint.to = orderTargetSpot( goalObj );
else if( path )
hint.to = *path->getLastNode()->getPosition();
@@ -4602,7 +4609,13 @@ void InGameUI::collectOrderHints( void )
hint.to = *ai->getGoalPosition();
}
- addOrderHint( hint, previous );
+ // a goal under the shroud - a radar contact, or a target that has driven into the fog - draws
+ // no thread: its end, or the end of the path chasing it, would trace the unit through the fog.
+ // The shift list that follows starts from the unit itself
+ if( goalHidden )
+ hint.to = hint.from;
+ else
+ addOrderHint( hint, previous );
}
// the rest of the unit's shift queue: every order still owed after this one, each drawn on from
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index 97e3795d8..dd6b16d55 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -64,6 +64,7 @@
#include "GameClient/GameWindowManager.h"
#include "GameClient/GameText.h"
#include "GameClient/ParticleSys.h"
+#include "GameClient/RadarContactMarks.h"
#include "GameClient/GUICallbacks.h"
#include "GameClient/KeyDefs.h"
#include "GameClient/ObserverCamera.h"
@@ -1216,9 +1217,13 @@ GameMessage::Type CommandTranslator::issueAttackCommand( Drawable *target,
// only make sounds if the command was for real
if( commandType == DO_COMMAND )
{
+ // a target in the fog, a radar contact, gets the ground line from whoever answers first: the air
+ // line, or the pick of a unit that can reach it, would say what the radar has not shown. The
+ // drawable's own flag, set by the client's shroud pass, not a shroud read beside a tick
+ const Bool hidden = target->getFullyObscuredByShroud();
PickAndPlayInfo info;
- info.m_air = targetObj->isUsingAirborneLocomotor();
- info.m_drawTarget = target;
+ info.m_air = !hidden && targetObj->isUsingAirborneLocomotor();
+ info.m_drawTarget = hidden ? NULL : target;
pickAndPlayUnitVoiceResponse( TheInGameUI->getAllSelectedDrawables(), msgType, &info );
} // end if
@@ -1606,10 +1611,37 @@ void CommandTranslator::finishFormationDrag( const ICoord2D& lift )
pickAndPlayUnitVoiceResponse( selected, GameMessage::MSG_DO_MOVETO );
}
+//-------------------------------------------------------------------------------------------------
+/** The radar contact whose ring a click at pos lands on, or NULL. The contact is hidden in the fog,
+ * so whether it can be attacked is decided from the selection alone: anything selected that can
+ * shoot at all gets the same attack on every ring. Asking about the contact itself - in range, air
+ * or ground, hijackable - would tell the player what they cannot see. A unit that cannot hit it
+ * takes the order and holds its fire, as in retail. */
+//-------------------------------------------------------------------------------------------------
+static Object *pickRadarContact( const Coord3D *pos )
+{
+ if( TheInGameUI->getGUICommand() || TheInGameUI->isInForceMoveToMode() || TheInGameUI->isLineOrderArmed()
+ || !TheInGameUI->areSelectedObjectsControllable() )
+ return NULL;
+ const DrawableList *selected = TheInGameUI->getAllSelectedDrawables();
+ for( DrawableListCIt it = selected->begin(); it != selected->end(); ++it )
+ {
+ const Object *obj = (*it)->getObject();
+ // a dozer's only weapon clears mines, and a contact is never one
+ if( obj->isKindOf( KINDOF_DOZER ) || !obj->isAbleToAttack() )
+ continue;
+ for( Int i = 0; i < WEAPONSLOT_COUNT; i++ )
+ {
+ if( obj->getWeaponInWeaponSlotCommandSourceMask( (WeaponSlotType)i ) )
+ return TheGameLogic->findObjectByID( RadarContactMarks_pick( *pos ) );
+ }
+ }
+ return NULL;
+}
//-------------------------------------------------------------------------------------------------
-GameMessage::Type CommandTranslator::evaluateForceAttack( Drawable *draw, const Coord3D *pos, CommandEvaluateType type )
+GameMessage::Type CommandTranslator::evaluateForceAttack(Drawable *draw, const Coord3D *pos, CommandEvaluateType type )
{
// evaluateForceAttack is used to determine whether or not we can force attack the
// given target, and if we can, to issue the appropriate command.
@@ -1622,15 +1654,27 @@ GameMessage::Type CommandTranslator::evaluateForceAttack( Drawable *draw, const
const DrawableList *allSelected = TheInGameUI->getAllSelectedDrawables();
- if( draw )
+ // the attack key over a radar contact's ring fires on the contact, decided as a plain click on it is
+ Bool ringPick = FALSE;
+ if( !draw )
+ {
+ Object *contact = pickRadarContact( pos );
+ if( contact )
+ {
+ draw = contact->getDrawable();
+ ringPick = TRUE;
+ }
+ }
+
+ if( draw )
{
Object *obj = draw ? draw->getObject() : NULL;
- if( !obj )
+ if( !obj )
{
return retVal;
}
- CanAttackResult result = canAnyForceAttack( allSelected, obj, pos );
+ CanAttackResult result = ringPick ? ATTACKRESULT_POSSIBLE : canAnyForceAttack( allSelected, obj, pos );
if( result == ATTACKRESULT_POSSIBLE || result == ATTACKRESULT_POSSIBLE_AFTER_MOVING )
{
@@ -1741,7 +1785,26 @@ GameMessage::Type CommandTranslator::evaluateContextCommand( Drawable *draw,
// if there is a location to which we should attack.
drawableInWay = draw;
}
-
+
+ // A plain click on a radar contact's ring is an attack on the unit the radar painted, hidden in the
+ // fog as it is. It skips every branch below, since each of them reads the target; the hint carries
+ // no id and the cursor reads the drawable under the mouse, never this one.
+ if( obj == NULL )
+ {
+ Object *contact = pickRadarContact( pos );
+ if( contact )
+ {
+ if( type == DO_HINT )
+ {
+ TheMessageStream->appendMessage( GameMessage::MSG_DO_ATTACK_OBJECT_HINT );
+ return GameMessage::MSG_DO_ATTACK_OBJECT_HINT;
+ }
+ if( TheInGameUI->isInWaypointMode() && type == DO_COMMAND )
+ TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );
+ return issueAttackCommand( contact->getDrawable(), type );
+ }
+ }
+
GameMessage::Type msgType = GameMessage::MSG_INVALID;
// Then we should determine if the game currently prefers selection events. If it does, then return
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/RadarContactMarks.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/RadarContactMarks.cpp
new file mode 100644
index 000000000..123e625dd
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/RadarContactMarks.cpp
@@ -0,0 +1,255 @@
+// The Turkiye radar's contacts on the ground (RadarContactMarks.h): per contact a red ring with a
+// bright centre pip lying on the terrain and two ping ripples running out of it, and where the
+// sweep before saw something, a faint thin ring fading out. The decals are the smoke-signal marks'
+// kind (InGameUI::addSignalMark), so every renderer draws them through the shared decal path.
+// Client side: it reads the logic (the water, the bridges) and the drawables, and writes nothing
+// back.
+// Distributed under the repository's GPL-3.0 terms; see LICENSE.md.
+
+#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+
+#include "GameClient/RadarContactMarks.h"
+
+#include "Common/GameEngine.h"
+#include "Common/Player.h"
+#include "Common/PlayerList.h"
+#include "GameClient/CinemaDirector.h"
+#include "GameClient/Drawable.h"
+#include "GameClient/ObserverCamera.h"
+#include "GameClient/Shadow.h"
+#include "GameLogic/GameLogic.h"
+#include "GameLogic/Object.h"
+#include "GameLogic/TerrainLogic.h"
+
+namespace
+{
+ // ponytail: a hard cap on the contacts drawn per sweep; a radar painting more than this is a
+ // screen of red already, and the pool would want to grow without bound
+ const size_t MAX_CONTACTS = 64;
+
+ struct Sweep
+ {
+ UnsignedInt frame;
+ std::vector< RadarContact > all;
+ };
+
+ Sweep s_sweeps[ 2 ]; ///< [0] the last publication, [1] the one before
+ Int s_publications = 0; ///< how many s_sweeps hold, 0..2
+
+ // what RadarContactMarks_update worked out this pass, for the minimap draw to read without
+ // touching the logic or a drawable while it may run beside the tick (logic thread)
+ std::vector< RadarContact > s_fresh;
+ std::vector< RadarContact > s_echoes;
+ Real s_sweepAge = 0.0f;
+
+ std::vector< Shadow * > s_contactDecals; ///< ReforgedRadarContact, one per fresh contact
+ std::vector< Shadow * > s_ringDecals; ///< ReforgedRadarRing, two ripples per fresh contact and one per echo
+
+ /** The player's contacts in a sweep, less any whose unit is drawn now: a red ring left under a unit
+ * he can see would only say what he sees already. It asks the drawable, which GameClient::update's
+ * walk has just set for this pass and for this same shown player, so the ring goes on the very
+ * frame the unit appears (and stays off through the walk's two seconds of keeping a unit that
+ * slipped back into the fog drawn). */
+ void pickOut( const Sweep &sweep, Int player, std::vector< RadarContact > &out )
+ {
+ out.clear();
+ for( size_t index = 0; index < sweep.all.size() && out.size() < MAX_CONTACTS; index++ )
+ {
+ const RadarContact &contact = sweep.all[ index ];
+ if( contact.player != player )
+ continue;
+ const Object *obj = TheGameLogic->findObjectByID( contact.id );
+ Drawable *draw = obj != NULL ? obj->getDrawable() : NULL;
+ if( draw != NULL && !draw->getFullyObscuredByShroud() )
+ continue;
+ out.push_back( contact );
+ }
+ }
+
+ /// the shown player's two lists, refilled every pass: what is drawn changes with the pass, not the sweep
+ void refreshShown( void )
+ {
+ const Int player = TheObserverCamera.getShroudPlayerIndex();
+ s_fresh.clear();
+ s_echoes.clear();
+ if( s_publications > 0 )
+ pickOut( s_sweeps[ 0 ], player, s_fresh );
+ if( s_publications > 1 )
+ pickOut( s_sweeps[ 1 ], player, s_echoes );
+ }
+
+ /// seconds since the last publication, by the logic's clock and the way into the next tick, so a
+ /// ripple runs smooth at a frame rate over the logic's
+ Real secondsSinceSweep( void )
+ {
+ if( s_publications == 0 )
+ return 0.0f;
+ const UnsignedInt now = TheGameLogic->getFrame();
+ const UnsignedInt since = now > s_sweeps[ 0 ].frame ? now - s_sweeps[ 0 ].frame : 0;
+ return ( (Real)since + GameEngine_logicTickFraction() ) / LOGICFRAMES_PER_SECOND;
+ }
+
+ /** Whether a mark at pos lies where the ground under it is drawn. A decal without a render object
+ * is laid on the terrain heightmap whatever its height, so over water it would sit on the seabed
+ * and on a bridge under the deck; those contacts keep only their minimap pip. */
+ Bool onOpenGround( const Coord3D &pos )
+ {
+ return !TheTerrainLogic->isUnderwater( pos.x, pos.y ) && TheTerrainLogic->getLayerForDestination( &pos ) == LAYER_GROUND;
+ }
+
+ Shadow *newDecal( const char *texture )
+ {
+ Shadow::ShadowTypeInfo decalInfo;
+ decalInfo.allowUpdates = FALSE;
+ decalInfo.allowWorldAlign = TRUE; // wrapped over the terrain it lands on
+ decalInfo.m_type = SHADOW_ALPHA_DECAL;
+ strcpy( decalInfo.m_ShadowName, texture );
+ decalInfo.m_sizeX = RadarContactLook::RingSize;
+ decalInfo.m_sizeY = RadarContactLook::RingSize;
+ decalInfo.m_offsetX = 0.0f;
+ decalInfo.m_offsetY = 0.0f;
+ Shadow *decal = TheProjectedShadowManager->addDecal( &decalInfo );
+ decal->setColor( (Color)RadarContactLook::Colour );
+ decal->setOpacity( 0 );
+ decal->enableShadowRender( FALSE );
+ return decal;
+ }
+
+ /// the next decal from a pool, made when the pool has run out
+ Shadow *take( std::vector< Shadow * > &pool, size_t &used, const char *texture )
+ {
+ if( used == pool.size() )
+ pool.push_back( newDecal( texture ) );
+ return pool[ used++ ];
+ }
+
+ void place( Shadow *decal, const Coord3D &pos, Real size, Real alpha )
+ {
+ const Int opacity = REAL_TO_INT( clamp( 0.0f, alpha, 1.0f ) * 255.0f );
+ decal->setPosition( pos.x, pos.y, pos.z );
+ decal->setSize( size, size );
+ decal->setOpacity( opacity );
+ decal->enableShadowRender( opacity > 0 );
+ }
+
+ void hideFrom( std::vector< Shadow * > &pool, size_t used )
+ {
+ for( size_t index = used; index < pool.size(); index++ )
+ {
+ pool[ index ]->setOpacity( 0 );
+ pool[ index ]->enableShadowRender( FALSE );
+ }
+ }
+}
+
+void RadarContactMarks_publish( UnsignedInt sweepFrame, const std::vector<RadarContact> &all )
+{
+ std::swap( s_sweeps[ 0 ], s_sweeps[ 1 ] );
+ s_sweeps[ 0 ].frame = sweepFrame;
+ s_sweeps[ 0 ].all = all;
+ s_publications = min( s_publications + 1, 2 );
+}
+
+//-------------------------------------------------------------------------------------------------
+/** Lays this frame's marks. Ripples leave the ring at the sweep and run out to RippleTo, fading;
+ * the ring holds through its sweep and fades over the next if no sweep follows, so a radar that
+ * stops publishing does not leave its last paint on the ground. Hidden while scripts or -cinema
+ * hide the icons, like the signal marks. */
+//-------------------------------------------------------------------------------------------------
+void RadarContactMarks_update( void )
+{
+ refreshShown();
+ const Real seconds = secondsSinceSweep();
+ const Real age = seconds / RadarContactLook::SweepSeconds;
+ s_sweepAge = min( age, 1.0f );
+
+ // no decal manager without a renderer (headless): nothing to lay
+ if( TheProjectedShadowManager == NULL )
+ return;
+
+ size_t contactsUsed = 0;
+ size_t ringsUsed = 0;
+ if( TheGameLogic->getDrawIconUI() && !CinemaDirector_hidesHud() )
+ {
+ using namespace RadarContactLook;
+ const Real ringAlpha = RingAlpha * clamp( 0.0f, 2.0f - age, 1.0f );
+ for( size_t index = 0; index < s_fresh.size(); index++ )
+ {
+ const Coord3D &pos = s_fresh[ index ].pos;
+ if( !onOpenGround( pos ) )
+ continue;
+ place( take( s_contactDecals, contactsUsed, "ReforgedRadarContact" ), pos, RingSize, ringAlpha );
+ for( Int ripple = 0; ripple < 2; ripple++ )
+ {
+ // a square-root fade keeps a ripple seen until it is nearly out, as the approved still has it
+ const Real t = ( seconds - ripple * RippleGap ) / RippleSeconds;
+ const Bool running = t >= 0.0f && t < 1.0f;
+ place( take( s_ringDecals, ringsUsed, "ReforgedRadarRing" ), pos,
+ RippleFrom + ( RippleTo - RippleFrom ) * clamp( 0.0f, t, 1.0f ), running ? RippleAlpha * sqrtf( 1.0f - t ) : 0.0f );
+ }
+ }
+ const Real echoAlpha = EchoAlpha * ( 1.0f - s_sweepAge );
+ for( size_t index = 0; index < s_echoes.size(); index++ )
+ {
+ if( onOpenGround( s_echoes[ index ].pos ) )
+ place( take( s_ringDecals, ringsUsed, "ReforgedRadarRing" ), s_echoes[ index ].pos, RingSize, echoAlpha );
+ }
+ }
+ hideFrom( s_contactDecals, contactsUsed );
+ hideFrom( s_ringDecals, ringsUsed );
+}
+
+void RadarContactMarks_reset( void )
+{
+ for( size_t index = 0; index < s_contactDecals.size(); index++ )
+ s_contactDecals[ index ]->release();
+ for( size_t index = 0; index < s_ringDecals.size(); index++ )
+ s_ringDecals[ index ]->release();
+ s_contactDecals.clear();
+ s_ringDecals.clear();
+ s_sweeps[ 0 ].all.clear();
+ s_sweeps[ 1 ].all.clear();
+ s_publications = 0;
+ s_fresh.clear();
+ s_echoes.clear();
+ s_sweepAge = 0.0f;
+}
+
+const std::vector<RadarContact> &RadarContactMarks_fresh( void )
+{
+ return s_fresh;
+}
+
+const std::vector<RadarContact> &RadarContactMarks_echoes( void )
+{
+ return s_echoes;
+}
+
+Real RadarContactMarks_sweepAge( void )
+{
+ return s_sweepAge;
+}
+
+ObjectID RadarContactMarks_pick( const Coord3D &pos )
+{
+ const Int player = ThePlayerList->getLocalPlayer()->getPlayerIndex();
+ ObjectID best = INVALID_ID;
+ Real bestSquared = RadarContactLook::PickRadius * RadarContactLook::PickRadius;
+ if( s_publications == 0 )
+ return best;
+ const std::vector< RadarContact > &all = s_sweeps[ 0 ].all;
+ for( size_t index = 0; index < all.size(); index++ )
+ {
+ if( all[ index ].player != player )
+ continue;
+ const Real dx = all[ index ].pos.x - pos.x;
+ const Real dy = all[ index ].pos.y - pos.y;
+ const Real squared = dx * dx + dy * dy;
+ if( squared <= bestSquared )
+ {
+ bestSquared = squared;
+ best = all[ index ].id;
+ }
+ }
+ return best;
+}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
index 8dd0d5221..c42fb67de 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
@@ -909,8 +909,9 @@ Object *AI::findClosestEnemy( const Object *me, Real range, UnsignedInt qualifie
// (optional) only stuff that is significant
PartitionFilterInsignificantBuildings filterInsignificant(true, false);
- // (optional) only stuff clear of fog
- PartitionFilterFreeOfFog filterFogged(me->getControllingPlayer()->getPlayerIndex());
+ // (optional) only stuff clear of fog, or for a beyond-vision shooter, tracked by its player's radar
+ PartitionFilterFreeOfFog filterFogged(me->getControllingPlayer()->getPlayerIndex(),
+ me->getTemplate()->acquiresBeyondVision() ? me->getControllingPlayer() : NULL);
PartitionFilter *filters[16];
Int numFilters = 0;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/RadarCoverageBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/RadarCoverageBehavior.cpp
index 84063dca9..7e768ade7 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/RadarCoverageBehavior.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/RadarCoverageBehavior.cpp
@@ -26,13 +26,57 @@
#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+#include "Common/LogicThread.h"
#include "Common/Player.h"
+#include "Common/PlayerList.h"
#include "Common/Xfer.h"
+#include "GameClient/RadarContactMarks.h"
+#include "GameLogic/GameLogic.h"
#include "GameLogic/Object.h"
+#include "GameLogic/Module/PhysicsUpdate.h"
#include "GameLogic/Module/RadarCoverageBehavior.h"
RadarCoverageBehavior *RadarCoverageBehavior::s_first = NULL;
+/* How often the radar hands its contacts to the client, which draws one sweep's rings and the
+ previous one's echoes (RadarContactLook::SweepSeconds is the same two seconds). */
+static const UnsignedInt RADAR_SWEEP_FRAMES = 2 * LOGICFRAMES_PER_SECOND;
+
+/* Horizontal speed in units a frame above which a unit counts as moving. A tank creeping at a tenth
+ of its pace still shows; one turning its turret on the spot does not. */
+static const Real RADAR_MOVING_SPEED = 0.05f;
+
+//-------------------------------------------------------------------------------------------------
+/** finished, alive and switched on */
+static Bool isWorking( const Object *obj )
+{
+ return !( obj->isEffectivelyDead() || obj->isDestroyed() || obj->isDisabled() || obj->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ) );
+}
+
+//-------------------------------------------------------------------------------------------------
+/** a radar of owner's covers for player */
+static Bool serves( const Player *owner, const Player *player )
+{
+ return owner == player || owner->getRelationship( player->getDefaultTeam() ) == ALLIES;
+}
+
+//-------------------------------------------------------------------------------------------------
+static Bool isMoving( const Object *obj )
+{
+ const PhysicsBehavior *physics = obj->getPhysics();
+ if( !physics )
+ return FALSE;
+ const Coord3D *vel = physics->getVelocity();
+ return vel->x * vel->x + vel->y * vel->y > RADAR_MOVING_SPEED * RADAR_MOVING_SPEED;
+}
+
+//-------------------------------------------------------------------------------------------------
+/** stealthed and nobody's detector has it */
+static Bool isHidden( const Object *obj )
+{
+ return obj->testStatus( OBJECT_STATUS_STEALTHED ) && !obj->testStatus( OBJECT_STATUS_DETECTED );
+}
+
//-------------------------------------------------------------------------------------------------
RadarCoverageBehaviorModuleData::RadarCoverageBehaviorModuleData()
{
@@ -74,11 +118,7 @@ RadarCoverageBehavior::~RadarCoverageBehavior( void )
for( const RadarCoverageBehavior *radar = s_first; radar; radar = radar->m_next )
{
const Object *obj = radar->getObject();
- if( obj->isEffectivelyDead() || obj->isDestroyed() || obj->isDisabled() || obj->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ) )
- continue;
-
- const Player *owner = obj->getControllingPlayer();
- if( owner != player && owner->getRelationship( player->getDefaultTeam() ) != ALLIES )
+ if( !isWorking( obj ) || !serves( obj->getControllingPlayer(), player ) )
continue;
const Real radius = radar->getRadarCoverageBehaviorModuleData()->m_radius;
@@ -90,6 +130,87 @@ RadarCoverageBehavior::~RadarCoverageBehavior( void )
return FALSE;
}
+//-------------------------------------------------------------------------------------------------
+/*static*/ Bool RadarCoverageBehavior::isTracked( const Player *player, const Object *obj )
+{
+ return !isHidden( obj ) && isMoving( obj ) && isCovered( player, obj->getPosition() );
+}
+
+//-------------------------------------------------------------------------------------------------
+/** Walks the object list in its own order and the players in index order, so every machine builds
+ * the same list, though only the client reads it: the logic keeps nothing of a sweep. */
+//-------------------------------------------------------------------------------------------------
+/*static*/ void RadarCoverageBehavior::sweep( void )
+{
+ const UnsignedInt frame = TheGameLogic->getFrame();
+ if( frame % RADAR_SWEEP_FRAMES != 0 )
+ return;
+
+ // which players any working radar covers for, theirs or an ally's
+ const Int playerCount = ThePlayerList->getPlayerCount();
+ Bool covered[ MAX_PLAYER_COUNT ] = { FALSE };
+ Bool anyCovered = FALSE;
+ for( const RadarCoverageBehavior *radar = s_first; radar; radar = radar->m_next )
+ {
+ const Object *obj = radar->getObject();
+ if( !isWorking( obj ) )
+ continue;
+ for( Int i = 0; i < playerCount; ++i )
+ {
+ if( !covered[ i ] && serves( obj->getControllingPlayer(), ThePlayerList->getNthPlayer( i ) ) )
+ covered[ i ] = anyCovered = TRUE;
+ }
+ }
+
+ std::vector<RadarContact> contacts;
+ if( anyCovered )
+ {
+ for( Object *obj = TheGameLogic->getFirstObject(); obj; obj = obj->getNextObject() )
+ {
+ if( obj->isEffectivelyDead() || obj->isDestroyed() || obj->isContained() || obj->isStructure()
+ || obj->isKindOf( KINDOF_PROJECTILE ) || isHidden( obj ) || !isMoving( obj ) )
+ continue;
+
+ for( Int i = 0; i < playerCount; ++i )
+ {
+ if( !covered[ i ] )
+ continue;
+ const Player *player = ThePlayerList->getNthPlayer( i );
+ if( player->getRelationship( obj->getTeam() ) != ENEMIES )
+ continue;
+ if( obj->getShroudedStatus( player->getPlayerIndex() ) <= OBJECTSHROUD_PARTIAL_CLEAR )
+ continue;
+ if( !isCovered( player, obj->getPosition() ) )
+ continue;
+
+ RadarContact contact;
+ contact.player = player->getPlayerIndex();
+ contact.id = obj->getID();
+ contact.pos = *obj->getPosition();
+ contacts.push_back( contact );
+ }
+ }
+
+#ifdef DEBUG_LOGGING
+ Int counts[ MAX_PLAYER_COUNT ] = { 0 };
+ for( size_t c = 0; c < contacts.size(); ++c )
+ ++counts[ contacts[ c ].player ];
+ char line[ 256 ];
+ Int used = 0;
+ for( Int i = 0; i < playerCount; ++i )
+ {
+ if( covered[ i ] )
+ used += snprintf( line + used, sizeof( line ) - used, " p%d=%d", ThePlayerList->getNthPlayer( i )->getPlayerIndex(), counts[ ThePlayerList->getNthPlayer( i )->getPlayerIndex() ] );
+ }
+ line[ used ] = 0;
+ DEBUG_LOG(( "RADARSWEEP frame %u contacts%s\n", frame, line ));
+#endif
+ }
+
+ // the client draws them; logic hands over a copy and is done (LogicThread::callAfterTick)
+ LogicThread::callAfterTick( [frame, contacts]() { RadarContactMarks_publish( frame, contacts ); } );
+}
+
//-------------------------------------------------------------------------------------------------
void RadarCoverageBehavior::crc( Xfer *xfer )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
index 9121d0dcb..5c56d919b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
@@ -72,6 +72,7 @@
#include "GameLogic/Module/BodyModule.h"
#include "GameLogic/Module/CollideModule.h"
#include "GameLogic/Module/ContainModule.h"
+#include "GameLogic/Module/RadarCoverageBehavior.h"
#include "GameLogic/Module/StealthUpdate.h"
#include "GameLogic/PartitionManager.h"
#include "GameLogic/AI.h" // aiIsIncomeNotATarget - a derrick is money, not a target
@@ -5664,11 +5665,14 @@ Bool PartitionFilterRejectBuildings::allow( Object *other )
//-----------------------------------------------------------------------------
/** Partly in sight counts. Since hills and buildings block sight, a building hides its own back
cells from anyone lower than its roof and is never wholly clear, so taking only CLEAR here left
- every unit the AI controls standing in front of an enemy base without firing a shot. */
+ every unit the AI controls standing in front of an enemy base without firing a shot.
+ A beyond-vision shooter passes its player as radar and also takes what that player's radar
+ tracks moving in the fog. */
Bool PartitionFilterFreeOfFog::allow( Object *other )
{
const ObjectShroudStatus status = other->getShroudedStatus(m_comparisonIndex);
- return status == OBJECTSHROUD_CLEAR || status == OBJECTSHROUD_PARTIAL_CLEAR;
+ return status == OBJECTSHROUD_CLEAR || status == OBJECTSHROUD_PARTIAL_CLEAR
+ || (m_radar && RadarCoverageBehavior::isTracked(m_radar, other));
}
//-----------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index e51764d36..2c4ea05e3 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -7060,7 +7060,8 @@ Object* AIUpdateInterface::getNextMoodTarget( Bool calledByAI, Bool calledDuring
}
// Turkiye's artillery sees 100 and shoots 600: it takes what a spotter shows its player, out to its
- // weapon's reach. The fog filter below is what keeps that to targets the team actually sees.
+ // weapon's reach. The fog filter below is what keeps that to targets the team actually sees, or
+ // that a radar of its player or an ally tracks moving in the fog (RadarCoverageBehavior::isTracked).
const Bool beyondVision = obj->getTemplate()->acquiresBeyondVision();
if (beyondVision)
rangeToFindWithin = max(rangeToFindWithin, obj->getLargestWeaponRange());
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
index 869b8719e..ffebede8e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
@@ -100,6 +100,7 @@
#include "GameLogic/Module/CreateModule.h"
#include "GameLogic/Module/DestroyModule.h"
#include "GameLogic/Module/OpenContain.h"
+#include "GameLogic/Module/RadarCoverageBehavior.h"
#include "GameLogic/PartitionManager.h"
#include "Common/ControlServer.h"
#include "GameLogic/PolygonTrigger.h"
@@ -5149,6 +5150,9 @@ void GameLogic::update( void )
ThePartitionManager->UPDATE();
}
+ // the radar's fogged contacts, against the shroud the partition update just settled
+ RadarCoverageBehavior::sweep();
+
tPartition = Clock_Ticks();
//
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h
index 39407bef8..a1c53968a 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h
@@ -82,6 +82,7 @@ protected:
void initializeTextureFormats( void ); ///< find format to use for the radar texture
void deleteResources( void ); ///< delete resources used
void drawEvents( Int pixelX, Int pixelY, Int width, Int height); ///< draw all of the radar events
+ void drawRadarContacts( Int pixelX, Int pixelY, Int width, Int height ); ///< the Turkiye radar's fogged contacts, this sweep and the last
void drawHeroIcon( Int pixelX, Int pixelY, Int width, Int height, const Coord3D *pos ); //< draw a hero icon
void drawViewBox( Int pixelX, Int pixelY, Int width, Int height ); ///< draw view box
void drawBoxLines( const ICoord2D *corners ); ///< a view box's lines through its four corners in pixels
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp
index 6e86180b9..3e097a48f 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp
@@ -51,6 +51,7 @@
#include "GameClient/Line2D.h"
#include "GameClient/MapUtil.h"
#include "GameClient/PlayerColorScheme.h"
+#include "GameClient/RadarContactMarks.h"
#include "GameClient/TerrainVisual.h"
#include "GameClient/Water.h"
#include "W3DDevice/Common/W3DRadar.h"
@@ -275,6 +276,82 @@ void W3DRadar::drawHeroIcon( Int pixelX, Int pixelY, Int width, Int height, cons
}
}
+//-------------------------------------------------------------------------------------------------
+/** A filled square cut to the radar's picture: drawFillRect clips to nothing, and a contact at the
+ * map's edge would otherwise spill onto the frame. */
+//-------------------------------------------------------------------------------------------------
+static void fillClipped( const IRegion2D &clip, Int x, Int y, Int size, UnsignedInt colour )
+{
+ Int x0 = max( x, clip.lo.x );
+ Int y0 = max( y, clip.lo.y );
+ Int x1 = min( x + size, clip.hi.x );
+ Int y1 = min( y + size, clip.hi.y );
+ if( x1 > x0 && y1 > y0 )
+ TheDisplay->drawFillRect( x0, y0, x1 - x0, y1 - y0, colour );
+}
+
+//-------------------------------------------------------------------------------------------------
+/** The radar's contacts on the minimap: this sweep's as a red square on a dark keyline with a dim
+ * ring round it, the sweep before as a small red square fading out as the next sweep comes due. */
+//-------------------------------------------------------------------------------------------------
+void W3DRadar::drawRadarContacts( Int pixelX, Int pixelY, Int width, Int height )
+{
+ const std::vector<RadarContact> &fresh = RadarContactMarks_fresh();
+ const std::vector<RadarContact> &echoes = RadarContactMarks_echoes();
+ if( fresh.empty() && echoes.empty() )
+ return;
+
+ IRegion2D clip;
+ clip.lo.x = pixelX;
+ clip.lo.y = pixelY;
+ clip.hi.x = pixelX + width;
+ clip.hi.y = pixelY + height;
+
+ // the ring is opaque, a darker shade of the contact's red: twelve translucent segments blended
+ // twice where they meet and the ring came out beaded
+ const UnsignedInt red = RadarContactLook::Colour & 0x00FFFFFF;
+ const Color ringColour = GameMakeColor( (UnsignedByte)(((red >> 16) & 0xFF) * 3 / 5), (UnsignedByte)(((red >> 8) & 0xFF) * 3 / 5),
+ (UnsignedByte)((red & 0xFF) * 3 / 5), 255 );
+ const Color keyline = GameMakeColor( 8, 10, 8, 200 );
+ const Int pip = RadarContactLook::MinimapPip;
+ const Real ringRadius = RadarContactLook::MinimapRing * 0.5f;
+ const Int ringSegments = 12;
+
+ for( size_t i = 0; i < fresh.size(); ++i )
+ {
+ ICoord2D radar, pixel;
+ radar.x = fresh[ i ].pos.x / (m_mapExtent.width() / RADAR_CELL_WIDTH);
+ radar.y = fresh[ i ].pos.y / (m_mapExtent.height() / RADAR_CELL_HEIGHT);
+ radarToPixel( &radar, &pixel, pixelX, pixelY, width, height );
+
+ for( Int s = 0; s < ringSegments; ++s )
+ {
+ Real a0 = TWO_PI * s / ringSegments;
+ Real a1 = TWO_PI * (s + 1) / ringSegments;
+ ICoord2D from, to, clippedFrom, clippedTo;
+ from.x = pixel.x + REAL_TO_INT( Cos( a0 ) * ringRadius );
+ from.y = pixel.y + REAL_TO_INT( Sin( a0 ) * ringRadius );
+ to.x = pixel.x + REAL_TO_INT( Cos( a1 ) * ringRadius );
+ to.y = pixel.y + REAL_TO_INT( Sin( a1 ) * ringRadius );
+ if( ClipLine2D( &from, &to, &clippedFrom, &clippedTo, &clip ) )
+ TheDisplay->drawLine( clippedFrom.x, clippedFrom.y, clippedTo.x, clippedTo.y, 1.0f, ringColour );
+ }
+ fillClipped( clip, pixel.x - (pip + 2) / 2, pixel.y - (pip + 2) / 2, pip + 2, keyline );
+ fillClipped( clip, pixel.x - pip / 2, pixel.y - pip / 2, pip, RadarContactLook::Colour );
+ }
+
+ const UnsignedInt echoAlpha = REAL_TO_UNSIGNEDBYTE( 255.0f * (1.0f - RadarContactMarks_sweepAge()) );
+ const Int echo = RadarContactLook::MinimapEcho;
+ for( size_t i = 0; i < echoes.size(); ++i )
+ {
+ ICoord2D radar, pixel;
+ radar.x = echoes[ i ].pos.x / (m_mapExtent.width() / RADAR_CELL_WIDTH);
+ radar.y = echoes[ i ].pos.y / (m_mapExtent.height() / RADAR_CELL_HEIGHT);
+ radarToPixel( &radar, &pixel, pixelX, pixelY, width, height );
+ fillClipped( clip, pixel.x - echo / 2, pixel.y - echo / 2, echo, red | (echoAlpha << 24) );
+ }
+}
+
//-------------------------------------------------------------------------------------------------
/** Draw a "box" into the texture passed in that represents the viewable area for
* the tactical display into the game world */
@@ -1457,6 +1534,12 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height )
TheDisplay->drawImage( m_shroudImage, ul.x, ul.y, lr.x, lr.y );
}
+ // the radar's contacts go over the shroud, which would dim them in the fog and black them out in
+ // the shroud, and so over the unit dots of the overlay as well. A contact is only ever a unit the
+ // shown player cannot see, so it never covers its own dot; it can cover a neighbour's. The icons
+ // still go on top
+ drawRadarContacts( ul.x, ul.y, scaledWidth, scaledHeight );
+
// draw any icons
drawIcons( ul.x, ul.y, scaledWidth, scaledHeight );
diff --git a/GeneralsMD/Code/Tools/radar_marks.py b/GeneralsMD/Code/Tools/radar_marks.py
new file mode 100644
index 000000000..e0deac5b5
--- /dev/null
+++ b/GeneralsMD/Code/Tools/radar_marks.py
@@ -0,0 +1,69 @@
+"""The ground marks of a Turkiye radar contact (GameClient/RadarContactMarks.cpp): a ring with a pip in
+its centre where the sweep painted a hidden enemy, and a thin ring for the ping ripples and the last
+sweep's echo. The game lays them on the terrain as decals tinted the contact red, so they are white
+where the colour goes; the contact mark has a soft dark edge so it reads on sand and in shadow.
+
+ python Tools/radar_marks.py # writes Data/Art/Textures/ReforgedRadar*.tga
+
+Drawn eight times too big and brought down, which is the antialiasing. Shipped small and with strokes
+four texels wide or more: the decal manager turns mipmapping off, so a finer sheet or a thinner line
+shimmers as the camera moves."""
+import os
+import sys
+
+from PIL import Image, ImageChops, ImageDraw, ImageFilter
+
+DRAWN = 512
+SHIPPED = 64
+CENTRE = DRAWN // 2
+RING_OUTER = 232
+RING_INNER = 196 # the contact ring's stroke, 2.2 of 15 in the approved still
+PIP = 46
+KEYLINE = 17 # a MaxFilter size, odd: the dark edge round every white shape, 8 drawn pixels, 1 texel
+KEYLINE_BLUR = 8 # drawn pixels the dark edge is softened over, a shadow rather than an outline
+KEYLINE_ALPHA = 150 # out of 255: enough to lift the red off bright desert, not a black ring
+THIN_INNER = 200 # the ripple and echo ring's stroke, four shipped texels
+OUT_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "Data", "Art", "Textures")
+
+
+def blank():
+ return Image.new("L", (DRAWN, DRAWN), 0)
+
+
+def disc(mask, radius, fill):
+ ImageDraw.Draw(mask).ellipse((CENTRE - radius, CENTRE - radius, CENTRE + radius, CENTRE + radius), fill=fill)
+
+
+def ring(outer, inner):
+ mask = blank()
+ disc(mask, outer, 255)
+ disc(mask, inner, 0)
+ return mask
+
+
+def shipped(white, alpha):
+ return Image.merge("RGBA", (white, white, white, alpha)).resize((SHIPPED, SHIPPED), Image.LANCZOS)
+
+
+def contact():
+ white = ring(RING_OUTER, RING_INNER)
+ disc(white, PIP, 255)
+ edge = white.filter(ImageFilter.MaxFilter(KEYLINE)).filter(ImageFilter.GaussianBlur(KEYLINE_BLUR))
+ return shipped(white, ImageChops.lighter(white, edge.point(lambda v: v * KEYLINE_ALPHA // 255)))
+
+
+def thin():
+ white = ring(RING_OUTER, THIN_INNER)
+ return shipped(white, white)
+
+
+def main():
+ out_folder = sys.argv[1] if len(sys.argv) > 1 else OUT_FOLDER
+ for name, mark in (("Contact", contact()), ("Ring", thin())):
+ path = os.path.join(out_folder, "ReforgedRadar%s.tga" % name)
+ mark.save(path)
+ print(path)
+
+
+if __name__ == "__main__":
+ main()