Fixed emotes not being sent to the emoter. Fixed appearance packets' gloves/legs being ordered wrong. Chat is implemented. Changed commands to start with '!'.

This commit is contained in:
Filip Maj 2016-02-18 22:38:54 -05:00
parent c6ac8b2f14
commit a47d5f96a5
8 changed files with 86 additions and 43 deletions

View File

@ -233,14 +233,14 @@ namespace FFXIVClassic_Lobby_Server
offHand, offHand,
head, head,
body, body,
hands,
legs, legs,
hands,
feet, feet,
waist, waist,
leftFinger, leftFinger,
rightFinger, rightFinger,
leftEars, leftEar,
rightEars rightEar
FROM characters_appearance WHERE characterId = @charId"; FROM characters_appearance WHERE characterId = @charId";
cmd = new MySqlCommand(query, conn); cmd = new MySqlCommand(query, conn);

View File

@ -158,7 +158,13 @@ namespace FFXIVClassic_Lobby_Server
} }
else if (subpacket.header.type == 0x03) else if (subpacket.header.type == 0x03)
{ {
ConnectedPlayer player = mPlayers[client.owner]; ConnectedPlayer player = null;
if(mPlayers.ContainsKey(client.owner))
player = mPlayers[client.owner];
if (player == null)
return;
//Normal Game Opcode //Normal Game Opcode
switch (subpacket.gameMessage.opcode) switch (subpacket.gameMessage.opcode)
@ -181,9 +187,15 @@ namespace FFXIVClassic_Lobby_Server
case 0x0003: case 0x0003:
ChatMessagePacket chatMessage = new ChatMessagePacket(subpacket.data); ChatMessagePacket chatMessage = new ChatMessagePacket(subpacket.data);
Log.info(String.Format("Got type-{5} message: {0} @ {1}, {2}, {3}, Rot: {4}", chatMessage.message, chatMessage.posX, chatMessage.posY, chatMessage.posZ, chatMessage.posRot, chatMessage.logType)); Log.info(String.Format("Got type-{5} message: {0} @ {1}, {2}, {3}, Rot: {4}", chatMessage.message, chatMessage.posX, chatMessage.posY, chatMessage.posZ, chatMessage.posRot, chatMessage.logType));
//subpacket.debugPrintSubPacket(); subpacket.debugPrintSubPacket();
mServer.doCommand(chatMessage.message, player); if (chatMessage.message.StartsWith("!"))
{
if (mServer.doCommand(chatMessage.message, player))
continue;
}
player.getActor().broadcastPacket(SendMessagePacket.buildPacket(player.actorID, player.actorID, chatMessage.logType, player.getActor().customDisplayName, chatMessage.message), false);
break; break;
//Unknown //Unknown
@ -203,7 +215,7 @@ namespace FFXIVClassic_Lobby_Server
SetTargetPacket setTarget = new SetTargetPacket(subpacket.data); SetTargetPacket setTarget = new SetTargetPacket(subpacket.data);
player.getActor().currentTarget = setTarget.actorID; player.getActor().currentTarget = setTarget.actorID;
client.queuePacket(BasePacket.createPacket(SetActorTargetAnimatedPacket.buildPacket(player.actorID, player.actorID, setTarget.actorID), true, false)); player.getActor().broadcastPacket(SetActorTargetAnimatedPacket.buildPacket(player.actorID, player.actorID, setTarget.actorID), true);
break; break;
//Lock Target //Lock Target
case 0x00CC: case 0x00CC:

View File

@ -205,8 +205,6 @@ namespace FFXIVClassic_Lobby_Server
if (offset < bytesRead) if (offset < bytesRead)
Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset); Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset);
Array.Clear(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset));
conn.lastPartialSize = bytesRead - offset; conn.lastPartialSize = bytesRead - offset;
//Build any queued subpackets into basepackets and send //Build any queued subpackets into basepackets and send
@ -573,9 +571,11 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
internal void doCommand(string input, ConnectedPlayer client) internal bool doCommand(string input, ConnectedPlayer client)
{ {
input.Trim(); input.Trim();
if (input.StartsWith("!"))
input = input.Substring(1);
String[] split = input.Split(' '); String[] split = input.Split(' ');
@ -586,6 +586,7 @@ namespace FFXIVClassic_Lobby_Server
try try
{ {
printPos(client); printPos(client);
return true;
} }
catch (Exception e) catch (Exception e)
{ {
@ -603,15 +604,17 @@ namespace FFXIVClassic_Lobby_Server
client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Resting zone {0}...", client.getActor().zoneId)), true, false)); client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Resting zone {0}...", client.getActor().zoneId)), true, false));
} }
mWorldManager.reloadZone(client.getActor().zoneId); mWorldManager.reloadZone(client.getActor().zoneId);
return true;
} }
else if (split[0].Equals("sendpacket")) else if (split[0].Equals("sendpacket"))
{ {
if (split.Length < 2) if (split.Length < 2)
return; return false;
try try
{ {
sendPacket(client, "./packets/" + split[1]); sendPacket(client, "./packets/" + split[1]);
return true;
} }
catch (Exception e) catch (Exception e)
{ {
@ -628,6 +631,7 @@ namespace FFXIVClassic_Lobby_Server
giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]));
else if (split.Length == 4) else if (split.Length == 4)
giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3]));
return true;
} }
catch (Exception e) catch (Exception e)
{ {
@ -637,7 +641,7 @@ namespace FFXIVClassic_Lobby_Server
else if (split[0].Equals("removeitem")) else if (split[0].Equals("removeitem"))
{ {
if (split.Length < 2) if (split.Length < 2)
return; return false;
try try
{ {
@ -647,6 +651,7 @@ namespace FFXIVClassic_Lobby_Server
removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]));
else if (split.Length == 4) else if (split.Length == 4)
removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3]));
return true;
} }
catch (Exception e) catch (Exception e)
{ {
@ -668,12 +673,13 @@ namespace FFXIVClassic_Lobby_Server
else if (split[0].Equals("removekeyitem")) else if (split[0].Equals("removekeyitem"))
{ {
if (split.Length < 2) if (split.Length < 2)
return; return false;
try try
{ {
if (split.Length == 2) if (split.Length == 2)
removeKeyItem(client, UInt32.Parse(split[1])); removeKeyItem(client, UInt32.Parse(split[1]));
return true;
} }
catch (Exception e) catch (Exception e)
{ {
@ -697,7 +703,7 @@ namespace FFXIVClassic_Lobby_Server
else if (split[0].Equals("removecurrancy")) else if (split[0].Equals("removecurrancy"))
{ {
if (split.Length < 2) if (split.Length < 2)
return; return false;
try try
{ {
@ -705,6 +711,7 @@ namespace FFXIVClassic_Lobby_Server
removeCurrancy(client, UInt32.Parse(split[1]), 1); removeCurrancy(client, UInt32.Parse(split[1]), 1);
else if (split.Length == 3) else if (split.Length == 3)
removeCurrancy(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); removeCurrancy(client, UInt32.Parse(split[1]), Int32.Parse(split[2]));
return true;
} }
catch (Exception e) catch (Exception e)
{ {
@ -714,11 +721,12 @@ namespace FFXIVClassic_Lobby_Server
else if (split[0].Equals("music")) else if (split[0].Equals("music"))
{ {
if (split.Length < 2) if (split.Length < 2)
return; return false;
try try
{ {
doMusic(client, split[1]); doMusic(client, split[1]);
return true;
} }
catch (Exception e) catch (Exception e)
{ {
@ -731,13 +739,16 @@ namespace FFXIVClassic_Lobby_Server
doWarp(client, split[1]); doWarp(client, split[1]);
else if (split.Length == 5) else if (split.Length == 5)
doWarp(client, split[1], split[2], split[3], split[4]); doWarp(client, split[1], split[2], split[3], split[4]);
return true;
} }
else if (split[0].Equals("property")) else if (split[0].Equals("property"))
{ {
if (split.Length == 5) if (split.Length == 5)
testCodePacket(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]); testCodePacket(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]);
return true;
} }
} }
return false;
} }
} }

View File

@ -216,6 +216,16 @@ namespace FFXIVClassic_Map_Server.Actors
} }
} }
//Remove players if isolation zone
if (isIsolated)
{
for (int i = 0; i < result.Count; i++)
{
if (result[i] is Player)
result.RemoveAt(i);
}
}
return result; return result;
} }
@ -306,11 +316,17 @@ namespace FFXIVClassic_Map_Server.Actors
public void broadcastPacketAroundActor(Actor actor, SubPacket packet) public void broadcastPacketAroundActor(Actor actor, SubPacket packet)
{ {
if (isIsolated)
return;
List<Actor> aroundActor = getActorsAroundActor(actor, 50); List<Actor> aroundActor = getActorsAroundActor(actor, 50);
foreach (Actor a in aroundActor) foreach (Actor a in aroundActor)
{ {
if (a is Player) if (a is Player)
{ {
if (isIsolated && packet.header.sourceId != a.actorId)
continue;
SubPacket clonedPacket = new SubPacket(packet, actor.actorId); SubPacket clonedPacket = new SubPacket(packet, actor.actorId);
Player p = (Player)a; Player p = (Player)a;
p.queuePacket(clonedPacket); p.queuePacket(clonedPacket);

View File

@ -129,8 +129,8 @@ namespace FFXIVClassic_Map_Server.Actors
feet, feet,
waist, waist,
neck, neck,
leftEars, leftEar,
rightEars, rightEar,
leftIndex, leftIndex,
rightIndex, rightIndex,
leftFinger, leftFinger,

View File

@ -538,8 +538,11 @@ namespace FFXIVClassic_Map_Server.Actors
playerSession.queuePacket(packet, true, false); playerSession.queuePacket(packet, true, false);
} }
public void broadcastPacket(SubPacket packet) public void broadcastPacket(SubPacket packet, bool sendToSelf)
{ {
if (sendToSelf)
queuePacket(packet);
foreach (Actor a in playerSession.actorInstanceList) foreach (Actor a in playerSession.actorInstanceList)
{ {
if (a is Player) if (a is Player)
@ -598,7 +601,7 @@ namespace FFXIVClassic_Map_Server.Actors
public void doEmote(uint emoteId) public void doEmote(uint emoteId)
{ {
broadcastPacket(ActorDoEmotePacket.buildPacket(actorId, actorId, emoteId)); broadcastPacket(ActorDoEmotePacket.buildPacket(actorId, actorId, currentTarget, emoteId), true);
} }
public void sendGameMessage(Actor sourceActor, Actor textIdOwner, ushort textId, byte log, params object[] msgParams) public void sendGameMessage(Actor sourceActor, Actor textIdOwner, ushort textId, byte log, params object[] msgParams)

View File

@ -13,26 +13,27 @@ namespace FFXIVClassic_Map_Server.packets.send.actor
public const ushort OPCODE = 0x00E1; public const ushort OPCODE = 0x00E1;
public const uint PACKET_SIZE = 0x30; public const uint PACKET_SIZE = 0x30;
public static SubPacket buildPacket(uint playerActorID, uint targetActorID, uint emoteID) public static SubPacket buildPacket(uint sourceActorId, uint targetActorId, uint targettedActorId, uint emoteID)
{ {
byte[] data = new byte[PACKET_SIZE - 0x20]; byte[] data = new byte[PACKET_SIZE - 0x20];
if (targetActorID == 0xC0000000) if (targettedActorId == 0xC0000000)
targetActorID = playerActorID; targettedActorId = sourceActorId;
using (MemoryStream mem = new MemoryStream(data)) using (MemoryStream mem = new MemoryStream(data))
{ {
using (BinaryWriter binWriter = new BinaryWriter(mem)) using (BinaryWriter binWriter = new BinaryWriter(mem))
{ {
uint realAnimID = 0x5000000 | ((emoteID - 100) << 12); uint realAnimID = 0x5000000 | ((emoteID - 100) << 12);
uint realDescID = 20000 + ((emoteID - 1) * 10) + (targetActorID == playerActorID ? (uint)2 : (uint)1); uint realDescID = 20000 + ((emoteID - 1) * 10) + (targettedActorId == sourceActorId ? (uint)2 : (uint)1);
binWriter.Write((UInt32)realAnimID); binWriter.Write((UInt32)realAnimID);
binWriter.Write((UInt32)targetActorID); binWriter.Write((UInt32)targettedActorId);
binWriter.Write((UInt32)realDescID); binWriter.Write((UInt32)realDescID);
} }
} }
SubPacket packet = new SubPacket(OPCODE, playerActorID, targetActorID, data); SubPacket packet = new SubPacket(OPCODE, sourceActorId, targetActorId, data);
packet.debugPrintSubPacket();
return packet; return packet;
} }
} }

View File

@ -21,19 +21,19 @@ namespace FFXIVClassic_Map_Server.packets.send.actor
public const int WEAPON1 = 5; public const int WEAPON1 = 5;
public const int WEAPON2 = 6; public const int WEAPON2 = 6;
public const int WEAPON3 = 7; public const int WEAPON3 = 7;
public const int HEADGEAR = 8; public const int HEADGEAR = 12;
public const int BODYGEAR = 9; public const int BODYGEAR = 13;
public const int LEGSGEAR = 10; public const int LEGSGEAR = 14;
public const int HANDSGEAR = 11; public const int HANDSGEAR = 15;
public const int FEETGEAR = 12; public const int FEETGEAR = 16;
public const int WAISTGEAR = 13; public const int WAISTGEAR = 17;
public const int UNKNOWN1 = 14; public const int UNKNOWN1 = 18;
public const int R_EAR = 15; public const int R_EAR = 19;
public const int L_EAR = 16; public const int L_EAR = 20;
public const int UNKNOWN2 = 17; public const int UNKNOWN2 = 21;
public const int UNKNOWN3 = 18; public const int UNKNOWN3 = 22;
public const int R_FINGER = 19; public const int R_FINGER = 23;
public const int L_FINGER = 20; public const int L_FINGER = 24;
public uint modelID; public uint modelID;
public uint[] appearanceIDs; public uint[] appearanceIDs;