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.

fix(gameengine): no high ground behind the main menu, voice boost 2D only

Olcay Seyganb5f0fdd468fa
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b53273b94..9b3a18525 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -746,7 +746,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
## Twenty-two-year-old bugs, found by testing
- Pressing Continue after a campaign mission goes straight to the next one. The main menu used to wake up behind the score screen on the way out, show its buttons and start loading its own background battle, so the menu sat on screen over the next mission's load.
-- The main menu no longer opens with a man screaming. The battleship in the battle behind the menu shells GLA infantry, and each of them died out loud, the first one eight frames in. The guns, the explosions and the jungle still play.
+- The main menu no longer opens with a man screaming. The battle behind it is staged the way EA laid it out: Jarmen Kell sits on the cliff over the GLA infantry as scenery, and the extra reach high ground gives in a match let his rifle hit them from nearly twice its range a quarter of a second after the menu came up. High ground adds nothing behind the menu now, so the first soldier falls about six seconds in, under the battleship's shells, as he always did. Soldiers' death cries on the battlefield also sit back at their own volume; the boost that lifts your units' replies over the guns had been catching them too.
- A civilian car no longer drives into your base in the first minute of every game. A map's civilians are owned by a computer player like any other, and the scouting pass looks for anything of that player's that can drive - so it was picking a parked car out of the scenery and sending it to a start position. A side with no faction and no build list has nothing to learn from the map and does not scout.
- A rifleman pulled off an oil derrick mid-capture left it flashing and chiming for the rest of the match, and the derrick changed hands anyway with nobody standing on it. Walking away now stops the capture, whether you or the computer gave the order.
- Every countdown on screen was a second too long. Rounding up a whole number of seconds gave a whole number plus one, so a ten second build said eleven - production queues, buildings going up, superweapons, all of it.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
index a63812e7b..257f7ae0f 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
@@ -910,6 +910,9 @@ private:
extern WeaponStore *TheWeaponStore;
///< how much further a range reaches from heightAboveTarget above what it is aimed at; never less
+extern Real Weapon_highGroundRangeBonus( Real range, Real heightAboveTarget );
+
+///< Weapon_highGroundRangeBonus in a match; nothing in the battle behind the main menu
extern Real Weapon_elevationRangeBonus( Real range, Real heightAboveTarget );
///< range as source reaches something standing at targetZ; an aircraft gets no high ground
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
index ecb903187..722f3da00 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
@@ -408,11 +408,6 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
return AHSV_NoSound;
}
- // The battle behind the main menu kills infantry, and their death cries are not menu sound.
- if (eventToAdd->getEventName().endsWith("VoiceDie") && TheGameLogic->isInShellGame()) {
- return AHSV_NoSound;
- }
-
#ifdef INTENSIVE_AUDIO_DEBUG
DEBUG_LOG(("AUDIO (%d): Received addAudioEvent('%s')", TheGameLogic->getFrame(), eventToAdd->getEventName().str()));
#endif
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIInfluenceMap.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIInfluenceMap.cpp
index c403f7b74..e070aefb1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIInfluenceMap.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIInfluenceMap.cpp
@@ -76,7 +76,7 @@ void AIInfluenceMap::stamp( std::vector<Real> &layer, Real x, Real y, Real z, Re
if( m_cols <= 0 || power <= 0.0f || range <= 0.0f )
return;
- const Real farthest = range + Weapon_elevationRangeBonus( range, FLT_MAX );
+ const Real farthest = range + Weapon_highGroundRangeBonus( range, FLT_MAX );
const Int colLo = max<Int>( 0, REAL_TO_INT_FLOOR( (x - farthest - m_originX) / m_cellSize ) );
const Int colHi = min<Int>( m_cols - 1, REAL_TO_INT_FLOOR( (x + farthest - m_originX) / m_cellSize ) );
const Int rowLo = max<Int>( 0, REAL_TO_INT_FLOOR( (y - farthest - m_originY) / m_cellSize ) );
@@ -88,7 +88,7 @@ void AIInfluenceMap::stamp( std::vector<Real> &layer, Real x, Real y, Real z, Re
{
const Int index = row * m_cols + col;
const Real cx = m_originX + (col + 0.5f) * m_cellSize;
- const Real reach = range + Weapon_elevationRangeBonus( range, z - m_height[ index ] );
+ const Real reach = range + Weapon_highGroundRangeBonus( range, z - m_height[ index ] );
if( sqr( cx - x ) + sqr( cy - y ) <= sqr( reach ) )
layer[ index ] += power;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
index 278e06984..dbf1593f7 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
@@ -106,7 +106,7 @@ const DistanceCalculationType DAMAGE_RANGE_CALC_TYPE = FROM_BOUNDINGSPHERE_3D;
static const Real ELEVATION_RANGE_PER_HEIGHT = 3.0f;
static const Real ELEVATION_RANGE_CAP = 1.0f;
-Real Weapon_elevationRangeBonus( Real range, Real heightAboveTarget )
+Real Weapon_highGroundRangeBonus( Real range, Real heightAboveTarget )
{
if( heightAboveTarget <= 0.0f )
return 0.0f;
@@ -114,6 +114,18 @@ Real Weapon_elevationRangeBonus( Real range, Real heightAboveTarget )
return min( heightAboveTarget * ELEVATION_RANGE_PER_HEIGHT, range * ELEVATION_RANGE_CAP );
}
+/** The battle behind the main menu is EA's staging, laid out for flat ranges. Its Jarmen Kell
+ * stands on a cliff 115 units above the GLA infantry he was placed beside, and with the high ground
+ * he reached them from 416 away with a 225 rifle: the first one died eight frames after the menu
+ * came up, screaming over it. */
+Real Weapon_elevationRangeBonus( Real range, Real heightAboveTarget )
+{
+ if( TheGameLogic->isInShellGame() )
+ return 0.0f;
+
+ return Weapon_highGroundRangeBonus( range, heightAboveTarget );
+}
+
Real Weapon_elevatedRange( const Object *source, Real range, Real targetZ )
{
if( source->isKindOf( KINDOF_AIRCRAFT ) )
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
index 06d2a7151..79d79e30a 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
@@ -2213,7 +2213,9 @@ Real MilesAudioManager::getVoiceMixedVolume( const AudioEventRTS *event, Real sl
// looping sound's next pass died at address 0x40 on the XAudio2 service thread.
const AudioEventInfo *info = event->getAudioEventInfo();
const Real eventVolume = event->getVolume() * event->getVolumeShift();
- if (info != NULL && (info->m_type & ST_VOICE)) {
+ // A reply is heard in the ear, not out on the field. A world sound flagged as voice - a soldier's
+ // death cry - kept its place in the battle before this boost and keeps it now.
+ if (info != NULL && (info->m_type & ST_VOICE) && !event->isPositionalAudio()) {
return min( 1.0f, eventVolume * max( sliderVolume, m_speechVolume ) * VOICE_BOOST );
}
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 8a177f29b..7bb4be28c 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -7275,11 +7275,11 @@ TEST(an_armed_unit_sees_little_further_than_it_can_shoot)
range, and nothing taken away for standing lower. */
TEST(high_ground_reaches_further_and_low_ground_no_shorter)
{
- CHECK_NEAR( Weapon_elevationRangeBonus( 200.0f, 20.0f ), 60.0f, 0.0001f );
- CHECK_NEAR( Weapon_elevationRangeBonus( 200.0f, 400.0f ), 200.0f, 0.0001f );
- CHECK_NEAR( Weapon_elevationRangeBonus( 200.0f, FLT_MAX ), 200.0f, 0.0001f );
- CHECK_NEAR( Weapon_elevationRangeBonus( 200.0f, 0.0f ), 0.0f, 0.0001f );
- CHECK_NEAR( Weapon_elevationRangeBonus( 200.0f, -40.0f ), 0.0f, 0.0001f );
+ CHECK_NEAR( Weapon_highGroundRangeBonus( 200.0f, 20.0f ), 60.0f, 0.0001f );
+ CHECK_NEAR( Weapon_highGroundRangeBonus( 200.0f, 400.0f ), 200.0f, 0.0001f );
+ CHECK_NEAR( Weapon_highGroundRangeBonus( 200.0f, FLT_MAX ), 200.0f, 0.0001f );
+ CHECK_NEAR( Weapon_highGroundRangeBonus( 200.0f, 0.0f ), 0.0f, 0.0001f );
+ CHECK_NEAR( Weapon_highGroundRangeBonus( 200.0f, -40.0f ), 0.0f, 0.0001f );
}
/** A hill hides the ground behind it. Standing in the middle of flat ground with a wall of high cells