Skip to content

Commit

Permalink
Attempt to fix more Realm bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmbook committed Mar 2, 2017
1 parent f3cb794 commit 8d46458
Showing 1 changed file with 50 additions and 39 deletions.
89 changes: 50 additions & 39 deletions trunk/frmRealm.frm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -657,45 +657,45 @@ Private Sub Form_Load()
Dim i As Integer Dim i As Integer


Me.Icon = frmChat.Icon Me.Icon = frmChat.Icon

' must have a MCPHandler ' must have a MCPHandler
If ds.MCPHandler Is Nothing Then If ds.MCPHandler Is Nothing Then
Set ds.MCPHandler = New clsMCPHandler Set ds.MCPHandler = New clsMCPHandler
ds.MCPHandler.IsRealmError = True ds.MCPHandler.IsRealmError = True
Unload Me Unload Me
End If End If

' must be on D2 ' must be on D2
If (BotVars.Product <> "PX2D" And BotVars.Product <> "VD2D") Then If (BotVars.Product <> "PX2D" And BotVars.Product <> "VD2D") Then
ds.MCPHandler.IsRealmError = True ds.MCPHandler.IsRealmError = True
Unload Me Unload Me
End If End If

' store if expansion ' store if expansion
m_IsExpansion = (BotVars.Product = "PX2D") m_IsExpansion = (BotVars.Product = "PX2D")

' this is for deciding whether to enter chat after a form close ' this is for deciding whether to enter chat after a form close
m_Unload_SuccessfulLogin = False m_Unload_SuccessfulLogin = False

With lblRealm(0) ' detail With lblRealm(0) ' detail
.Caption = "Please wait..." .Caption = "Please wait..."
.ForeColor = &H888888 .ForeColor = &H888888
End With End With

' subclass for listview... ' subclass for listview...
#If COMPILE_DEBUG = 0 Then #If COMPILE_DEBUG = 0 Then
HookWindowProc hWnd HookWindowProc hWnd
'm_OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf SkipDragLVItem) 'm_OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf SkipDragLVItem)
#End If #End If

' read auto choose settings from handler ' read auto choose settings from handler
m_Ticks = ds.MCPHandler.AutoChooseWait m_Ticks = ds.MCPHandler.AutoChooseWait
m_Choice = ds.MCPHandler.AutoChooseTarget m_Choice = ds.MCPHandler.AutoChooseTarget
m_Selection = m_Choice m_Selection = m_Choice

' UI setup ' UI setup
Call RealmStartupResponse Call RealmStartupResponse

' set up char creation defaults ' set up char creation defaults
chkExpansion.Enabled = m_IsExpansion chkExpansion.Enabled = m_IsExpansion
chkExpansion.Value = IIf(m_IsExpansion, 1, 0) chkExpansion.Value = IIf(m_IsExpansion, 1, 0)
Expand All @@ -704,24 +704,25 @@ Private Sub Form_Load()
optNewCharType(7).Enabled = m_IsExpansion optNewCharType(7).Enabled = m_IsExpansion
optNewCharType(1).Value = True optNewCharType(1).Value = True
Call optNewCharType_Click(1) Call optNewCharType_Click(1)

' view existing ' view existing
optViewExisting.Value = True optViewExisting.Value = True
Call CharListResponse Call CharListResponse


' MCP handler state
ds.MCPHandler.FormActive = True

' setup timer ' setup timer
If m_Ticks >= 0 Then If m_Ticks > 0 Then
tmrLoginTimeout.Enabled = True
tmrLoginTimeout_Timer

' hide delete button here as it's been made visible (over seconds remaining in timer) ' hide delete button here as it's been made visible (over seconds remaining in timer)
' will be made visible by stopping timer (if character is selected) ' will be made visible by stopping timer (if character is selected)
btnUpgrade.Visible = False btnUpgrade.Visible = False
btnDelete.Visible = False btnDelete.Visible = False

' enable the timer and call in last to avoid infinite loops
tmrLoginTimeout.Enabled = True
tmrLoginTimeout_Timer
End If End If

' MCP handler state
ds.MCPHandler.FormActive = True
End Sub End Sub


Private Sub Form_Click() Private Sub Form_Click()
Expand Down Expand Up @@ -1307,36 +1308,45 @@ End Sub


Private Sub tmrLoginTimeout_Timer() Private Sub tmrLoginTimeout_Timer()
Static indexValid As Integer Static indexValid As Integer

indexValid = m_Choice indexValid = m_Choice

' if selecting nothing, find first unexpired account (no choose setting) ' if selecting nothing, find first unexpired account (no choose setting)
If (indexValid = -1) Then If (indexValid = -1) Then
Dim i As Integer Dim i As Integer


