Skip to content

Commit ddf9d6d

Browse files
authored
Merge branch 'TheSuperHackers:main' into feature/unlimited-zoom-terrain
2 parents 2fc7a53 + 7ce6eeb commit ddf9d6d

File tree

12 files changed

+98
-35
lines changed

12 files changed

+98
-35
lines changed

Core/GameEngine/Include/Common/GameAudio.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ enum
131131
class AudioManager : public SubsystemInterface
132132
{
133133
public:
134+
typedef UnsignedInt MuteAudioReasonInt;
135+
136+
enum MuteAudioReason CPP_11(: UnsignedInt)
137+
{
138+
MuteAudioReason_WindowFocus,
139+
140+
MuteAudioReason_Count
141+
};
142+
143+
static const char *const MuteAudioReasonNames[];
144+
134145
AudioManager();
135146
virtual ~AudioManager();
136147
#if defined(RTS_DEBUG)
@@ -149,9 +160,8 @@ class AudioManager : public SubsystemInterface
149160
virtual void resumeAudio( AudioAffect which ) = 0;
150161
virtual void pauseAmbient( Bool shouldPause ) = 0;
151162

152-
// for focus issues
153-
virtual void loseFocus( void );
154-
virtual void regainFocus( void );
163+
void muteAudio( MuteAudioReason reason );
164+
void unmuteAudio( MuteAudioReason reason );
155165

156166
// control for AudioEventsRTS
157167
virtual AudioHandle addAudioEvent( const AudioEventRTS *eventToAdd ); ///< Add an audio event (event must be declared in an INI file)
@@ -361,6 +371,7 @@ class AudioManager : public SubsystemInterface
361371
NUM_VOLUME_TYPES
362372
};
363373
Real *m_savedValues;
374+
MuteAudioReasonInt m_muteReasonBits;
364375

365376
// Group of 8
366377
Bool m_speechOn : 1;

Core/GameEngine/Include/GameNetwork/LANAPI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class LANAPIInterface : public SubsystemInterface
130130
// Misc utility functions
131131
virtual LANGameInfo * LookupGame( UnicodeString gameName ) = 0; ///< return a pointer to a game we know about
132132
virtual LANGameInfo * LookupGameByListOffset( Int offset ) = 0; ///< return a pointer to a game we know about
133+
virtual LANGameInfo * LookupGameByHost( UnsignedInt hostIP ) = 0; ///< return a pointer to the most recent game associated to the host IP address
133134
virtual Bool SetLocalIP( UnsignedInt localIP ) = 0; ///< For multiple NIC machines
134135
virtual void SetLocalIP( AsciiString localIP ) = 0; ///< For multiple NIC machines
135136
virtual Bool AmIHost( void ) = 0; ///< Am I hosting a game?
@@ -331,6 +332,7 @@ class LANAPI : public LANAPIInterface
331332
// Misc utility functions
332333
virtual LANGameInfo * LookupGame( UnicodeString gameName ); ///< return a pointer to a game we know about
333334
virtual LANGameInfo * LookupGameByListOffset( Int offset ); ///< return a pointer to a game we know about
335+
virtual LANGameInfo * LookupGameByHost( UnsignedInt hostIP ); ///< return a pointer to the most recent game associated to the host IP address
334336
virtual LANPlayer * LookupPlayer( UnsignedInt playerIP ); ///< return a pointer to a player we know about
335337
virtual Bool SetLocalIP( UnsignedInt localIP ); ///< For multiple NIC machines
336338
virtual void SetLocalIP( AsciiString localIP ); ///< For multiple NIC machines

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ static const FieldParse audioSettingsFieldParseTable[] =
139139
// Singleton TheAudio /////////////////////////////////////////////////////////////////////////////
140140
AudioManager *TheAudio = nullptr;
141141

142+
const char *const AudioManager::MuteAudioReasonNames[] =
143+
{
144+
"MuteAudioReason_WindowFocus",
145+
};
142146

