mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-20 11:47:48 +00:00
Finished writing the query and editing the inventory methods to use the gamedata.
This commit is contained in:
parent
4bebeb387a
commit
83fb9badd7
5 changed files with 63 additions and 38 deletions
|
@ -108,10 +108,14 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
string query = @"
|
||||
SELECT
|
||||
equipSlot,
|
||||
itemSlot
|
||||
FROM characters_inventory_equipment
|
||||
WHERE characterId = @charId ORDER BY equipSlot";
|
||||
*
|
||||
FROM gamedata_items
|
||||
LEFT JOIN gamedata_items_equipment ON gamedata_items.catalogID = gamedata_items_equipment.catalogID
|
||||
LEFT JOIN gamedata_items_accessory ON gamedata_items.catalogID = gamedata_items_accessory.catalogID
|
||||
LEFT JOIN gamedata_items_armor ON gamedata_items.catalogID = gamedata_items_armor.catalogID
|
||||
LEFT JOIN gamedata_items_weapon ON gamedata_items.catalogID = gamedata_items_weapon.catalogID
|
||||
LEFT JOIN gamedata_items_graphics ON gamedata_items.catalogID = gamedata_items_graphics.catalogID
|
||||
";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
|
||||
|
@ -670,7 +674,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
int quantity = reader.GetInt32(2);
|
||||
ushort slot = reader.GetUInt16(3);
|
||||
|
||||
bool isUntradeable = reader.GetBoolean(4);
|
||||
byte itemType = reader.GetByte(4);
|
||||
byte qualityNumber = reader.GetByte(5);
|
||||
|
||||
uint durability = reader.GetUInt32(6);
|
||||
|
@ -682,7 +686,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
byte materia4 = reader.GetByte(11);
|
||||
byte materia5 = reader.GetByte(12);
|
||||
|
||||
items.Add(new InventoryItem(uniqueId, itemId, quantity, slot, isUntradeable, qualityNumber, durability, spiritBind, materia1, materia2, materia3, materia4, materia5));
|
||||
items.Add(new InventoryItem(uniqueId, itemId, quantity, slot, itemType, qualityNumber, durability, spiritBind, materia1, materia2, materia3, materia4, materia5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -697,7 +701,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
return items;
|
||||
}
|
||||
|
||||
public static InventoryItem addItem(Player player, uint itemId, int quantity, byte quality, bool isUntradeable, uint durability, ushort type)
|
||||
public static InventoryItem addItem(Player player, uint itemId, int quantity, byte quality, byte itemType, uint durability, ushort type)
|
||||
{
|
||||
InventoryItem insertedItem = null;
|
||||
|
||||
|
@ -728,7 +732,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
cmd.Parameters.AddWithValue("@itemId", itemId);
|
||||
cmd.Parameters.AddWithValue("@quality", quality);
|
||||
cmd.Parameters.AddWithValue("@isUntradeable", isUntradeable);
|
||||
cmd.Parameters.AddWithValue("@itemType", itemType);
|
||||
cmd.Parameters.AddWithValue("@durability", durability);
|
||||
|
||||
cmd2.Parameters.AddWithValue("@charId", player.actorId);
|
||||
|
@ -738,7 +742,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
cmd.ExecuteNonQuery();
|
||||
cmd2.ExecuteNonQuery();
|
||||
|
||||
insertedItem = new InventoryItem((uint)cmd.LastInsertedId, itemId, quantity, (ushort)player.getInventory(type).getNextEmptySlot(), isUntradeable, quality, durability, 0, 0, 0, 0, 0, 0);
|
||||
insertedItem = new InventoryItem((uint)cmd.LastInsertedId, itemId, quantity, (ushort)player.getInventory(type).getNextEmptySlot(), itemType, quality, durability, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{ Console.WriteLine(e); }
|
||||
|
|
|
@ -35,7 +35,8 @@ namespace FFXIVClassic_Lobby_Server
|
|||
private List<ClientConnection> mConnectionList = new List<ClientConnection>();
|
||||
private LuaEngine mLuaEngine = new LuaEngine();
|
||||
|
||||
private WorldManager mWorldManager;
|
||||
private WorldManager mWorldManager;
|
||||
private static Dictionary<uint, Item> gamedataItems;
|
||||
private static StaticActors mStaticActors;
|
||||
|
||||
private PacketProcessor mProcessor;
|
||||
|
@ -50,10 +51,12 @@ namespace FFXIVClassic_Lobby_Server
|
|||
return mSelf;
|
||||
}
|
||||
|
||||
#region Socket Handling
|
||||
public bool startServer()
|
||||
{
|
||||
mStaticActors = new StaticActors(STATIC_ACTORS_PATH);
|
||||
|
||||
gamedataItems = Database.getItemGamedata();
|
||||
Log.info(String.Format("Loaded {0} items.",gamedataItems.Count));
|
||||
|
||||
mWorldManager = new WorldManager(this);
|
||||
mWorldManager.LoadZoneList();
|
||||
|
@ -99,6 +102,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
return true;
|
||||
}
|
||||
|
||||
#region Socket Handling
|
||||
private void acceptCallback(IAsyncResult result)
|
||||
{
|
||||
ClientConnection conn = null;
|
||||
|
@ -157,6 +161,14 @@ namespace FFXIVClassic_Lobby_Server
|
|||
return mStaticActors.findStaticActor(name);
|
||||
}
|
||||
|
||||
public static Item getItemGamedata(uint id)
|
||||
{
|
||||
if (gamedataItems.ContainsKey(id))
|
||||
return gamedataItems[id];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Receive Callback. Reads in incoming data, converting them to base packets. Base packets are sent to be parsed. If not enough data at the end to build a basepacket, move to the beginning and prepend.
|
||||
/// </summary>
|
||||
|
|
|
@ -75,20 +75,21 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
if (!isSpaceForAdd(itemId, quantity))
|
||||
return;
|
||||
|
||||
Item gItem = Server.getItemGamedata(itemId);
|
||||
List<ushort> slotsToUpdate = new List<ushort>();
|
||||
List<SubPacket> addItemPackets = new List<SubPacket>();
|
||||
|
||||
//Check if item id exists
|
||||
int quantityCount = quantity;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
{
|
||||
InventoryItem item = list[i];
|
||||
if (item.itemId == itemId && item.quantity < item.maxStack)
|
||||
if (item.itemId == itemId && item.quantity < gItem.maxStack)
|
||||
{
|
||||
slotsToUpdate.Add(item.slot);
|
||||
int oldQuantity = item.quantity;
|
||||
item.quantity = Math.Min(item.quantity + quantityCount, item.maxStack);
|
||||
quantityCount -= (item.maxStack - oldQuantity);
|
||||
item.quantity = Math.Min(item.quantity + quantityCount, gItem.maxStack);
|
||||
quantityCount -= (gItem.maxStack - oldQuantity);
|
||||
if (quantityCount <= 0)
|
||||
break;
|
||||
}
|
||||
|
@ -118,13 +119,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
//New item that spilled over
|
||||
while (quantityCount > 0)
|
||||
{
|
||||
InventoryItem addedItem = Database.addItem(owner, itemId, Math.Min(quantityCount, 5), quality, false, 100, inventoryCode);
|
||||
InventoryItem addedItem = Database.addItem(owner, itemId, Math.Min(quantityCount, 5), quality, gItem.isExclusive ? (byte)0x3 : (byte)0x0, 100, inventoryCode);
|
||||
|
||||
|
||||
list.Add(addedItem);
|
||||
|
||||
if (inventoryCode != CURRANCY && inventoryCode != KEYITEMS)
|
||||
sendInventoryPackets(addedItem);
|
||||
|
||||
quantityCount -= addedItem.maxStack;
|
||||
quantityCount -= gItem.maxStack;
|
||||
}
|
||||
|
||||
if (inventoryCode == CURRANCY || inventoryCode == KEYITEMS)
|
||||
|
@ -405,9 +408,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
|||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
InventoryItem item = list[i];
|
||||
if (item.itemId == itemId && item.quantity < item.maxStack)
|
||||
Item gItem = Server.getItemGamedata(item.itemId);
|
||||
if (item.itemId == itemId && item.quantity < gItem.maxStack)
|
||||
{
|
||||
quantityCount -= (item.maxStack - item.quantity);
|
||||
quantityCount -= (gItem.maxStack - item.quantity);
|
||||
if (quantityCount <= 0)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using FFXIVClassic_Lobby_Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -14,9 +15,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
public int quantity = 1;
|
||||
public ushort slot;
|
||||
|
||||
public int maxStack = 99999;
|
||||
|
||||
public bool isUntradeable = false;
|
||||
public byte itemType;
|
||||
public byte quality = 1;
|
||||
|
||||
public uint durability = 0;
|
||||
|
@ -34,16 +33,19 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
this.uniqueId = id;
|
||||
this.itemId = itemId;
|
||||
this.quantity = quantity;
|
||||
this.slot = slot;
|
||||
this.slot = slot;
|
||||
|
||||
Item gItem = Server.getItemGamedata(id);
|
||||
itemType = gItem.isExclusive ? (byte)0x3 : (byte)0x0;
|
||||
}
|
||||
|
||||
public InventoryItem(uint uniqueId, uint itemId, int quantity, ushort slot, bool isUntradeable, byte qualityNumber, uint durability, ushort spiritbind, byte materia1, byte materia2, byte materia3, byte materia4, byte materia5)
|
||||
public InventoryItem(uint uniqueId, uint itemId, int quantity, ushort slot, byte itemType, byte qualityNumber, uint durability, ushort spiritbind, byte materia1, byte materia2, byte materia3, byte materia4, byte materia5)
|
||||
{
|
||||
this.uniqueId = uniqueId;
|
||||
this.itemId = itemId;
|
||||
this.quantity = quantity;
|
||||
this.slot = slot;
|
||||
this.isUntradeable = isUntradeable;
|
||||
this.itemType = itemType;
|
||||
this.quality = qualityNumber;
|
||||
this.durability = durability;
|
||||
this.spiritbind = spiritbind;
|
||||
|
@ -73,7 +75,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
binWriter.Write((UInt32)0x00000000);
|
||||
binWriter.Write((UInt32)0x00000000);
|
||||
|
||||
binWriter.Write(isUntradeable ? (UInt32)0x3 : (UInt32)0x0);
|
||||
binWriter.Write((UInt32)itemType);
|
||||
|
||||
binWriter.Write((UInt32)0x00000000);
|
||||
|
||||
|
|
|
@ -426,15 +426,18 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
|
||||
public readonly short additionalEffect;
|
||||
public readonly bool materialBindPermission;
|
||||
public readonly short materiaTable;
|
||||
public readonly short materializeTable;
|
||||
|
||||
public EquipmentItem(MySqlDataReader reader)
|
||||
: base (reader)
|
||||
{
|
||||
graphicsWeaponId = reader.GetUInt32("weaponId");
|
||||
graphicsEquipmentId = reader.GetUInt32("equipmentId");
|
||||
graphicsVariantId = reader.GetUInt32("variantId");
|
||||
graphicsColorId = reader.GetUInt32("colorId");
|
||||
if (!reader.IsDBNull(reader.GetOrdinal("weaponId")) && !reader.IsDBNull(reader.GetOrdinal("equipmentId")) && !reader.IsDBNull(reader.GetOrdinal("variantId")) && !reader.IsDBNull(reader.GetOrdinal("colorId")))
|
||||
{
|
||||
graphicsWeaponId = reader.GetUInt32("weaponId");
|
||||
graphicsEquipmentId = reader.GetUInt32("equipmentId");
|
||||
graphicsVariantId = reader.GetUInt32("variantId");
|
||||
graphicsColorId = reader.GetUInt32("colorId");
|
||||
}
|
||||
|
||||
equipPoint = reader.GetInt32("equipPoint");
|
||||
equipTribe = reader.GetInt16("equipTribe");
|
||||
|
@ -461,8 +464,8 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
paramBonusValue10 = reader.GetInt16("paramBonusValue10");
|
||||
|
||||
additionalEffect = reader.GetInt16("additionalEffect");
|
||||
materialBindPermission = reader.GetBoolean("materialBindPermission");
|
||||
materiaTable = reader.GetInt16("materiaTable");
|
||||
materialBindPermission = reader.GetBoolean("materiaBindPermission");
|
||||
materializeTable = reader.GetInt16("materializeTable");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -529,8 +532,8 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
class ArmorItem : EquipmentItem
|
||||
{
|
||||
//armor sheet
|
||||
public readonly short defence;
|
||||
public readonly short magicDefence;
|
||||
public readonly short defense;
|
||||
public readonly short magicDefense;
|
||||
public readonly short criticalDefense;
|
||||
public readonly short evasion;
|
||||
public readonly short magicResistance;
|
||||
|
@ -547,8 +550,8 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
public ArmorItem(MySqlDataReader reader)
|
||||
: base(reader)
|
||||
{
|
||||
defence = reader.GetInt16("defence");
|
||||
magicDefence = reader.GetInt16("magicDefence");
|
||||
defense = reader.GetInt16("defense");
|
||||
magicDefense = reader.GetInt16("magicDefense");
|
||||
criticalDefense = reader.GetInt16("criticalDefense");
|
||||
evasion = reader.GetInt16("evasion");
|
||||
magicResistance = reader.GetInt16("magicResistance");
|
||||
|
|
Loading…
Add table
Reference in a new issue