Robin Posted August 9, 2011 Author Share Posted August 9, 2011 Replace it with this;```Option ExplicitPrivate Const inDevelopment as Boolean = False' Maximum soundsPrivate Const MAX_SOUNDS as byte = 32' Hardcoded sound effectsPublic Const Sound_ButtonHover As String = "Cursor1.wav"Public Const Sound_ButtonClick As String = "Decision1.wav"' Last sounds playedPublic lastButtonSound As LongPublic lastNpcChatsound As Long' Init statusPublic bInit_Music As BooleanPublic curSong As String' Music HandlersPrivate songHandle As LongPrivate streamHandle As Long' Sound pointer arrayPrivate soundHandle(1 To MAX_SOUNDS) As LongPrivate soundChannel(1 To MAX_SOUNDS) As LongPrivate soundIndex As LongPublic Function Init_Music() As BooleanDim result As Boolean If inDevelopment Then Exit Function On Error GoTo errorhandler ' init music engine result = FSOUND_Init(44100, 32, FSOUND_INIT_USEDEFAULTMIDISYNTH) If Not result Then GoTo errorhandler ' return positive Init_Music = True bInit_Music = True Exit Functionerrorhandler: Init_Music = False bInit_Music = FalseEnd FunctionPublic Sub Destroy_Music() ' destroy music engine Stop_Music FSOUND_Close bInit_Music = False curSong = vbNullStringEnd SubPublic Sub Play_Music(ByVal song As String) On Error GoTo errorhandler If Not bInit_Music Then Exit Sub ' exit out early if we have the system turned off If Options.Music = 0 Then Exit Sub ' does it exist? If Not FileExist(App.path & MUSIC_PATH & song) Then Exit Sub ' don't re-start currently playing songs If curSong = song Then Exit Sub ' stop the existing music Stop_Music ' find the extension Select Case Right$(song, 4) Case ".mid", ".s3m", ".mod" ' open the song songHandle = FMUSIC_LoadSong(App.path & MUSIC_PATH & song) ' play it FMUSIC_PlaySong songHandle ' set volume FMUSIC_SetMasterVolume songHandle, 150 Case ".wav", ".mp3", ".ogg", ".wma" ' open the stream streamHandle = FSOUND_Stream_Open(App.path & MUSIC_PATH & song, FSOUND_LOOP_NORMAL, 0, 0) ' play it FSOUND_Stream_Play FSOUND_FREE, streamHandle ' set volume FSOUND_SetVolume streamHandle, 150 Case Else Exit Sub End Select ' new current song curSong = song Exit Suberrorhandler: Destroy_MusicEnd SubPublic Sub Stop_Music() On Error GoTo errorhandler If Not streamHandle = 0 Then ' stop stream FSOUND_Stream_Stop streamHandle ' destroy FSOUND_Stream_Close streamHandle streamHandle = 0 End If If Not songHandle = 0 Then ' stop song FMUSIC_StopSong songHandle ' destroy FMUSIC_FreeSong songHandle songHandle = 0 End If ' no music curSong = vbNullString Exit Suberrorhandler: Destroy_MusicEnd SubPublic Sub Play_Sound(ByVal sound As String, Optional ByVal x As Long = -1, Optional ByVal y As Long = -1)Dim dX As Long, dY As Long, volume As Long, distance As Long On Error GoTo errorhandler If Not bInit_Music Then Exit Sub ' exit out early if we have the system turned off If Options.sound = 0 Then Exit Sub If x > -1 And y > -1 Then ' x If x < GetPlayerX(MyIndex) Then dX = GetPlayerX(MyIndex) - x ElseIf x > GetPlayerX(MyIndex) Then dX = x - GetPlayerX(MyIndex) End If ' y If y < GetPlayerY(MyIndex) Then dY = GetPlayerY(MyIndex) - y ElseIf y > GetPlayerY(MyIndex) Then dY = y - GetPlayerY(MyIndex) End If ' distance distance = dX ^ 2 + dY ^ 2 volume = 150 - (distance / 2) Else volume = 150 End If ' cap the volume If volume < 0 Then volume = 0 If volume > 256 Then volume = 256 ' load the sound Load_Sound sound FSOUND_Sample_SetDefaults soundHandle(soundIndex), -1, volume, FSOUND_STEREOPAN, -1 ' play it FSOUND_PlaySound FSOUND_FREE, soundHandle(soundIndex) Exit Suberrorhandler: Destroy_MusicEnd SubPublic Sub Load_Sound(ByVal sound As String)Dim bRestart As Boolean On Error GoTo errorhandler ' next sound buffer soundIndex = soundIndex + 1 ' reset if we run out If soundIndex > MAX_SOUNDS Or soundIndex < 1 Then bRestart = True soundIndex = 1 End If ' load the sound soundHandle(soundIndex) = FSOUND_Sample_Load(FSOUND_FREE, App.path & SOUND_PATH & sound, FSOUND_NORMAL, 0, 0) Exit Suberrorhandler: Destroy_MusicEnd Sub``` Link to comment Share on other sites More sharing options...
Kemerd Posted August 9, 2011 Share Posted August 9, 2011 Yay robin. :D Thnks. Link to comment Share on other sites More sharing options...
SpiceyWolf Posted August 9, 2011 Share Posted August 9, 2011 robin is this to mod EO2 or fix something on ur CS source? Link to comment Share on other sites More sharing options...
Robin Posted August 9, 2011 Author Share Posted August 9, 2011 @SpiceyWolf:> robin is this to mod EO2 or fix something on ur CS source?Read the title then bugger off. Link to comment Share on other sites More sharing options...
Medleyy Posted August 9, 2011 Share Posted August 9, 2011 @SpiceyWolf:> robin is this to mod EO2 or fix something on ur CS source?It fixes the CS:DE sound engine, I think. Link to comment Share on other sites More sharing options...
DJMaxus Posted August 9, 2011 Share Posted August 9, 2011 @Aeri:> It fixes the CS:DE sound engine, I think.This was the original fix Robin posted on the CS:DE support section of his site, so yes, replace your old fix if you did it already. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now