143147
// AudioManager Device Independent functions //////////////////////////////////////////////////////
144148
AudioManager::AudioManager() :
@@ -152,6 +156,8 @@ AudioManager::AudioManager() :
152156
m_hardwareAccel(FALSE),
153157
m_musicPlayingFromCD(FALSE)
154158
{
159+
static_assert(ARRAY_SIZE(AudioManager::MuteAudioReasonNames) == MuteAudioReason_Count, "Incorrect array size");
160+
155161
m_adjustedVolumes.clear();
156162
m_audioRequests.clear();
157163
m_listenerPosition.zero();
@@ -171,6 +177,7 @@ AudioManager::AudioManager() :
171177
m_miscAudio = NEW MiscAudio;
172178
m_silentAudioEvent = NEW AudioEventRTS;
173179
m_savedValues = nullptr;
180+
m_muteReasonBits = 0;
174181
m_disallowSpeech = FALSE;
175182
}
176183

@@ -1103,12 +1110,17 @@ void AudioManager::releaseAudioEventRTS( AudioEventRTS *&eventToRelease )
11031110
}
11041111

11051112
//-------------------------------------------------------------------------------------------------
1106-
void AudioManager::loseFocus( void )
1113+
void AudioManager::muteAudio( MuteAudioReason reason )
11071114
{
1108-
if (m_savedValues)
1115+
m_muteReasonBits |= 1u << reason;
1116+
1117+
DEBUG_LOG(("AudioManager::muteAudio(%s): m_muteReason=%u muted=%d",
1118+
MuteAudioReasonNames[reason], m_muteReasonBits, (int)(m_muteReasonBits != 0)));
1119+
1120+
if (m_muteReasonBits == 0 || m_savedValues)
11091121
return;
11101122

1111-
// In this case, make all the audio go silent.
1123+
// Make all the audio go silent.
11121124
m_savedValues = NEW Real[NUM_VOLUME_TYPES];
11131125
m_savedValues[VOLUME_TYPE_MUSIC] = m_systemMusicVolume;
11141126
m_savedValues[VOLUME_TYPE_SOUND] = m_systemSoundVolume;
@@ -1120,12 +1132,17 @@ void AudioManager::loseFocus( void )
11201132
}
11211133

11221134
//-------------------------------------------------------------------------------------------------
1123-
void AudioManager::regainFocus( void )
1135+
void AudioManager::unmuteAudio( MuteAudioReason reason )
11241136
{
1125-
if (!m_savedValues)
1137+
m_muteReasonBits &= ~(1u << reason);
1138+
1139+
DEBUG_LOG(("AudioManager::unmuteAudio(%s): m_muteReason=%u muted=%d",
1140+
MuteAudioReasonNames[reason], m_muteReasonBits, (int)(m_muteReasonBits != 0)));
1141+
1142+
if (m_muteReasonBits != 0 || !m_savedValues)
11261143
return;
11271144

1128-
// We got focus back. Restore the previous audio values.
1145+
// Restore the previous audio values.
11291146
setVolume(m_savedValues[VOLUME_TYPE_MUSIC], (AudioAffect) (AudioAffect_Music | AudioAffect_SystemSetting));
11301147
setVolume(m_savedValues[VOLUME_TYPE_SOUND], (AudioAffect) (AudioAffect_Sound | AudioAffect_SystemSetting));
11311148
setVolume(m_savedValues[VOLUME_TYPE_SOUND3D], (AudioAffect) (AudioAffect_Sound3D | AudioAffect_SystemSetting));

Core/GameEngine/Source/GameNetwork/LANAPI.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,23 @@ LANGameInfo * LANAPI::LookupGameByListOffset( Int offset )
11121112
return theGame; // null means we didn't find anything.
11131113
}
11141114

