Skip to content

Commit c5b707a

Browse files
committed
Fix issue #15 & Cleanup
1 parent fa5b074 commit c5b707a

2 files changed

Lines changed: 27 additions & 23 deletions

File tree

SLAM/Form1.vb

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,71 +40,62 @@ Public Class Form1
4040
css.directory = "common\Counter-Strike Source\"
4141
css.ToCfg = "cstrike\cfg\"
4242
css.libraryname = "css\"
43-
css.VoiceFadeOut = True
4443
Games.Add(css)
4544

4645
Dim tf2 As New SourceGame
4746
tf2.name = "Team Fortress 2"
4847
tf2.directory = "common\Team Fortress 2\"
4948
tf2.ToCfg = "tf\cfg\"
5049
tf2.libraryname = "tf2\"
51-
tf2.VoiceFadeOut = True
5250
Games.Add(tf2)
5351

5452
Dim gmod As New SourceGame
5553
gmod.name = "Garry's Mod"
5654
gmod.directory = "common\GarrysMod\"
5755
gmod.ToCfg = "garrysmod\cfg\"
5856
gmod.libraryname = "gmod\"
59-
gmod.VoiceFadeOut = True
6057
Games.Add(gmod)
6158

6259
Dim hl2dm As New SourceGame
6360
hl2dm.name = "Half-Life 2 Deathmatch"
6461
hl2dm.directory = "common\half-life 2 deathmatch\"
6562
hl2dm.ToCfg = "hl2mp\cfg\"
6663
hl2dm.libraryname = "hl2dm\"
67-
hl2dm.VoiceFadeOut = True
6864
Games.Add(hl2dm)
6965

7066
Dim l4d As New SourceGame
7167
l4d.name = "Left 4 Dead"
7268
l4d.directory = "common\Left 4 Dead\"
7369
l4d.ToCfg = "left4dead\cfg\"
7470
l4d.libraryname = "l4d\"
75-
l4d.VoiceFadeOut = True
7671
Games.Add(l4d)
7772

7873
Dim l4d2 As New SourceGame
7974
l4d2.name = "Left 4 Dead 2"
8075
l4d2.directory = "common\Left 4 Dead 2\"
8176
l4d2.ToCfg = "left4dead2\cfg\"
8277
l4d2.libraryname = "l4d2\"
83-
l4d2.VoiceFadeOut = True
8478
Games.Add(l4d2)
8579

8680
Dim dods As New SourceGame
8781
dods.name = "Day of Defeat Source"
8882
dods.directory = "common\day of defeat source\"
8983
dods.ToCfg = "dod\cfg\"
9084
dods.libraryname = "dods\"
91-
dods.VoiceFadeOut = True
9285
Games.Add(dods)
9386

9487
Dim goldeye As New SourceGame
9588
goldeye.name = "Goldeneye Source"
9689
goldeye.directory = "sourcemods\"
9790
goldeye.ToCfg = "gesource\cfg\"
9891
goldeye.libraryname = "goldeye\"
99-
goldeye.VoiceFadeOut = True
10092
Games.Add(goldeye)
10193

10294
Dim insurg As New SourceGame
10395
insurg.name = "Insurgency"
10496
insurg.directory = "common\insurgency2\"
10597
insurg.ToCfg = "insurgency\cfg\"
10698
insurg.libraryname = "insurgen\"
107-
insurg.VoiceFadeOut = True
10899
Games.Add(insurg)
109100

110101
LoadGames()
@@ -349,7 +340,7 @@ Public Class Form1
349340
CfgData = "voice_enable 1; voice_modenable 1; voice_forcemicrecord 0; con_enable 1"
350341

351342
If Game.VoiceFadeOut Then
352-
CfgData = CfgData + ";voice_fadeouttime 0.0"
343+
CfgData = CfgData + "; voice_fadeouttime 0.0"
353344
End If
354345

355346
slam_cfg.WriteLine(CfgData)
@@ -435,7 +426,10 @@ Public Class Form1
435426
Return False
436427
End Try
437428

429+
Else
430+
Return False
438431
End If
432+
439433
Return True
440434
End Function
441435

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

452-
Try
453-
Do
446+
447+
Do
448+
Try
454449
If PollRelayWorker.CancellationPending Then
455450
Exit Do
456451
End If
@@ -461,7 +456,7 @@ Public Class Form1
461456

462457
If File.Exists(GameCfg) Then
463458
Dim RelayCfg As String
464-
Using reader As StreamReader = New StreamReader(New FileStream(GameCfg, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
459+
Using reader As StreamReader = New StreamReader(GameCfg)
465460
RelayCfg = reader.ReadToEnd
466461
End Using
467462

@@ -478,11 +473,16 @@ Public Class Form1
478473
End If
479474

480475
Thread.Sleep(Game.PollInterval)
481-
Loop
482-
Catch ex As Exception
483-
LogError(ex)
484-
e.Result = ex
485-
End Try
476+
477+
Catch ex As Exception
478+
If Not ex.HResult = -2147024864 Then '-2147024864 = "System.IO.IOException: The process cannot access the file because it is being used by another process."
479+
LogError(ex)
480+
e.Result = ex
481+
Return
482+
End If
483+
End Try
484+
Loop
485+
486486
End Sub
487487

488488
Public Function UserDataCFG(Game As SourceGame) As String
@@ -826,10 +826,14 @@ Public Class Form1
826826
Private Async Sub CheckForUpdate()
827827
Dim UpdateText As String
828828

829-
Using client As New HttpClient
830-
Dim UpdateTextTask As Task(Of String) = client.GetStringAsync("http://slam.flankers.net/updates.php")
831-
UpdateText = Await UpdateTextTask
832-
End Using
829+
Try
830+
Using client As New HttpClient
831+
Dim UpdateTextTask As Task(Of String) = client.GetStringAsync("http://slam.flankers.net/updates.php")
832+
UpdateText = Await UpdateTextTask
833+
End Using
834+
Catch ex As Exception
835+
Return
836+
End Try
833837

834838
Dim NewVersion As New Version("0.0.0.0") 'generic
835839
Dim UpdateURL As String = UpdateText.Split()(1)

SLAM/SourceGame.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Public Class SourceGame
66
Public directory As String
77
Public ToCfg As String
88
Public libraryname As String
9-
Public VoiceFadeOut As Boolean
9+
Public VoiceFadeOut As Boolean = True
1010

1111
Public FileExtension As String = ".wav"
1212
Public samplerate As Integer = 11025

0 commit comments

Comments
 (0)