Renamed Item dataobject to ItemData. Added guildleve data.

This commit is contained in:
Filip Maj 2017-06-24 14:12:52 -04:00
parent 44a76c94af
commit 2d7d10a417
12 changed files with 806 additions and 22 deletions

View file

@ -14,7 +14,7 @@ namespace FFXIVClassic_Map_Server
{
class CommandProcessor
{
private static Dictionary<uint, Item> gamedataItems = Server.GetGamedataItems();
private static Dictionary<uint, ItemData> gamedataItems = Server.GetGamedataItems();
const UInt32 ITEM_GIL = 1000001;

View file

@ -70,11 +70,11 @@ namespace FFXIVClassic_Map_Server
}
}
public static Dictionary<uint, Item> GetItemGamedata()
public static Dictionary<uint, ItemData> GetItemGamedata()
{
using (var conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
Dictionary<uint, Item> gamedataItems = new Dictionary<uint, Item>();
Dictionary<uint, ItemData> gamedataItems = new Dictionary<uint, ItemData>();
try
{
@ -98,16 +98,16 @@ namespace FFXIVClassic_Map_Server
while (reader.Read())
{
uint id = reader.GetUInt32("catalogID");
Item item = null;
ItemData item = null;
if (Item.IsWeapon(id))
if (ItemData.IsWeapon(id))
item = new WeaponItem(reader);
else if (Item.IsArmor(id))
else if (ItemData.IsArmor(id))
item = new ArmorItem(reader);
else if (Item.IsAccessory(id))
else if (ItemData.IsAccessory(id))
item = new AccessoryItem(reader);
else
item = new Item(reader);
item = new ItemData(reader);
gamedataItems.Add(item.catalogID, item);
}
@ -126,6 +126,47 @@ namespace FFXIVClassic_Map_Server
}
}
public static Dictionary<uint, GuildleveData> GetGuildleveGamedata()
{
using (var conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
Dictionary<uint, GuildleveData> gamedataGuildleves = new Dictionary<uint, GuildleveData>();
try
{
conn.Open();
string query = @"
SELECT
*
FROM gamedata_guildleves
";
MySqlCommand cmd = new MySqlCommand(query, conn);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
uint id = reader.GetUInt32("id");
GuildleveData guildleve = new GuildleveData(reader);
gamedataGuildleves.Add(guildleve.id, guildleve);
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
return gamedataGuildleves;
}
}
public static void SavePlayerAppearance(Player player)
{
string query;

View file

@ -104,6 +104,7 @@
<Compile Include="actors\quest\Quest.cs" />
<Compile Include="actors\StaticActors.cs" />
<Compile Include="actors\world\WorldMaster.cs" />
<Compile Include="dataobjects\GuildleveData.cs" />
<Compile Include="dataobjects\ZoneConnection.cs" />
<Compile Include="CommandProcessor.cs" />
<Compile Include="ConfigConstants.cs" />
@ -123,7 +124,7 @@
<Compile Include="actors\chara\player\PlayerWork.cs" />
<Compile Include="dataobjects\InventoryItem.cs" />
<Compile Include="dataobjects\Session.cs" />
<Compile Include="dataobjects\Item.cs" />
<Compile Include="dataobjects\ItemData.cs" />
<Compile Include="dataobjects\RecruitmentDetails.cs" />
<Compile Include="dataobjects\SeamlessBoundry.cs" />
<Compile Include="dataobjects\SearchEntry.cs" />

View file

@ -19,7 +19,6 @@ namespace FFXIVClassic_Map_Server
static void Main(string[] args)
{
// set up logging
Log = LogManager.GetCurrentClassLogger();
#if DEBUG

View file

@ -27,7 +27,8 @@ namespace FFXIVClassic_Map_Server
private static CommandProcessor mCommandProcessor = new CommandProcessor();
private static ZoneConnection mWorldConnection = new ZoneConnection();
private static WorldManager mWorldManager;
private static Dictionary<uint, Item> mGamedataItems;
private static Dictionary<uint, ItemData> mGamedataItems;
private static Dictionary<uint, GuildleveData> mGamedataGuildleves;
private static StaticActors mStaticActors;
private PacketProcessor mProcessor;
@ -43,6 +44,8 @@ namespace FFXIVClassic_Map_Server
mGamedataItems = Database.GetItemGamedata();
Program.Log.Info("Loaded {0} items.", mGamedataItems.Count);
mGamedataGuildleves = Database.GetGuildleveGamedata();
Program.Log.Info("Loaded {0} guildleves.", mGamedataGuildleves.Count);
mWorldManager = new WorldManager(this);
mWorldManager.LoadZoneList();
@ -267,7 +270,7 @@ namespace FFXIVClassic_Map_Server
return mWorldManager;
}
public static Dictionary<uint, Item> GetGamedataItems()
public static Dictionary<uint, ItemData> GetGamedataItems()
{
return mGamedataItems;
}
@ -282,7 +285,7 @@ namespace FFXIVClassic_Map_Server
return mStaticActors.FindStaticActor(name);
}
public static Item GetItemGamedata(uint id)
public static ItemData GetItemGamedata(uint id)
{
if (mGamedataItems.ContainsKey(id))
return mGamedataItems[id];
@ -290,5 +293,13 @@ namespace FFXIVClassic_Map_Server
return null;
}
public static GuildleveData GetGuildleveGamedata(uint id)
{
if (mGamedataGuildleves.ContainsKey(id))
return mGamedataGuildleves[id];
else
return null;
}
}
}

View file

@ -92,7 +92,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
if (!IsSpaceForAdd(itemId, quantity))
return false;
Item gItem = Server.GetItemGamedata(itemId);
ItemData gItem = Server.GetItemGamedata(itemId);
List<ushort> slotsToUpdate = new List<ushort>();
List<SubPacket> addItemPackets = new List<SubPacket>();
@ -175,7 +175,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
//New item that spilled over
for (int i = 0; i < itemId.Length; i++)
{
Item gItem = Server.GetItemGamedata(itemId[i]);
ItemData gItem = Server.GetItemGamedata(itemId[i]);
InventoryItem addedItem = Database.AddItem(owner, itemId[i], 1, (byte)1, gItem.isExclusive ? (byte)0x3 : (byte)0x0, gItem.durability, inventoryCode);
list.Add(addedItem);
}
@ -457,7 +457,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
for (int i = 0; i < list.Count; i++)
{
InventoryItem item = list[i];
Item gItem = Server.GetItemGamedata(item.itemId);
ItemData gItem = Server.GetItemGamedata(item.itemId);
if (item.itemId == itemId && item.quantity < gItem.maxStack)
{
quantityCount -= (gItem.maxStack - item.quantity);

View file

@ -984,7 +984,7 @@ namespace FFXIVClassic_Map_Server.Actors
appearanceIds[slot] = 0;
else
{
Item item = Server.GetItemGamedata(invItem.itemId);
ItemData item = Server.GetItemGamedata(invItem.itemId);
if (item is EquipmentItem)
{
EquipmentItem eqItem = (EquipmentItem)item;

View file

@ -0,0 +1,61 @@
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.dataobjects
{
class GuildleveData
{
public readonly uint id;
public readonly uint classType;
public readonly uint location;
public readonly ushort factionCreditRequired;
public readonly ushort level;
public readonly uint aetheryte;
public readonly uint plateId;
public readonly uint borderId;
public readonly uint objective;
public readonly byte timeLimit;
public readonly uint skill;
public readonly byte favorCount;
public readonly sbyte[] aimNum = new sbyte[4];
public readonly uint[] itemTarget = new uint[4];
public readonly uint[] mobTarget = new uint[4];
public GuildleveData(MySqlDataReader reader)
{
id = reader.GetUInt32("id");
classType = reader.GetUInt32("classType");
location = reader.GetUInt32("location");
factionCreditRequired = reader.GetByte("factionCreditRequired");
level = reader.GetByte("level");
aetheryte = reader.GetUInt32("aetheryte");
plateId = reader.GetUInt32("plateId");
borderId = reader.GetUInt32("borderId");
objective = reader.GetUInt32("objective");
timeLimit = reader.GetByte("timeLimit");
skill = reader.GetUInt32("skill");
favorCount = reader.GetByte("favorCount");
aimNum[0] = reader.GetSByte("aimNum1");
aimNum[1] = reader.GetSByte("aimNum2");
aimNum[2] = reader.GetSByte("aimNum3");
aimNum[3] = reader.GetSByte("aimNum4");
itemTarget[0] = reader.GetUInt32("item1");
itemTarget[1] = reader.GetUInt32("item2");
itemTarget[2] = reader.GetUInt32("item3");
itemTarget[3] = reader.GetUInt32("item4");
mobTarget[0] = reader.GetUInt32("mob1");
mobTarget[1] = reader.GetUInt32("mob2");
mobTarget[2] = reader.GetUInt32("mob3");
mobTarget[3] = reader.GetUInt32("mob4");
}
}
}

View file

@ -30,7 +30,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
this.quantity = 1;
this.slot = slot;
Item gItem = Server.GetItemGamedata(itemId);
ItemData gItem = Server.GetItemGamedata(itemId);
itemType = gItem.isExclusive ? (byte)0x3 : (byte)0x0;
}

View file

@ -3,7 +3,7 @@ using System;
namespace FFXIVClassic_Map_Server.dataobjects
{
class Item
class ItemData
{
//Basic
public readonly uint catalogID;
@ -39,7 +39,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
public readonly int repairLevel;
public readonly int repairLicense;
public Item(MySqlDataReader reader)
public ItemData(MySqlDataReader reader)
{
catalogID = reader.GetUInt32("catalogID");
name = reader.GetString("name");
@ -387,7 +387,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
}
class EquipmentItem : Item
class EquipmentItem : ItemData
{
//graphics
public readonly uint graphicsWeaponId;

View file

@ -575,7 +575,7 @@ namespace FFXIVClassic_Map_Server.lua
script.Globals["GetStaticActor"] = (Func<string, Actor>)Server.GetStaticActors;
script.Globals["GetStaticActorById"] = (Func<uint, Actor>)Server.GetStaticActors;
script.Globals["GetWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
script.Globals["GetItemGamedata"] = (Func<uint, Item>)Server.GetItemGamedata;
script.Globals["GetItemGamedata"] = (Func<uint, ItemData>)Server.GetItemGamedata;
script.Globals["GetLuaInstance"] = (Func<LuaEngine>)LuaEngine.GetInstance;
script.Options.DebugPrint = s => { Program.Log.Debug(s); };