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): alt+z/x/c smoke signals for allies

Olcay Seygan6090fb74aaf6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63f775386..fadb53f59 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -502,6 +502,8 @@ found and fixed — EA's own, not port damage.**
- Allies only, and only mutual ones. Your position is sent to the players you are actually allied with and to nobody else; an enemy is never sent it at all, and a machine that has been made to send it anyway is ignored by everyone who is not your ally.
- An ally who alt-tabs away fades out over a couple of seconds instead of freezing on the map, so a marker that is still there is a marker somebody is still behind.
- Off in one place. `ShowAllyCursors = no` in `Options.ini` stops both halves: nothing is sent from your machine and nothing is drawn on it.
+- Alt+Z, Alt+X and Alt+C put up a puff of smoke where your mouse is. Red says attack here, blue says defend here, yellow says look at this. Point at the radar instead and the smoke goes up on that spot of the map.
+- Your allies see the smoke and their radar blinks at the spot, and the message area says who sent it. Three seconds later the smoke has cleared, so the call you made a minute ago is never still standing next to the one you are making now. Enemies see none of it.
## The options screen has pages
diff --git a/GeneralsMD/Code/Data/INI/CommandMap.ini b/GeneralsMD/Code/Data/INI/CommandMap.ini
index 31935402c..9ad9cd092 100644
--- a/GeneralsMD/Code/Data/INI/CommandMap.ini
+++ b/GeneralsMD/Code/Data/INI/CommandMap.ini
@@ -400,6 +400,39 @@ CommandMap HOLD_POSITION
DisplayName = GUI:HoldPosition
End
+; smoke signals for your allies, where the cursor is or on the radar spot under it,
+; gone after three seconds. The grid's bottom row again, on the one modifier the
+; grid leaves alone: Z attack here, X defend here, C look here. Network games only.
+CommandMap SIGNAL_ATTACK
+ Key = KEY_Z
+ Transition = DOWN
+ Modifiers = ALT
+ UseableIn = GAME
+ Category = INFORMATION
+ Description = GUI:SignalAttackDescription
+ DisplayName = GUI:SignalAttack
+End
+
+CommandMap SIGNAL_DEFEND
+ Key = KEY_X
+ Transition = DOWN
+ Modifiers = ALT
+ UseableIn = GAME
+ Category = INFORMATION
+ Description = GUI:SignalDefendDescription
+ DisplayName = GUI:SignalDefend
+End
+
+CommandMap SIGNAL_ATTENTION
+ Key = KEY_C
+ Transition = DOWN
+ Modifiers = ALT
+ UseableIn = GAME
+ Category = INFORMATION
+ Description = GUI:SignalAttentionDescription
+ DisplayName = GUI:SignalAttention
+End
+
; single player and replays only
CommandMap TOGGLE_PAUSE
Key = KEY_P
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index 436b7a311..60fa5e54c 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -185,6 +185,43 @@ GUI:HoldPositionDescription
"Every selected unit guards the spot it is standing on: it shoots what comes into range and never chases it."
END
+// Smoke signals. The three ...Placed lines are what an ally reads; %s is the sender's name.
+GUI:SignalAttack
+"Signal: Attack"
+END
+
+GUI:SignalAttackDescription
+"Red smoke for three seconds where the cursor is, or on the radar spot under it. Only your allies see it."
+END
+
+GUI:SignalDefend
+"Signal: Defend"
+END
+
+GUI:SignalDefendDescription
+"Blue smoke for three seconds where the cursor is, or on the radar spot under it. Only your allies see it."
+END
+
+GUI:SignalAttention
+"Signal: Look Here"
+END
+
+GUI:SignalAttentionDescription
+"Yellow smoke for three seconds where the cursor is, or on the radar spot under it. Only your allies see it."
+END
+
+GUI:SignalAttackPlaced
+"%s: attack here!"
+END
+
+GUI:SignalDefendPlaced
+"%s: defend here!"
+END
+
+GUI:SignalAttentionPlaced
+"%s: look here!"
+END
+
GUI:TogglePause
"Pause"
END
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
index 78bad8381..078cfe081 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
@@ -472,6 +472,9 @@ public:
MSG_META_PLACE_BEACON,
MSG_META_REMOVE_BEACON,
+ MSG_META_SIGNAL_ATTACK, ///< smoke for the allies: attack here (fork)
+ MSG_META_SIGNAL_DEFEND, ///< smoke for the allies: defend here (fork)
+ MSG_META_SIGNAL_ATTENTION, ///< smoke for the allies: look here (fork)
MSG_END_META_MESSAGES, ///< Marker to delineate "meta" messages
@@ -643,6 +646,7 @@ public:
MSG_DO_FORMATION_ATTACKMOVETO, ///< (location...) the same curve, taken as an attack move (fork)
MSG_DO_FORMATION_FORCEATTACK, ///< (location...) the same curve, each unit force firing its own point (fork)
MSG_DO_FORMATION_GUARD, ///< (location...) the same curve, each unit guarding its own point (fork)
+ MSG_PLACE_SIGNAL, ///< (location, Int SignalKind) smoke only the sender's allies are shown (fork)
MSG_BEGIN_DEBUG_NETWORK_MESSAGES = 1900, ///< network messages that exist only in debug/internal builds. all grouped separately.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.h
index d0744d4e6..373b86cb2 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/CommandXlat.h
@@ -141,6 +141,20 @@ extern Bool Command_stopMeansCancelConstruction( Int selectionCount, Bool locall
extern Bool Command_formationDragArmed( Bool setting, Bool haveMovableSelection,
Bool guiCommandPending );
+/** The smoke signals a player drops for their allies, carried as the integer argument of
+ * MSG_PLACE_SIGNAL. The value arrives from another machine, so the receiving side range-checks
+ * it against SIGNAL_KIND_COUNT. */
+enum SignalKind
+{
+ SIGNAL_ATTACK,
+ SIGNAL_DEFEND,
+ SIGNAL_ATTENTION,
+ SIGNAL_KIND_COUNT
+};
+
+/** Which signal a SIGNAL_* meta key drops; SIGNAL_KIND_COUNT for every other message. */
+extern SignalKind Command_signalKindForMeta( GameMessage::Type meta );
+
class Player;
/** Single-player test hook: make this player the one at the keyboard, throwing away any AI behind
* it first. FALSE if that player cannot be played (yourself, neutral, observer, beaten) or this
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
index 56194135b..0fc8a27e3 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
@@ -702,6 +702,7 @@ public:
const Coord3D *getSlavePositionOffset( void ) { return &m_slavePosOffset; }
void setSystemLifetime( UnsignedInt frames ) { m_systemLifetimeLeft = frames; }; ///< not the particle life, the system!... Lorenzen
+ void setFiniteSystemLifetime( UnsignedInt frames ) { m_isForever = false; m_systemLifetimeLeft = frames; } ///< the same, and it ends even when the template said forever (fork)
void setLifetimeRange( Real min, Real max );
Bool isSystemForever() const {return m_isForever;}
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
index cee1abfc0..44156c30f 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
@@ -541,6 +541,9 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
#endif//DUMP_PERF_STATS
CHECK_IF(MSG_META_PLACE_BEACON)
CHECK_IF(MSG_META_REMOVE_BEACON)
+ CHECK_IF(MSG_META_SIGNAL_ATTACK)
+ CHECK_IF(MSG_META_SIGNAL_DEFEND)
+ CHECK_IF(MSG_META_SIGNAL_ATTENTION)
CHECK_IF(MSG_END_META_MESSAGES)
CHECK_IF(MSG_MOUSEOVER_DRAWABLE_HINT)
CHECK_IF(MSG_MOUSEOVER_LOCATION_HINT)
@@ -653,6 +656,7 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
CHECK_IF(MSG_DO_FORMATION_ATTACKMOVETO)
CHECK_IF(MSG_DO_FORMATION_FORCEATTACK)
CHECK_IF(MSG_DO_FORMATION_GUARD)
+ CHECK_IF(MSG_PLACE_SIGNAL)
CHECK_IF(MSG_DO_GUARD_OBJECT)
CHECK_IF(MSG_DO_STOP)
CHECK_IF(MSG_DO_SCATTER)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index e6b0b4e22..a61c6cb5f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -156,6 +156,18 @@ GameMessage::Type Command_formationMessage( Bool attackMoveArmed, Bool forceAtta
return GameMessage::MSG_DO_FORMATION_MOVETO;
}
+//-------------------------------------------------------------------------------------------------
+SignalKind Command_signalKindForMeta( GameMessage::Type meta )
+{
+ switch( meta )
+ {
+ case GameMessage::MSG_META_SIGNAL_ATTACK: return SIGNAL_ATTACK;
+ case GameMessage::MSG_META_SIGNAL_DEFEND: return SIGNAL_DEFEND;
+ case GameMessage::MSG_META_SIGNAL_ATTENTION: return SIGNAL_ATTENTION;
+ default: return SIGNAL_KIND_COUNT;
+ }
+}
+
static Bool isFormationDragArmed( void )
{
return Command_formationDragArmed( TheGlobalData->m_formationDrag,
@@ -3289,6 +3301,27 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
disp = DESTROY_MESSAGE;
break;
+ //-----------------------------------------------------------------------------------------
+ // Smoke for the allies where the cursor points: on the radar, the map spot it stands for,
+ // otherwise the ground under it.
+ case GameMessage::MSG_META_SIGNAL_ATTACK:
+ case GameMessage::MSG_META_SIGNAL_DEFEND:
+ case GameMessage::MSG_META_SIGNAL_ATTENTION:
+ if (TheGameLogic->isInMultiplayerGame() && !TheGameLogic->isInReplayGame() &&
+ ThePlayerList->getLocalPlayer()->isPlayerActive())
+ {
+ const ICoord2D *cursor = &TheMouse->getMouseStatus()->pos;
+ Coord3D world;
+ if( TheRadar->screenPixelToWorld( cursor, &world ) || TheTacticalView->screenToTerrain( cursor, &world ) )
+ {
+ GameMessage *signalMsg = TheMessageStream->appendMessage( GameMessage::MSG_PLACE_SIGNAL );
+ signalMsg->appendLocationArgument( world );
+ signalMsg->appendIntegerArgument( Command_signalKindForMeta( t ) );
+ }
+ }
+ disp = DESTROY_MESSAGE;
+ break;
+
//-----------------------------------------------------------------------------------------
case GameMessage::MSG_META_OPTIONS:
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
index 8e30b07d7..048005376 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
@@ -195,6 +195,9 @@ static const LookupListRec GameMessageMetaTypeNames[] =
{ "DIPLOMACY", GameMessage::MSG_META_DIPLOMACY },
{ "PLACE_BEACON", GameMessage::MSG_META_PLACE_BEACON },
{ "DELETE_BEACON", GameMessage::MSG_META_REMOVE_BEACON },
+ { "SIGNAL_ATTACK", GameMessage::MSG_META_SIGNAL_ATTACK },
+ { "SIGNAL_DEFEND", GameMessage::MSG_META_SIGNAL_DEFEND },
+ { "SIGNAL_ATTENTION", GameMessage::MSG_META_SIGNAL_ATTENTION },
{ "OPTIONS", GameMessage::MSG_META_OPTIONS },
{ "TOGGLE_LOWER_DETAILS", GameMessage::MSG_META_TOGGLE_LOWER_DETAILS },
{ "TOGGLE_CONTROL_BAR", GameMessage::MSG_META_TOGGLE_CONTROL_BAR },
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
index 98119cd11..8d47b214c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
@@ -398,6 +398,32 @@ void GameLogic::prepareNewGame( Int gameMode, GameDifficulty diff, Int rankPoint
} // end prepareNewGame
+//-------------------------------------------------------------------------------------------------
+/** What each smoke signal looks like on an ally's screen, indexed by SignalKind. The smoke is the
+ * beacon's white template tinted, which is all the coloured beacon templates are: they differ
+ * from it in their second colour key and nowhere else. No signal uses RADAR_EVENT_UNDER_ATTACK,
+ * because Radar::tryEvent refuses a real attack warning within ten seconds of one of those. */
+//-------------------------------------------------------------------------------------------------
+struct SignalLook
+{
+ Color smokeColor;
+ RadarEventType radarEvent;
+ const char *announcementLabel;
+};
+
+static const SignalLook SIGNAL_LOOKS[ SIGNAL_KIND_COUNT ] =
+{
+ { 0xFF0000, RADAR_EVENT_BATTLE_PLAN, "GUI:SignalAttackPlaced" },
+ { 0x4368FE, RADAR_EVENT_CONSTRUCTION, "GUI:SignalDefendPlaced" },
+ { 0xDDE20D, RADAR_EVENT_INFORMATION, "GUI:SignalAttentionPlaced" },
+};
+
+static const char *SIGNAL_SMOKE_TEMPLATE = "BeaconSmokeFFFFFF";
+static const Real SIGNAL_SECONDS = 3.0f;
+
+/// the smoke is fed for the first half of the signal and its last puff fades out over the second
+static const UnsignedInt SIGNAL_HALF_FRAMES = (UnsignedInt)( SIGNAL_SECONDS * LOGICFRAMES_PER_SECOND / 2 );
+
//-------------------------------------------------------------------------------------------------
/** This message handles dispatches object command messages to the
* appropriate objects.
@@ -2039,6 +2065,50 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
break;
} // end beacon placement
+ // --------------------------------------------------------------------------------------------
+ // A smoke signal is a picture and a line of text on the machines allowed to see it, and
+ // nothing else: no object is made and no logic state moves, so a machine that draws it and a
+ // machine that does not stay in step.
+ case GameMessage::MSG_PLACE_SIGNAL:
+ {
+ Int kind = msg->getArgument( 1 )->integer;
+ if( kind < 0 || kind >= SIGNAL_KIND_COUNT )
+ break;
+
+ Player *localPlayer = ThePlayerList->getLocalPlayer();
+ Bool mutualAllies = thisPlayer->getRelationship( localPlayer->getDefaultTeam() ) == ALLIES &&
+ localPlayer->getRelationship( thisPlayer->getDefaultTeam() ) == ALLIES;
+ if( thisPlayer != localPlayer && !mutualAllies && !localPlayer->isPlayerObserver() )
+ break;
+
+ const SignalLook &look = SIGNAL_LOOKS[ kind ];
+ Coord3D pos = msg->getArgument( 0 )->location;
+
+ ParticleSystem *smoke = TheParticleSystemManager->createParticleSystem(
+ TheParticleSystemManager->findTemplate( SIGNAL_SMOKE_TEMPLATE ) );
+ if( smoke )
+ {
+ smoke->setPosition( &pos );
+ smoke->tintAllColors( look.smokeColor );
+ smoke->setFiniteSystemLifetime( SIGNAL_HALF_FRAMES );
+ smoke->setLifetimeRange( SIGNAL_HALF_FRAMES, SIGNAL_HALF_FRAMES );
+ // the template's second alpha key is its fade to nothing, timed for a five second puff
+ smoke->m_alphaKey[ 1 ].frame = SIGNAL_HALF_FRAMES;
+ }
+
+ TheRadar->createEvent( &pos, look.radarEvent, SIGNAL_SECONDS );
+
+ UnicodeString announcement;
+ announcement.format( TheGameText->fetch( look.announcementLabel ), thisPlayer->getPlayerDisplayName().str() );
+ TheInGameUI->message( announcement );
+
+ static AudioEventRTS signalSound( "BeaconPlaced" );
+ signalSound.setPlayerIndex( thisPlayer->getPlayerIndex() );
+ signalSound.setPosition( &pos );
+ TheAudio->addAudioEvent( &signalSound );
+ break;
+ }
+
// --------------------------------------------------------------------------------------------
case GameMessage::MSG_REMOVE_BEACON:
{
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 11b1eb1e8..36ef1c93c 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -1036,6 +1036,16 @@ TEST(a_formation_line_carries_the_armed_order)
CHECK( Command_formationMessage( false, false, true ) == GameMessage::MSG_DO_FORMATION_GUARD );
}
+/* CommandXlat.cpp: each smoke signal key names its own kind, and nothing else names one - the
+ receiving side indexes a table with that value. */
+TEST(each_signal_key_drops_its_own_smoke)
+{
+ CHECK( Command_signalKindForMeta( GameMessage::MSG_META_SIGNAL_ATTACK ) == SIGNAL_ATTACK );
+ CHECK( Command_signalKindForMeta( GameMessage::MSG_META_SIGNAL_DEFEND ) == SIGNAL_DEFEND );
+ CHECK( Command_signalKindForMeta( GameMessage::MSG_META_SIGNAL_ATTENTION ) == SIGNAL_ATTENTION );
+ CHECK( Command_signalKindForMeta( GameMessage::MSG_META_PLACE_BEACON ) == SIGNAL_KIND_COUNT );
+}
+
/* DrawnPath.cpp: the drawn curve is measured by arc length, not by segment, so the stations divide
the whole line however uneven the hand that drew it was. */
#include "Common/DrawnPath.h"