diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index ee04b3a..1f85d61 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -1497,7 +1497,7 @@ Public Class frmMain Private Sub CheckForSavedDuplicate() For Each o As clsGame In oProcess.DuplicateList - If o.ProcessPath.ToLower = oProcess.GameInfo.ProcessPath.ToLower And o.Parameter = String.Empty Then + If o.ProcessPath.ToLower = oProcess.GameInfo.ProcessPath.ToLower Then oProcess.GameInfo = o oProcess.Duplicate = False End If diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index ba0f1ed..f73459d 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -76,6 +76,7 @@ Public Class mgrMonitorList Dim hshDupeList As New Hashtable Dim oGame As clsGame Dim oCompareGame As clsGame + Dim bIsDupe As Boolean sSQL = "Select * from monitorlist ORDER BY Name Asc" oData = oDatabase.ReadParamData(sSQL, New Hashtable) @@ -88,8 +89,32 @@ Public Class mgrMonitorList hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame) Case eListTypes.ScanList For Each de As DictionaryEntry In hshList + bIsDupe = False oCompareGame = DirectCast(de.Value, clsGame) - If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Or (oGame.ProcessName = oCompareGame.ProcessName) Then + + If oCompareGame.IsRegEx Then + If oGame.IsRegEx Then + If oCompareGame.ProcessName = oGame.ProcessName Then + bIsDupe = True + End If + Else + If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Then + bIsDupe = True + End If + End If + Else + If oGame.IsRegEx Then + If Regex.IsMatch(oCompareGame.ProcessName, oGame.ProcessName) Then + bIsDupe = True + End If + Else + If oGame.ProcessName = oCompareGame.ProcessName Then + bIsDupe = True + End If + End If + End If + + If bIsDupe Then DirectCast(hshList.Item(oCompareGame.ProcessName), clsGame).Duplicate = True oGame.ProcessName = oGame.ProcessName & ":" & oGame.SafeName oGame.Duplicate = True diff --git a/GBM/Managers/mgrProcesses.vb b/GBM/Managers/mgrProcesses.vb index 6c29a64..7d4d230 100644 --- a/GBM/Managers/mgrProcesses.vb +++ b/GBM/Managers/mgrProcesses.vb @@ -84,19 +84,43 @@ Public Class mgrProcesses Private Function HandleDuplicates(hshScanList As Hashtable) As Boolean Dim sProcess As String + Dim sParameter As String = String.Empty + Dim bParameter As Boolean = False + Dim oInitialDupes As New ArrayList + bDuplicates = True oDuplicateGames.Clear() + For Each o As clsGame In hshScanList.Values sProcess = o.ProcessName.Split(":")(0) - If o.Duplicate = True And (sProcess = oGame.TrueProcess Or Regex.IsMatch(sProcess, oGame.TrueProcess)) Then - If (o.Parameter <> String.Empty And FullCommand.Contains(o.Parameter)) Or (o.Parameter = String.Empty And FullCommand = String.Empty) Then - oDuplicateGames.Add(o.ShallowCopy) - End If + oInitialDupes.Add(o.ShallowCopy) End If Next + For Each o As clsGame In oInitialDupes + If (o.Parameter <> String.Empty And FullCommand.Contains(o.Parameter)) Then + sParameter = o.Parameter + bParameter = True + Exit For + End If + Next + + If bParameter Then + For Each o As clsGame In oInitialDupes + If (o.Parameter = sParameter) Then + oDuplicateGames.Add(o.ShallowCopy) + End If + Next + Else + For Each o As clsGame In oInitialDupes + If (o.Parameter = String.Empty) Then + oDuplicateGames.Add(o.ShallowCopy) + End If + Next + End If + If oDuplicateGames.Count = 1 Then oGame = DirectCast(oDuplicateGames(0), clsGame).ShallowCopy Return True @@ -131,7 +155,7 @@ Public Class mgrProcesses 'This function will only work correctly on Unix Private Function GetUnixProcessArguments(ByVal prs As Process) As String() - Dim sArguments As String + Dim sArguments As String Try sArguments = File.ReadAllText("/proc/" & prs.Id.ToString() & "/cmdline") Return sArguments.Split(vbNullChar) @@ -226,8 +250,6 @@ Public Class mgrProcesses GetWindowsCommand(prsCurrent) End If - FullCommand = FullCommand.Substring(prsCurrent.ProcessName.Length).Trim - If oGame.Duplicate = True Then If HandleDuplicates(hshScanList) Then bDuplicates = False