For i = 0 To ds.MCPHandler.CharacterCount - 1 For i = 0 To ds.MCPHandler.CharacterCount - 1
If Not IsDateExpired(ds.MCPHandler.CharacterExpires(i)) Or Not CanChooseCharacter(indexValid) Then If CanChooseCharacter(indexValid) Then
indexValid = i If Not IsDateExpired(ds.MCPHandler.CharacterExpires(i)) Then
Exit For indexValid = i
Exit For
End If
End If End If
Next i Next i
' if choose setting, then select only if not expired ' if choose setting, then select only if not expired
Else Else
If IsDateExpired(ds.MCPHandler.CharacterExpires(indexValid)) Or Not CanChooseCharacter(indexValid) Then If Not CanChooseCharacter(indexValid) Then
indexValid = -1
ElseIf IsDateExpired(ds.MCPHandler.CharacterExpires(indexValid)) Then
indexValid = -1 indexValid = -1
End If End If
End If End If


' seconds label (part 2 of timer labels)
lblRealm(3).Caption = CStr(m_Ticks)
' seconds cap label (part 2 of timer labels)
lblRealm(4).Caption = "second" & IIf(m_Ticks <> 1, "s", vbNullString) & "."

If (indexValid >= 0) Then If (indexValid >= 0) Then
' warning label (part 1 of timer labels) ' warning label (part 1 of timer labels)
lblRealm(2).Caption = lvwChars.ListItems(indexValid + 1).Text & vbCrLf & " will be chosen automatically in" lblRealm(2).Caption = lvwChars.ListItems(indexValid + 1).Text & vbCrLf & " will be chosen automatically in"

'If m_Selection < 0 Then 'If m_Selection < 0 Then
' lvwChars.ListItems.Item(indexValid + 1).Selected = True ' lvwChars.ListItems.Item(indexValid + 1).Selected = True
' Call lvwChars_ItemClick(lvwChars.ListItems.Item(indexValid + 1)) ' Call lvwChars_ItemClick(lvwChars.ListItems.Item(indexValid + 1))
'End If 'End If

If m_Ticks <= 1 Then If m_Ticks <= 0 Then
tmrLoginTimeout.Enabled = False tmrLoginTimeout.Enabled = False
If Not CanChooseCharacter(indexValid) Then If Not CanChooseCharacter(indexValid) Then
frmChat.AddChat RTBColors.ErrorMessageText, "[REALM] You must use Diablo II: Lord of Destruction to choose that character." frmChat.AddChat RTBColors.ErrorMessageText, "[REALM] You must use Diablo II: Lord of Destruction to choose that character."
Expand All @@ -1348,20 +1358,15 @@ Private Sub tmrLoginTimeout_Timer()
End If End If
Else Else
' warning label ' warning label
lblRealm(2).Caption = "No unexpired characters found! Realm login will be cancelled in" lblRealm(2).Caption = "No unexpired characters! Realm logon will be cancelled in"

If m_Ticks <= 1 Then If m_Ticks <= 0 Then
tmrLoginTimeout.Enabled = False tmrLoginTimeout.Enabled = False
UnloadNormal UnloadNormal
End If End If
End If End If


m_Ticks = m_Ticks - 1 m_Ticks = m_Ticks - 1

' seconds label (part 2 of timer labels)
lblRealm(3).Caption = CStr(m_Ticks)
' seconds cap label (part 2 of timer labels)
lblRealm(4).Caption = "seconds."
End Sub End Sub


Private Function FindCharacter(ByVal sKey As String) As Integer Private Function FindCharacter(ByVal sKey As String) As Integer
Expand Down Expand Up @@ -1389,17 +1394,23 @@ End Function


Private Function CanUpgradeCharacter(ByVal CharIndex As Integer) As Boolean Private Function CanUpgradeCharacter(ByVal CharIndex As Integer) As Boolean
Dim Stats As clsUserStats Dim Stats As clsUserStats

Set Stats = ds.MCPHandler.CharacterStats(CharIndex) Set Stats = ds.MCPHandler.CharacterStats(CharIndex)


CanUpgradeCharacter = False
If Stats Is Nothing Then Exit Function

CanUpgradeCharacter = (Not Stats.IsExpansionCharacter And m_IsExpansion) CanUpgradeCharacter = (Not Stats.IsExpansionCharacter And m_IsExpansion)
End Function End Function


Private Function CanChooseCharacter(ByVal CharIndex As Integer) As Boolean Private Function CanChooseCharacter(ByVal CharIndex As Integer) As Boolean
Dim Stats As clsUserStats Dim Stats As clsUserStats

Set Stats = ds.MCPHandler.CharacterStats(CharIndex) Set Stats = ds.MCPHandler.CharacterStats(CharIndex)


CanChooseCharacter = False
If Stats Is Nothing Then Exit Function

' must be PX2D if isExpansion, otherwise doesn't matter ' must be PX2D if isExpansion, otherwise doesn't matter
CanChooseCharacter = (Stats.IsExpansionCharacter Imp m_IsExpansion) CanChooseCharacter = (Stats.IsExpansionCharacter Imp m_IsExpansion)
End Function End Function
Expand Down

0 comments on commit 8d46458

Please sign in to comment.