diff --git a/Codigo/Modulo_UsUaRiOs.bas b/Codigo/Modulo_UsUaRiOs.bas index 380f8dec..3f4919c9 100644 --- a/Codigo/Modulo_UsUaRiOs.bas +++ b/Codigo/Modulo_UsUaRiOs.bas @@ -46,9 +46,7 @@ End Sub Public Function ReleaseUser(ByVal UserIndex As Integer) As Boolean On Error GoTo ErrHandler - If UserList(UserIndex).ConnIDValida Or _ - UserList(UserIndex).flags.UserLogged Or _ - UserList(UserIndex).flags.IsSlotFree Then + If UserList(UserIndex).flags.IsSlotFree Then ReleaseUser = False Exit Function End If @@ -70,13 +68,14 @@ 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) AvailableUserSlot.currentIndex = AvailableUserSlot.currentIndex - 1 If Not UserList(GetNextAvailableUserSlot).flags.IsSlotFree Then Call TraceError(Err.Number, "Trying to active the same user slot twice", "UserMod.GetNextAvailableUserSlot", Erl) + GetNextAvailableUserSlot = -1 End If UserList(GetNextAvailableUserSlot).flags.IsSlotFree = False Exit Function @@ -225,8 +224,8 @@ On Error GoTo Check_ConnectUser_Err End If If EsGM(UserIndex) Then - Call SendData(SendTarget.ToAdmins, 0, PrepareMessageConsoleMsg("Servidor » " & Name & " se conecto al juego.", e_FontTypeNames.FONTTYPE_INFOBOLD)) - Call LogGM(Name, "Se conectó con IP: " & .IP) + Call SendData(SendTarget.ToAdmins, 0, PrepareMessageConsoleMsg("Servidor » " & name & " se conecto al juego.", e_FontTypeNames.FONTTYPE_INFOBOLD)) + Call LogGM(name, "Se conectó con IP: " & .IP) End If End With @@ -766,10 +765,10 @@ On Error GoTo Complete_ConnectUser_Err 1120 Call WriteLoggedMessage(UserIndex, newUser) 1125 If .Stats.ELV = 1 Then -1130 Call WriteConsoleMsg(UserIndex, "¡Bienvenido a las tierras de AO20! ¡" & .Name & " que tengas buen viaje y mucha suerte!", e_FontTypeNames.FONTTYPE_GUILD) +1130 Call WriteConsoleMsg(UserIndex, "¡Bienvenido a las tierras de AO20! ¡" & .name & " que tengas buen viaje y mucha suerte!", e_FontTypeNames.FONTTYPE_GUILD) 1135 ElseIf .Stats.ELV < 14 Then -1140 Call WriteConsoleMsg(UserIndex, "¡Bienvenido de nuevo " & .Name & "! Actualmente estas en el nivel " & .Stats.ELV & " en " & get_map_name(.Pos.Map) & ", ¡buen viaje y mucha suerte!", e_FontTypeNames.FONTTYPE_GUILD) +1140 Call WriteConsoleMsg(UserIndex, "¡Bienvenido de nuevo " & .name & "! Actualmente estas en el nivel " & .Stats.ELV & " en " & get_map_name(.pos.Map) & ", ¡buen viaje y mucha suerte!", e_FontTypeNames.FONTTYPE_GUILD) End If @@ -3433,10 +3432,10 @@ On Error GoTo DoDamageOrHeal_Err DamageStr = PonerPuntos(Math.Abs(Amount)) If SourceType = eUser Then If UserList(SourceIndex).ChatCombate = 1 And DoDamageText > 0 Then - Call WriteLocaleMsg(SourceIndex, DoDamageText, e_FontTypeNames.FONTTYPE_FIGHT, UserList(UserIndex).Name & "¬" & DamageStr) + Call WriteLocaleMsg(SourceIndex, DoDamageText, e_FontTypeNames.FONTTYPE_FIGHT, UserList(UserIndex).name & "¬" & DamageStr) End If If UserList(UserIndex).ChatCombate = 1 And GotDamageText > 0 Then - Call WriteLocaleMsg(UserIndex, GotDamageText, e_FontTypeNames.FONTTYPE_FIGHT, UserList(SourceIndex).Name & "¬" & DamageStr) + Call WriteLocaleMsg(UserIndex, GotDamageText, e_FontTypeNames.FONTTYPE_FIGHT, UserList(SourceIndex).name & "¬" & DamageStr) End If End If amount = EffectsOverTime.TargetApplyDamageReduction(UserList(UserIndex).EffectOverTime, amount, SourceIndex, SourceType, DamageSourceType) diff --git a/Codigo/Protocol_GmCommands.bas b/Codigo/Protocol_GmCommands.bas index c9944017..658a5b4d 100644 --- a/Codigo/Protocol_GmCommands.bas +++ b/Codigo/Protocol_GmCommands.bas @@ -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 diff --git a/Codigo/Protocol_Writes.bas b/Codigo/Protocol_Writes.bas index c84e5579..d513bbd0 100644 --- a/Codigo/Protocol_Writes.bas +++ b/Codigo/Protocol_Writes.bas @@ -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)) diff --git a/Codigo/TCP.bas b/Codigo/TCP.bas index 3f03d76b..933faa90 100644 --- a/Codigo/TCP.bas +++ b/Codigo/TCP.bas @@ -657,11 +657,10 @@ Sub CloseSocket(ByVal UserIndex As Integer) Else 136 Call ResetUserSlot(UserIndex) - End If 140 .ConnIDValida = False -142 Call ReleaseUser(UserIndex) + End With @@ -671,7 +670,6 @@ ErrHandler: 144 UserList(UserIndex).ConnIDValida = False 146 Call ResetUserSlot(UserIndex) - Call ReleaseUser(UserIndex) 148 Call TraceError(Err.Number, Err.Description, "TCP.CloseSocket", Erl) @@ -686,7 +684,6 @@ Sub CloseSocketSL(ByVal UserIndex As Integer) 102 Call modNetwork.Kick(UserIndex) 106 UserList(UserIndex).ConnIDValida = False - Call ReleaseUser(UserIndex) End If Exit Sub diff --git a/Codigo/frmMain.frm b/Codigo/frmMain.frm index c1a152f7..0ec57598 100644 --- a/Codigo/frmMain.frm +++ b/Codigo/frmMain.frm @@ -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() diff --git a/Codigo/modNetwork.bas b/Codigo/modNetwork.bas index 56d18a30..2d986a7d 100644 --- a/Codigo/modNetwork.bas +++ b/Codigo/modNetwork.bas @@ -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 @@ -130,7 +135,6 @@ Public Sub close_not_logged_sockets_if_timeout() Else .ConnID = 0 .ConnIDValida = False - Call ReleaseUser(i) Call TraceError(Err.Number, Err.Description, "trying to kick an invalid mapping", Erl) End If End If @@ -150,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() @@ -201,7 +208,6 @@ On Error GoTo OnServerClose_Err: 132 UserList(UserRef.ArrayIndex).ConnIDValida = False 134 UserList(UserRef.ArrayIndex).ConnID = 0 -136 Call ReleaseUser(UserRef.ArrayIndex) End If 138 Call ClearUserRef(Mapping(Connection))