1115+
LANGameInfo* LANAPI::LookupGameByHost(UnsignedInt hostIP)
1116+
{
1117+
LANGameInfo* lastGame = nullptr;
1118+
UnsignedInt lastHeard = 0;
1119+
1120+
for (LANGameInfo* game = m_games; game; game = game->getNext())
1121+
{
1122+
if (game->getHostIP() == hostIP && game->getLastHeard() >= lastHeard)
1123+
{
1124+
lastGame = game;
1125+
lastHeard = game->getLastHeard();
1126+
}
1127+
}
1128+
1129+
return lastGame;
1130+
}
1131+
11151132
void LANAPI::removeGame( LANGameInfo *game )
11161133
{
11171134
LANGameInfo *g = m_games;

Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
#include "GameLogic/PartitionManager.h"
5050
#include "GameLogic/TerrainLogic.h"
5151
#include "GameLogic/Weapon.h"
52+
#if RETAIL_COMPATIBLE_PATHFINDING
53+
#include "GameClient/InGameUI.h"
54+
#include "GameClient/GameText.h"
55+
#include "Common/GameAudio.h"
56+
#include "Common/MiscAudio.h"
57+
#endif
5258

5359
#include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba.
5460

@@ -1105,6 +1111,11 @@ void PathfindCellInfo::forceCleanPathFindCellInfos()
11051111

11061112
void Pathfinder::forceCleanCells()
11071113
{
1114+
UnicodeString pathfinderFailoverMessage = TheGameText->FETCH_OR_SUBSTITUTE("GUI:PathfindingCrashPrevented", L"A pathfinding crash was prevented, now switching to the crash fixed pathfinding.");
1115+
TheInGameUI->message(pathfinderFailoverMessage);
1116+
1117+
TheAudio->addAudioEvent(&TheAudio->getMiscAudio()->m_allCheerSound);
1118+
11081119
PathfindCellInfo::forceCleanPathFindCellInfos();
11091120
m_openList = nullptr;
11101121
m_closedList = nullptr;

Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
#include "GameLogic/Module/PhysicsUpdate.h"
5959
#include "GameLogic/Module/ActiveBody.h"
6060

61-
61+
// TheSuperHackers @fix Mirelle 04/02/2026: Raised from 500.0f so that
62+
// enormous camera heights cannot see above the laser origin.
63+
constexpr const Real ORBITAL_BEAM_Z_OFFSET = 3500.0f;
6264

6365
//-------------------------------------------------------------------------------------------------
6466
//-------------------------------------------------------------------------------------------------
@@ -550,7 +552,7 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
550552

551553
Coord3D orbitPosition;
552554
orbitPosition.set( &m_currentTargetPosition );
553-
orbitPosition.z += 500.0f;
555+
orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
554556

555557
Real scorchRadius = 0.0f;
556558
Real damageRadius = 0.0f;
@@ -918,7 +920,7 @@ void ParticleUplinkCannonUpdate::createGroundToOrbitLaser( UnsignedInt growthFra
918920
{
919921
Coord3D orbitPosition;
920922
orbitPosition.set( &m_laserOriginPosition );
921-
orbitPosition.z += 500.0f;
923+
orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
922924
update->initLaser( nullptr, &m_laserOriginPosition, &orbitPosition, growthFrames );
923925
}
924926
}
@@ -957,7 +959,7 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
957959
{
958960
Coord3D orbitPosition;
959961
orbitPosition.set( &m_initialTargetPosition );
960-
orbitPosition.z += 500.0f;
962+
orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
961963
update->initLaser( nullptr, &orbitPosition, &m_initialTargetPosition, growthFrames );
962964
}
963965
}

Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProjectileStreamUpdate.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,10 @@
4141
//-------------------------------------------------------------------------------------------------
4242
ProjectileStreamUpdate::ProjectileStreamUpdate( Thing *thing, const ModuleData* moduleData ) : UpdateModule( thing, moduleData )
4343
{
44-
ObjectID m_projectileIDs[MAX_PROJECTILE_STREAM];
45-
for( Int index = 0; index < MAX_PROJECTILE_STREAM; index++ )
46-
{
47-
m_projectileIDs[index] = INVALID_ID;
48-
}
49-
50-
m_owningObject = INVALID_ID;
44+
std::fill(m_projectileIDs, m_projectileIDs + ARRAY_SIZE(m_projectileIDs), INVALID_ID);
5145
m_nextFreeIndex = 0;
5246
m_firstValidIndex = 0;
47+
m_owningObject = INVALID_ID;
5348
}
5449

5550
//-------------------------------------------------------------------------------------------------

Generals/Code/Main/WinMain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
464464
if( active == WA_INACTIVE )
465465
{
466466
if (TheAudio)
467-
TheAudio->loseFocus();
467+
TheAudio->muteAudio(AudioManager::MuteAudioReason_WindowFocus);
468468
}
469469
else
470470
{
471471
if (TheAudio)
472-
TheAudio->regainFocus();
472+
TheAudio->unmuteAudio(AudioManager::MuteAudioReason_WindowFocus);
473473

474474
// Cursor can only be captured after one of the activation events.
475475
if (TheMouse)

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
#include "GameLogic/PartitionManager.h"
5050
#include "GameLogic/TerrainLogic.h"
5151
#include "GameLogic/Weapon.h"
52+
#if RETAIL_COMPATIBLE_PATHFINDING
53+
#include "GameClient/InGameUI.h"
54+
#include "GameClient/GameText.h"
55+
#include "Common/GameAudio.h"
56+
#include "Common/MiscAudio.h"
57+
#endif
5258

5359
#include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba.
5460

@@ -1120,6 +1126,11 @@ void PathfindCellInfo::forceCleanPathFindCellInfos()
11201126

11211127
void Pathfinder::forceCleanCells()
11221128
{
1129+
UnicodeString pathfinderFailoverMessage = TheGameText->FETCH_OR_SUBSTITUTE("GUI:PathfindingCrashPrevented", L"A pathfinding crash was prevented, now switching to the crash fixed pathfinding.");
1130+
TheInGameUI->message(pathfinderFailoverMessage);
1131+
1132+
TheAudio->addAudioEvent(&TheAudio->getMiscAudio()->m_allCheerSound);
1133+
11231134
PathfindCellInfo::forceCleanPathFindCellInfos();
11241135
m_openList = nullptr;
11251136
m_closedList = nullptr;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
#include "GameLogic/Module/PhysicsUpdate.h"
5959
#include "GameLogic/Module/ActiveBody.h"
6060

61-
61+
// TheSuperHackers @fix Mirelle 04/02/2026: Raised from 500.0f so that
62+
// enormous camera heights cannot see above the laser origin.
63+
constexpr const Real ORBITAL_BEAM_Z_OFFSET = 3500.0f;
6264

6365
//-------------------------------------------------------------------------------------------------
6466
//-------------------------------------------------------------------------------------------------
@@ -625,7 +627,7 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
625627

626628
Coord3D orbitPosition;
627629
orbitPosition.set( &m_currentTargetPosition );
628-
orbitPosition.z += 500.0f;
630+
orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
629631

630632
Real scorchRadius = 0.0f;
631633
Real damageRadius = 0.0f;
@@ -1003,7 +1005,7 @@ void ParticleUplinkCannonUpdate::createGroundToOrbitLaser( UnsignedInt growthFra
10031005
{
10041006
Coord3D orbitPosition;
10051007
orbitPosition.set( &m_laserOriginPosition );
1006-
orbitPosition.z += 500.0f;
1008+
orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
10071009
update->initLaser( nullptr, nullptr, &m_laserOriginPosition, &orbitPosition, "", growthFrames );
10081010
}
10091011
}
@@ -1042,7 +1044,7 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
10421044
{
10431045
Coord3D orbitPosition;
10441046
orbitPosition.set( &m_initialTargetPosition );
1045-
orbitPosition.z += 500.0f;
1047+
orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
10461048
update->initLaser( nullptr, nullptr, &orbitPosition, &m_initialTargetPosition, "", growthFrames );
10471049
}
10481050
}

0 commit comments

Comments
 (0)