mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-21 20:27:47 +00:00
Rewrote the server commands. They can now accept a client connection, letting a user fire a command from within the game and only receive the response. Added actor removal for the instance system. Removed hardcoded packet 9.
This commit is contained in:
parent
7bc3c8c2dd
commit
f1025f89d3
6 changed files with 149 additions and 92 deletions
|
@ -181,7 +181,10 @@ 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);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
//Unknown
|
//Unknown
|
||||||
case 0x0007:
|
case 0x0007:
|
||||||
|
@ -347,16 +350,5 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPacket(string path)
|
|
||||||
{
|
|
||||||
BasePacket packet = new BasePacket(path);
|
|
||||||
|
|
||||||
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mPlayers)
|
|
||||||
{
|
|
||||||
packet.replaceActorID(entry.Value.actorID);
|
|
||||||
entry.Value.queuePacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,62 +72,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
String input = Console.ReadLine();
|
String input = Console.ReadLine();
|
||||||
String[] split = input.Split(' ');
|
server.doCommand(input, null);
|
||||||
|
|
||||||
if (split.Length >= 1)
|
|
||||||
{
|
|
||||||
if (split[0].Equals("mypos"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
server.printPos();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.error("Could not load packet: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (split.Length >= 2)
|
|
||||||
{
|
|
||||||
if (split[0].Equals("sendpacket"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
server.sendPacket("./packets/" + split[1]);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.error("Could not load packet: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (split[0].Equals("music"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
server.doMusic(split[1]);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.error("Could not change music: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (split[0].Equals("warp"))
|
|
||||||
{
|
|
||||||
server.doWarp(split[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (split.Length >= 3)
|
|
||||||
{
|
|
||||||
if (split[0].Equals("warp"))
|
|
||||||
{
|
|
||||||
server.doWarp(split[1], split[2], split[3], split[4]);
|
|
||||||
}
|
|
||||||
else if (split[0].Equals("property"))
|
|
||||||
{
|
|
||||||
server.testCodePacket(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,9 +230,23 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void sendPacket(string path)
|
public void sendPacket(ConnectedPlayer client, string path)
|
||||||
{
|
{
|
||||||
mProcessor.sendPacket(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 testCodePacket(uint id, uint value, string target)
|
public void testCodePacket(uint id, uint value, string target)
|
||||||
|
@ -254,7 +268,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doMusic(string music)
|
public void doMusic(ConnectedPlayer client, string music)
|
||||||
{
|
{
|
||||||
ushort musicId;
|
ushort musicId;
|
||||||
|
|
||||||
|
@ -263,14 +277,19 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
else
|
else
|
||||||
musicId = Convert.ToUInt16(music);
|
musicId = Convert.ToUInt16(music);
|
||||||
|
|
||||||
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
if (client != null)
|
||||||
|
client.queuePacket(BasePacket.createPacket(SetMusicPacket.buildPacket(client.actorID, musicId, 1), true, false));
|
||||||
|
else
|
||||||
{
|
{
|
||||||
BasePacket musicPacket = BasePacket.createPacket(SetMusicPacket.buildPacket(entry.Value.actorID, musicId, 1), true, false);
|
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
||||||
entry.Value.queuePacket(musicPacket);
|
{
|
||||||
|
BasePacket musicPacket = BasePacket.createPacket(SetMusicPacket.buildPacket(entry.Value.actorID, musicId, 1), true, false);
|
||||||
|
entry.Value.queuePacket(musicPacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doWarp(string entranceId)
|
public void doWarp(ConnectedPlayer client, string entranceId)
|
||||||
{
|
{
|
||||||
uint id;
|
uint id;
|
||||||
|
|
||||||
|
@ -284,13 +303,18 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
if (ze == null)
|
if (ze == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
if (client != null)
|
||||||
|
mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f);
|
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
||||||
|
{
|
||||||
|
mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doWarp(string map, string sx, string sy, string sz)
|
public void doWarp(ConnectedPlayer client, string map, string sx, string sy, string sz)
|
||||||
{
|
{
|
||||||
uint mapId;
|
uint mapId;
|
||||||
float x,y,z;
|
float x,y,z;
|
||||||
|
@ -303,10 +327,15 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
x = Single.Parse(sx);
|
x = Single.Parse(sx);
|
||||||
y = Single.Parse(sy);
|
y = Single.Parse(sy);
|
||||||
z = Single.Parse(sz);
|
z = Single.Parse(sz);
|
||||||
|
|
||||||
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
if (client != null)
|
||||||
|
mWorldManager.DoZoneChange(client.getActor(), mapId, 0x2, x, y, z, 0.0f);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
mWorldManager.DoZoneChange(entry.Value.getActor(), mapId, 0x2, x, y, z, 0.0f);
|
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
||||||
|
{
|
||||||
|
mWorldManager.DoZoneChange(entry.Value.getActor(), mapId, 0x2, x, y, z, 0.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,13 +345,81 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void printPos()
|
public void printPos(ConnectedPlayer client)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
if (client != null)
|
||||||
{
|
{
|
||||||
Player p = entry.Value.getActor();
|
Player p = client.getActor();
|
||||||
Log.info(String.Format("{0} position: {1}, {2}, {3}, {4}", p.customDisplayName, p.positionX, p.positionY, p.positionZ, p.rotation));
|
client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Position: {1}, {2}, {3}, {4}", p.customDisplayName, p.positionX, p.positionY, p.positionZ, p.rotation)), true, false));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
||||||
|
{
|
||||||
|
Player p = entry.Value.getActor();
|
||||||
|
Log.info(String.Format("{0} position: {1}, {2}, {3}, {4}", p.customDisplayName, p.positionX, p.positionY, p.positionZ, p.rotation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void doCommand(string input, ConnectedPlayer client)
|
||||||
|
{
|
||||||
|
String[] split = input.Split(' ');
|
||||||
|
|
||||||
|
if (split.Length >= 1)
|
||||||
|
{
|
||||||
|
if (split[0].Equals("mypos"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
printPos(client);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.error("Could not load packet: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (split.Length >= 2)
|
||||||
|
{
|
||||||
|
if (split[0].Equals("sendpacket"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sendPacket(client, "./packets/" + split[1]);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.error("Could not load packet: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (split[0].Equals("music"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
doMusic(client, split[1]);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.error("Could not change music: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (split[0].Equals("warp"))
|
||||||
|
{
|
||||||
|
doWarp(client, split[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (split.Length >= 3)
|
||||||
|
{
|
||||||
|
if (split[0].Equals("warp"))
|
||||||
|
{
|
||||||
|
doWarp(client, split[1], split[2], split[3], split[4]);
|
||||||
|
}
|
||||||
|
else if (split[0].Equals("property"))
|
||||||
|
{
|
||||||
|
testCodePacket(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,21 +458,18 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
|
|
||||||
playerSession.queuePacket(getInitPackets(actorId));
|
playerSession.queuePacket(getInitPackets(actorId));
|
||||||
|
|
||||||
BasePacket innSpawn = zone.getSpawnPackets(actorId);
|
BasePacket areaMasterSpawn = zone.getSpawnPackets(actorId);
|
||||||
BasePacket debugSpawn = world.GetDebugActor().getSpawnPackets(actorId);
|
BasePacket debugSpawn = world.GetDebugActor().getSpawnPackets(actorId);
|
||||||
BasePacket worldMasterSpawn = world.GetActor().getSpawnPackets(actorId);
|
BasePacket worldMasterSpawn = world.GetActor().getSpawnPackets(actorId);
|
||||||
playerSession.queuePacket(innSpawn);
|
playerSession.queuePacket(areaMasterSpawn);
|
||||||
playerSession.queuePacket(debugSpawn);
|
playerSession.queuePacket(debugSpawn);
|
||||||
playerSession.queuePacket(worldMasterSpawn);
|
playerSession.queuePacket(worldMasterSpawn);
|
||||||
|
|
||||||
#region hardcode
|
#region hardcode
|
||||||
BasePacket reply9 = new BasePacket("./packets/login/login9_zonesetup.bin"); //Bed, Book created
|
|
||||||
BasePacket reply10 = new BasePacket("./packets/login/login10.bin"); //Item Storage, Inn Door created
|
BasePacket reply10 = new BasePacket("./packets/login/login10.bin"); //Item Storage, Inn Door created
|
||||||
BasePacket reply11 = new BasePacket("./packets/login/login11.bin"); //NPC Create ??? Final init
|
BasePacket reply11 = new BasePacket("./packets/login/login11.bin"); //NPC Create ??? Final init
|
||||||
reply9.replaceActorID(actorId);
|
|
||||||
reply10.replaceActorID(actorId);
|
reply10.replaceActorID(actorId);
|
||||||
reply11.replaceActorID(actorId);
|
reply11.replaceActorID(actorId);
|
||||||
playerSession.queuePacket(reply9);
|
|
||||||
playerSession.queuePacket(reply10);
|
playerSession.queuePacket(reply10);
|
||||||
playerSession.queuePacket(reply11);
|
playerSession.queuePacket(reply11);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -95,8 +95,23 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||||
public List<BasePacket> updateInstance(List<Actor> list)
|
public List<BasePacket> updateInstance(List<Actor> list)
|
||||||
{
|
{
|
||||||
List<BasePacket> basePackets = new List<BasePacket>();
|
List<BasePacket> basePackets = new List<BasePacket>();
|
||||||
|
List<SubPacket> removeActorSubpackets = new List<SubPacket>();
|
||||||
List<SubPacket> posUpdateSubpackets = new List<SubPacket>();
|
List<SubPacket> posUpdateSubpackets = new List<SubPacket>();
|
||||||
|
|
||||||
|
//Remove missing actors
|
||||||
|
for (int i = 0; i < actorInstanceList.Count; i++)
|
||||||
|
{
|
||||||
|
if (!list.Contains(actorInstanceList[i]))
|
||||||
|
{
|
||||||
|
removeActorSubpackets.Add(RemoveActorPacket.buildPacket(playerActor.actorId, actorInstanceList[i].actorId));
|
||||||
|
actorInstanceList.RemoveAt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removeActorSubpackets.Count != 0)
|
||||||
|
basePackets.Add(BasePacket.createPacket(removeActorSubpackets, true, false));
|
||||||
|
|
||||||
|
//Add new actors or move
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
{
|
{
|
||||||
Actor actor = list[i];
|
Actor actor = list[i];
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using FFXIVClassic_Lobby_Server.packets;
|
using FFXIVClassic_Lobby_Server.packets;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -12,9 +13,19 @@ namespace FFXIVClassic_Map_Server.packets.send.actor
|
||||||
public const ushort OPCODE = 0x00CB;
|
public const ushort OPCODE = 0x00CB;
|
||||||
public const uint PACKET_SIZE = 0x28;
|
public const uint PACKET_SIZE = 0x28;
|
||||||
|
|
||||||
public static SubPacket buildPacket(uint playerActorID, uint actorID)
|
public static SubPacket buildPacket(uint playerActorID, uint actorId)
|
||||||
{
|
{
|
||||||
return new SubPacket(OPCODE, playerActorID, actorID, new byte[8]);
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
|
|
||||||
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
|
{
|
||||||
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
|
{
|
||||||
|
binWriter.Write((UInt32)actorId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SubPacket(OPCODE, actorId, playerActorID, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue