mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-10 22:44:36 +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
|
@ -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