diff --git a/Codigo/CharacterPersistence.bas b/Codigo/CharacterPersistence.bas index a34df587..40a2f7fd 100644 --- a/Codigo/CharacterPersistence.bas +++ b/Codigo/CharacterPersistence.bas @@ -60,7 +60,7 @@ GetCharacterName_Err: End Function Public Function LoadCharacterBank(ByVal UserIndex As Integer) As Boolean - On Error GoTo LoadCharacterInventory_Err + On Error GoTo LoadCharacterBank_Err 100 With UserList(UserIndex) Dim RS As ADODB.Recordset Dim counter As Long @@ -87,7 +87,7 @@ Public Function LoadCharacterBank(ByVal UserIndex As Integer) As Boolean LoadCharacterBank = True Exit Function -LoadCharacterInventory_Err: +LoadCharacterBank_Err: Call LogDatabaseError("Error en LoadCharacterFromDB LoadCharacterBank: " & UserList(UserIndex).name & ". " & Err.Number & " - " & Err.Description & ". Línea: " & Erl) End Function @@ -96,7 +96,22 @@ Public Function LoadCharacterInventory(ByVal UserIndex As Integer) As Boolean 100 With UserList(UserIndex) Dim RS As ADODB.Recordset Dim counter As Long -102 Set RS = Query("SELECT number, item_id, is_equipped, amount FROM inventory_item WHERE user_id = ?;", .id) + Dim SQLQuery As String + + ' Determine SQL query based on user type for inventory items + Select Case .Stats.tipoUsuario + Case tLeyenda + SQLQuery = "SELECT number, item_id, is_equipped, amount FROM inventory_item WHERE user_id = ?;" + Case tHeroe + SQLQuery = "SELECT number, item_id, is_equipped, amount FROM inventory_item WHERE number <= " & MAX_USERINVENTORY_HERO_SLOTS & " AND user_id = ?;" + Case Else + SQLQuery = "SELECT number, item_id, is_equipped, amount FROM inventory_item WHERE number <= " & MAX_USERINVENTORY_SLOTS & " AND user_id = ?;" + End Select + + + ' Execute the query + Set RS = Query(SQLQuery, .Id) + 104 counter = 0 106 If Not RS Is Nothing Then 108 While Not RS.EOF @@ -571,10 +586,18 @@ Public Sub SaveCharacterDB(ByVal userIndex As Integer) Call Execute(QUERY_UPSERT_SPELLS, Params) ' ************************** User inventory ********************************* -366 ReDim Params(MAX_INVENTORY_SLOTS * 5 - 1) -368 ParamC = 0 +350 ' First determine Inventory Slot Limit so we do not delete items in case they remove the subscription +351 Dim InventorySlots As Long + Select Case .Stats.tipoUsuario + Case tLeyenda +354 InventorySlots = MAX_INVENTORY_SLOTS +355 Case tHeroe +356 InventorySlots = MAX_USERINVENTORY_HERO_SLOTS +357 Case Else +358 InventorySlots = MAX_USERINVENTORY_SLOTS +359 End Select -370 For LoopC = 1 To MAX_INVENTORY_SLOTS +370 For LoopC = 1 To InventorySlots 372 Params(ParamC) = .ID 374 Params(ParamC + 1) = LoopC 376 Params(ParamC + 2) = .Invent.Object(LoopC).objIndex @@ -584,7 +607,7 @@ Public Sub SaveCharacterDB(ByVal userIndex As Integer) 382 ParamC = ParamC + 5 384 Next LoopC - Call Execute(QUERY_UPSERT_INVENTORY, Params) + Call Execute(QUERY_UPSERT_INVENTORY, Params) ' ************************** User bank inventory ********************************* 402 ReDim Params(MAX_BANCOINVENTORY_SLOTS * 4 - 1) diff --git a/Codigo/Declares.bas b/Codigo/Declares.bas index 9483e157..1379f599 100644 --- a/Codigo/Declares.bas +++ b/Codigo/Declares.bas @@ -811,6 +811,9 @@ Public Const MAX_INVENTORY_SLOTS As Byte = 42 ' Cantidad de "slots" en el inventario básico Public Const MAX_USERINVENTORY_SLOTS As Byte = 24 +' Cantidad de "slots" en el inventario heroe +Public Const MAX_USERINVENTORY_HERO_SLOTS As Byte = 31 + ' Cantidad de "slots" en el inventario por fila Public Const SLOTS_PER_ROW_INVENTORY As Byte = 6