Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Core/GameEngine/Include/Common/AudioSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@

enum { MAX_HW_PROVIDERS = 4 };

// TheSuperHackers @tweak xezon 23/07/2025 Adds setting to modify the volume of money deposit and withdraw sounds

struct AudioSettings
{
AudioSettings()
#if RTS_GENERALS
: m_defaultMoneyTransactionVolume(1.0f)
#elif RTS_ZEROHOUR
: m_defaultMoneyTransactionVolume(0.0f) // Uses zero volume by default because originally the money sounds did not work in Zero Hour
#endif
{
}

AsciiString m_audioRoot;
AsciiString m_soundsFolder;
AsciiString m_musicFolder;
Expand Down Expand Up @@ -66,6 +77,7 @@ struct AudioSettings
Real m_default3DSoundVolume;
Real m_defaultSpeechVolume;
Real m_defaultMusicVolume;
Real m_defaultMoneyTransactionVolume;
UnsignedInt m_defaultSpeakerType2D;
UnsignedInt m_defaultSpeakerType3D;

Expand All @@ -74,6 +86,7 @@ struct AudioSettings
Real m_preferred3DSoundVolume;
Real m_preferredSpeechVolume;
Real m_preferredMusicVolume;
Real m_preferredMoneyTransactionVolume;

//The desired altitude of the microphone to improve panning relative to terrain.
Real m_microphoneDesiredHeightAboveTerrain;
Expand Down
2 changes: 2 additions & 0 deletions Core/GameEngine/Source/Common/Audio/GameAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static const FieldParse audioSettingsFieldParseTable[] =
{ "Default3DSoundVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_default3DSoundVolume) },
{ "DefaultSpeechVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_defaultSpeechVolume) },
{ "DefaultMusicVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_defaultMusicVolume) },
{ "DefaultMoneyTransactionVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_defaultMoneyTransactionVolume) },
{ "MicrophoneDesiredHeightAboveTerrain", INI::parseReal, NULL, offsetof( AudioSettings, m_microphoneDesiredHeightAboveTerrain ) },
{ "MicrophoneMaxPercentageBetweenGroundAndCamera", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_microphoneMaxPercentageBetweenGroundAndCamera ) },
{ "ZoomMinDistance", INI::parseReal, NULL, offsetof( AudioSettings, m_zoomMinDistance ) },
Expand Down Expand Up @@ -1150,6 +1151,7 @@ void INI::parseAudioSettingsDefinition( INI *ini )
TheAudio->friend_getAudioSettings()->m_preferred3DSoundVolume = prefs.get3DSoundVolume() / 100.0f;
TheAudio->friend_getAudioSettings()->m_preferredSpeechVolume = prefs.getSpeechVolume() / 100.0f;
TheAudio->friend_getAudioSettings()->m_preferredMusicVolume = prefs.getMusicVolume() / 100.0f;
TheAudio->friend_getAudioSettings()->m_preferredMoneyTransactionVolume = prefs.getMoneyTransactionVolume() / 100.0f;
}

//-------------------------------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions Generals/Code/GameEngine/Include/Common/Money.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#include "Common/Debug.h"
#include "Common/Snapshot.h"

class AudioEventRTS;

// ----------------------------------------------------------------------------------------------
/**
How much "money" (Tiberium, Gems, Magic Resource Boxes, whatever) the Player has.
Expand Down Expand Up @@ -91,6 +93,9 @@ class Money : public Snapshot
}

protected:

void triggerAudioEvent(const AudioEventRTS& audioEvent);

// snapshot methods
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
Expand Down
1 change: 1 addition & 0 deletions Generals/Code/GameEngine/Include/Common/UserPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class OptionPreferences : public UserPreferences
Real get3DSoundVolume(void); // convenience function
Real getSpeechVolume(void); // convenience function
Real getMusicVolume(void); // convenience function
Real getMoneyTransactionVolume(void) const;
Bool saveCameraInReplays(void);
Bool useCameraInReplays(void);
Int getStaticGameDetail(void); // detail level selected by the user.
Expand Down
27 changes: 17 additions & 10 deletions Generals/Code/GameEngine/Source/Common/RTS/Money.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
#include "Common/Money.h"

#include "Common/AudioSettings.h"
#include "Common/GameAudio.h"
#include "Common/MiscAudio.h"
#include "Common/Player.h"
Expand All @@ -66,13 +67,9 @@ UnsignedInt Money::withdraw(UnsignedInt amountToWithdraw, Bool playSound)
if (amountToWithdraw == 0)
return amountToWithdraw;

// Play a sound
if (playSound)
{
//@todo: Do we do this frequently enough that it is a performance hit?
AudioEventRTS event = TheAudio->getMiscAudio()->m_moneyWithdrawSound;
event.setPlayerIndex(m_playerIndex);
TheAudio->addAudioEvent(&event);
triggerAudioEvent(TheAudio->getMiscAudio()->m_moneyWithdrawSound);
}

m_money -= amountToWithdraw;
Expand All @@ -86,18 +83,28 @@ void Money::deposit(UnsignedInt amountToDeposit, Bool playSound)
if (amountToDeposit == 0)
return;

// Play a sound
if (playSound)
{
//@todo: Do we do this frequently enough that it is a performance hit?
AudioEventRTS event = TheAudio->getMiscAudio()->m_moneyDepositSound;
event.setPlayerIndex(m_playerIndex);
TheAudio->addAudioEvent(&event);
triggerAudioEvent(TheAudio->getMiscAudio()->m_moneyDepositSound);
}

m_money += amountToDeposit;
}

void Money::triggerAudioEvent(const AudioEventRTS& audioEvent)
{
Real volume = TheAudio->getAudioSettings()->m_preferredMoneyTransactionVolume;
volume *= audioEvent.getVolume();
if (volume <= 0.0f)
return;

//@todo: Do we do this frequently enough that it is a performance hit?
AudioEventRTS event = audioEvent;
event.setPlayerIndex(m_playerIndex);
event.setVolume(volume);
TheAudio->addAudioEvent(&event);
}

// ------------------------------------------------------------------------------------------------
/** CRC */
// ------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,19 @@ Real OptionPreferences::getMusicVolume(void)
return volume;
}

Real OptionPreferences::getMoneyTransactionVolume(void) const
{
OptionPreferences::const_iterator it = find("MoneyTransactionVolume");
if (it == end())
return TheAudio->getAudioSettings()->m_defaultMoneyTransactionVolume * 100.0f;

Real volume = (Real) atof(it->second.str());
if (volume < 0.0f)
volume = 0.0f;

return volume;
}

Int OptionPreferences::getSystemTimeFontSize(void)
{
OptionPreferences::const_iterator it = find("SystemTimeFontSize");
Expand Down Expand Up @@ -1195,6 +1208,17 @@ static void saveOptions( void )
TheAudio->setVolume(val / 100.0f, (AudioAffect) (AudioAffect_Speech | AudioAffect_SystemSetting));
}

//-------------------------------------------------------------------------------------------------
// Money tick volume
// TheSuperHackers @todo Add options slider ?
{
val = pref->getMoneyTransactionVolume();
AsciiString prefString;
prefString.format("%d", val);
(*pref)["MoneyTransactionVolume"] = prefString;
TheAudio->friend_getAudioSettings()->m_preferredMoneyTransactionVolume = val / 100.0f;
}

//-------------------------------------------------------------------------------------------------
// slider Gamma
val = GadgetSliderGetPosition(sliderGamma);
Expand Down
5 changes: 5 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/Money.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#include "Common/Debug.h"
#include "Common/Snapshot.h"

class AudioEventRTS;

// ----------------------------------------------------------------------------------------------
/**
How much "money" (Tiberium, Gems, Magic Resource Boxes, whatever) the Player has.
Expand Down Expand Up @@ -91,6 +93,9 @@ class Money : public Snapshot
}

protected:

void triggerAudioEvent(const AudioEventRTS& audioEvent);

// snapshot methods
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class OptionPreferences : public UserPreferences
Real get3DSoundVolume(void); // convenience function
Real getSpeechVolume(void); // convenience function
Real getMusicVolume(void); // convenience function
Real getMoneyTransactionVolume(void) const;
Bool saveCameraInReplays(void);
Bool useCameraInReplays(void);
Int getStaticGameDetail(void); // detail level selected by the user.
Expand Down
27 changes: 17 additions & 10 deletions GeneralsMD/Code/GameEngine/Source/Common/RTS/Money.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
#include "Common/Money.h"

#include "Common/AudioSettings.h"
#include "Common/GameAudio.h"
#include "Common/MiscAudio.h"
#include "Common/Player.h"
Expand All @@ -66,13 +67,9 @@ UnsignedInt Money::withdraw(UnsignedInt amountToWithdraw, Bool playSound)
if (amountToWithdraw == 0)
return amountToWithdraw;

// Play a sound
if (playSound)
{
//@todo: Do we do this frequently enough that it is a performance hit?
AudioEventRTS event = TheAudio->getMiscAudio()->m_moneyWithdrawSound;
event.setPlayerIndex(m_playerIndex);
TheAudio->addAudioEvent(&event);
triggerAudioEvent(TheAudio->getMiscAudio()->m_moneyWithdrawSound);
}

m_money -= amountToWithdraw;
Expand All @@ -86,13 +83,9 @@ void Money::deposit(UnsignedInt amountToDeposit, Bool playSound)
if (amountToDeposit == 0)
return;

// Play a sound
if (playSound)
{
//@todo: Do we do this frequently enough that it is a performance hit?
AudioEventRTS event = TheAudio->getMiscAudio()->m_moneyDepositSound;
event.setPlayerIndex(m_playerIndex);
TheAudio->addAudioEvent(&event);
triggerAudioEvent(TheAudio->getMiscAudio()->m_moneyDepositSound);
}

m_money += amountToDeposit;
Expand All @@ -107,6 +100,20 @@ void Money::deposit(UnsignedInt amountToDeposit, Bool playSound)
}
}

void Money::triggerAudioEvent(const AudioEventRTS& audioEvent)
{
Real volume = TheAudio->getAudioSettings()->m_preferredMoneyTransactionVolume;
volume *= audioEvent.getVolume();
if (volume <= 0.0f)
return;

//@todo: Do we do this frequently enough that it is a performance hit?
AudioEventRTS event = audioEvent;
event.setPlayerIndex(m_playerIndex);
event.setVolume(volume);
TheAudio->addAudioEvent(&event);
}

// ------------------------------------------------------------------------------------------------
/** CRC */
// ------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,19 @@ Real OptionPreferences::getMusicVolume(void)
return volume;
}

Real OptionPreferences::getMoneyTransactionVolume(void) const
{
OptionPreferences::const_iterator it = find("MoneyTransactionVolume");
if (it == end())
return TheAudio->getAudioSettings()->m_defaultMoneyTransactionVolume * 100.0f;

Real volume = (Real) atof(it->second.str());
if (volume < 0.0f)
volume = 0.0f;

return volume;
}

Int OptionPreferences::getSystemTimeFontSize(void)
{
OptionPreferences::const_iterator it = find("SystemTimeFontSize");
Expand Down Expand Up @@ -1255,6 +1268,17 @@ static void saveOptions( void )
TheAudio->setVolume(val / 100.0f, (AudioAffect) (AudioAffect_Speech | AudioAffect_SystemSetting));
}

//-------------------------------------------------------------------------------------------------
// Money tick volume
// TheSuperHackers @todo Add options slider ?
{
val = pref->getMoneyTransactionVolume();
AsciiString prefString;
prefString.format("%d", val);
(*pref)["MoneyTransactionVolume"] = prefString;
TheAudio->friend_getAudioSettings()->m_preferredMoneyTransactionVolume = val / 100.0f;
}

//-------------------------------------------------------------------------------------------------
// slider Gamma
val = GadgetSliderGetPosition(sliderGamma);
Expand Down
Loading