mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Merge branch 'ai-open' into develop
# Conflicts: # FFXIVClassic Lobby Server/Database.cs # FFXIVClassic Map Server/Database.cs # FFXIVClassic Map Server/FFXIVClassic Map Server.csproj # FFXIVClassic Map Server/actors/chara/player/Inventory.cs # FFXIVClassic Map Server/actors/chara/player/Player.cs # FFXIVClassic Map Server/dataobjects/Session.cs # FFXIVClassic World Server/Server.cs
This commit is contained in:
		| @@ -163,6 +163,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|             owner.QueuePacket(InventoryEndChangePacket.BuildPacket(owner.actorId)); | ||||
|  | ||||
|             list[slot] = item; | ||||
|             owner.CalculateBaseStats();// RecalculateStats(); | ||||
|         } | ||||
|  | ||||
|         public void ToggleDBWrite(bool flag) | ||||
| @@ -189,6 +190,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|             owner.QueuePacket(InventoryEndChangePacket.BuildPacket(owner.actorId)); | ||||
|  | ||||
|             list[slot] = null; | ||||
|             owner.RecalculateStats(); | ||||
|         } | ||||
|  | ||||
|         private void SendEquipmentPackets(ushort equipSlot, InventoryItem item) | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
|  | ||||
| using FFXIVClassic.Common; | ||||
| using FFXIVClassic.Common; | ||||
| using FFXIVClassic_Map_Server.actors.chara.npc; | ||||
| using FFXIVClassic_Map_Server.Actors; | ||||
| using FFXIVClassic_Map_Server.dataobjects; | ||||
| @@ -7,66 +6,66 @@ using FFXIVClassic_Map_Server.packets.send.actor.inventory; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Diagnostics; | ||||
| using System.Linq; | ||||
|  | ||||
| namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
| { | ||||
|     class Inventory | ||||
|     {        | ||||
| using System.Linq; | ||||
|  | ||||
| namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
| { | ||||
|     class Inventory | ||||
|     {        | ||||
|         public const ushort NORMAL                  = 0; //Max 0xC8 | ||||
|         public const ushort TRADE                   = 1; //Max 0x96 | ||||
|         public const ushort LOOT                    = 4; //Max 0xA | ||||
|         public const ushort TRADE                   = 1; //Max 0x96 | ||||
|         public const ushort LOOT                    = 4; //Max 0xA | ||||
|         public const ushort MELDREQUEST             = 5; //Max 0x04 | ||||
|         public const ushort BAZAAR                  = 7; //Max 0x0A | ||||
|         public const ushort CURRENCY_CRYSTALS       = 99; //Max 0x140 | ||||
|         public const ushort KEYITEMS                = 100; //Max 0x500 | ||||
|         public const ushort EQUIPMENT               = 0x00FE; //Max 0x23 | ||||
|         public const ushort BAZAAR                  = 7; //Max 0x0A | ||||
|         public const ushort CURRENCY_CRYSTALS       = 99; //Max 0x140 | ||||
|         public const ushort KEYITEMS                = 100; //Max 0x500 | ||||
|         public const ushort EQUIPMENT               = 0x00FE; //Max 0x23 | ||||
|         public const ushort EQUIPMENT_OTHERPLAYER   = 0x00F9; //Max 0x23 | ||||
|          | ||||
|         public enum INV_ERROR { | ||||
|             SUCCESS = 0, | ||||
|          | ||||
|         public enum INV_ERROR { | ||||
|             SUCCESS = 0, | ||||
|             INVENTORY_FULL, | ||||
|             ALREADY_HAS_UNIQUE, | ||||
|             SYSTEM_ERROR | ||||
|         }; | ||||
|  | ||||
|         private Character owner; | ||||
|         private ushort inventoryCapacity; | ||||
|         }; | ||||
|  | ||||
|         private Character owner; | ||||
|         private ushort inventoryCapacity; | ||||
|         private ushort inventoryCode; | ||||
|         private bool isTemporary; | ||||
|         private bool isTemporary; | ||||
|         private InventoryItem[] list; | ||||
|         private bool[] isDirty; | ||||
|  | ||||
|         private int endOfListIndex = 0; | ||||
|  | ||||
|         public Inventory(Character ownerPlayer, ushort capacity, ushort code, bool temporary = false) | ||||
|         { | ||||
|             owner = ownerPlayer; | ||||
|             inventoryCapacity = capacity; | ||||
|         public Inventory(Character ownerPlayer, ushort capacity, ushort code, bool temporary = false) | ||||
|         { | ||||
|             owner = ownerPlayer; | ||||
|             inventoryCapacity = capacity; | ||||
|             inventoryCode = code; | ||||
|             isTemporary = temporary; | ||||
|             list = new InventoryItem[capacity]; | ||||
|             isDirty = new bool[capacity]; | ||||
|         } | ||||
|  | ||||
|         #region Inventory Management | ||||
|         public void InitList(List<InventoryItem> itemsFromDB) | ||||
|         { | ||||
|             isDirty = new bool[capacity]; | ||||
|         } | ||||
|  | ||||
|         #region Inventory Management | ||||
|         public void InitList(List<InventoryItem> itemsFromDB) | ||||
|         { | ||||
|             int i = 0; | ||||
|             foreach (InventoryItem item in itemsFromDB) | ||||
|                 list[i++] = item; | ||||
|             endOfListIndex = i; | ||||
|         } | ||||
|  | ||||
|         public InventoryItem GetItemAtSlot(ushort slot) | ||||
|         { | ||||
|             if (slot < list.Length) | ||||
|                 return list[slot]; | ||||
|             else | ||||
|                 return null; | ||||
|         } | ||||
|  | ||||
|         public InventoryItem GetItemByUniqueId(ulong uniqueItemId) | ||||
|             endOfListIndex = i; | ||||
|         } | ||||
|  | ||||
|         public InventoryItem GetItemAtSlot(ushort slot) | ||||
|         { | ||||
|             if (slot < list.Length) | ||||
|                 return list[slot]; | ||||
|             else | ||||
|                 return null; | ||||
|         } | ||||
|  | ||||
|         public InventoryItem GetItemByUniqueId(ulong uniqueItemId) | ||||
|         { | ||||
|             for (int i = 0; i < endOfListIndex; i++) | ||||
|             { | ||||
| @@ -74,10 +73,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|  | ||||
|                 Debug.Assert(item != null, "Item slot was null!!!"); | ||||
|  | ||||
|                 if (item.uniqueId == uniqueItemId) | ||||
|                     return item; | ||||
|             } | ||||
|             return null; | ||||
|                 if (item.uniqueId == uniqueItemId) | ||||
|                     return item; | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         public InventoryItem GetItemByCatelogId(ulong catelogId) | ||||
| @@ -95,9 +94,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public int GetItemQuantity(uint itemId) | ||||
|         { | ||||
|             return GetItemQuantity(itemId, 1); | ||||
|         public int GetItemQuantity(uint itemId) | ||||
|         { | ||||
|             return GetItemQuantity(itemId, 1); | ||||
|         } | ||||
|  | ||||
|         public int GetItemQuantity(uint itemId, uint quality) | ||||
| @@ -111,9 +110,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|                 if (item.itemId == itemId && item.quality == quality) | ||||
|                     count += item.quantity; | ||||
|  | ||||
|             } | ||||
|  | ||||
|             return count; | ||||
|             } | ||||
|  | ||||
|             return count; | ||||
|         } | ||||
|  | ||||
|  | ||||
| @@ -128,99 +127,99 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|                 AddItem(itemId[i]); | ||||
|         } | ||||
|  | ||||
|         public int AddItem(uint itemId, int quantity) | ||||
|         public int AddItem(uint itemId, int quantity) | ||||
|         { | ||||
|             return AddItem(itemId, quantity, 1); | ||||
|         } | ||||
|  | ||||
|         public int AddItem(uint itemId, int quantity, byte quality) | ||||
|         { | ||||
|             if (!IsSpaceForAdd(itemId, quantity, quality)) | ||||
|                 return (int)INV_ERROR.INVENTORY_FULL; | ||||
|  | ||||
|             ItemData gItem = Server.GetItemGamedata(itemId); | ||||
|            | ||||
|             return AddItem(itemId, quantity, 1); | ||||
|         } | ||||
|  | ||||
|         public int AddItem(uint itemId, int quantity, byte quality) | ||||
|         { | ||||
|             if (!IsSpaceForAdd(itemId, quantity, quality)) | ||||
|                 return (int)INV_ERROR.INVENTORY_FULL; | ||||
|  | ||||
|             ItemData gItem = Server.GetItemGamedata(itemId); | ||||
|  | ||||
|             if (gItem == null) | ||||
|             { | ||||
|                 Program.Log.Error("Inventory.AddItem: unable to find item %u", itemId); | ||||
|                 return (int)INV_ERROR.SYSTEM_ERROR; | ||||
|             } | ||||
|  | ||||
|             //Check if item id exists  | ||||
|             } | ||||
|  | ||||
|             //Check if item id exists  | ||||
|             int quantityCount = quantity; | ||||
|             for (int i = 0; i < endOfListIndex; i++) | ||||
|             {                 | ||||
|             for (int i = 0; i < endOfListIndex; i++) | ||||
|             {                 | ||||
|                 InventoryItem item = list[i]; | ||||
|  | ||||
|                 Debug.Assert(item != null, "Item slot was null!!!"); | ||||
|  | ||||
|                 if (item.itemId == itemId && item.quality == quality && item.quantity < gItem.maxStack) | ||||
|                 { | ||||
|                     int oldQuantity = item.quantity; | ||||
|                 Debug.Assert(item != null, "Item slot was null!!!"); | ||||
|  | ||||
|                 if (item.itemId == itemId && item.quality == quality && item.quantity < gItem.maxStack) | ||||
|                 { | ||||
|                     int oldQuantity = item.quantity; | ||||
|                     item.quantity = Math.Min(item.quantity + quantityCount, gItem.maxStack); | ||||
|                     isDirty[i] = true; | ||||
|                     isDirty[i] = true; | ||||
|                     quantityCount -= (gItem.maxStack - oldQuantity); | ||||
|  | ||||
|                     DoDatabaseQuantity(item.uniqueId, item.quantity); | ||||
|                      | ||||
|                     if (quantityCount <= 0) | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|                    | ||||
|             //If it's unique, abort | ||||
|             if (HasItem(itemId) && gItem.isRare) | ||||
|                 return (int)INV_ERROR.ALREADY_HAS_UNIQUE; | ||||
|  | ||||
|             //New item that spilled over | ||||
|             while (quantityCount > 0) | ||||
|             { | ||||
|                      | ||||
|                     if (quantityCount <= 0) | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|                    | ||||
|             //If it's unique, abort | ||||
|             if (HasItem(itemId) && gItem.isRare) | ||||
|                 return (int)INV_ERROR.ALREADY_HAS_UNIQUE; | ||||
|  | ||||
|             //New item that spilled over | ||||
|             while (quantityCount > 0) | ||||
|             { | ||||
|                 InventoryItem addedItem = Database.CreateItem(itemId, Math.Min(quantityCount, gItem.maxStack), quality, gItem.isExclusive ? (byte)0x3 : (byte)0x0, gItem.durability); | ||||
|                 addedItem.slot = (ushort)endOfListIndex; | ||||
|                 isDirty[endOfListIndex] = true; | ||||
|                 list[endOfListIndex++] = addedItem;                 | ||||
|                 list[endOfListIndex++] = addedItem;                 | ||||
|                 quantityCount -= gItem.maxStack; | ||||
|  | ||||
|                 DoDatabaseAdd(addedItem); | ||||
|                 DoDatabaseAdd(addedItem); | ||||
|             } | ||||
|  | ||||
|             SendUpdatePackets(); | ||||
|  | ||||
|             return (int)INV_ERROR.SUCCESS; | ||||
|         } | ||||
|  | ||||
|             return (int)INV_ERROR.SUCCESS; | ||||
|         } | ||||
|  | ||||
|         public void RemoveItem(uint itemId) | ||||
|         { | ||||
|             RemoveItem(itemId, 1); | ||||
|         } | ||||
|          | ||||
|         } | ||||
|          | ||||
|         public void RemoveItem(uint itemId, int quantity) | ||||
|         { | ||||
|             RemoveItem(itemId, quantity, 1); | ||||
|         } | ||||
|  | ||||
|         public void RemoveItem(uint itemId, int quantity, int quality) | ||||
|         { | ||||
|             if (!HasItem(itemId, quantity, quality)) | ||||
|                 return; | ||||
|  | ||||
|             List<ushort> slotsToUpdate = new List<ushort>(); | ||||
|             List<InventoryItem> itemsToRemove = new List<InventoryItem>(); | ||||
|             List<ushort> slotsToRemove = new List<ushort>(); | ||||
|             List<SubPacket> AddItemPackets = new List<SubPacket>(); | ||||
|  | ||||
|             //Remove as we go along | ||||
|             int quantityCount = quantity; | ||||
|             ushort lowestSlot = 0; | ||||
|             for (int i = endOfListIndex - 1; i >= 0; i--) | ||||
|             { | ||||
|         } | ||||
|  | ||||
|         public void RemoveItem(uint itemId, int quantity, int quality) | ||||
|         { | ||||
|             if (!HasItem(itemId, quantity, quality)) | ||||
|                 return; | ||||
|  | ||||
|             List<ushort> slotsToUpdate = new List<ushort>(); | ||||
|             List<InventoryItem> itemsToRemove = new List<InventoryItem>(); | ||||
|             List<ushort> slotsToRemove = new List<ushort>(); | ||||
|             List<SubPacket> AddItemPackets = new List<SubPacket>(); | ||||
|  | ||||
|             //Remove as we go along | ||||
|             int quantityCount = quantity; | ||||
|             ushort lowestSlot = 0; | ||||
|             for (int i = endOfListIndex - 1; i >= 0; i--) | ||||
|             { | ||||
|                 InventoryItem item = list[i]; | ||||
|  | ||||
|                 Debug.Assert(item != null, "Item slot was null!!!"); | ||||
|  | ||||
|                 if (item.itemId == itemId && item.quality == quality) | ||||
|                 { | ||||
|                     int oldQuantity = item.quantity; | ||||
|                 Debug.Assert(item != null, "Item slot was null!!!"); | ||||
|  | ||||
|                 if (item.itemId == itemId && item.quality == quality) | ||||
|                 { | ||||
|                     int oldQuantity = item.quantity; | ||||
|                     //Stack nomnomed | ||||
|                     if (item.quantity - quantityCount <= 0) | ||||
|                     { | ||||
| @@ -234,53 +233,53 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|                         DoDatabaseQuantity(list[i].uniqueId, list[i].quantity); | ||||
|                     }                         | ||||
|  | ||||
|                     isDirty[i] = true; | ||||
|  | ||||
|                     quantityCount -= oldQuantity; | ||||
|                     lowestSlot = item.slot; | ||||
|  | ||||
|                     if (quantityCount <= 0) | ||||
|                         break; | ||||
|                 } | ||||
|                     isDirty[i] = true; | ||||
|  | ||||
|                     quantityCount -= oldQuantity; | ||||
|                     lowestSlot = item.slot; | ||||
|  | ||||
|                     if (quantityCount <= 0) | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             DoRealign(); | ||||
|             SendUpdatePackets(); | ||||
|         } | ||||
|  | ||||
|         public void RemoveItemByUniqueId(ulong itemDBId) | ||||
|         { | ||||
|             ushort slot = 0; | ||||
|             SendUpdatePackets(); | ||||
|         } | ||||
|  | ||||
|         public void RemoveItemByUniqueId(ulong itemDBId) | ||||
|         { | ||||
|             ushort slot = 0; | ||||
|             InventoryItem toDelete = null; | ||||
|             for (int i = endOfListIndex - 1; i >= 0; i--) | ||||
|             { | ||||
|                 InventoryItem item = list[i]; | ||||
|  | ||||
|                 Debug.Assert(item != null, "Item slot was null!!!"); | ||||
|  | ||||
|                 if (item.uniqueId == itemDBId) | ||||
|                 { | ||||
|                     toDelete = item; | ||||
|                     break; | ||||
|                 } | ||||
|                 slot++; | ||||
|             } | ||||
|  | ||||
|             if (toDelete == null) | ||||
|                 Debug.Assert(item != null, "Item slot was null!!!"); | ||||
|  | ||||
|                 if (item.uniqueId == itemDBId) | ||||
|                 { | ||||
|                     toDelete = item; | ||||
|                     break; | ||||
|                 } | ||||
|                 slot++; | ||||
|             } | ||||
|  | ||||
|             if (toDelete == null) | ||||
|                 return; | ||||
|              | ||||
|             DoDatabaseRemove(toDelete.uniqueId); | ||||
|  | ||||
|             DoDatabaseRemove(toDelete.uniqueId); | ||||
|  | ||||
|             list[slot] = null; | ||||
|             isDirty[slot] = true; | ||||
|  | ||||
|             DoRealign(); | ||||
|             SendUpdatePackets(); | ||||
|         } | ||||
|  | ||||
|         public void RemoveItemAtSlot(ushort slot) | ||||
|         { | ||||
|             if (slot >= endOfListIndex) | ||||
|             SendUpdatePackets(); | ||||
|         } | ||||
|  | ||||
|         public void RemoveItemAtSlot(ushort slot) | ||||
|         { | ||||
|             if (slot >= endOfListIndex) | ||||
|                 return; | ||||
|  | ||||
|             DoDatabaseRemove(list[slot].uniqueId); | ||||
| @@ -289,7 +288,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|             isDirty[slot] = true; | ||||
|              | ||||
|             DoRealign(); | ||||
|             SendUpdatePackets(); | ||||
|             SendUpdatePackets(); | ||||
|         } | ||||
|  | ||||
|         public void RemoveItemAtSlot(ushort slot, int quantity) | ||||
| @@ -314,64 +313,64 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|                 isDirty[slot] = true; | ||||
|                 SendUpdatePackets(); | ||||
|             }                                   | ||||
|         } | ||||
|  | ||||
|         public void ChangeDurability(uint slot, uint durabilityChange) | ||||
|         } | ||||
|  | ||||
|         public void ChangeDurability(uint slot, uint durabilityChange) | ||||
|         { | ||||
|             isDirty[slot] = true; | ||||
|         } | ||||
|  | ||||
|         public void ChangeSpiritBind(uint slot, uint spiritBindChange) | ||||
|             isDirty[slot] = true; | ||||
|         } | ||||
|  | ||||
|         public void ChangeSpiritBind(uint slot, uint spiritBindChange) | ||||
|         { | ||||
|             isDirty[slot] = true; | ||||
|         } | ||||
|  | ||||
|         public void ChangeMateria(uint slot, byte materiaSlot, byte materiaId) | ||||
|             isDirty[slot] = true; | ||||
|         } | ||||
|  | ||||
|         public void ChangeMateria(uint slot, byte materiaSlot, byte materiaId) | ||||
|         { | ||||
|             isDirty[slot] = true; | ||||
|         } | ||||
|         #endregion | ||||
|  | ||||
|         #region Packet Functions | ||||
|         public void SendFullInventory(Player player) | ||||
|             isDirty[slot] = true; | ||||
|         } | ||||
|         #endregion | ||||
|  | ||||
|         #region Packet Functions | ||||
|         public void SendFullInventory(Player player) | ||||
|         { | ||||
|             player.QueuePacket(InventorySetBeginPacket.BuildPacket(owner.actorId, inventoryCapacity, inventoryCode)); | ||||
|             player.QueuePacket(InventorySetBeginPacket.BuildPacket(owner.actorId, inventoryCapacity, inventoryCode)); | ||||
|             SendInventoryPackets(player, 0); | ||||
|             player.QueuePacket(InventorySetEndPacket.BuildPacket(owner.actorId)); | ||||
|             player.QueuePacket(InventorySetEndPacket.BuildPacket(owner.actorId)); | ||||
|         } | ||||
|  | ||||
|         private void SendInventoryPackets(Player player, InventoryItem item) | ||||
|         private void SendInventoryPackets(Player player, InventoryItem item) | ||||
|         { | ||||
|             player.QueuePacket(InventoryListX01Packet.BuildPacket(owner.actorId, item)); | ||||
|             player.QueuePacket(InventoryListX01Packet.BuildPacket(owner.actorId, item)); | ||||
|         } | ||||
|  | ||||
|         private void SendInventoryPackets(Player player, List<InventoryItem> items) | ||||
|         { | ||||
|             int currentIndex = 0; | ||||
|  | ||||
|             while (true) | ||||
|             { | ||||
|         private void SendInventoryPackets(Player player, List<InventoryItem> items) | ||||
|         { | ||||
|             int currentIndex = 0; | ||||
|  | ||||
|             while (true) | ||||
|             { | ||||
|                 if (items.Count - currentIndex >= 64) | ||||
|                     player.QueuePacket(InventoryListX64Packet.BuildPacket(owner.actorId, items, ref currentIndex)); | ||||
|                     player.QueuePacket(InventoryListX64Packet.BuildPacket(owner.actorId, items, ref currentIndex)); | ||||
|                 else if (items.Count - currentIndex >= 32) | ||||
|                     player.QueuePacket(InventoryListX32Packet.BuildPacket(owner.actorId, items, ref currentIndex)); | ||||
|                     player.QueuePacket(InventoryListX32Packet.BuildPacket(owner.actorId, items, ref currentIndex)); | ||||
|                 else if (items.Count - currentIndex >= 16) | ||||
|                     player.QueuePacket(InventoryListX16Packet.BuildPacket(owner.actorId, items, ref currentIndex)); | ||||
|                     player.QueuePacket(InventoryListX16Packet.BuildPacket(owner.actorId, items, ref currentIndex)); | ||||
|                 else if (items.Count - currentIndex > 1) | ||||
|                     player.QueuePacket(InventoryListX08Packet.BuildPacket(owner.actorId, items, ref currentIndex)); | ||||
|                 else if (items.Count - currentIndex == 1) | ||||
|                     player.QueuePacket(InventoryListX08Packet.BuildPacket(owner.actorId, items, ref currentIndex)); | ||||
|                 else if (items.Count - currentIndex == 1) | ||||
|                 { | ||||
|                     player.QueuePacket(InventoryListX01Packet.BuildPacket(owner.actorId, items[currentIndex])); | ||||
|                     currentIndex++; | ||||
|                 } | ||||
|                 else | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
|                     player.QueuePacket(InventoryListX01Packet.BuildPacket(owner.actorId, items[currentIndex])); | ||||
|                     currentIndex++; | ||||
|                 } | ||||
|                 else | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         private void SendInventoryPackets(Player player, int startOffset) | ||||
|         { | ||||
|         private void SendInventoryPackets(Player player, int startOffset) | ||||
|         { | ||||
|             int currentIndex = startOffset; | ||||
|  | ||||
|             List<InventoryItem> lst = new List<InventoryItem>(); | ||||
| @@ -395,38 +394,38 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|                 } | ||||
|                 else | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         private void SendInventoryRemovePackets(Player player, ushort index) | ||||
|         { | ||||
|             player.QueuePacket(InventoryRemoveX01Packet.BuildPacket(owner.actorId, index)); | ||||
|         private void SendInventoryRemovePackets(Player player, ushort index) | ||||
|         { | ||||
|             player.QueuePacket(InventoryRemoveX01Packet.BuildPacket(owner.actorId, index)); | ||||
|         } | ||||
|  | ||||
|         private void SendInventoryRemovePackets(Player player, List<ushort> indexes) | ||||
|         { | ||||
|             int currentIndex = 0; | ||||
|  | ||||
|             while (true) | ||||
|             { | ||||
|  | ||||
|         private void SendInventoryRemovePackets(Player player, List<ushort> indexes) | ||||
|         { | ||||
|             int currentIndex = 0; | ||||
|  | ||||
|             while (true) | ||||
|             { | ||||
|                 if (indexes.Count - currentIndex >= 64) | ||||
|                     player.QueuePacket(InventoryRemoveX64Packet.BuildPacket(owner.actorId, indexes, ref currentIndex)); | ||||
|                     player.QueuePacket(InventoryRemoveX64Packet.BuildPacket(owner.actorId, indexes, ref currentIndex)); | ||||
|                 else if (indexes.Count - currentIndex >= 32) | ||||
|                     player.QueuePacket(InventoryRemoveX32Packet.BuildPacket(owner.actorId, indexes, ref currentIndex)); | ||||
|                     player.QueuePacket(InventoryRemoveX32Packet.BuildPacket(owner.actorId, indexes, ref currentIndex)); | ||||
|                 else if (indexes.Count - currentIndex >= 16) | ||||
|                     player.QueuePacket(InventoryRemoveX16Packet.BuildPacket(owner.actorId, indexes, ref currentIndex)); | ||||
|                     player.QueuePacket(InventoryRemoveX16Packet.BuildPacket(owner.actorId, indexes, ref currentIndex)); | ||||
|                 else if (indexes.Count - currentIndex > 1) | ||||
|                     player.QueuePacket(InventoryRemoveX08Packet.BuildPacket(owner.actorId, indexes, ref currentIndex)); | ||||
|                 else if (indexes.Count - currentIndex == 1) | ||||
|                     player.QueuePacket(InventoryRemoveX08Packet.BuildPacket(owner.actorId, indexes, ref currentIndex)); | ||||
|                 else if (indexes.Count - currentIndex == 1) | ||||
|                 { | ||||
|                     player.QueuePacket(InventoryRemoveX01Packet.BuildPacket(owner.actorId, indexes[currentIndex])); | ||||
|                     currentIndex++; | ||||
|                 } | ||||
|                 else | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
|                     player.QueuePacket(InventoryRemoveX01Packet.BuildPacket(owner.actorId, indexes[currentIndex])); | ||||
|                     currentIndex++; | ||||
|                 } | ||||
|                 else | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         public void RefreshItem(Player player, InventoryItem item) | ||||
| @@ -448,8 +447,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|             player.QueuePacket(InventorySetBeginPacket.BuildPacket(owner.actorId, inventoryCapacity, inventoryCode)); | ||||
|             SendInventoryPackets(player, items); | ||||
|             player.QueuePacket(InventorySetEndPacket.BuildPacket(owner.actorId)); | ||||
|         } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         #endregion | ||||
|  | ||||
|         #region Automatic Client and DB Updating | ||||
| @@ -536,41 +535,41 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|  | ||||
|         #region Inventory Utils | ||||
|  | ||||
|         public bool IsFull() | ||||
|         { | ||||
|             return endOfListIndex >= inventoryCapacity; | ||||
|         } | ||||
|          | ||||
|         public bool IsSpaceForAdd(uint itemId, int quantity, int quality) | ||||
|         { | ||||
|         public bool IsFull() | ||||
|         { | ||||
|             return endOfListIndex >= inventoryCapacity; | ||||
|         } | ||||
|          | ||||
|         public bool IsSpaceForAdd(uint itemId, int quantity, int quality) | ||||
|         { | ||||
|             int quantityCount = quantity; | ||||
|             for (int i = 0; i < endOfListIndex; i++) | ||||
|             { | ||||
|                 InventoryItem item = list[i]; | ||||
|             for (int i = 0; i < endOfListIndex; i++) | ||||
|             { | ||||
|                 InventoryItem item = list[i]; | ||||
|                 ItemData gItem = Server.GetItemGamedata(item.itemId); | ||||
|                 if (item.itemId == itemId && item.quality == quality && item.quantity < gItem.maxStack) | ||||
|                 { | ||||
|                     quantityCount -= (gItem.maxStack - item.quantity); | ||||
|                     if (quantityCount <= 0) | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return quantityCount <= 0 || (quantityCount > 0 && !IsFull()); | ||||
|         } | ||||
|  | ||||
|         public bool HasItem(uint itemId) | ||||
|         { | ||||
|             return HasItem(itemId, 1); | ||||
|                 if (item.itemId == itemId && item.quality == quality && item.quantity < gItem.maxStack) | ||||
|                 { | ||||
|                     quantityCount -= (gItem.maxStack - item.quantity); | ||||
|                     if (quantityCount <= 0) | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return quantityCount <= 0 || (quantityCount > 0 && !IsFull()); | ||||
|         } | ||||
|  | ||||
|         public bool HasItem(uint itemId) | ||||
|         { | ||||
|             return HasItem(itemId, 1); | ||||
|         } | ||||
|  | ||||
|         public bool HasItem(uint itemId, int minQuantity) | ||||
|         { | ||||
|             return HasItem(itemId, minQuantity, 1); | ||||
|         } | ||||
|  | ||||
|         public bool HasItem(uint itemId, int minQuantity, int quality) | ||||
|         { | ||||
|         } | ||||
|  | ||||
|         public bool HasItem(uint itemId, int minQuantity, int quality) | ||||
|         { | ||||
|             int count = 0; | ||||
|  | ||||
|             for (int i = endOfListIndex - 1; i >= 0; i--) | ||||
| @@ -584,16 +583,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|  | ||||
|                 if (count >= minQuantity) | ||||
|                     return true; | ||||
|             } | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         public int GetNextEmptySlot() | ||||
|             } | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         public int GetNextEmptySlot() | ||||
|         { | ||||
|             return endOfListIndex; | ||||
|         } | ||||
|  | ||||
|             return endOfListIndex; | ||||
|         } | ||||
|  | ||||
|         private void DoRealign() | ||||
|         { | ||||
|             int lastNullSlot = -1;             | ||||
| @@ -618,9 +617,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.player | ||||
|  | ||||
|             if (lastNullSlot != -1) | ||||
|                 endOfListIndex = lastNullSlot; | ||||
|         } | ||||
|  | ||||
|         #endregion | ||||
|  | ||||
|     } | ||||
| } | ||||
|         } | ||||
|  | ||||
|         #endregion | ||||
|  | ||||
|     } | ||||
| } | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user