mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-23 21:27:46 +00:00
Fixed the retainer database error. Loading code now matches the new retainer db schema.
This commit is contained in:
parent
4762811347
commit
62484e2f87
3 changed files with 44 additions and 11 deletions
|
@ -530,24 +530,50 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
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> retainers = new List<Retainer>();
|
||||
|
||||
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<Retainer> retainerList = null;
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
retainerList = conn.Query<Retainer>("SELECT * FROM retainers WHERE id=@UserId ORDER BY characterId, slot", new { UserId = userId }).ToList();
|
||||
|
||||
string query = @"
|
||||
SELECT characters.id as charaId, server_retainers.id as retainerId, server_retainers.name, characters_retainers.doRename FROM characters
|
||||
INNER JOIN characters_retainers ON characters.id = characters_retainers.characterId
|
||||
INNER JOIN server_retainers ON characters_retainers.retainerId = server_retainers.id
|
||||
WHERE userId = @userId
|
||||
";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@userId", userId);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
uint characterId = reader.GetUInt32("charaId");
|
||||
uint retainerId = reader.GetUInt32("retainerId");
|
||||
string name = reader.GetString("name");
|
||||
bool doRename = reader.GetBoolean("doRename");
|
||||
|
||||
retainers.Add(new Retainer(characterId, retainerId, name, doRename));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
retainerList = new List<Retainer>(); }
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
return retainerList;
|
||||
|
||||
return retainers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,17 @@
|
|||
{
|
||||
class Retainer
|
||||
{
|
||||
public uint id;
|
||||
public uint characterId;
|
||||
public string name;
|
||||
public ushort slot;
|
||||
public bool doRename;
|
||||
public readonly uint id;
|
||||
public readonly uint characterId;
|
||||
public readonly string name;
|
||||
public readonly bool doRename;
|
||||
|
||||
public Retainer(uint characterId, uint retainerId, string name, bool doRename)
|
||||
{
|
||||
this.id = retainerId;
|
||||
this.characterId = characterId;
|
||||
this.name = name;
|
||||
this.doRename = doRename;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ namespace FFXIVClassic_Lobby_Server.packets
|
|||
//Write Entries
|
||||
binWriter.Write((uint)retainer.id);
|
||||
binWriter.Write((uint)retainer.characterId);
|
||||
binWriter.Write((ushort)retainer.slot);
|
||||
binWriter.Write((ushort)totalCount);
|
||||
binWriter.Write((ushort)(retainer.doRename ? 0x04 : 0x00));
|
||||
binWriter.Write((uint)0);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(retainer.name.PadRight(0x20, '\0')));
|
||||
|
|
Loading…
Add table
Reference in a new issue