mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-23 21:27:46 +00:00
implemented sendpacket and speed commands
- fixed data race on logging in - todo: implement reloadzones, reloaditems, property, property2
This commit is contained in:
parent
7a25c818f2
commit
30b0d4a97d
11 changed files with 74 additions and 81 deletions
|
@ -24,6 +24,7 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
|
|
@ -35,25 +35,6 @@ namespace FFXIVClassic_Map_Server
|
|||
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)
|
||||
{
|
||||
SetActorPropetyPacket ChangeProperty = new SetActorPropetyPacket(target);
|
||||
|
@ -87,7 +68,7 @@ namespace FFXIVClassic_Map_Server
|
|||
|
||||
internal bool DoCommand(string input, ConnectedPlayer client)
|
||||
{
|
||||
if (!input.Any())
|
||||
if (!input.Any() || input.Equals(""))
|
||||
return false;
|
||||
|
||||
input.Trim();
|
||||
|
@ -102,7 +83,7 @@ namespace FFXIVClassic_Map_Server
|
|||
|
||||
split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands
|
||||
|
||||
var cmd = split?.ElementAt(0);
|
||||
var cmd = split[0];
|
||||
|
||||
if (cmd.Any())
|
||||
{
|
||||
|
@ -138,6 +119,8 @@ namespace FFXIVClassic_Map_Server
|
|||
if (split.Length >= 1)
|
||||
{
|
||||
|
||||
// TODO: reloadzones
|
||||
|
||||
#region !reloaditems
|
||||
if (split[0].Equals("reloaditems"))
|
||||
{
|
||||
|
@ -151,24 +134,6 @@ namespace FFXIVClassic_Map_Server
|
|||
}
|
||||
#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
|
||||
else if (split[0].Equals("property"))
|
||||
{
|
||||
|
|
|
@ -419,6 +419,8 @@ namespace FFXIVClassic_Map_Server
|
|||
player.oldRotation = player.rotation = reader.GetFloat(4);
|
||||
player.currentMainState = reader.GetUInt16(5);
|
||||
player.zoneId = reader.GetUInt32(6);
|
||||
player.isZoning = true;
|
||||
player.zone = Server.GetWorldManager().GetZone(player.zoneId);
|
||||
player.gcCurrent = reader.GetByte(7);
|
||||
player.gcRankLimsa = reader.GetByte(8);
|
||||
player.gcRankGridania = reader.GetByte(9);
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace FFXIVClassic_Map_Server
|
|||
|
||||
if (packet.header.connectionType == BasePacket.TYPE_ZONE)
|
||||
{
|
||||
while (!mPlayers.ContainsKey(client.owner))
|
||||
while (mPlayers != null && !mPlayers.ContainsKey(client.owner))
|
||||
{ }
|
||||
player = mPlayers[client.owner];
|
||||
}
|
||||
|
@ -127,9 +127,9 @@ namespace FFXIVClassic_Map_Server
|
|||
player.SetConnection(packet.header.connectionType, client);
|
||||
|
||||
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)
|
||||
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
|
||||
reply1.DebugPrintPacket();
|
||||
|
@ -139,12 +139,14 @@ namespace FFXIVClassic_Map_Server
|
|||
}
|
||||
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);
|
||||
}
|
||||
else if (subpacket.header.type == 0x08)
|
||||
{
|
||||
//Response, client's current [actorID][time]
|
||||
//BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC(), 0x07);
|
||||
//client.QueuePacket(init);
|
||||
packet.DebugPrintPacket();
|
||||
}
|
||||
else if (subpacket.header.type == 0x03)
|
||||
|
@ -154,7 +156,7 @@ namespace FFXIVClassic_Map_Server
|
|||
if(mPlayers.ContainsKey(client.owner))
|
||||
player = mPlayers[client.owner];
|
||||
|
||||
if (player == null)
|
||||
if (player == null || !player.IsClientConnectionsReady())
|
||||
return;
|
||||
|
||||
//Normal Game Opcode
|
||||
|
|
|
@ -601,6 +601,21 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
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)
|
||||
{
|
||||
if (sendToSelf)
|
||||
|
@ -749,26 +764,6 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
//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)
|
||||
{
|
||||
appearanceIds[slot] = graphicId;
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
|
||||
public void QueuePacket(SubPacket subPacket, bool isAuthed, bool isEncrypted)
|
||||
{
|
||||
zoneConnection.QueuePacket(subPacket, isAuthed, isEncrypted);
|
||||
zoneConnection.QueuePacket(subPacket, isAuthed, isEncrypted);
|
||||
}
|
||||
|
||||
public Player GetActor()
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace FFXIVClassic_Map_Server.packets.send.login
|
|||
{
|
||||
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];
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace FFXIVClassic_Map_Server.packets.send.login
|
|||
try
|
||||
{
|
||||
binWriter.Write((short)0x18);
|
||||
binWriter.Write((short)0x8);
|
||||
binWriter.Write((short)type);
|
||||
binWriter.Write((uint)0);
|
||||
binWriter.Write((uint)0);
|
||||
binWriter.Write((uint)0xFFFFFD7F);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "",
|
||||
description = "",
|
||||
}
|
||||
|
||||
function onTrigger(player)
|
||||
|
||||
end;
|
24
data/scripts/commands/gm/sendpacket.lua
Normal file
24
data/scripts/commands/gm/sendpacket.lua
Normal 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;
|
13
data/scripts/commands/gm/speed.lua
Normal file
13
data/scripts/commands/gm/speed.lua
Normal 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;
|
Loading…
Add table
Reference in a new issue