Skip to content

Commit

Permalink
Merge pull request #391 from ao-org/fix-user-index-release-on-kick
Browse files Browse the repository at this point in the history
Fix user index release on kick
  • Loading branch information
RecoX authored Sep 19, 2023
2 parents 894db56 + 8c07234 commit 98bee9f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Codigo/Modulo_UsUaRiOs.bas
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ End Function
Public Function GetNextAvailableUserSlot() As Integer
On Error GoTo ErrHandler
If (AvailableUserSlot.currentIndex = 0) Then
GetNextAvailableUserSlot = 0
GetNextAvailableUserSlot = -1
Return
End If
GetNextAvailableUserSlot = AvailableUserSlot.IndexInfo(AvailableUserSlot.currentIndex)
Expand Down
2 changes: 2 additions & 0 deletions Codigo/Protocol_GmCommands.bas
Original file line number Diff line number Diff line change
Expand Up @@ -4728,6 +4728,8 @@ On Error GoTo HandleDebugRequest_Err:
ElseIf debugType = 1 Then
ReDim Args(1) As String
Args(0) = Reader.ReadString8()
ElseIf debugType = 2 Then
ReDim Args(0) As String
Else
Exit Sub
End If
Expand Down
3 changes: 3 additions & 0 deletions Codigo/Protocol_Writes.bas
Original file line number Diff line number Diff line change
Expand Up @@ -5778,6 +5778,9 @@ Public Sub WriteDebugLogResponse(ByVal UserIndex As Integer, ByVal debugType, By
timeSinceLastReset = GetTickCount() - .Counters.TimeLastReset
Call Writer.WriteString8("validConnection: " & .ConnIDValida & " connectionID: " & .ConnID & " UserIndex: " & tIndex & " charNmae" & .name & " UserLogged state: " & .flags.UserLogged & ", time since last message: " & timeSinceLastReset & " timeout setting: " & DisconnectTimeout)
End With
ElseIf debugType = 2 Then
Call Writer.WriteInt16(1)
Call Writer.WriteString8("remote DEBUG: avialable user slots: " & GetAvailableUserSlot)
Else
Call Writer.WriteInt16(1)
Call Writer.WriteString8("DEBUG: failed to find user: " & args(0))
Expand Down
2 changes: 1 addition & 1 deletion Codigo/frmMain.frm
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ Private Sub t_Extraer_Timer()
Call Trabajar(i, UserList(i).Trabajo.TargetSkill)
End If
Next i
Call PerformTimeLimitCheck(PerformanceTimer, "Segundo_Timer", 100)
Call PerformTimeLimitCheck(PerformanceTimer, "t_Extraer_Timer", 100)
End Sub

Private Sub T_UsersOnline_Timer()
Expand Down
12 changes: 10 additions & 2 deletions Codigo/modNetwork.bas
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ On Error GoTo Kick_ErrHandler:
Call AddLogToCircularBuffer("Kick connection: " & Connection)
End If
End If
Dim UserRef As t_UserReference
UserRef = Mapping(Connection)
If IsValidUserRef(UserRef) Then
If Not UserList(UserRef.ArrayIndex).flags.UserLogged Then
Call ReleaseUser(UserRef.ArrayIndex)
End If
End If
If (message <> vbNullString) Then
Dim UserRef As t_UserReference
UserRef = Mapping(Connection)
If UserRef.ArrayIndex > 0 Then
Call Protocol_Writes.WriteErrorMsg(UserRef.ArrayIndex, Message)
If UserList(UserRef.ArrayIndex).flags.UserLogged Then
Expand Down Expand Up @@ -149,6 +154,9 @@ On Error GoTo OnServerConnect_Err:
If Connection <= MaxUsers Then
Dim FreeUser As Long
FreeUser = NextOpenUser()
If FreeUser < 0 Then
Call Kick(Connection, "El server se encuentra lleno en este momento. Disculpe las molestias ocasionadas.")
End If
If UserList(FreeUser).InUse Then
Call LogError("Trying to use an user slot marked as in use! slot: " & FreeUser)
FreeUser = NextOpenUser()
Expand Down

0 comments on commit 98bee9f

Please sign in to comment.