Skip to content

Commit

Permalink
Fix issue #15 & Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SilentSys committed Mar 1, 2016
1 parent fa5b074 commit c5b707a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
48 changes: 26 additions & 22 deletions SLAM/Form1.vb
Original file line number Diff line number Diff line change
Expand Up @@ -40,71 +40,62 @@ Public Class Form1
css.directory = "common\Counter-Strike Source\"
css.ToCfg = "cstrike\cfg\"
css.libraryname = "css\"
css.VoiceFadeOut = True
Games.Add(css)

Dim tf2 As New SourceGame
tf2.name = "Team Fortress 2"
tf2.directory = "common\Team Fortress 2\"
tf2.ToCfg = "tf\cfg\"
tf2.libraryname = "tf2\"
tf2.VoiceFadeOut = True
Games.Add(tf2)

Dim gmod As New SourceGame
gmod.name = "Garry's Mod"
gmod.directory = "common\GarrysMod\"
gmod.ToCfg = "garrysmod\cfg\"
gmod.libraryname = "gmod\"
gmod.VoiceFadeOut = True
Games.Add(gmod)

Dim hl2dm As New SourceGame
hl2dm.name = "Half-Life 2 Deathmatch"
hl2dm.directory = "common\half-life 2 deathmatch\"
hl2dm.ToCfg = "hl2mp\cfg\"
hl2dm.libraryname = "hl2dm\"
hl2dm.VoiceFadeOut = True
Games.Add(hl2dm)

Dim l4d As New SourceGame
l4d.name = "Left 4 Dead"
l4d.directory = "common\Left 4 Dead\"
l4d.ToCfg = "left4dead\cfg\"
l4d.libraryname = "l4d\"
l4d.VoiceFadeOut = True
Games.Add(l4d)

Dim l4d2 As New SourceGame
l4d2.name = "Left 4 Dead 2"
l4d2.directory = "common\Left 4 Dead 2\"
l4d2.ToCfg = "left4dead2\cfg\"
l4d2.libraryname = "l4d2\"
l4d2.VoiceFadeOut = True
Games.Add(l4d2)

Dim dods As New SourceGame
dods.name = "Day of Defeat Source"
dods.directory = "common\day of defeat source\"
dods.ToCfg = "dod\cfg\"
dods.libraryname = "dods\"
dods.VoiceFadeOut = True
Games.Add(dods)

Dim goldeye As New SourceGame
goldeye.name = "Goldeneye Source"
goldeye.directory = "sourcemods\"
goldeye.ToCfg = "gesource\cfg\"
goldeye.libraryname = "goldeye\"
goldeye.VoiceFadeOut = True
Games.Add(goldeye)

Dim insurg As New SourceGame
insurg.name = "Insurgency"
insurg.directory = "common\insurgency2\"
insurg.ToCfg = "insurgency\cfg\"
insurg.libraryname = "insurgen\"
insurg.VoiceFadeOut = True
Games.Add(insurg)

LoadGames()
Expand Down Expand Up @@ -349,7 +340,7 @@ Public Class Form1
CfgData = "voice_enable 1; voice_modenable 1; voice_forcemicrecord 0; con_enable 1"

If Game.VoiceFadeOut Then
CfgData = CfgData + ";voice_fadeouttime 0.0"
CfgData = CfgData + "; voice_fadeouttime 0.0"
End If

slam_cfg.WriteLine(CfgData)
Expand Down Expand Up @@ -435,7 +426,10 @@ Public Class Form1
Return False
End Try

Else
Return False
End If

Return True
End Function

Expand All @@ -449,8 +443,9 @@ Public Class Form1
Dim GameDir As String = Path.Combine(SteamappsPath, Game.directory)
Dim GameCfg As String = Path.Combine(GameDir, Game.ToCfg) & "slam_relay.cfg"

Try
Do

Do
Try
If PollRelayWorker.CancellationPending Then
Exit Do
End If
Expand All @@ -461,7 +456,7 @@ Public Class Form1

If File.Exists(GameCfg) Then
Dim RelayCfg As String
Using reader As StreamReader = New StreamReader(New FileStream(GameCfg, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Using reader As StreamReader = New StreamReader(GameCfg)
RelayCfg = reader.ReadToEnd
End Using

Expand All @@ -478,11 +473,16 @@ Public Class Form1
End If

Thread.Sleep(Game.PollInterval)
Loop
Catch ex As Exception
LogError(ex)
e.Result = ex
End Try

Catch ex As Exception
If Not ex.HResult = -2147024864 Then '-2147024864 = "System.IO.IOException: The process cannot access the file because it is being used by another process."
LogError(ex)
e.Result = ex
Return
End If
End Try
Loop

End Sub

Public Function UserDataCFG(Game As SourceGame) As String
Expand Down Expand Up @@ -826,10 +826,14 @@ Public Class Form1
Private Async Sub CheckForUpdate()
Dim UpdateText As String

Using client As New HttpClient
Dim UpdateTextTask As Task(Of String) = client.GetStringAsync("http://slam.flankers.net/updates.php")
UpdateText = Await UpdateTextTask
End Using
Try
Using client As New HttpClient
Dim UpdateTextTask As Task(Of String) = client.GetStringAsync("http://slam.flankers.net/updates.php")
UpdateText = Await UpdateTextTask
End Using
Catch ex As Exception
Return
End Try

Dim NewVersion As New Version("0.0.0.0") 'generic
Dim UpdateURL As String = UpdateText.Split()(1)
Expand Down
2 changes: 1 addition & 1 deletion SLAM/SourceGame.vb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Public Class SourceGame
Public directory As String
Public ToCfg As String
Public libraryname As String
Public VoiceFadeOut As Boolean
Public VoiceFadeOut As Boolean = True

Public FileExtension As String = ".wav"
Public samplerate As Integer = 11025
Expand Down

2 comments on commit c5b707a

@g0ddish
Copy link
Contributor

@g0ddish g0ddish commented on c5b707a Mar 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 464 did New FileStream not work for you?

@SilentSys
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I was still able to reproduce issue #15 with or without the FileStream.

Please sign in to comment.