mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-23 13:17:45 +00:00
Removed more dapper code and unsupported syntax.
This commit is contained in:
parent
5bb3cc3b4e
commit
bec0cae0eb
3 changed files with 244 additions and 86 deletions
|
@ -1,6 +1,5 @@
|
|||
using FFXIVClassic_Lobby_Server.dataobjects;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Dapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -361,49 +360,106 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
public static List<World> GetServers()
|
||||
{
|
||||
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)))
|
||||
string query;
|
||||
MySqlCommand cmd;
|
||||
List<World> worldList = new List<World>();
|
||||
|
||||
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)))
|
||||
{
|
||||
List<World> worldList = null;
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
worldList = conn.Query<World>("SELECT * FROM servers WHERE isActive=true").ToList();
|
||||
query = "SELECT * FROM servers WHERE isActive=true";
|
||||
cmd = new MySqlCommand(query, conn);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
ushort id;
|
||||
string address;
|
||||
ushort port;
|
||||
ushort listPosition;
|
||||
ushort population;
|
||||
string name;
|
||||
bool isActive;
|
||||
|
||||
id = reader.GetUInt16("id");
|
||||
address = reader.GetString("address");
|
||||
port = reader.GetUInt16("port");
|
||||
listPosition = reader.GetUInt16("listPosition");
|
||||
population = reader.GetUInt16("population");
|
||||
name = reader.GetString("name");
|
||||
isActive = reader.GetBoolean("isActive");
|
||||
|
||||
worldList.Add(new World(id, address, port, listPosition, population, name, isActive));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
worldList = new List<World>(); }
|
||||
worldList = new List<World>();
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
return worldList;
|
||||
}
|
||||
return worldList;
|
||||
}
|
||||
|
||||
public static World GetServer(uint serverId)
|
||||
{
|
||||
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)))
|
||||
{
|
||||
string query;
|
||||
MySqlCommand cmd;
|
||||
World world = null;
|
||||
|
||||
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();
|
||||
world = conn.Query<World>("SELECT * FROM servers WHERE id=@ServerId", new {ServerId = serverId}).SingleOrDefault();
|
||||
query = "SELECT * FROM servers WHERE id=@ServerId";
|
||||
cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@ServerId", serverId);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
ushort id;
|
||||
string address;
|
||||
ushort port;
|
||||
ushort listPosition;
|
||||
ushort population;
|
||||
string name;
|
||||
bool isActive;
|
||||
|
||||
id = reader.GetUInt16("id");
|
||||
address = reader.GetString("address");
|
||||
port = reader.GetUInt16("port");
|
||||
listPosition = reader.GetUInt16("listPosition");
|
||||
population = reader.GetUInt16("population");
|
||||
name = reader.GetString("name");
|
||||
isActive = reader.GetBoolean("isActive");
|
||||
|
||||
world = new World(id, address, port, listPosition, population, name, isActive);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Character> GetCharacters(uint userId)
|
||||
{
|
||||
|
@ -467,6 +523,8 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Character chara = null;
|
||||
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)))
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
|
@ -515,18 +573,102 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
return chara;
|
||||
}
|
||||
|
||||
public static Appearance GetAppearance(uint charaId)
|
||||
{
|
||||
Appearance appearance = null;
|
||||
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)))
|
||||
{
|
||||
Appearance appearance = null;
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
appearance = conn.Query<Appearance>("SELECT * FROM characters_appearance WHERE characterId=@CharaId", new { CharaId = charaId }).SingleOrDefault();
|
||||
//Load appearance
|
||||
string query = @"
|
||||
SELECT
|
||||
baseId,
|
||||
size,
|
||||
voice,
|
||||
skinColor,
|
||||
hairStyle,
|
||||
hairColor,
|
||||
hairHighlightColor,
|
||||
eyeColor,
|
||||
characteristics,
|
||||
characteristicsColor,
|
||||
faceType,
|
||||
ears,
|
||||
faceMouth,
|
||||
faceFeatures,
|
||||
faceNose,
|
||||
faceEyeShape,
|
||||
faceIrisSize,
|
||||
faceEyebrows,
|
||||
mainHand,
|
||||
offHand,
|
||||
head,
|
||||
body,
|
||||
legs,
|
||||
hands,
|
||||
feet,
|
||||
waist,
|
||||
leftFinger,
|
||||
rightFinger,
|
||||
leftEar,
|
||||
rightEar
|
||||
FROM characters_appearance WHERE characterId = @charaId";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@charaId", charaId);
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
appearance.size = reader.GetByte("size");
|
||||
appearance.voice = reader.GetByte("voice");
|
||||
appearance.skinColor = reader.GetByte("skinColor");
|
||||
appearance.hairStyle = reader.GetByte("hairStyle");
|
||||
appearance.hairColor = reader.GetByte("hairColor");
|
||||
appearance.hairHighlightColor = reader.GetByte("hairHighlightColor");
|
||||
appearance.eyeColor = reader.GetByte("eyeColor");
|
||||
appearance.characteristics = reader.GetByte("characteristics");
|
||||
appearance.characteristicsColor = reader.GetByte("characteristicsColor");
|
||||
appearance.faceType = reader.GetByte("faceType");
|
||||
appearance.ears = reader.GetByte("ears");
|
||||
appearance.faceMouth = reader.GetByte("faceMouth");
|
||||
appearance.faceFeatures = reader.GetByte("faceFeatures");
|
||||
appearance.faceNose = reader.GetByte("faceNose");
|
||||
appearance.faceEyeShape = reader.GetByte("faceEyeShape");
|
||||
appearance.faceIrisSize = reader.GetByte("faceIrisSize");
|
||||
appearance.faceEyebrows = reader.GetByte("faceEyebrows");
|
||||
|
||||
appearance.mainHand = reader.GetByte("mainHand");
|
||||
appearance.offHand = reader.GetByte("offHand");
|
||||
appearance.head = reader.GetByte("head");
|
||||
appearance.body = reader.GetByte("body");
|
||||
appearance.mainHand = reader.GetByte("mainHand");
|
||||
appearance.legs = reader.GetByte("legs");
|
||||
appearance.hands = reader.GetByte("hands");
|
||||
appearance.feet = reader.GetByte("feet");
|
||||
appearance.waist = reader.GetByte("waist");
|
||||
appearance.leftFinger = reader.GetByte("leftFinger");
|
||||
appearance.rightFinger = reader.GetByte("rightFinger");
|
||||
appearance.leftEar = reader.GetByte("leftEar");
|
||||
appearance.rightEar = reader.GetByte("rightEar");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
|
@ -537,53 +679,48 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return appearance;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> GetReservedNames(uint userId)
|
||||
{
|
||||
List<String> reservedNames = new List<String>();
|
||||
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)))
|
||||
{
|
||||
List<String> nameList = null;
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
nameList = conn.Query<String>("SELECT name FROM reserved_names WHERE userId=@UserId", new { UserId = userId }).ToList();
|
||||
|
||||
string query = "SELECT name FROM reserved_names WHERE userId=@UserId";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@UserId", userId);
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
reservedNames.Add(reader.GetString("name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
nameList = new List<String>(); }
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
return nameList;
|
||||
}
|
||||
return reservedNames;
|
||||
}
|
||||
|
||||
public static List<Retainer> GetRetainers(uint userId)
|
||||
{
|
||||
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)))
|
||||
{
|
||||
List<Retainer> retainerList = null;
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
retainerList = conn.Query<Retainer>("SELECT * FROM retainers WHERE id=@UserId ORDER BY characterId, slot", new { UserId = userId }).ToList();
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
retainerList = new List<Retainer>(); }
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
return retainerList;
|
||||
}
|
||||
return new List<Retainer>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,30 @@
|
|||
{
|
||||
class World
|
||||
{
|
||||
public ushort id;
|
||||
public string address;
|
||||
public ushort port;
|
||||
public ushort listPosition;
|
||||
public ushort population;
|
||||
public string name;
|
||||
public bool isActive;
|
||||
public readonly ushort id;
|
||||
public readonly string address;
|
||||
public readonly ushort port;
|
||||
public readonly ushort listPosition;
|
||||
public readonly ushort population;
|
||||
public readonly string name;
|
||||
public readonly bool isActive;
|
||||
|
||||
public World(
|
||||
ushort id,
|
||||
string address,
|
||||
ushort port,
|
||||
ushort listPosition,
|
||||
ushort population,
|
||||
string name,
|
||||
bool isActive)
|
||||
{
|
||||
this.id = id;
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.listPosition = listPosition;
|
||||
this.population = population;
|
||||
this.name = name;
|
||||
this.isActive = isActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
{
|
||||
if (!effect.GetHidden())
|
||||
{
|
||||
propPacketUtil.AddProperty($"charaWork.statusShownTime[{i}]");
|
||||
propPacketUtil.AddProperty(String.Format("charaWork.statusShownTime[{0}]", i));
|
||||
propPacketUtil.AddProperty(String.Format("charaWork.statusShownTime[{0}]", i));
|
||||
i++;
|
||||
}
|
||||
|
@ -287,7 +287,8 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
#region ai stuff
|
||||
public void PathTo(float x, float y, float z, float stepSize = 0.70f, int maxPath = 40, float polyRadius = 0.0f)
|
||||
{
|
||||
aiContainer?.pathFind?.PreparePath(x, y, z, stepSize, maxPath, polyRadius);
|
||||
if (aiContainer != null && aiContainer.pathFind != null)
|
||||
aiContainer.pathFind.PreparePath(x, y, z, stepSize, maxPath, polyRadius);
|
||||
}
|
||||
|
||||
public void FollowTarget(Actor target, float stepSize = 1.2f, int maxPath = 25, float radius = 0.0f)
|
||||
|
@ -759,7 +760,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
foreach (BattleAction action in actions)
|
||||
{
|
||||
if (zone.FindActorInArea<Character>(action.targetId) is Character chara)
|
||||
if (zone.FindActorInArea<Character>(action.targetId) is Character)
|
||||
{
|
||||
//BattleUtils.HandleHitType(this, chara, action);
|
||||
//BattleUtils.DoAction(this, chara, action, DamageTakenType.Magic);
|
||||
|
@ -775,7 +776,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
foreach (BattleAction action in actions)
|
||||
{
|
||||
//Should we just store the character insteado f having to find it again?
|
||||
if (zone.FindActorInArea<Character>(action.targetId) is Character chara)
|
||||
if (zone.FindActorInArea<Character>(action.targetId) is Character)
|
||||
{
|
||||
//BattleUtils.DoAction(this, chara, action, DamageTakenType.Weaponskill);
|
||||
}
|
||||
|
@ -788,7 +789,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
{
|
||||
foreach (var action in actions)
|
||||
{
|
||||
if (zone.FindActorInArea<Character>(action.targetId) is Character chara)
|
||||
if (zone.FindActorInArea<Character>(action.targetId) is Character)
|
||||
{
|
||||
//BattleUtils.DoAction(this, chara, action, DamageTakenType.Ability);
|
||||
}
|
||||
|
@ -947,12 +948,12 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
{
|
||||
shouldSend = true;
|
||||
charaWork.battleTemp.timingCommandFlag[i] = false;
|
||||
propPacketUtil.AddProperty($"charaWork.battleTemp.timingCommandFlag[{i}]");
|
||||
propPacketUtil.AddProperty(String.Format("charaWork.battleTemp.timingCommandFlag[{0}]", i));
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSend && this is Player player)
|
||||
player.QueuePackets(propPacketUtil.Done());
|
||||
if (shouldSend && this is Player)
|
||||
((Player)this).QueuePackets(propPacketUtil.Done());
|
||||
}
|
||||
|
||||
//Set given proc to true and send packet if this is a player
|
||||
|
@ -976,11 +977,11 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
statusEffects.RemoveStatusEffect(statusEffects.GetStatusEffectById((uint)effectId));
|
||||
}
|
||||
|
||||
if (this is Player player)
|
||||
if (this is Player)
|
||||
{
|
||||
var propPacketUtil = new ActorPropertyPacketUtil("charaWork/timingCommand", this);
|
||||
propPacketUtil.AddProperty($"charaWork.battleTemp.timingCommandFlag[{procId}]");
|
||||
player.QueuePackets(propPacketUtil.Done());
|
||||
propPacketUtil.AddProperty(String.Format("charaWork.battleTemp.timingCommandFlag[{0}]", procId));
|
||||
((Player)this).QueuePackets(propPacketUtil.Done());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1106,11 +1107,13 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
}
|
||||
|
||||
//Now that we know if we hit the target we can check if the combo continues
|
||||
if (this is Player player)
|
||||
if (this is Player)
|
||||
{
|
||||
if (command.isCombo && hitTarget)
|
||||
player.SetCombos(command.comboNextCommandId);
|
||||
((Player)this).SetCombos(command.comboNextCommandId);
|
||||
else
|
||||
player.SetCombos();
|
||||
((Player)this).SetCombos();
|
||||
}
|
||||
|
||||
BattleAction error = new BattleAction(actorId, 0, 0);
|
||||
DelMP(command.CalculateMpCost(this));
|
||||
|
|
Loading…
Add table
Reference in a new issue