mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-24 21:57:45 +00:00
Fixed a character appearance bug when making a character. Current zone now shown. Added a utility for setting new gear appearance.
This commit is contained in:
parent
23dcc1dafe
commit
1c5f8b3d0b
7 changed files with 161 additions and 20 deletions
|
@ -53,7 +53,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
conn.Open();
|
||||
|
||||
//Check if exists
|
||||
MySqlCommand cmd = new MySqlCommand("SELECT * FROM characters WHERE name=@name AND serverId=@serverId", conn);
|
||||
MySqlCommand cmd = new MySqlCommand("SELECT * FROM characters WHERE name=@name AND serverId=@serverId AND state != 2 AND state != 1", conn);
|
||||
cmd.Parameters.AddWithValue("@serverId", serverId);
|
||||
cmd.Parameters.AddWithValue("@name", name);
|
||||
using (MySqlDataReader Reader = cmd.ExecuteReader())
|
||||
|
@ -111,19 +111,72 @@ namespace FFXIVClassic_Lobby_Server
|
|||
conn.Open();
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = "UPDATE characters SET state=2, charaInfo=@encodedInfo WHERE userId=@userId AND id=@cid";
|
||||
cmd.Prepare();
|
||||
cmd.CommandText = @"
|
||||
UPDATE characters SET
|
||||
state=2,
|
||||
currentZoneId=@zoneId,
|
||||
positionX=@x,
|
||||
positionY=@y,
|
||||
positionZ=@z,
|
||||
rotation=@r,
|
||||
guardian=@guardian,
|
||||
birthDay=@birthDay,
|
||||
birthMonth=@birthMonth,
|
||||
initialTown=@initialTown,
|
||||
tribe=@tribe,
|
||||
currentClassJob=@currentClass
|
||||
WHERE userId=@userId AND id=@cid;
|
||||
|
||||
INSERT INTO characters_appearance
|
||||
(characterId, baseId, size, voice, skinColor, hairStyle, hairColor, hairHighlightColor, eyeColor, faceType, faceEyebrows, faceEyeShape, faceIrisSize, faceNose, faceMouth, faceFeatures, ears, characteristics, characteristicsColor, mainhand, head, body, hands, legs, feet)
|
||||
VALUES
|
||||
(@cid, 4294967295, @size, @voice, @skinColor, @hairStyle, @hairColor, @hairHighlightColor, @eyeColor, @faceType, @faceEyebrows, @faceEyeShape, @faceIrisSize, @faceNose, @faceMouth, @faceFeatures, @ears, @characteristics, @characteristicsColor, @mainhand, @head, @body, @hands, @legs, @feet)
|
||||
";
|
||||
cmd.Parameters.AddWithValue("@userId", accountId);
|
||||
cmd.Parameters.AddWithValue("@cid", cid);
|
||||
string json = JsonConvert.SerializeObject(charaInfo);
|
||||
cmd.Parameters.AddWithValue("@encodedInfo", json);
|
||||
cmd.Parameters.AddWithValue("@guardian", charaInfo.guardian);
|
||||
cmd.Parameters.AddWithValue("@birthDay", charaInfo.birthDay);
|
||||
cmd.Parameters.AddWithValue("@birthMonth", charaInfo.birthMonth);
|
||||
cmd.Parameters.AddWithValue("@initialTown", charaInfo.initialTown);
|
||||
cmd.Parameters.AddWithValue("@tribe", charaInfo.tribe);
|
||||
cmd.Parameters.AddWithValue("@currentClass", charaInfo.currentClass);
|
||||
|
||||
cmd.Parameters.AddWithValue("@zoneId", charaInfo.zoneId);
|
||||
cmd.Parameters.AddWithValue("@x", charaInfo.x);
|
||||
cmd.Parameters.AddWithValue("@y", charaInfo.y);
|
||||
cmd.Parameters.AddWithValue("@z", charaInfo.z);
|
||||
cmd.Parameters.AddWithValue("@r", charaInfo.rot);
|
||||
|
||||
cmd.Parameters.AddWithValue("@size", charaInfo.appearance.size);
|
||||
cmd.Parameters.AddWithValue("@voice", charaInfo.appearance.voice);
|
||||
cmd.Parameters.AddWithValue("@skinColor", charaInfo.appearance.skinColor);
|
||||
cmd.Parameters.AddWithValue("@hairStyle", charaInfo.appearance.hairStyle);
|
||||
cmd.Parameters.AddWithValue("@hairColor", charaInfo.appearance.hairColor);
|
||||
cmd.Parameters.AddWithValue("@hairHighlightColor", charaInfo.appearance.hairHighlightColor);
|
||||
cmd.Parameters.AddWithValue("@eyeColor", charaInfo.appearance.eyeColor);
|
||||
cmd.Parameters.AddWithValue("@faceType", charaInfo.appearance.faceType);
|
||||
cmd.Parameters.AddWithValue("@faceEyebrows", charaInfo.appearance.faceEyebrows);
|
||||
cmd.Parameters.AddWithValue("@faceEyeShape", charaInfo.appearance.faceEyeShape);
|
||||
cmd.Parameters.AddWithValue("@faceIrisSize", charaInfo.appearance.faceIrisSize);
|
||||
cmd.Parameters.AddWithValue("@faceNose", charaInfo.appearance.faceNose);
|
||||
cmd.Parameters.AddWithValue("@faceMouth", charaInfo.appearance.faceMouth);
|
||||
cmd.Parameters.AddWithValue("@faceFeatures", charaInfo.appearance.faceFeatures);
|
||||
cmd.Parameters.AddWithValue("@ears", charaInfo.appearance.ears);
|
||||
cmd.Parameters.AddWithValue("@characteristics", charaInfo.appearance.characteristics);
|
||||
cmd.Parameters.AddWithValue("@characteristicsColor", charaInfo.appearance.characteristicsColor);
|
||||
|
||||
cmd.Parameters.AddWithValue("@mainhand", 0);
|
||||
cmd.Parameters.AddWithValue("@head", 1024);
|
||||
cmd.Parameters.AddWithValue("@body", 1024);
|
||||
cmd.Parameters.AddWithValue("@hands", 1024);
|
||||
cmd.Parameters.AddWithValue("@legs", 1024);
|
||||
cmd.Parameters.AddWithValue("@feet", 1024);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -246,7 +299,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
conn.Open();
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = "DELETE FROM characters WHERE id=@cid AND name=@name";
|
||||
cmd.CommandText = "UPDATE characters SET state=1 WHERE id=@cid AND name=@name";
|
||||
cmd.Prepare();
|
||||
cmd.Parameters.AddWithValue("@cid", characterId);
|
||||
cmd.Parameters.AddWithValue("@name", name);
|
||||
|
@ -316,7 +369,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
try
|
||||
{
|
||||
conn.Open();
|
||||
charaList = conn.Query<Character>("SELECT * FROM characters WHERE userId=@UserId AND state in (1,2) ORDER BY slot", new { UserId = userId }).ToList();
|
||||
charaList = conn.Query<Character>("SELECT * FROM characters WHERE userId=@UserId AND state = 2 ORDER BY slot", new { UserId = userId }).ToList();
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{ charaList = new List<Character>(); }
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Server.cs" />
|
||||
<Compile Include="utils\CharacterCreatorUtils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using FFXIVClassic_Lobby_Server.dataobjects;
|
||||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using FFXIVClassic_Lobby_Server.packets.receive;
|
||||
using FFXIVClassic_Lobby_Server.utils;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -80,6 +81,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
private void ProcessSessionAcknowledgement(ClientConnection client, SubPacket packet)
|
||||
{
|
||||
packet.debugPrintSubPacket();
|
||||
SessionPacket sessionPacket = new SessionPacket(packet.data);
|
||||
String clientVersion = sessionPacket.version;
|
||||
|
||||
|
@ -159,7 +161,6 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
CharacterModifyPacket charaReq = new CharacterModifyPacket(packet.data);
|
||||
var slot = charaReq.slot;
|
||||
var code = charaReq.command;
|
||||
var name = charaReq.characterName;
|
||||
var worldId = charaReq.worldId;
|
||||
|
||||
|
@ -196,7 +197,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
bool alreadyTaken;
|
||||
|
||||
switch (code)
|
||||
switch (charaReq.command)
|
||||
{
|
||||
case 0x01://Reserve
|
||||
|
||||
|
@ -227,6 +228,45 @@ namespace FFXIVClassic_Lobby_Server
|
|||
case 0x02://Make
|
||||
CharaInfo info = CharaInfo.getFromNewCharRequest(charaReq.characterInfoEncoded);
|
||||
|
||||
//Set Initial Appearance
|
||||
/*
|
||||
uint[] classAppearance = CharacterCreatorUtils.getEquipmentForClass(info.currentClass);
|
||||
info.weapon1 = classAppearance[0];
|
||||
info.weapon2 = classAppearance[1];
|
||||
info.head = classAppearance[2];
|
||||
info.body = classAppearance[3];
|
||||
info.hands = classAppearance[4];
|
||||
info.legs = classAppearance[5];
|
||||
info.feet = classAppearance[6];
|
||||
info.belt = classAppearance[7];
|
||||
|
||||
*/
|
||||
//Set Initial Position
|
||||
switch (info.initialTown)
|
||||
{
|
||||
case 1:
|
||||
info.zoneId = 193;
|
||||
info.x = 0.016f;
|
||||
info.y = 10.35f;
|
||||
info.z = -36.91f;
|
||||
info.rot = 0.025f;
|
||||
break;
|
||||
case 2:
|
||||
info.zoneId = 166;
|
||||
info.x = 356.09f;
|
||||
info.y = 3.74f;
|
||||
info.z = -701.62f;
|
||||
info.rot = -1.4f;
|
||||
break;
|
||||
case 3:
|
||||
info.zoneId = 184;
|
||||
info.x = 12.63f;
|
||||
info.y = 196.05f;
|
||||
info.z = 131.01f;
|
||||
info.rot = -1.34f;
|
||||
break;
|
||||
}
|
||||
|
||||
Database.makeCharacter(client.currentUserId, client.newCharaCid, info);
|
||||
|
||||
pid = 1;
|
||||
|
@ -264,7 +304,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
break;
|
||||
}
|
||||
|
||||
CharaCreatorPacket charaCreator = new CharaCreatorPacket(charaReq.sequence, code, pid, cid, 1, name, worldName);
|
||||
CharaCreatorPacket charaCreator = new CharaCreatorPacket(charaReq.sequence, charaReq.command, pid, cid, 1, name, worldName);
|
||||
BasePacket charaCreatorPacket = BasePacket.createPacket(charaCreator.buildPacket(), true, false);
|
||||
BasePacket.encryptPacket(client.blowfish, charaCreatorPacket);
|
||||
client.queuePacket(charaCreatorPacket);
|
||||
|
|
|
@ -43,9 +43,12 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
|
|||
public uint birthDay = 0;
|
||||
public uint currentClass = 0;
|
||||
public uint currentJob = 0;
|
||||
public uint allegiance = 0;
|
||||
public uint initialTown = 0;
|
||||
public uint tribe = 0;
|
||||
|
||||
public ushort zoneId;
|
||||
public float x, y, z, rot;
|
||||
|
||||
public uint currentLevel = 1;
|
||||
|
||||
public static CharaInfo getFromNewCharRequest(String encoded)
|
||||
|
@ -97,7 +100,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
|
|||
|
||||
reader.BaseStream.Seek(0x10, SeekOrigin.Current);
|
||||
|
||||
info.allegiance = reader.ReadByte();
|
||||
info.initialTown = reader.ReadByte();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ namespace FFXIVClassic_Lobby_Server
|
|||
public bool doRename;
|
||||
public uint currentZoneId;
|
||||
|
||||
public byte guardian = 0;
|
||||
public byte birthMonth = 0;
|
||||
public byte birthDay = 0;
|
||||
public byte guardian;
|
||||
public byte birthMonth;
|
||||
public byte birthDay;
|
||||
public uint currentClass = 3;
|
||||
public uint currentJob = 0;
|
||||
public byte initialTown = 0;
|
||||
public byte tribe = 0;
|
||||
public byte initialTown;
|
||||
public byte tribe;
|
||||
|
||||
public uint currentLevel = 1;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace FFXIVClassic_Lobby_Server.packets
|
|||
|
||||
binWriter.Write((byte)options); //Options (0x01: Service Account not active, 0x72: Change Chara Name)
|
||||
binWriter.Write((ushort)0);
|
||||
binWriter.Write((uint)0xF4); //Logged out zone
|
||||
binWriter.Write((uint)chara.currentZoneId); //Logged out zone
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(chara.name.PadRight(0x20, '\0'))); //Name
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(worldname.PadRight(0xE, '\0'))); //World Name
|
||||
|
||||
|
|
44
FFXIVClassic_Lobby_Server/utils/CharacterCreatorUtils.cs
Normal file
44
FFXIVClassic_Lobby_Server/utils/CharacterCreatorUtils.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Lobby_Server.utils
|
||||
{
|
||||
class CharacterCreatorUtils
|
||||
{
|
||||
private static readonly Dictionary<uint, uint[]> equipmentAppearance = new Dictionary<uint, uint[]>
|
||||
{
|
||||
{ 2, new uint[]{1} }, //PUG
|
||||
{ 3, new uint[]{1} }, //GLA
|
||||
{ 4, new uint[]{1} }, //MRD
|
||||
{ 7, new uint[]{1} }, //ARC
|
||||
|
||||
{ 22, new uint[]{1} }, //THM
|
||||
{ 23, new uint[]{1} }, //CNJ
|
||||
|
||||
{ 29, new uint[]{1} }, //CRP
|
||||
{ 30, new uint[]{1} }, //BSM
|
||||
{ 31, new uint[]{1} }, //ARM
|
||||
{ 32, new uint[]{1} }, //GSM
|
||||
{ 33, new uint[]{1} }, //LTW
|
||||
{ 34, new uint[]{1} }, //WVR
|
||||
{ 35, new uint[]{1} }, //ALC
|
||||
{ 36, new uint[]{1} }, //CUL
|
||||
|
||||
{ 39, new uint[]{1} }, //MIN
|
||||
{ 40, new uint[]{1} }, //BOT
|
||||
{ 41, new uint[]{1} }, //FSH
|
||||
};
|
||||
|
||||
public static uint[] getEquipmentForClass(uint charClass)
|
||||
{
|
||||
if (equipmentAppearance.ContainsKey(charClass))
|
||||
return equipmentAppearance[charClass];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue