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): signal smoke lasts ten seconds and the mark goes with it

Olcay Seygan4098a141144b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b68cfcd4a..b6562ed4b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -720,7 +720,7 @@ found and fixed — EA's own, not port damage.**
- 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 in your own colour where your mouse is, and lay a mark on the ground under it: crossed swords, a shield or an eye. The colour says who, the mark says what, with no word to read in anyone's language. 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 feed says who sent it. The smoke clears in three seconds and the mark in ten, 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.
+- Your allies see the smoke and their radar blinks at the spot, and the feed says who sent it. The smoke and the mark stay ten seconds and go together, 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.
- One signal a second per player. Hammering the key gets you the first puff and nothing else, and a teammate who tries it cannot bury your screen in smoke either, because every machine in the game holds everyone to the same limit.
## A console, on the key above Tab
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 498d2b041..d9238a85d 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -14790,7 +14790,7 @@ GUI:SignalAttack
END
GUI:SignalAttackDescription
-"İmlecin olduğu yere ya da altındaki radar noktasına sizin renginizde bir duman ve on saniyeliğine yere çapraz kılıçlar bırakır. Yalnızca müttefikleriniz görür."
+"İmlecin olduğu yere ya da altındaki radar noktasına on saniyeliğine sizin renginizde bir duman ve yere çapraz kılıçlar bırakır. Yalnızca müttefikleriniz görür."
END
GUI:SignalDefend
@@ -14798,7 +14798,7 @@ GUI:SignalDefend
END
GUI:SignalDefendDescription
-"İmlecin olduğu yere ya da altındaki radar noktasına sizin renginizde bir duman ve on saniyeliğine yere bir kalkan bırakır. Yalnızca müttefikleriniz görür."
+"İmlecin olduğu yere ya da altındaki radar noktasına on saniyeliğine sizin renginizde bir duman ve yere bir kalkan bırakır. Yalnızca müttefikleriniz görür."
END
GUI:SignalAttention
@@ -14806,7 +14806,7 @@ GUI:SignalAttention
END
GUI:SignalAttentionDescription
-"İmlecin olduğu yere ya da altındaki radar noktasına sizin renginizde bir duman ve on saniyeliğine yere bir göz bırakır. Yalnızca müttefikleriniz görür."
+"İmlecin olduğu yere ya da altındaki radar noktasına on saniyeliğine sizin renginizde bir duman ve yere bir göz bırakır. Yalnızca müttefikleriniz görür."
END
GUI:SignalAttackPlaced
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index 4667dbd79..f511941fc 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -895,8 +895,8 @@ public: // ********************************************************************
// Floating Test Methods
/// the text it added, for a caller that wants to hold it longer; NULL while icons are not drawn
virtual FloatingTextData *addFloatingText(const UnicodeString& text,const Coord3D * pos, Color color);
- /// a smoke signal's mark laid on the ground in the sender's colour, faded in and out over holdFrames
- void addSignalMark( SignalKind kind, const Coord3D &pos, Color color, UnsignedInt holdFrames );
+ /// a smoke signal's mark laid on the ground in the sender's colour, there until its smoke is gone
+ void addSignalMark( SignalKind kind, const Coord3D &pos, Color color, ParticleSystemID smoke );
/// a signal button pressed: the next left click on the ground or the radar drops that signal there
void armSignal( SignalKind kind ) { m_armedSignal = kind; }
void disarmSignal( void ) { m_armedSignal = SIGNAL_KIND_COUNT; }
@@ -1295,8 +1295,7 @@ protected:
struct SignalMark
{
Shadow *decal;
- UnsignedInt born; ///< the logic frame it went down on
- UnsignedInt until; ///< and the one it is gone by
+ ParticleSystemID smoke; ///< the signal's smoke, which the mark lasts exactly as long as
};
std::vector< SignalMark > m_signalMarks;
void updateSignalMarks( void );
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
index 06dd84ecc..176902715 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
@@ -187,6 +187,7 @@ public:
inline Real getSize( void ) { return m_size; }
inline Real getAngle( void ) { return m_angleZ; }
inline Real getAlpha( void ) { return m_alpha; }
+ inline UnsignedInt getLifetimeLeft( void ) const { return m_lifetimeLeft; }
inline const RGBColor *getColor( void ) { return &m_color; }
inline void setColor( RGBColor *color ) { m_color = *color; }
@@ -751,6 +752,8 @@ public:
// @todo Const this jkmcd
Particle *getFirstParticle( void ) { return m_systemParticlesHead; }
+ const Particle *getLastParticle( void ) const { return m_systemParticlesTail; } ///< the youngest, the last one emitted
+ UnsignedInt getSystemLifetimeLeft( void ) const { return m_systemLifetimeLeft; }
void addParticle( Particle *particleToAdd );
/// when a particle dies, it calls this method - ONLY FOR USE BY PARTICLE
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 7b2d9fbc0..ef3928bfe 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -88,6 +88,7 @@
#include "GameClient/Display.h"
#include "GameClient/WindowLayout.h"
#include "GameClient/LookAtXlat.h"
+#include "GameClient/ParticleSys.h"
#include "GameClient/SelectionXlat.h"
#include "GameClient/Shadow.h"
#include "GameClient/GlobalLanguage.h"
@@ -8807,15 +8808,14 @@ enum
{
SIGNAL_MARK_SIZE = 160, ///< across, in world units: 90 read as a coin from the default camera
SIGNAL_MARK_OPACITY = 230, ///< out of 255, so the ground under it still shows a little
- SIGNAL_MARK_FADE_IN_FRAMES = LOGICFRAMES_PER_SECOND / 4,
- SIGNAL_MARK_FADE_OUT_FRAMES = LOGICFRAMES_PER_SECOND * 2
+ SIGNAL_MARK_FADE_OUT_FRAMES = LOGICFRAMES_PER_SECOND * 2 ///< the smoke's last steps, over which the mark fades
};
//-------------------------------------------------------------------------------------------------
/** The mark a signal lays on the ground: crossed swords, a shield or an eye in a ring, in `color`,
* turned to this viewer's camera as it stands now so it reads upright. */
//-------------------------------------------------------------------------------------------------
-void InGameUI::addSignalMark( SignalKind kind, const Coord3D &pos, Color color, UnsignedInt holdFrames )
+void InGameUI::addSignalMark( SignalKind kind, const Coord3D &pos, Color color, ParticleSystemID smoke )
{
Shadow::ShadowTypeInfo decalInfo;
decalInfo.allowUpdates = FALSE;
@@ -8834,33 +8834,36 @@ void InGameUI::addSignalMark( SignalKind kind, const Coord3D &pos, Color color,
mark.decal->setColor( color );
mark.decal->setOpacity( 0 );
mark.decal->setPosition( pos.x, pos.y, pos.z );
- mark.born = TheGameLogic->getFrame();
- mark.until = mark.born + holdFrames;
+ mark.smoke = smoke;
m_signalMarks.push_back( mark );
}
//-------------------------------------------------------------------------------------------------
-/** Fades each mark in and out by the logic frame, so a paused game holds them, and takes off the
- * ones whose time is up. Hidden while scripts or -cinema hide the icons, like a radius decal. */
+/** Each mark lasts as long as its smoke and fades out over the smoke's last steps. Both can't
+ * simply count logic frames: ParticleSystemManager::update steps once per pass that sees a new
+ * logic frame, so a network game catching up several frames in one pass keeps its smoke longer
+ * than the frame count says, and a mark on its own clock went a second early or late. The smoke
+ * has left in it what it still has to emit plus the life of its youngest puff. Hidden while
+ * scripts or -cinema hide the icons, like a radius decal. */
//-------------------------------------------------------------------------------------------------
void InGameUI::updateSignalMarks( void )
{
- const UnsignedInt frame = TheGameLogic->getFrame();
const Bool shown = TheGameLogic->getDrawIconUI() && !CinemaDirector_hidesHud();
for( size_t index = 0; index < m_signalMarks.size(); )
{
- // a frame going backwards is a loaded save, and the mark is not from this game any more
SignalMark &mark = m_signalMarks[ index ];
- if( frame >= mark.until || frame < mark.born )
+ const ParticleSystem *smoke = TheParticleSystemManager->findParticleSystem( mark.smoke );
+ if( smoke == NULL )
{
mark.decal->release();
m_signalMarks.erase( m_signalMarks.begin() + index );
continue;
}
- const UnsignedInt rising = ( frame - mark.born ) * SIGNAL_MARK_OPACITY / SIGNAL_MARK_FADE_IN_FRAMES;
- const UnsignedInt falling = ( mark.until - frame ) * SIGNAL_MARK_OPACITY / SIGNAL_MARK_FADE_OUT_FRAMES;
- mark.decal->setOpacity( shown ? (Int)min( (UnsignedInt)SIGNAL_MARK_OPACITY, min( rising, falling ) ) : 0 );
+ const Particle *youngest = smoke->getLastParticle();
+ const UnsignedInt left = smoke->getSystemLifetimeLeft() + ( youngest ? youngest->getLifetimeLeft() : 0 );
+ const UnsignedInt opacity = min( (UnsignedInt)SIGNAL_MARK_OPACITY, left * SIGNAL_MARK_OPACITY / SIGNAL_MARK_FADE_OUT_FRAMES );
+ mark.decal->setOpacity( shown ? (Int)opacity : 0 );
index++;
}
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
index 9f71616f3..95b93037d 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
@@ -421,19 +421,17 @@ static const SignalLook SIGNAL_LOOKS[ SIGNAL_KIND_COUNT ] =
};
static const char *SIGNAL_SMOKE_TEMPLATE = "BeaconSmokeFFFFFF";
-static const Real SIGNAL_SECONDS = 3.0f;
+/// the smoke, the mark on the ground and the radar ping all go together, as long as the feed's line
+static const Real SIGNAL_SECONDS = 10.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 );
-/// the mark on the ground and the radar ping outlast the smoke, as long as the feed's line about it
-static const Real SIGNAL_MARK_SECONDS = 10.0f;
-
static const UnsignedInt SIGNAL_COOLDOWN_FRAMES = LOGICFRAMES_PER_SECOND;
// The beacon template draws a column nine units wide that needs five seconds to climb, which at the
-// signal's three seconds and the default camera height is a dark speck. Measured on screen, not
-// derived: these make it a plume a tank's width across that a player finds at a glance.
+// signal's first three seconds and the default camera height is a dark speck. Measured on screen,
+// not derived: these make it a plume a tank's width across that a player finds at a glance.
static const Real SIGNAL_SMOKE_SIZE_SCALE = 5.0f;
static const Real SIGNAL_SMOKE_DENSITY_SCALE = 3.0f;
static const Real SIGNAL_SMOKE_RISE_SCALE = 3.0f;
@@ -2144,11 +2142,10 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
smoke->setBurstCountMultiplier( SIGNAL_SMOKE_DENSITY_SCALE );
Coord3D rise = { 1.0f, 1.0f, SIGNAL_SMOKE_RISE_SCALE };
smoke->setVelocityMultiplier( &rise );
+ TheInGameUI->addSignalMark( (SignalKind)kind, pos, clientPlayerColor( thisPlayer ), smoke->getSystemID() );
}
- TheRadar->createEvent( &pos, look.radarEvent, SIGNAL_MARK_SECONDS );
- TheInGameUI->addSignalMark( (SignalKind)kind, pos, clientPlayerColor( thisPlayer ),
- (UnsignedInt)( SIGNAL_MARK_SECONDS * LOGICFRAMES_PER_SECOND ) );
+ TheRadar->createEvent( &pos, look.radarEvent, SIGNAL_SECONDS );
UnicodeString announcement;
announcement.format( TheGameText->fetch( look.announcementLabel ), thisPlayer->getPlayerDisplayName().str() );