implemented sendpacket and speed commands

- fixed data race on logging in
- todo: implement reloadzones, reloaditems, property, property2
This commit is contained in:
Tahir Akhlaq 2016-06-24 20:52:30 +01:00
parent 7a25c818f2
commit 30b0d4a97d
11 changed files with 74 additions and 81 deletions

View File

@ -24,6 +24,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
<RegisterForComInterop>false</RegisterForComInterop> <RegisterForComInterop>false</RegisterForComInterop>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>

View File

@ -35,25 +35,6 @@ namespace FFXIVClassic_Map_Server
mConnectedPlayerList = playerList; mConnectedPlayerList = playerList;
} }
public void SendPacket(ConnectedPlayer client, string path)
{
BasePacket packet = new BasePacket(path);
if (client != null)
{
packet.ReplaceActorID(client.actorID);
client.QueuePacket(packet);
}
else
{
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{
packet.ReplaceActorID(entry.Value.actorID);
entry.Value.QueuePacket(packet);
}
}
}
public void ChangeProperty(uint id, uint value, string target) public void ChangeProperty(uint id, uint value, string target)
{ {
SetActorPropetyPacket ChangeProperty = new SetActorPropetyPacket(target); SetActorPropetyPacket ChangeProperty = new SetActorPropetyPacket(target);
@ -87,7 +68,7 @@ namespace FFXIVClassic_Map_Server
internal bool DoCommand(string input, ConnectedPlayer client) internal bool DoCommand(string input, ConnectedPlayer client)
{ {
if (!input.Any()) if (!input.Any() || input.Equals(""))
return false; return false;
input.Trim(); input.Trim();
@ -102,7 +83,7 @@ namespace FFXIVClassic_Map_Server
split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands
var cmd = split?.ElementAt(0); var cmd = split[0];
if (cmd.Any()) if (cmd.Any())
{ {
@ -138,6 +119,8 @@ namespace FFXIVClassic_Map_Server
if (split.Length >= 1) if (split.Length >= 1)
{ {
// TODO: reloadzones
#region !reloaditems #region !reloaditems
if (split[0].Equals("reloaditems")) if (split[0].Equals("reloaditems"))
{ {
@ -151,24 +134,6 @@ namespace FFXIVClassic_Map_Server
} }
#endregion #endregion
#region !sendpacket
else if (split[0].Equals("sendpacket"))
{
if (split.Length < 2)
return false;
try
{
SendPacket(client, "./packets/" + split[1]);
return true;
}
catch (Exception e)
{
Program.Log.Error("Could not load packet: " + e);
}
}
#endregion
#region !property #region !property
else if (split[0].Equals("property")) else if (split[0].Equals("property"))
{ {

View File

@ -419,6 +419,8 @@ namespace FFXIVClassic_Map_Server
player.oldRotation = player.rotation = reader.GetFloat(4); player.oldRotation = player.rotation = reader.GetFloat(4);
player.currentMainState = reader.GetUInt16(5); player.currentMainState = reader.GetUInt16(5);
player.zoneId = reader.GetUInt32(6); player.zoneId = reader.GetUInt32(6);
player.isZoning = true;
player.zone = Server.GetWorldManager().GetZone(player.zoneId);
player.gcCurrent = reader.GetByte(7); player.gcCurrent = reader.GetByte(7);
player.gcRankLimsa = reader.GetByte(8); player.gcRankLimsa = reader.GetByte(8);
player.gcRankGridania = reader.GetByte(9); player.gcRankGridania = reader.GetByte(9);

View File

@ -112,7 +112,7 @@ namespace FFXIVClassic_Map_Server
if (packet.header.connectionType == BasePacket.TYPE_ZONE) if (packet.header.connectionType == BasePacket.TYPE_ZONE)
{ {
while (!mPlayers.ContainsKey(client.owner)) while (mPlayers != null && !mPlayers.ContainsKey(client.owner))
{ } { }
player = mPlayers[client.owner]; player = mPlayers[client.owner];
} }
@ -127,9 +127,9 @@ namespace FFXIVClassic_Map_Server
player.SetConnection(packet.header.connectionType, client); player.SetConnection(packet.header.connectionType, client);
if (packet.header.connectionType == BasePacket.TYPE_ZONE) if (packet.header.connectionType == BasePacket.TYPE_ZONE)
Program.Log.Debug("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.GetAddress()); Program.Log.Info("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.GetAddress());
else if (packet.header.connectionType == BasePacket.TYPE_CHAT) else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
Program.Log.Debug("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.GetAddress()); Program.Log.Info("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.GetAddress());
//Create player actor //Create player actor
reply1.DebugPrintPacket(); reply1.DebugPrintPacket();
@ -139,12 +139,14 @@ namespace FFXIVClassic_Map_Server
} }
else if (subpacket.header.type == 0x07) else if (subpacket.header.type == 0x07)
{ {
BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC()); BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC(), 0x08);
//client.QueuePacket(init); //client.QueuePacket(init);
} }
else if (subpacket.header.type == 0x08) else if (subpacket.header.type == 0x08)
{ {
//Response, client's current [actorID][time] //Response, client's current [actorID][time]
//BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC(), 0x07);
//client.QueuePacket(init);
packet.DebugPrintPacket(); packet.DebugPrintPacket();
} }
else if (subpacket.header.type == 0x03) else if (subpacket.header.type == 0x03)
@ -154,7 +156,7 @@ namespace FFXIVClassic_Map_Server
if(mPlayers.ContainsKey(client.owner)) if(mPlayers.ContainsKey(client.owner))
player = mPlayers[client.owner]; player = mPlayers[client.owner];
if (player == null) if (player == null || !player.IsClientConnectionsReady())
return; return;
//Normal Game Opcode //Normal Game Opcode

View File

@ -601,6 +601,21 @@ namespace FFXIVClassic_Map_Server.Actors
playerSession.QueuePacket(subpacket, true, false); playerSession.QueuePacket(subpacket, true, false);
} }
public void SendPacket(string path)
{
try
{
BasePacket packet = new BasePacket(path);
packet.ReplaceActorID(actorId);
QueuePacket(packet);
}
catch (Exception e)
{
this.SendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "[SendPacket]", "Unable to send packet.");
}
}
public void BroadcastPacket(SubPacket packet, bool sendToSelf) public void BroadcastPacket(SubPacket packet, bool sendToSelf)
{ {
if (sendToSelf) if (sendToSelf)
@ -749,26 +764,6 @@ namespace FFXIVClassic_Map_Server.Actors
//zone.BroadcastPacketAroundActor(this, worldMasterMessage); //zone.BroadcastPacketAroundActor(this, worldMasterMessage);
} }
public void ChangeProperty(uint id, uint value, string target)
{
SetActorPropetyPacket ChangeProperty = new SetActorPropetyPacket(target);
ChangeProperty.SetTarget(target);
ChangeProperty.AddInt(id, value);
ChangeProperty.AddTarget();
/*foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{
SubPacket ChangePropertyPacket = ChangeProperty.BuildPacket((entry.Value.actorID), (entry.Value.actorID));
BasePacket packet = BasePacket.CreatePacket(ChangePropertyPacket, true, false);
packet.DebugPrintPacket();
entry.Value.QueuePacket(packet);
}
*/
}
public void GraphicChange(uint slot, uint graphicId) public void GraphicChange(uint slot, uint graphicId)
{ {
appearanceIds[slot] = graphicId; appearanceIds[slot] = graphicId;

View File

@ -5,7 +5,7 @@ namespace FFXIVClassic_Map_Server.packets.send.login
{ {
class Login0x7ResponsePacket class Login0x7ResponsePacket
{ {
public static BasePacket BuildPacket(uint actorID, uint time) public static BasePacket BuildPacket(uint actorID, uint time, uint type)
{ {
byte[] data = new byte[0x18]; byte[] data = new byte[0x18];
@ -16,7 +16,7 @@ namespace FFXIVClassic_Map_Server.packets.send.login
try try
{ {
binWriter.Write((short)0x18); binWriter.Write((short)0x18);
binWriter.Write((short)0x8); binWriter.Write((short)type);
binWriter.Write((uint)0); binWriter.Write((uint)0);
binWriter.Write((uint)0); binWriter.Write((uint)0);
binWriter.Write((uint)0xFFFFFD7F); binWriter.Write((uint)0xFFFFFD7F);

View File

@ -1,9 +0,0 @@
properties = {
permissions = 0,
parameters = "",
description = "",
}
function onTrigger(player)
end;

View File

@ -0,0 +1,24 @@
properties = {
permissions = 0,
parameters = "ssss",
description = "<name> <target name>",
}
function onTrigger(player, argc, path, name, lastName)
local sender = "[sendpacket ]";
lastName = lastName or "";
path = "./packets/"..path;
if name then
if lastName then
player = GetWorldManager():GetPCInWorld(name.." "..lastName) or nil;
else
player = GetWorldManager():GetPCInWorld(name) or nil;
end;
end;
value = tonumber(value) or 0;
if player and argc > 0 then
player:SendPacket(path)
end;
end;

View File

@ -0,0 +1,13 @@
properties = {
permissions = 0,
parameters = "sss",
description = "<stop> <walk> <run> speed",
}
function onTrigger(player, argc, stop, walk, run)
stop = tonumber(stop) or 0;
walk = tonumber(walk) or 2;
run = tonumber(run) or 5;
player:ChangeSpeed(stop, walk, run);
end;