Skip to content

Commit 2c26a90

Browse files
authored
refactor(audioevent): Remove const casts for calling AudioEventRTS::setPlayingAudioIndex() (#2179)
1 parent 3966fa8 commit 2c26a90

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Core/GameEngine/Include/Common/AudioEventRTS.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class AudioEventRTS
9999
void decreaseLoopCount( void );
100100
Bool hasMoreLoops( void ) const;
101101

102-
void setAudioEventInfo( const AudioEventInfo *eventInfo ) const;
102+
void setAudioEventInfo( const AudioEventInfo *eventInfo ) const; // is mutable
103103
const AudioEventInfo *getAudioEventInfo( void ) const;
104104

105105
void setPlayingHandle( AudioHandle handle ); // for ID of this audio piece.
@@ -141,8 +141,8 @@ class AudioEventRTS
141141
Int getPlayerIndex( void ) const;
142142
void setPlayerIndex( Int playerNdx );
143143

144-
Int getPlayingAudioIndex( void ) { return m_playingAudioIndex; };
145-
void setPlayingAudioIndex( Int pai ) { m_playingAudioIndex = pai; };
144+
Int getPlayingAudioIndex( void ) const { return m_playingAudioIndex; }
145+
void setPlayingAudioIndex( Int pai ) const { m_playingAudioIndex = pai; } // is mutable
146146

147147
Bool getUninterruptible( ) const { return m_uninterruptible; }
148148
void setUninterruptible( Bool uninterruptible ) { m_uninterruptible = uninterruptible; }
@@ -191,7 +191,7 @@ class AudioEventRTS
191191
Real m_volumeShift; ///< Volume shift that should occur on this piece of audio
192192
Real m_delay; ///< Amount to delay before playing this sound
193193
Int m_loopCount; ///< The current loop count value. Only valid if this is a looping type event or the override has been set.
194-
Int m_playingAudioIndex; ///< The sound index we are currently playing. In the case of non-random, we increment this to move to the next sound
194+
mutable Int m_playingAudioIndex; ///< The sound index we are currently playing. In the case of non-random, we increment this to move to the next sound
195195
Int m_allCount; ///< If this sound is an ALL type, then this is how many sounds we have played so far.
196196

197197
Int m_playerIndex; ///< The index of the player who owns this sound. Used for sounds that should have an owner, but don't have an object, etc.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
461461
AudioEventRTS *audioEvent = MSGNEW("AudioEventRTS") AudioEventRTS(*eventToAdd); // poolify
462462
audioEvent->setPlayingHandle( allocateNewHandle() );
463463
audioEvent->generateFilename(); // which file are we actually going to play?
464-
((AudioEventRTS*)eventToAdd)->setPlayingAudioIndex( audioEvent->getPlayingAudioIndex() );
464+
eventToAdd->setPlayingAudioIndex( audioEvent->getPlayingAudioIndex() );
465465
audioEvent->generatePlayInfo(); // generate pitch shift and volume shift now as well
466466

467467
std::list<std::pair<AsciiString, Real> >::iterator it;

Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ void pickAndPlayUnitVoiceResponse( const DrawableList *list, GameMessage::Type m
792792

793793
// This seems really hacky, and MarkL admits that it is. However, we do this so that we
794794
// can "randomly" pick a different sound the next time, if we have 3 or more sounds. - jkmcd
795-
((AudioEventRTS*)soundToPlayPtr)->setPlayingAudioIndex( soundToPlay.getPlayingAudioIndex() );
795+
soundToPlayPtr->setPlayingAudioIndex( soundToPlay.getPlayingAudioIndex() );
796796

797797
if( objectWithSound->testStatus( OBJECT_STATUS_IS_CARBOMB ) )
798798
{

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ void pickAndPlayUnitVoiceResponse( const DrawableList *list, GameMessage::Type m
850850

851851
// This seems really hacky, and MarkL admits that it is. However, we do this so that we
852852
// can "randomly" pick a different sound the next time, if we have 3 or more sounds. - jkmcd
853-
((AudioEventRTS*)soundToPlayPtr)->setPlayingAudioIndex( soundToPlay.getPlayingAudioIndex() );
853+
soundToPlayPtr->setPlayingAudioIndex( soundToPlay.getPlayingAudioIndex() );
854854

855855
if( objectWithSound->testStatus( OBJECT_STATUS_IS_CARBOMB ) )
856856
{

0 commit comments

Comments
 (0)