Fixed wine detection, it wasn't able to handle duplicates

This commit is contained in:
Michael J. Seiferling
2019-02-09 08:23:15 -06:00
parent 08ac487f72
commit 8edd916830
2 changed files with 41 additions and 35 deletions
+18 -22
View File
@@ -1940,12 +1940,11 @@ Public Class frmMain
Private Sub ScanTimerEventProcessor(myObject As Object, ByVal myEventArgs As EventArgs) Handles tmScanTimer.Tick Private Sub ScanTimerEventProcessor(myObject As Object, ByVal myEventArgs As EventArgs) Handles tmScanTimer.Tick
Dim bNeedsPath As Boolean = False Dim bNeedsPath As Boolean = False
Dim bWineProcess As Boolean = False
Dim bContinue As Boolean = True Dim bContinue As Boolean = True
Dim iErrorCode As Integer = 0 Dim iErrorCode As Integer = 0
Dim sErrorMessage As String = String.Empty Dim sErrorMessage As String = String.Empty
If oProcess.SearchRunningProcesses(hshScanList, bNeedsPath, bWineProcess, iErrorCode, bProcessDebugMode) Then If oProcess.SearchRunningProcesses(hshScanList, bNeedsPath, iErrorCode, bProcessDebugMode) Then
PauseScan(True) PauseScan(True)
If bNeedsPath Then If bNeedsPath Then
@@ -1975,30 +1974,18 @@ Public Class frmMain
End If End If
End If End If
If bWineProcess Then 'We need to determine this Wine information and store it before the process ends.
'Attempt a path conversion if the game configuration is using an absolute windows path that we can convert If oProcess.WineProcess Then
If mgrVariables.CheckForReservedVariables(oProcess.GameInfo.TruePath) Then
Dim oWineData As New clsWineData Dim oWineData As New clsWineData
oWineData.MonitorID = oProcess.GameInfo.ID
oWineData.Prefix = mgrPath.GetWinePrefix(oProcess.FoundProcess) oWineData.Prefix = mgrPath.GetWinePrefix(oProcess.FoundProcess)
oWineData.BinaryPath = Path.GetDirectoryName(oProcess.FoundProcess.MainModule.FileName) oWineData.BinaryPath = Path.GetDirectoryName(oProcess.FoundProcess.MainModule.FileName)
UpdateLog(mgrCommon.FormatString(frmMain_WineBinaryPath, New String() {oProcess.GameInfo.Name, oWineData.BinaryPath}), False) UpdateLog(mgrCommon.FormatString(frmMain_WineBinaryPath, New String() {oProcess.GameInfo.Name, oWineData.BinaryPath}), False)
If Not oWineData.Prefix = String.Empty Then If Not oWineData.Prefix = String.Empty Then
UpdateLog(mgrCommon.FormatString(frmMain_WinePrefix, New String() {oProcess.GameInfo.Name, oWineData.Prefix}), False)
oWineData.SavePath = mgrPath.GetWineSavePath(oWineData.Prefix, oProcess.GameInfo.TruePath)
If Not oWineData.SavePath = oProcess.GameInfo.TruePath Then
oProcess.GameInfo.TruePath = oWineData.SavePath
oProcess.WineData = oWineData oProcess.WineData = oWineData
UpdateLog(mgrCommon.FormatString(frmMain_WineSavePath, New String() {oProcess.GameInfo.Name, oWineData.SavePath}), False) UpdateLog(mgrCommon.FormatString(frmMain_WinePrefix, New String() {oProcess.GameInfo.Name, oWineData.Prefix}), False)
Else Else
bContinue = False bContinue = False
End If End If
Else
bContinue = False
End If
End If
'This does required mods to include/exclude data and relative paths (if required)
mgrPath.ModWinePathData(oProcess.GameInfo)
End If End If
If bContinue = True Then If bContinue = True Then
@@ -2074,12 +2061,22 @@ Public Class frmMain
If bContinue Then If bContinue Then
If DoMultiGameCheck() Then If DoMultiGameCheck() Then
UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False) UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False)
If oProcess.WineProcess Then
'Attempt a path conversion if the game configuration is using an absolute windows path that we can convert
If mgrVariables.CheckForReservedVariables(oProcess.GameInfo.TruePath) Then
oProcess.WineData.MonitorID = oProcess.GameInfo.ID
oProcess.WineData.SavePath = mgrPath.GetWineSavePath(oProcess.WineData.Prefix, oProcess.GameInfo.TruePath)
If Not oProcess.WineData.SavePath = oProcess.GameInfo.TruePath Then
oProcess.GameInfo.TruePath = oProcess.WineData.SavePath
mgrWineData.DoWineDataAddUpdate(oProcess.WineData)
UpdateLog(mgrCommon.FormatString(frmMain_WineSavePath, New String() {oProcess.GameInfo.Name, oProcess.WineData.SavePath}), False)
End If
End If
'This does required mods to include/exclude data and relative paths (if required)
mgrPath.ModWinePathData(oProcess.GameInfo)
End If
If oSettings.TimeTracking Then HandleTimeSpent() If oSettings.TimeTracking Then HandleTimeSpent()
If oSettings.SessionTracking Then HandleSession() If oSettings.SessionTracking Then HandleSession()
If Not oProcess.WineData Is Nothing Then
oProcess.WineData.MonitorID = oProcess.GameInfo.ID
mgrWineData.DoWineDataAddUpdate(oProcess.WineData)
End If
RunBackup() RunBackup()
Else Else
UpdateLog(frmMain_UnknownGameEnded, False) UpdateLog(frmMain_UnknownGameEnded, False)
@@ -2094,7 +2091,6 @@ Public Class frmMain
bPathDetectionFailure = False bPathDetectionFailure = False
sPathDetectionError = String.Empty sPathDetectionError = String.Empty
bCancelledByUser = False bCancelledByUser = False
oProcess.WineData = Nothing
oProcess.StartTime = Now : oProcess.EndTime = Now oProcess.StartTime = Now : oProcess.EndTime = Now
End Sub End Sub
+15 -5
View File
@@ -8,6 +8,7 @@ Public Class mgrProcessDetection
Private dStartTime As DateTime = Now, dEndTime As DateTime = Now Private dStartTime As DateTime = Now, dEndTime As DateTime = Now
Private lTimeSpent As Long = 0 Private lTimeSpent As Long = 0
Private oGame As clsGame Private oGame As clsGame
Private bWineProcess As Boolean = False
Private oWineData As clsWineData Private oWineData As clsWineData
Private oDuplicateGames As New ArrayList Private oDuplicateGames As New ArrayList
Private bDuplicates As Boolean Private bDuplicates As Boolean
@@ -64,6 +65,15 @@ Public Class mgrProcessDetection
End Set End Set
End Property End Property
Property WineProcess As Boolean
Get
Return bWineProcess
End Get
Set(value As Boolean)
bWineProcess = value
End Set
End Property
Property WineData As clsWineData Property WineData As clsWineData
Get Get
Return oWineData Return oWineData
@@ -167,7 +177,7 @@ Public Class mgrProcessDetection
Return False Return False
End Function End Function
Private Function GetProcessPath(ByVal bWineProcess As Boolean) As String Private Function GetProcessPath() As String
Try Try
If Not bWineProcess Then If Not bWineProcess Then
Return Path.GetDirectoryName(FoundProcess.MainModule.FileName) Return Path.GetDirectoryName(FoundProcess.MainModule.FileName)
@@ -179,7 +189,7 @@ Public Class mgrProcessDetection
End Try End Try
End Function End Function
Private Sub FilterDetected(ByVal oDetectedGames As ArrayList, ByVal bWineProcess As Boolean) Private Sub FilterDetected(ByVal oDetectedGames As ArrayList)
Dim bMatch As Boolean = False Dim bMatch As Boolean = False
Dim sFullCommand As String Dim sFullCommand As String
Dim oNotDetectedWithParameters As New ArrayList Dim oNotDetectedWithParameters As New ArrayList
@@ -195,7 +205,7 @@ Public Class mgrProcessDetection
End If End If
'Get Process Path 'Get Process Path
ProcessPath = GetProcessPath(bWineProcess) ProcessPath = GetProcessPath()
'Look for any games using parameters and any matches 'Look for any games using parameters and any matches
For Each oDetectedGame As clsGame In oDetectedGames For Each oDetectedGame As clsGame In oDetectedGames
@@ -258,7 +268,7 @@ Public Class mgrProcessDetection
End If End If
End Sub End Sub
Public Function SearchRunningProcesses(ByVal hshScanList As Hashtable, ByRef bNeedsPath As Boolean, ByRef bWineProcess As Boolean, ByRef iErrorCode As Integer, ByVal bDebugMode As Boolean) As Boolean Public Function SearchRunningProcesses(ByVal hshScanList As Hashtable, ByRef bNeedsPath As Boolean, ByRef iErrorCode As Integer, ByVal bDebugMode As Boolean) As Boolean
Dim prsList() As Process = Process.GetProcesses Dim prsList() As Process = Process.GetProcesses
Dim sProcessCheck As String = String.Empty Dim sProcessCheck As String = String.Empty
Dim sProcessList As String = String.Empty Dim sProcessList As String = String.Empty
@@ -302,7 +312,7 @@ Public Class mgrProcessDetection
Next Next
If oDetectedGames.Count > 0 Then If oDetectedGames.Count > 0 Then
FilterDetected(oDetectedGames, bWineProcess) FilterDetected(oDetectedGames)
End If End If
If oDetectedGames.Count > 0 Then If oDetectedGames.Count > 0 Then