mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-22 12:47:46 +00:00
Added a load player character function to the database class. As I went through, changed the various properties to their correct datatype. Also added Work object to Character.
This commit is contained in:
parent
c9f35a207b
commit
4dec77aa69
8 changed files with 353 additions and 16 deletions
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||||
using FFXIVClassic_Lobby_Server.common;
|
using FFXIVClassic_Lobby_Server.common;
|
||||||
using FFXIVClassic_Map_Server.dataobjects.database;
|
using FFXIVClassic_Map_Server.dataobjects.database;
|
||||||
using FFXIVClassic_Map_Server.dataobjects.chara.npc;
|
using FFXIVClassic_Map_Server.dataobjects.chara.npc;
|
||||||
|
using FFXIVClassic_Map_Server.dataobjects.chara;
|
||||||
|
|
||||||
namespace FFXIVClassic_Lobby_Server
|
namespace FFXIVClassic_Lobby_Server
|
||||||
{
|
{
|
||||||
|
@ -158,5 +159,306 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void loadPlayerCharacter(Player player, bool isMe)
|
||||||
|
{
|
||||||
|
//Load basic info
|
||||||
|
string query;
|
||||||
|
MySqlCommand cmd;
|
||||||
|
|
||||||
|
using (MySqlConnection 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)))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
if (isMe)
|
||||||
|
{
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
name,
|
||||||
|
positionX,
|
||||||
|
positionY,
|
||||||
|
positionZ,
|
||||||
|
rotation,
|
||||||
|
actorState,
|
||||||
|
currentZoneId,
|
||||||
|
currentClassJob,
|
||||||
|
gcCurrent,
|
||||||
|
gcLimsaRank,
|
||||||
|
gcGridaniaRank,
|
||||||
|
gcUldahRank,
|
||||||
|
currentTitle,
|
||||||
|
guardian,
|
||||||
|
birthDay,
|
||||||
|
birthMonth,
|
||||||
|
initialNation,
|
||||||
|
currentParty,
|
||||||
|
restBonus,
|
||||||
|
achievementPoints
|
||||||
|
FROM characters WHERE id = @charId";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
name,
|
||||||
|
positionX,
|
||||||
|
positionY,
|
||||||
|
positionZ,
|
||||||
|
rotation,
|
||||||
|
actorState,
|
||||||
|
currentZoneId,
|
||||||
|
currentClassJob,
|
||||||
|
gcCurrent,
|
||||||
|
gcLimsaRank,
|
||||||
|
gcGridaniaRank,
|
||||||
|
gcUldahRank,
|
||||||
|
currentTitle
|
||||||
|
FROM characters WHERE id = @charId";
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = new MySqlCommand(query, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@charId", player.actorId);
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
player.displayNameId = 0xFFFFFFFF;
|
||||||
|
player.customDisplayName = reader.GetString(0);
|
||||||
|
player.oldPositionX = player.positionX = reader.GetFloat(1);
|
||||||
|
player.oldPositionY = player.positionY = reader.GetFloat(2);
|
||||||
|
player.oldPositionZ = player.positionZ = reader.GetFloat(3);
|
||||||
|
player.oldRotation = player.rotation = reader.GetFloat(4);
|
||||||
|
player.currentMainState = reader.GetUInt16(5);
|
||||||
|
player.currentZoneId = reader.GetUInt32(6);
|
||||||
|
reader.GetByte(7);
|
||||||
|
player.gcCurrent = reader.GetByte(8);
|
||||||
|
player.gcRankLimsa = reader.GetByte(9);
|
||||||
|
player.gcRankGridania = reader.GetByte(10);
|
||||||
|
player.gcRankUldah = reader.GetByte(11);
|
||||||
|
player.currentTitle = reader.GetUInt32(12);
|
||||||
|
|
||||||
|
if (isMe)
|
||||||
|
{
|
||||||
|
player.playerWork.guardian = reader.GetByte(13);
|
||||||
|
player.playerWork.birthdayDay = reader.GetByte(14);
|
||||||
|
player.playerWork.birthdayMonth = reader.GetByte(15);
|
||||||
|
player.playerWork.initialTown = reader.GetByte(16);
|
||||||
|
player.playerWork.restBonusExpRate = reader.GetInt32(17);
|
||||||
|
player.achievementPoints = reader.GetUInt32(18);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load appearance
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
baseId,
|
||||||
|
tribe,
|
||||||
|
size,
|
||||||
|
voice,
|
||||||
|
skinColor,
|
||||||
|
hairStyle,
|
||||||
|
hairColor,
|
||||||
|
hairHighlightColor,
|
||||||
|
eyeColor,
|
||||||
|
faceType,
|
||||||
|
faceEyebrows,
|
||||||
|
faceEyeShape,
|
||||||
|
faceIrisSize,
|
||||||
|
faceNose,
|
||||||
|
faceMouth,
|
||||||
|
faceFeatures,
|
||||||
|
ears,
|
||||||
|
characteristics,
|
||||||
|
characteristicsColor,
|
||||||
|
mainHand,
|
||||||
|
offHand,
|
||||||
|
head,
|
||||||
|
body,
|
||||||
|
hands,
|
||||||
|
legs,
|
||||||
|
feet,
|
||||||
|
waist,
|
||||||
|
leftFinger,
|
||||||
|
rightFinger,
|
||||||
|
leftEars,
|
||||||
|
rightEars
|
||||||
|
FROM characters_appearance WHERE characterId = @charId";
|
||||||
|
|
||||||
|
|
||||||
|
cmd = new MySqlCommand(query, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@charId", player.actorId);
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
reader.GetUInt32(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Load Status Effects
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
statusId,
|
||||||
|
expireTime
|
||||||
|
FROM characters_statuseffect WHERE characterId = %u";
|
||||||
|
|
||||||
|
cmd = new MySqlCommand(query, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@charId", player.actorId);
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
player.charaWork.status[count] = reader.GetUInt16(0);
|
||||||
|
player.charaWork.statusShownTime[count] = reader.GetUInt32(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load Chocobo
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
hasChocobo,
|
||||||
|
hasGoobbue,
|
||||||
|
chocoboAppearance,
|
||||||
|
chocoboName
|
||||||
|
FROM characters_chocobo WHERE characterId = @charId";
|
||||||
|
|
||||||
|
cmd = new MySqlCommand(query, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@charId", player.actorId);
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
player.hasChocobo = reader.GetBoolean(0);
|
||||||
|
player.hasGoobbue = reader.GetBoolean(1);
|
||||||
|
player.chocoboAppearance = reader.GetByte(2);
|
||||||
|
player.chocoboName = reader.GetString(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load Achievements
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
achievementId
|
||||||
|
FROM characters_achievements WHERE characterId = %u AND timeDone NOT NULL";
|
||||||
|
|
||||||
|
//Load Last 5 Completed
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
achievementId
|
||||||
|
FROM characters_achievements WHERE characterId = %u ORDER BY timeDone DESC LIMIT 5";
|
||||||
|
|
||||||
|
//Load Timers
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
thousandmaws,
|
||||||
|
dzemaeldarkhold,
|
||||||
|
bowlofembers_hard,
|
||||||
|
bowlofembers,
|
||||||
|
thornmarch,
|
||||||
|
aurumvale,
|
||||||
|
cutterscry,
|
||||||
|
battle_aleport,
|
||||||
|
battle_hyrstmill,
|
||||||
|
battle_goldenbazaar,
|
||||||
|
howlingeye_hard,
|
||||||
|
howlingeye,
|
||||||
|
castrumnovum,
|
||||||
|
bowlofembers_extreme,
|
||||||
|
rivenroad,
|
||||||
|
rivenroad_hard,
|
||||||
|
behests,
|
||||||
|
companybehests,
|
||||||
|
returntimer,
|
||||||
|
skirmish,
|
||||||
|
FROM characters_timers WHERE characterId = @charId";
|
||||||
|
|
||||||
|
cmd = new MySqlCommand(query, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@charId", player.actorId);
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
for (int i = 0; i < player.timers.Length; i++)
|
||||||
|
player.timers[i] = reader.GetUInt32(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load Hotbar
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
hotbarIndex,
|
||||||
|
commandId,
|
||||||
|
recastTime
|
||||||
|
FROM characters_hotbar WHERE characterId = @charId AND classId = @classId ORDER BY hotbarIndex DESC";
|
||||||
|
|
||||||
|
cmd = new MySqlCommand(query, conn);
|
||||||
|
cmd.Parameters.AddWithValue("@charId", player.actorId);
|
||||||
|
//cmd.Parameters.AddWithValue("@classId", player.currentClassId);
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
int index = reader.GetUInt16(0);
|
||||||
|
player.charaWork.command[index+32] = reader.GetUInt32(1);
|
||||||
|
player.charaWork.parameterSave.commandSlot_recastTime[index] = reader.GetUInt32(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load Scenario Quests
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
index,
|
||||||
|
questId
|
||||||
|
FROM characters_quest_scenario WHERE characterId = %u";
|
||||||
|
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
int index = reader.GetUInt16(0);
|
||||||
|
player.playerWork.questScenario[index] = reader.GetUInt32(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load Guildleve Quests
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
index,
|
||||||
|
questId,
|
||||||
|
abandoned,
|
||||||
|
completed
|
||||||
|
FROM characters_quest_scenario WHERE characterId = %u";
|
||||||
|
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
int index = reader.GetUInt16(0);
|
||||||
|
player.playerWork.questGuildLeve[index] = reader.GetUInt32(1);
|
||||||
|
player.work.guildleveDone[index] = reader.GetBoolean(2);
|
||||||
|
player.work.guildleveChecked[index] = reader.GetBoolean(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load NPC Linkshell
|
||||||
|
query = @"
|
||||||
|
SELECT
|
||||||
|
npcLinkshellId,
|
||||||
|
isCalling,
|
||||||
|
isExtra
|
||||||
|
FROM characters_quest_scenario WHERE characterId = %u ORDER BY npcLinkshellId DESC";
|
||||||
|
|
||||||
|
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
int npcLSId = reader.GetUInt16(0);
|
||||||
|
player.playerWork.npcLinkshellChatCalling[npcLSId] = reader.GetBoolean(1);
|
||||||
|
player.playerWork.npcLinkshellChatExtra[npcLSId] = reader.GetBoolean(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (MySqlException e)
|
||||||
|
{ Console.WriteLine(e); }
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||||
public uint displayNameId = 0xFFFFFFFF;
|
public uint displayNameId = 0xFFFFFFFF;
|
||||||
public string customDisplayName;
|
public string customDisplayName;
|
||||||
|
|
||||||
public uint currentMainState = SetActorStatePacket.MAIN_STATE_PASSIVE;
|
public ushort currentMainState = SetActorStatePacket.MAIN_STATE_PASSIVE;
|
||||||
public uint currentSubState = SetActorStatePacket.SUB_STATE_NONE;
|
public ushort currentSubState = SetActorStatePacket.SUB_STATE_NONE;
|
||||||
public float positionX = SetActorPositionPacket.INNPOS_X, positionY = SetActorPositionPacket.INNPOS_Y, positionZ = SetActorPositionPacket.INNPOS_Z, rotation = SetActorPositionPacket.INNPOS_ROT;
|
public float positionX = SetActorPositionPacket.INNPOS_X, positionY = SetActorPositionPacket.INNPOS_Y, positionZ = SetActorPositionPacket.INNPOS_Z, rotation = SetActorPositionPacket.INNPOS_ROT;
|
||||||
public float oldPositionX, oldPositionY, oldPositionZ, oldRotation;
|
public float oldPositionX, oldPositionY, oldPositionZ, oldRotation;
|
||||||
public ushort moveState, oldMoveState;
|
public ushort moveState, oldMoveState;
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
|
||||||
public ushort[] status = new ushort[20];
|
public ushort[] status = new ushort[20];
|
||||||
public uint[] statusShownTime = new uint[20];
|
public uint[] statusShownTime = new uint[20];
|
||||||
|
|
||||||
public int[] command = new int[64];
|
public uint[] command = new uint[64];
|
||||||
public int[] commandCategory = new int[64];
|
public int[] commandCategory = new int[64];
|
||||||
public int commandBorder = 0x20;
|
public int commandBorder = 0x20;
|
||||||
public bool commandAcquired = false;
|
public bool commandAcquired = false;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using FFXIVClassic_Lobby_Server.packets;
|
using FFXIVClassic_Lobby_Server.packets;
|
||||||
|
using FFXIVClassic_Map_Server.actors.chara;
|
||||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -45,7 +46,8 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
|
||||||
public uint currentLockedTarget = 0xC0000000;
|
public uint currentLockedTarget = 0xC0000000;
|
||||||
|
|
||||||
public uint currentActorIcon = 0;
|
public uint currentActorIcon = 0;
|
||||||
|
|
||||||
|
public Work work = new Work();
|
||||||
public CharaWork charaWork = new CharaWork();
|
public CharaWork charaWork = new CharaWork();
|
||||||
public PlayerWork playerWork = new PlayerWork();
|
public PlayerWork playerWork = new PlayerWork();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
|
||||||
public int[] state_boostPointForSkill;
|
public int[] state_boostPointForSkill;
|
||||||
|
|
||||||
public int[] commandSlot_compatibility;
|
public int[] commandSlot_compatibility;
|
||||||
public int[] commandSlot_recastTime;
|
public uint[] commandSlot_recastTime = new uint[40];
|
||||||
|
|
||||||
public int[] giftCommandSlot_commandId;
|
public int[] giftCommandSlot_commandId;
|
||||||
}
|
}
|
||||||
|
|
15
FFXIVClassic Map Server/actors/chara/Work.cs
Normal file
15
FFXIVClassic Map Server/actors/chara/Work.cs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FFXIVClassic_Map_Server.actors.chara
|
||||||
|
{
|
||||||
|
class Work
|
||||||
|
{
|
||||||
|
public bool[] guildleveDone = new bool[16];
|
||||||
|
public bool[] guildleveChecked = new bool[16];
|
||||||
|
public bool betacheck = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ using FFXIVClassic_Lobby_Server.packets;
|
||||||
using FFXIVClassic_Map_Server.dataobjects.database;
|
using FFXIVClassic_Map_Server.dataobjects.database;
|
||||||
using FFXIVClassic_Map_Server.lua;
|
using FFXIVClassic_Map_Server.lua;
|
||||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -39,6 +40,20 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
|
||||||
|
|
||||||
public uint[] timers = new uint[20];
|
public uint[] timers = new uint[20];
|
||||||
|
|
||||||
|
public uint currentTitle;
|
||||||
|
|
||||||
|
public byte gcCurrent;
|
||||||
|
public byte gcRankLimsa;
|
||||||
|
public byte gcRankGridania;
|
||||||
|
public byte gcRankUldah;
|
||||||
|
|
||||||
|
public bool hasChocobo;
|
||||||
|
public bool hasGoobbue;
|
||||||
|
public byte chocoboAppearance;
|
||||||
|
public string chocoboName;
|
||||||
|
|
||||||
|
public uint achievementPoints;
|
||||||
|
|
||||||
PlayerWork playerWork = new PlayerWork();
|
PlayerWork playerWork = new PlayerWork();
|
||||||
|
|
||||||
public Player(uint actorID) : base(actorID)
|
public Player(uint actorID) : base(actorID)
|
||||||
|
@ -150,6 +165,9 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
|
||||||
public bool isMyPlayer(uint otherActorId)
|
public bool isMyPlayer(uint otherActorId)
|
||||||
{
|
{
|
||||||
return actorId == otherActorId;
|
return actorId == otherActorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,16 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
|
||||||
{
|
{
|
||||||
class PlayerWork
|
class PlayerWork
|
||||||
{
|
{
|
||||||
public int tribe;
|
public byte tribe;
|
||||||
public int guardian;
|
public byte guardian;
|
||||||
public int birthdayMonth;
|
public byte birthdayMonth;
|
||||||
public int birthdayDay;
|
public byte birthdayDay;
|
||||||
public int initialTown;
|
public byte initialTown;
|
||||||
|
|
||||||
public int restBonusExpRate;
|
public int restBonusExpRate;
|
||||||
|
|
||||||
public int[] questScenario = new int[16];
|
public uint[] questScenario = new uint[16];
|
||||||
public int[] questGuildLeve = new int[8];
|
public uint[] questGuildLeve = new uint[8];
|
||||||
|
|
||||||
public int questScenarioComplete;
|
public int questScenarioComplete;
|
||||||
public int questGuildleveComplete;
|
public int questGuildleveComplete;
|
||||||
|
@ -32,8 +32,8 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
|
||||||
|
|
||||||
public bool isRemainBonusPoint;
|
public bool isRemainBonusPoint;
|
||||||
|
|
||||||
public int[] npcLinkshellChatCalling = new int[64];
|
public bool[] npcLinkshellChatCalling = new bool[64];
|
||||||
public int[] npcLinkshellChatExtra = new int[64];
|
public bool[] npcLinkshellChatExtra = new bool[64];
|
||||||
|
|
||||||
public int variableCommandConfirmWarp;
|
public int variableCommandConfirmWarp;
|
||||||
public int variableCommandConfirmWarpSender;
|
public int variableCommandConfirmWarpSender;
|
||||||
|
@ -46,6 +46,6 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara
|
||||||
public int variableCommandConfirmRaiseSenderByID;
|
public int variableCommandConfirmRaiseSenderByID;
|
||||||
public int variableCommandConfirmRaiseSenderSex;
|
public int variableCommandConfirmRaiseSenderSex;
|
||||||
public int variableCommandConfirmRaisePlace;
|
public int variableCommandConfirmRaisePlace;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue