mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-10 14:34:32 +02:00
Added implementations of the event receive/send packets. Added lua scripting stuff. Added some utils.
This commit is contained in:
parent
d60938346b
commit
734a3f4e7f
15 changed files with 603 additions and 261 deletions
|
@ -1,36 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.receive
|
||||
{
|
||||
class StartScriptPacket
|
||||
{
|
||||
public uint sourceActor;
|
||||
public uint targetActor;
|
||||
|
||||
public string scriptName;
|
||||
|
||||
public bool invalidPacket = false;
|
||||
|
||||
public StartScriptPacket(byte[] data)
|
||||
{
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try{
|
||||
sourceActor = binReader.ReadUInt32();
|
||||
targetActor = binReader.ReadUInt32();
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
using FFXIVClassic_Map_Server.lua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.receive.events
|
||||
{
|
||||
class EventStartPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x012D;
|
||||
public const uint PACKET_SIZE = 0xD8;
|
||||
|
||||
public bool invalidPacket = false;
|
||||
|
||||
public uint actorID;
|
||||
public uint scriptOwnerActorID;
|
||||
public uint val1;
|
||||
public uint val2;
|
||||
|
||||
public byte val3;
|
||||
|
||||
public string eventStarter;
|
||||
|
||||
public List<LuaParam> luaParams;
|
||||
|
||||
public EventStartPacket(byte[] data)
|
||||
{
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try{
|
||||
actorID = binReader.ReadUInt32();
|
||||
scriptOwnerActorID = binReader.ReadUInt32();
|
||||
val1 = binReader.ReadUInt32();
|
||||
val2 = binReader.ReadUInt32();
|
||||
val3 = binReader.ReadByte();
|
||||
|
||||
List<byte> strList = new List<byte>();
|
||||
byte curByte;
|
||||
while ((curByte = binReader.ReadByte())!=0)
|
||||
{
|
||||
strList.Add(curByte);
|
||||
}
|
||||
eventStarter = Encoding.ASCII.GetString(strList.ToArray());
|
||||
|
||||
binReader.ReadUInt32();
|
||||
binReader.ReadUInt32();
|
||||
binReader.ReadUInt32();
|
||||
binReader.ReadUInt32();
|
||||
|
||||
binReader.ReadByte();
|
||||
|
||||
luaParams = LuaUtils.readLuaParams(binReader);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
using System;
|
||||
using FFXIVClassic_Map_Server.lua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.send.script
|
||||
namespace FFXIVClassic_Map_Server.packets.receive.events
|
||||
{
|
||||
class CommandStartRequestPacket
|
||||
class EventUpdatePacket
|
||||
{
|
||||
public const ushort OPCODE = 0x012E;
|
||||
public const uint PACKET_SIZE = 0x78;
|
||||
|
@ -18,9 +19,10 @@ namespace FFXIVClassic_Map_Server.packets.send.script
|
|||
public uint scriptOwnerActorID;
|
||||
public uint val1;
|
||||
public uint val2;
|
||||
public ScriptParamReader reader;
|
||||
public byte step;
|
||||
public List<LuaParam> luaParams;
|
||||
|
||||
public CommandStartRequestPacket(byte[] data)
|
||||
public EventUpdatePacket(byte[] data)
|
||||
{
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
|
@ -31,10 +33,8 @@ namespace FFXIVClassic_Map_Server.packets.send.script
|
|||
scriptOwnerActorID = binReader.ReadUInt32();
|
||||
val1 = binReader.ReadUInt32();
|
||||
val2 = binReader.ReadUInt32();
|
||||
binReader.ReadByte();
|
||||
|
||||
binReader.BaseStream.Seek(0x31, SeekOrigin.Begin);
|
||||
reader = new ScriptParamReader(binReader);
|
||||
step = binReader.ReadByte();
|
||||
luaParams = LuaUtils.readLuaParams(binReader);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
|
@ -1,44 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.send.script
|
||||
{
|
||||
class ScriptResultPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x012E;
|
||||
public const uint PACKET_SIZE = 0xD8;
|
||||
|
||||
public bool invalidPacket = false;
|
||||
|
||||
public uint actorID;
|
||||
public uint scriptOwnerActorID;
|
||||
public uint val1;
|
||||
public uint val2;
|
||||
ScriptParamReader reader;
|
||||
|
||||
public ScriptResultPacket(byte[] data)
|
||||
{
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try{
|
||||
actorID = binReader.ReadUInt32();
|
||||
scriptOwnerActorID = binReader.ReadUInt32();
|
||||
val1 = binReader.ReadUInt32();
|
||||
val2 = binReader.ReadUInt32();
|
||||
binReader.ReadByte();
|
||||
reader = new ScriptParamReader(binReader);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,25 +6,26 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.send.script
|
||||
namespace FFXIVClassic_Map_Server.packets.send.events
|
||||
{
|
||||
class ScriptEndPacket
|
||||
class EndEventPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x0131;
|
||||
public const uint PACKET_SIZE = 0x50;
|
||||
|
||||
public static SubPacket buildPacket(uint playerActorID, string startName)
|
||||
public static SubPacket buildPacket(uint playerActorID, uint eventOwnerActorID, string eventStarter)
|
||||
{
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
int maxBodySize = data.Length - 0x80;
|
||||
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((uint)playerActorID);
|
||||
binWriter.Write((uint)0);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write(Encoding.Unicode.GetBytes(startName));
|
||||
binWriter.Write((UInt32)playerActorID);
|
||||
binWriter.Write((UInt32)eventOwnerActorID);
|
||||
binWriter.Write((Byte)0);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(eventStarter), 0, Encoding.ASCII.GetByteCount(eventStarter) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(eventStarter));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
using FFXIVClassic_Lobby_Server.common;
|
||||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using FFXIVClassic_Map_Server.lua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.send.events
|
||||
{
|
||||
class RunEventFunctionPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x0130;
|
||||
public const uint PACKET_SIZE = 0x2B8;
|
||||
|
||||
public static SubPacket buildPacket(uint playerActorID, uint eventOwnerActorID, string eventStarter, string callFunction, List<LuaParam> luaParams)
|
||||
{
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
int maxBodySize = data.Length - 0x80;
|
||||
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((UInt32)playerActorID);
|
||||
binWriter.Write((UInt32)eventOwnerActorID);
|
||||
binWriter.Write((Byte)0);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(eventStarter), 0, Encoding.ASCII.GetByteCount(eventStarter) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(eventStarter));
|
||||
binWriter.Seek(0x29, SeekOrigin.Begin);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(callFunction), 0, Encoding.ASCII.GetByteCount(callFunction) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(callFunction));
|
||||
binWriter.Seek(0x49, SeekOrigin.Begin);
|
||||
|
||||
//Write out params
|
||||
foreach (LuaParam p in luaParams)
|
||||
{
|
||||
binWriter.Write((Byte)p.typeID);
|
||||
switch (p.typeID)
|
||||
{
|
||||
case 0x0: //Int32
|
||||
binWriter.Write(Utils.swapEndian((UInt32)p.value));
|
||||
break;
|
||||
case 0x1: //Int32
|
||||
binWriter.Write(Utils.swapEndian((UInt32)p.value));
|
||||
break;
|
||||
case 0x2: //Null Termed String
|
||||
string svalue = (string)p.value;
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(svalue), 0, Encoding.ASCII.GetByteCount(svalue));
|
||||
if (svalue[svalue.Length - 1] != '\0')
|
||||
binWriter.Write((Byte)0);
|
||||
break;
|
||||
case 0x3: //Boolean False
|
||||
break;
|
||||
case 0x4: //Boolean True
|
||||
break;
|
||||
case 0x5: //Nil
|
||||
break;
|
||||
case 0x6: //Actor (By Id)
|
||||
binWriter.Write(Utils.swapEndian((UInt32)p.value));
|
||||
break;
|
||||
case 0x10: //Byte?
|
||||
//value = reader.ReadByte();
|
||||
break;
|
||||
case 0x1B: //Short?
|
||||
//value = reader.ReadUInt16();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
binWriter.Write((Byte)0xF);
|
||||
}
|
||||
}
|
||||
|
||||
return new SubPacket(OPCODE, playerActorID, playerActorID, data);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.send.login
|
||||
{
|
||||
class InitPacket
|
||||
{
|
||||
public static BasePacket buildPacket(uint actorID, uint time)
|
||||
{
|
||||
byte[] data = new byte[0x18];
|
||||
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
try
|
||||
{
|
||||
binWriter.Write((short)0x18);
|
||||
binWriter.Write((short)0x7);
|
||||
binWriter.Write((uint)0);
|
||||
binWriter.Write((uint)0);
|
||||
binWriter.Write((uint)0xFFFFFD7F);
|
||||
|
||||
binWriter.Write((uint)actorID);
|
||||
binWriter.Write((uint)time);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BasePacket.createPacket(data, false, false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.send.script
|
||||
{
|
||||
class ScriptStartPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x0130;
|
||||
public const uint PACKET_SIZE = 0xB0;
|
||||
|
||||
//Known types
|
||||
public const byte TYPE_END = 0xF;
|
||||
public const byte TYPE_UINT = 0x6;
|
||||
public const byte TYPE_BYTE = 0x5;
|
||||
public const byte TYPE_STRING = 0x2;
|
||||
public const byte TYPE_STRING_20B = 0x1;
|
||||
public const byte TYPE_STRING_NULLTERM = 0x0;
|
||||
|
||||
public static SubPacket buildPacket(uint playerActorID, uint scriptOwnerActorID, string startName, string scriptName)
|
||||
{
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((uint)playerActorID);
|
||||
binWriter.Write((uint)scriptOwnerActorID);
|
||||
binWriter.Write((byte)1);
|
||||
binWriter.Write(Encoding.Unicode.GetBytes(startName));
|
||||
binWriter.Seek(0x29, SeekOrigin.Begin);
|
||||
binWriter.Write(Encoding.Unicode.GetBytes(scriptName));
|
||||
binWriter.Seek(0x29 + 0x20, SeekOrigin.Begin);
|
||||
binWriter.Write((byte)6);
|
||||
|
||||
byte[] actorID = BitConverter.GetBytes(playerActorID);
|
||||
Array.Reverse(actorID);
|
||||
binWriter.Write(actorID);
|
||||
|
||||
binWriter.Write((byte)0x0F);
|
||||
}
|
||||
}
|
||||
|
||||
return new SubPacket(OPCODE, playerActorID, playerActorID, data);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue