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(gameclient): upgrades and a per-building row on the production strip

Olcay Seyganf4fa107dc4b1
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
index 3d876dcc9..951dbc5b8 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -791,6 +791,9 @@ public:
const Image *getStarImage( void );
Color getBorderColor( void ){return m_commandBarBorderColor;}
+ /// the two button border colours the bar itself uses, so anything drawn outside it can match
+ Color getBuildBorderColor( void ){return m_commandButtonBorderBuildColor;}
+ Color getUpgradeBorderColor( void ){return m_commandButtonBorderUpgradeColor;}
void updateBorderColor( Color color) {m_commandBarBorderColor = color; }
/// set the command data into the button
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index a2caaefb5..75ae514b3 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -475,12 +475,13 @@ public: // ********************************************************************
// One cameo of the global production strip: which producer it belongs to, which entry of that
// producer's queue it is, and where it was drawn this frame.
//
- enum { MAX_PRODUCTION_STRIP = 24 }; ///< as many cameos as the strip will ever draw
+ enum { MAX_PRODUCTION_STRIP = 40 }; ///< as many cameos as the strip will ever draw, both rows
struct ProductionStripSlot
{
ObjectID producer; ///< the building this item is queued on
- Int id; ///< its ProductionID in that building's queue
+ Int id; ///< a unit's ProductionID, or an upgrade's name key
/// (kept as an Int so this header stays clear of GameLogic)
+ Bool isUpgrade; ///< which of those two the id means
ICoord2D pos; ///< top left corner of the cameo on screen
};
@@ -772,7 +773,8 @@ protected:
void drawHudOverlay( void ); ///< the small elapsed-time / fps plate (ShowHudOverlay)
void drawIncomeRate( void ); ///< income per minute, drawn beside the money window
void updateIncomeEstimate( Player *player ); ///< income per minute, shown beside the money
- void drawProductionStrip( void ); ///< the global production queue, above the control bar
+ void drawProductionStrip( void ); ///< the production queue rows above the control bar
+ void drawProductionStripRow( Int first, Int last, Int y ); ///< one row of those, [first, last)
Bool m_placementRangeRingUp; ///< we put a radius cursor up for a pending structure, so we owe a clear
Real m_placementRingRadius; ///< the radius that ring was built at, so it is not rebuilt every frame
@@ -794,6 +796,7 @@ protected:
//
ProductionStripSlot m_productionStrip[ MAX_PRODUCTION_STRIP ];
Int m_productionStripCount; ///< how many of those slots are live this frame
+ Int m_productionStripGlobalCount; ///< of those, how many belong to the top (global) row
Coord2D m_superweaponPosition;
Real m_superweaponFlashDuration;
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
index 7184be9d2..8265130db 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
@@ -288,6 +288,15 @@ static char *WindMotionNames[] =
* All of the properties of a particle system, used by both ParticleSystemTemplates
* and ParticleSystem classes.
*/
+/**
+ * Collide one particle with the ground. Free of ParticleSystem on purpose: it needs no
+ * subsystems, so it can be exercised directly (test_gameengine). pos/vel are world space and
+ * are updated in place; groundZ and normal are what TheTerrainLogic reports under pos.
+ * Returns TRUE if the particle was at or below the ground.
+ */
+extern Bool particleGroundBounce( Coord3D *pos, Coord3D *vel, Real groundZ,
+ const Coord3D *normal, Real bounce, Real friction );
+
class ParticleSystemInfo : public Snapshot
{
@@ -357,6 +366,13 @@ public:
Coord3D m_driftVelocity; ///< additional velocity added to all particles
Real m_gravity; ///< gravity acceleration (global Z) for particles in this system
+ // Terrain collision. Retail particles fall straight through the ground; sparks, debris and
+ // smoke all vanish into the hillside instead of hitting it. Off by default, so every
+ // existing particle system keeps its shipped behaviour until its INI opts in.
+ Bool m_groundCollision; ///< if true, particles bounce off the terrain instead of passing through
+ Real m_groundBounce; ///< fraction of the velocity into the ground that comes back out (0 = dead stop, 1 = elastic)
+ Real m_groundFriction; ///< fraction of the velocity along the ground kept per contact (1 = frictionless slide)
+
AsciiString m_slaveSystemName; ///< if non-empty, create a system whose particles track this system's
Coord3D m_slavePosOffset; ///< positional offset of slave particles relative to master's
@@ -547,6 +563,9 @@ public:
void setSkipParentXfrm(Bool enable) { m_skipParentXfrm = enable; } ///<disable transforming particle system with parent matrix.
const Coord3D *getDriftVelocity( void ) { return &m_driftVelocity; } ///< get the drift velocity of the system
+ Bool isGroundCollision( void ) const { return m_groundCollision; } ///< do this system's particles hit the terrain?
+ Real getGroundBounce( void ) const { return m_groundBounce; } ///< restitution against the terrain
+ Real getGroundFriction( void ) const { return m_groundFriction; } ///< drag along the terrain
void attachToDrawable( const Drawable *draw ); ///< attach this particle system to a Drawable
void attachToObject( const Object *obj ); ///< attach this particle system to an Object
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index eb5bd2b53..bb24b37c9 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -38,6 +38,7 @@
#include "Common/MessageStream.h"
#include "Common/PerfTimer.h"
#include "Common/Player.h"
+#include "Common/Upgrade.h"
#include "Common/PlayerList.h"
#include "Common/Radar.h"
#include "Common/Team.h"
@@ -1032,6 +1033,7 @@ InGameUI::InGameUI()
m_hudLastMoneyFrame = 0;
m_hudIncomePerMin = 0;
m_productionStripCount = 0;
+ m_productionStripGlobalCount = 0;
m_superweaponPosition.x = 0.7f;
m_superweaponPosition.y = 0.7f;
@@ -5402,21 +5404,72 @@ void InGameUI::drawHudOverlay( void )
}
//-------------------------------------------------------------------------------------------------
-// The global production strip: one cameo per queued unit across every building the local player
-// owns, oldest first, left aligned in a row that grows to the right just above the control bar.
-// The item a building is actually working on wears a radial fill. A click jumps the camera to the
-// building it is queued on; ctrl-click cancels it.
+// The production strip: one cameo per queued item, drawn over the world just above the control
+// bar, left aligned in a row that grows to the right. The top row is global - everything the local
+// player has queued anywhere. When a single producer is selected its own queue gets a second row
+// beneath it. Units and upgrades wear the same two border colours the command bar uses. The item a
+// building is actually working on wears a radial fill. A click takes the camera to the building an
+// item is queued on; ctrl-click cancels it.
//-------------------------------------------------------------------------------------------------
enum
{
PRODUCTION_STRIP_CAMEO = 32, ///< cameo edge in pixels
- PRODUCTION_STRIP_GAP = 3, ///< space between cameos
+ PRODUCTION_STRIP_GAP = 3, ///< space between cameos, and between the two rows
PRODUCTION_STRIP_LEFT = 8, ///< inset from the left edge of the screen
PRODUCTION_STRIP_LIFT = 6 ///< clearance above the control bar
};
//-------------------------------------------------------------------------------------------------
-/** Player::iterateObjects callback: append every unit this producer has queued. */
+/** Append everything this object has queued, units and upgrades alike, in queue order. */
+//-------------------------------------------------------------------------------------------------
+static void appendProducerQueue( Object *obj, InGameUI::ProductionStripSlot *slots, Int *count )
+{
+ if( obj == NULL || *count >= InGameUI::MAX_PRODUCTION_STRIP )
+ return;
+
+ ProductionUpdateInterface *pu = obj->getProductionUpdateInterface();
+ if( pu == NULL )
+ return;
+
+ for( const ProductionEntry *p = pu->firstProduction(); p; p = pu->nextProduction( p ) )
+ {
+ Int repeat = 1;
+ Int id = 0;
+ Bool isUpgrade = FALSE;
+
+ if( p->getProductionType() == PRODUCTION_UNIT )
+ {
+ //
+ // an entry can stand for several units of the same kind, and each of them is its own
+ // cameo here - the strip counts units, not orders
+ //
+ repeat = p->getProductionQuantityRemaining();
+ if( repeat < 1 )
+ repeat = 1;
+ id = (Int)p->getProductionID();
+ }
+ else if( p->getProductionType() == PRODUCTION_UPGRADE && p->getProductionUpgrade() )
+ {
+ isUpgrade = TRUE;
+ id = (Int)p->getProductionUpgrade()->getUpgradeNameKey();
+ }
+ else
+ continue;
+
+ while( repeat-- > 0 && *count < InGameUI::MAX_PRODUCTION_STRIP )
+ {
+ InGameUI::ProductionStripSlot *slot = &slots[ (*count)++ ];
+ slot->producer = obj->getID();
+ slot->id = id;
+ slot->isUpgrade = isUpgrade;
+ slot->pos.x = 0;
+ slot->pos.y = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------
+/** Player::iterateObjects callback for the global row. */
//-------------------------------------------------------------------------------------------------
struct ProductionStripGather
{
@@ -5427,35 +5480,89 @@ struct ProductionStripGather
static void gatherProductionStrip( Object *obj, void *userData )
{
ProductionStripGather *g = (ProductionStripGather *)userData;
+ appendProducerQueue( obj, g->slot, g->count );
+}
- if( obj == NULL || *g->count >= InGameUI::MAX_PRODUCTION_STRIP )
- return;
-
- ProductionUpdateInterface *pu = obj->getProductionUpdateInterface();
+//-------------------------------------------------------------------------------------------------
+/** Find the queue entry a slot stands for. Re-read every frame rather than cached: production runs
+ * on the logic clock and this draws on the render clock, so anything held is stale. */
+//-------------------------------------------------------------------------------------------------
+static const ProductionEntry *findStripEntry( ProductionUpdateInterface *pu,
+ const InGameUI::ProductionStripSlot *slot )
+{
if( pu == NULL )
- return;
+ return NULL;
for( const ProductionEntry *p = pu->firstProduction(); p; p = pu->nextProduction( p ) )
{
- if( p->getProductionType() != PRODUCTION_UNIT )
- continue;
+ if( slot->isUpgrade )
+ {
+ if( p->getProductionType() == PRODUCTION_UPGRADE && p->getProductionUpgrade() &&
+ (Int)p->getProductionUpgrade()->getUpgradeNameKey() == slot->id )
+ return p;
+ }
+ else if( p->getProductionType() == PRODUCTION_UNIT && (Int)p->getProductionID() == slot->id )
+ return p;
+ }
- //
- // an entry can stand for several units of the same kind, and each of them is its own
- // cameo here - the strip counts units, not orders
- //
- Int remaining = p->getProductionQuantityRemaining();
- if( remaining < 1 )
- remaining = 1;
+ return NULL;
+}
- while( remaining-- > 0 && *g->count < InGameUI::MAX_PRODUCTION_STRIP )
+//-------------------------------------------------------------------------------------------------
+/** Lay out and draw one row, [first, last) of the slot array, with its top edge at y. */
+//-------------------------------------------------------------------------------------------------
+void InGameUI::drawProductionStripRow( Int first, Int last, Int y )
+{
+ if( first >= last )
+ return;
+
+ const Int count = last - first;
+ const Int rowWidth = count * PRODUCTION_STRIP_CAMEO + ( count - 1 ) * PRODUCTION_STRIP_GAP;
+
+ // one plate behind the row, so the cameos read over any terrain
+ TheDisplay->drawFillRect( PRODUCTION_STRIP_LEFT - 3, y - 3, rowWidth + 6, PRODUCTION_STRIP_CAMEO + 6,
+ GameMakeColor( 0, 0, 0, 130 ) );
+
+ Int x = PRODUCTION_STRIP_LEFT;
+ for( Int i = first; i < last; i++ )
+ {
+ ProductionStripSlot *slot = &m_productionStrip[ i ];
+ slot->pos.x = x;
+ slot->pos.y = y;
+
+ Object *producer = TheGameLogic->findObjectByID( slot->producer );
+ ProductionUpdateInterface *pu = producer ? producer->getProductionUpdateInterface() : NULL;
+ const ProductionEntry *entry = findStripEntry( pu, slot );
+
+ if( entry )
{
- InGameUI::ProductionStripSlot *slot = &g->slot[ (*g->count)++ ];
- slot->producer = obj->getID();
- slot->id = (Int)p->getProductionID();
- slot->pos.x = 0;
- slot->pos.y = 0;
+ const Image *cameo = NULL;
+ if( slot->isUpgrade )
+ {
+ if( entry->getProductionUpgrade() )
+ cameo = entry->getProductionUpgrade()->getButtonImage();
+ }
+ else if( entry->getProductionObject() )
+ cameo = entry->getProductionObject()->getButtonImage();
+
+ if( cameo )
+ TheDisplay->drawImage( cameo, x, y, x + PRODUCTION_STRIP_CAMEO, y + PRODUCTION_STRIP_CAMEO );
+
+ // the head of a building's queue is the one being worked on, and only it has progress
+ if( pu->firstProduction() == entry && entry->getPercentComplete() > 0.0f )
+ TheDisplay->drawRectClock( x, y, PRODUCTION_STRIP_CAMEO, PRODUCTION_STRIP_CAMEO,
+ REAL_TO_INT( entry->getPercentComplete() ),
+ GameMakeColor( 0, 0, 0, 100 ) );
}
+
+ // same border colours the command bar puts on its build and upgrade buttons
+ Color border = GameMakeColor( 160, 160, 160, 160 );
+ if( TheControlBar )
+ border = slot->isUpgrade ? TheControlBar->getUpgradeBorderColor()
+ : TheControlBar->getBuildBorderColor();
+ TheDisplay->drawOpenRect( x, y, PRODUCTION_STRIP_CAMEO, PRODUCTION_STRIP_CAMEO, 1.0f, border );
+
+ x += PRODUCTION_STRIP_CAMEO + PRODUCTION_STRIP_GAP;
}
}
@@ -5463,6 +5570,7 @@ static void gatherProductionStrip( Object *obj, void *userData )
void InGameUI::drawProductionStrip( void )
{
m_productionStripCount = 0;
+ m_productionStripGlobalCount = 0;
if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )
return;
@@ -5475,6 +5583,18 @@ void InGameUI::drawProductionStrip( void )
gather.slot = m_productionStrip;
gather.count = &m_productionStripCount;
player->iterateObjects( gatherProductionStrip, &gather );
+ m_productionStripGlobalCount = m_productionStripCount;
+
+ //
+ // a single selected producer gets its own row underneath, so the building you are looking at
+ // is readable without picking its items out of the whole base's queue
+ //
+ if( getSelectCount() == 1 && !m_selectedDrawables.empty() )
+ {
+ Object *sel = m_selectedDrawables.front()->getObject();
+ if( sel && sel->getControllingPlayer() == player )
+ appendProducerQueue( sel, m_productionStrip, &m_productionStripCount );
+ }
if( m_productionStripCount == 0 )
return;
@@ -5493,55 +5613,23 @@ void InGameUI::drawProductionStrip( void )
barTop = barPos.y;
}
- const Int y = barTop - PRODUCTION_STRIP_CAMEO - PRODUCTION_STRIP_LIFT;
- if( y < 0 )
- return;
-
- // one plate behind the whole row, so the cameos read over any terrain
- const Int rowWidth = m_productionStripCount * PRODUCTION_STRIP_CAMEO +
- ( m_productionStripCount - 1 ) * PRODUCTION_STRIP_GAP;
- TheDisplay->drawFillRect( PRODUCTION_STRIP_LEFT - 3, y - 3, rowWidth + 6, PRODUCTION_STRIP_CAMEO + 6,
- GameMakeColor( 0, 0, 0, 130 ) );
+ // the selected building's row is the lower one, nearest the bar it belongs to
+ const Bool hasSelectedRow = ( m_productionStripCount > m_productionStripGlobalCount );
+ const Int lowerY = barTop - PRODUCTION_STRIP_CAMEO - PRODUCTION_STRIP_LIFT;
+ const Int upperY = lowerY - PRODUCTION_STRIP_CAMEO - PRODUCTION_STRIP_GAP;
- Int x = PRODUCTION_STRIP_LEFT;
- for( Int i = 0; i < m_productionStripCount; i++ )
+ if( hasSelectedRow )
{
- ProductionStripSlot *slot = &m_productionStrip[ i ];
- slot->pos.x = x;
- slot->pos.y = y;
-
- //
- // re-read the entry rather than caching the template: production runs on the logic clock
- // and this draws on the render clock, so anything held from the gather can be stale
- //
- Object *producer = TheGameLogic->findObjectByID( slot->producer );
- ProductionUpdateInterface *pu = producer ? producer->getProductionUpdateInterface() : NULL;
- const ProductionEntry *entry = NULL;
- if( pu )
- for( const ProductionEntry *p = pu->firstProduction(); p; p = pu->nextProduction( p ) )
- if( (Int)p->getProductionID() == slot->id )
- {
- entry = p;
- break;
- }
-
- if( entry && entry->getProductionObject() )
- {
- const Image *cameo = entry->getProductionObject()->getButtonImage();
- if( cameo )
- TheDisplay->drawImage( cameo, x, y, x + PRODUCTION_STRIP_CAMEO, y + PRODUCTION_STRIP_CAMEO );
-
- // the head of a building's queue is the one being worked on, and only it has progress
- if( pu->firstProduction() == entry && entry->getPercentComplete() > 0.0f )
- TheDisplay->drawRectClock( x, y, PRODUCTION_STRIP_CAMEO, PRODUCTION_STRIP_CAMEO,
- REAL_TO_INT( entry->getPercentComplete() ),
- GameMakeColor( 0, 0, 0, 100 ) );
- }
-
- TheDisplay->drawOpenRect( x, y, PRODUCTION_STRIP_CAMEO, PRODUCTION_STRIP_CAMEO, 1.0f,
- GameMakeColor( 160, 160, 160, 160 ) );
-
- x += PRODUCTION_STRIP_CAMEO + PRODUCTION_STRIP_GAP;
+ if( upperY < 0 )
+ return;
+ drawProductionStripRow( 0, m_productionStripGlobalCount, upperY );
+ drawProductionStripRow( m_productionStripGlobalCount, m_productionStripCount, lowerY );
+ }
+ else
+ {
+ if( lowerY < 0 )
+ return;
+ drawProductionStripRow( 0, m_productionStripGlobalCount, lowerY );
}
}
@@ -5565,8 +5653,13 @@ Bool InGameUI::handleProductionStripClick( const ICoord2D *mouse, Bool cancel )
if( cancel )
{
- // the producer travels with the message: the logic cannot tell whose queue this is otherwise
- GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_CANCEL_UNIT_CREATE );
+ //
+ // the producer travels with the message: the strip cancels on buildings that are not
+ // selected, so the logic cannot work out whose queue this is otherwise
+ //
+ GameMessage *msg = TheMessageStream->appendMessage( slot->isUpgrade
+ ? GameMessage::MSG_CANCEL_UPGRADE
+ : GameMessage::MSG_CANCEL_UNIT_CREATE );
msg->appendIntegerArgument( slot->id );
msg->appendObjectIDArgument( slot->producer );
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
index 49f25fb47..de545a479 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
@@ -354,6 +354,37 @@ void Particle::applyForce( const Coord3D *force )
m_accel.z += force->z;
}
+// ------------------------------------------------------------------------------------------------
+/** Collide a particle with the ground. The velocity is split into the part heading into the
+ * surface and the part sliding along it: the first is reflected and scaled by 'bounce', the
+ * second scaled by 'friction'. Working off the terrain normal rather than a flat Z flip means
+ * debris rolls down a slope instead of hopping straight up off it.
+ *
+ * A particle already moving away from the surface is only lifted clear, never flipped back in -
+ * that is what keeps a resting particle resting instead of jittering. */
+// ------------------------------------------------------------------------------------------------
+Bool particleGroundBounce( Coord3D *pos, Coord3D *vel, Real groundZ,
+ const Coord3D *normal, Real bounce, Real friction )
+{
+ if( pos->z >= groundZ )
+ return FALSE;
+
+ pos->z = groundZ;
+
+ const Real intoSurface = vel->x * normal->x + vel->y * normal->y + vel->z * normal->z;
+ if( intoSurface >= 0.0f )
+ return TRUE;
+
+ Coord3D alongNormal;
+ alongNormal.set( normal->x * intoSurface, normal->y * intoSurface, normal->z * intoSurface );
+
+ vel->x = (vel->x - alongNormal.x) * friction - alongNormal.x * bounce;
+ vel->y = (vel->y - alongNormal.y) * friction - alongNormal.y * bounce;
+ vel->z = (vel->z - alongNormal.z) * friction - alongNormal.z * bounce;
+
+ return TRUE;
+}
+
// ------------------------------------------------------------------------------------------------
/** Update the behavior of an individual particle */
// ------------------------------------------------------------------------------------------------
@@ -381,6 +412,18 @@ Bool Particle::update( void )
if( windMotion != ParticleSystemInfo::WIND_MOTION_NOT_USED )
doWindMotion();
+ // hit the ground, if this system asked to. Only while descending, so the terrain is not
+ // sampled for every rising smoke puff in the scene.
+ // ponytail: terrain heightmap only - buildings, bridges and the water surface are not consulted
+ if( m_system->isGroundCollision() && TheTerrainLogic != NULL
+ && (m_vel.z + driftVel->z) < 0.0f )
+ {
+ Coord3D groundNormal;
+ const Real groundZ = TheTerrainLogic->getGroundHeight( m_pos.x, m_pos.y, &groundNormal );
+ particleGroundBounce( &m_pos, &m_vel, groundZ, &groundNormal,
+ m_system->getGroundBounce(), m_system->getGroundFriction() );
+ }
+
// update orientation
m_angleZ += m_angularRateZ;
m_angularRateZ *= m_angularDamping;
@@ -738,6 +781,9 @@ ParticleSystemInfo::ParticleSystemInfo()
//Initializations inserted
m_driftVelocity.zero();
m_gravity = 0.0f;
+ m_groundCollision = FALSE; // retail behaviour: particles pass through the terrain
+ m_groundBounce = 0.35f; // only consulted once an INI sets GroundCollision = Yes
+ m_groundFriction = 0.6f;
m_isEmissionVolumeHollow = FALSE;
m_isOneShot = FALSE;
m_slavePosOffset.zero();
@@ -796,7 +842,8 @@ void ParticleSystemInfo::xfer( Xfer *xfer )
Int i;
// version
- XferVersion currentVersion = 1;
+ // 2: ground collision (m_groundCollision / m_groundBounce / m_groundFriction)
+ XferVersion currentVersion = 2;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
@@ -1017,6 +1064,14 @@ void ParticleSystemInfo::xfer( Xfer *xfer )
// wind motion moving to end angle
xfer->xferByte( &m_windMotionMovingToEndAngle );
+ // ground collision - added in version 2, absent from saves written before it
+ if( version >= 2 )
+ {
+ xfer->xferBool( &m_groundCollision );
+ xfer->xferReal( &m_groundBounce );
+ xfer->xferReal( &m_groundFriction );
+ }
+
} // end xfer
// ------------------------------------------------------------------------------------------------
@@ -2622,6 +2677,9 @@ const FieldParse ParticleSystemTemplate::m_fieldParseTable[] =
{ "VelocityDamping", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_velDamping ) },
{ "Gravity", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_gravity ) },
+ { "GroundCollision", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_groundCollision ) },
+ { "GroundBounce", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_groundBounce ) },
+ { "GroundFriction", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_groundFriction ) },
{ "SlaveSystem", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_slaveSystemName ) },
{ "SlavePosOffset", INI::parseCoord3D, NULL, offsetof( ParticleSystemTemplate, m_slavePosOffset ) },
{ "PerParticleAttachedSystem", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_attachedSystemName ) },
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
index 5bebfeca2..4279d9348 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
@@ -1381,7 +1381,11 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
//---------------------------------------------------------------------------------------------
case GameMessage::MSG_CANCEL_UPGRADE:
{
- Object *producer = getSingleObjectFromSelection(currentlySelectedGroup);
+ // as above: an explicit producer means the click came from somewhere other than that
+ // building's own command bar, and the ownership check below authorizes it
+ Object *producer = msg->getArgumentCount() > 1
+ ? TheGameLogic->findObjectByID( msg->getArgument( 1 )->objectID )
+ : getSingleObjectFromSelection(currentlySelectedGroup);
const UpgradeTemplate *upgradeT = TheUpgradeCenter->findUpgradeByKey( (NameKeyType)(msg->getArgument( 0 )->integer) );
// sanity
@@ -1454,14 +1458,14 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
Object *producer = NULL;
ProductionID productionID = (ProductionID)msg->getArgument( 0 )->integer;
- // an explicit producer (right-click cancel, multi-select) must be one of the selected objects
- if( msg->getArgumentCount() > 1 && currentlySelectedGroup )
- {
- ObjectID producerID = msg->getArgument( 1 )->objectID;
- const VecObjectID& ids = currentlySelectedGroup->getAllIDs();
- if( std::find( ids.begin(), ids.end(), producerID ) != ids.end() )
- producer = TheGameLogic->findObjectByID( producerID );
- }
+ //
+ // An explicit producer travels with the message when the click did not come from the
+ // selected building's own bar - a multi-selection's queue, or the global production
+ // strip, which cancels on a building the player never selected. The ownership check
+ // below is what authorizes it; membership of the current selection is not required.
+ //
+ if( msg->getArgumentCount() > 1 )
+ producer = TheGameLogic->findObjectByID( msg->getArgument( 1 )->objectID );
else
producer = getSingleObjectFromSelection(currentlySelectedGroup);