mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-11 06:54:43 +02:00
Packet refactoring.
This commit is contained in:
parent
96641865bc
commit
0ec9c5576c
22 changed files with 115 additions and 109 deletions
|
@ -19,9 +19,10 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Meteor.Map.packets.receive
|
||||
{
|
||||
|
@ -51,7 +52,7 @@ namespace Meteor.Map.packets.receive
|
|||
posZ = binReader.ReadSingle();
|
||||
posRot = binReader.ReadSingle();
|
||||
logType = binReader.ReadUInt32();
|
||||
message = Encoding.ASCII.GetString(binReader.ReadBytes(0x200)).Trim(new [] { '\0' });
|
||||
message = Utils.ReadNullTermString(binReader, 0x200);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
|
|
|
@ -19,11 +19,11 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
using Meteor.Map.lua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Meteor.Map.packets.receive.events
|
||||
{
|
||||
|
@ -34,20 +34,18 @@ namespace Meteor.Map.packets.receive.events
|
|||
|
||||
public bool invalidPacket = false;
|
||||
|
||||
public uint actorID;
|
||||
public uint scriptOwnerActorID;
|
||||
public uint val1;
|
||||
public uint val2;
|
||||
public byte val3;
|
||||
public uint triggerActorID;
|
||||
public uint ownerActorID;
|
||||
public uint serverCodes;
|
||||
public uint unknown;
|
||||
public byte eventType;
|
||||
public string eventName;
|
||||
public List<LuaParam> luaParams;
|
||||
|
||||
public uint errorIndex;
|
||||
public uint errorNum;
|
||||
public string error = null;
|
||||
|
||||
public string triggerName;
|
||||
|
||||
public List<LuaParam> luaParams;
|
||||
|
||||
|
||||
public EventStartPacket(byte[] data)
|
||||
{
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
|
@ -55,11 +53,11 @@ namespace Meteor.Map.packets.receive.events
|
|||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try{
|
||||
actorID = binReader.ReadUInt32();
|
||||
scriptOwnerActorID = binReader.ReadUInt32();
|
||||
val1 = binReader.ReadUInt32();
|
||||
val2 = binReader.ReadUInt32();
|
||||
val3 = binReader.ReadByte();
|
||||
triggerActorID = binReader.ReadUInt32();
|
||||
ownerActorID = binReader.ReadUInt32();
|
||||
serverCodes = binReader.ReadUInt32();
|
||||
unknown = binReader.ReadUInt32();
|
||||
eventType = binReader.ReadByte();
|
||||
/*
|
||||
//Lua Error Dump
|
||||
if (val1 == 0x39800010)
|
||||
|
@ -74,15 +72,7 @@ namespace Meteor.Map.packets.receive.events
|
|||
return;
|
||||
}
|
||||
*/
|
||||
List<byte> strList = new List<byte>();
|
||||
byte curByte;
|
||||
while ((curByte = binReader.ReadByte())!=0)
|
||||
{
|
||||
strList.Add(curByte);
|
||||
}
|
||||
triggerName = Encoding.ASCII.GetString(strList.ToArray());
|
||||
|
||||
binReader.BaseStream.Seek(0x31, SeekOrigin.Begin);
|
||||
eventName = Utils.ReadNullTermString(binReader);
|
||||
|
||||
if (binReader.PeekChar() == 0x1)
|
||||
luaParams = new List<LuaParam>();
|
||||
|
|
|
@ -19,11 +19,12 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Map.lua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Meteor.Map.lua;
|
||||
|
||||
namespace Meteor.Map.packets.receive.events
|
||||
{
|
||||
class EventUpdatePacket
|
||||
|
@ -33,11 +34,11 @@ namespace Meteor.Map.packets.receive.events
|
|||
|
||||
public bool invalidPacket = false;
|
||||
|
||||
public uint actorID;
|
||||
public uint scriptOwnerActorID;
|
||||
public uint val1;
|
||||
public uint val2;
|
||||
public byte step;
|
||||
public uint triggerActorID;
|
||||
public uint serverCodes;
|
||||
public uint unknown1;
|
||||
public uint unknown2;
|
||||
public byte eventType;
|
||||
public List<LuaParam> luaParams;
|
||||
|
||||
public EventUpdatePacket(byte[] data)
|
||||
|
@ -47,11 +48,11 @@ namespace Meteor.Map.packets.receive.events
|
|||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try{
|
||||
actorID = binReader.ReadUInt32();
|
||||
scriptOwnerActorID = binReader.ReadUInt32();
|
||||
val1 = binReader.ReadUInt32();
|
||||
val2 = binReader.ReadUInt32();
|
||||
step = binReader.ReadByte();
|
||||
triggerActorID = binReader.ReadUInt32();
|
||||
serverCodes = binReader.ReadUInt32();
|
||||
unknown1 = binReader.ReadUInt32();
|
||||
unknown2 = binReader.ReadUInt32();
|
||||
eventType = binReader.ReadByte();
|
||||
luaParams = LuaUtils.ReadLuaParams(binReader);
|
||||
}
|
||||
catch (Exception){
|
||||
|
|
|
@ -19,6 +19,7 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
@ -40,7 +41,7 @@ namespace Meteor.Map.packets.receive
|
|||
{
|
||||
try{
|
||||
groupId = binReader.ReadUInt64();
|
||||
workString = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
|
||||
workString = Utils.ReadNullTermString(binReader);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
|
|
|
@ -19,6 +19,7 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
@ -39,7 +40,7 @@ namespace Meteor.Map.packets.receive
|
|||
{
|
||||
try{
|
||||
binReader.BaseStream.Seek(4, SeekOrigin.Begin);
|
||||
actorID = UInt32.Parse(Encoding.ASCII.GetString(binReader.ReadBytes(10)));
|
||||
actorID = UInt32.Parse(Utils.ReadNullTermString(binReader, 10));
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
|
|
|
@ -37,8 +37,7 @@ namespace Meteor.Map.packets.receive.recruitment
|
|||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try{
|
||||
recruitmentId = binReader.ReadUInt64();
|
||||
|
||||
recruitmentId = binReader.ReadUInt64();
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
|
|
|
@ -21,7 +21,8 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Meteor.Common;
|
||||
|
||||
namespace Meteor.Map.packets.receive.recruitment
|
||||
{
|
||||
|
@ -54,8 +55,8 @@ namespace Meteor.Map.packets.receive.recruitment
|
|||
|
||||
unknown1 = binReader.ReadByte();
|
||||
unknown2 = binReader.ReadByte();
|
||||
|
||||
text = Encoding.ASCII.GetString(binReader.ReadBytes(0x20));
|
||||
|
||||
text = Utils.ReadNullTermString(binReader);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
|
|
|
@ -19,9 +19,9 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Meteor.Map.packets.receive.recruitment
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ namespace Meteor.Map.packets.receive.recruitment
|
|||
binReader.ReadByte();
|
||||
}
|
||||
|
||||
comment = Encoding.ASCII.GetString(binReader.ReadBytes(0x168));
|
||||
comment = Utils.ReadNullTermString(binReader, 0x168);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
|
|
|
@ -19,15 +19,16 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Meteor.Map.packets.receive.social
|
||||
{
|
||||
class AddRemoveSocialPacket
|
||||
{
|
||||
public bool invalidPacket = false;
|
||||
|
||||
public string name;
|
||||
|
||||
public AddRemoveSocialPacket(byte[] data)
|
||||
|
@ -37,7 +38,7 @@ namespace Meteor.Map.packets.receive.social
|
|||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try{
|
||||
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20));
|
||||
name = Utils.ReadNullTermString(binReader);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
|
|
|
@ -19,9 +19,9 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Meteor.Map.packets.receive.supportdesk
|
||||
{
|
||||
|
@ -42,8 +42,8 @@ namespace Meteor.Map.packets.receive.supportdesk
|
|||
{
|
||||
langCode = binReader.ReadUInt32();
|
||||
ticketIssueIndex = binReader.ReadUInt32();
|
||||
ticketTitle = Encoding.ASCII.GetString(binReader.ReadBytes(0x80)).Trim(new[] { '\0' });
|
||||
ticketBody = Encoding.ASCII.GetString(binReader.ReadBytes(0x800)).Trim(new[] { '\0' });
|
||||
ticketTitle = Utils.ReadNullTermString(binReader, 0x80);
|
||||
ticketBody = Utils.ReadNullTermString(binReader, 0x800);
|
||||
}
|
||||
catch (Exception){
|
||||
invalidPacket = true;
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace Meteor.Map.packets.receive
|
|||
{
|
||||
bool invalidPacket = false;
|
||||
|
||||
public ulong time;
|
||||
public ulong timestamp;
|
||||
public float x, y, z, rot;
|
||||
public ushort moveState; //0: Standing, 1: Walking, 2: Running
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace Meteor.Map.packets.receive
|
|||
using (BinaryReader binReader = new BinaryReader(mem))
|
||||
{
|
||||
try{
|
||||
time = binReader.ReadUInt64();
|
||||
timestamp = binReader.ReadUInt64();
|
||||
x = binReader.ReadSingle();
|
||||
y = binReader.ReadSingle();
|
||||
z = binReader.ReadSingle();
|
||||
|
|
|
@ -21,7 +21,6 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Meteor.Common;
|
||||
|
||||
|
@ -32,7 +31,7 @@ namespace Meteor.Map.packets.send.events
|
|||
public const ushort OPCODE = 0x0131;
|
||||
public const uint PACKET_SIZE = 0x50;
|
||||
|
||||
public static SubPacket BuildPacket(uint sourcePlayerActorId, uint eventOwnerActorID, string eventStarter)
|
||||
public static SubPacket BuildPacket(uint sourcePlayerActorId, uint eventOwnerActorID, string eventName, byte eventType)
|
||||
{
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
int maxBodySize = data.Length - 0x80;
|
||||
|
@ -43,8 +42,8 @@ namespace Meteor.Map.packets.send.events
|
|||
{
|
||||
binWriter.Write((UInt32)sourcePlayerActorId);
|
||||
binWriter.Write((UInt32)0);
|
||||
binWriter.Write((Byte)1);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(eventStarter), 0, Encoding.ASCII.GetByteCount(eventStarter) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(eventStarter));
|
||||
binWriter.Write((Byte)eventType);
|
||||
Utils.WriteNullTermString(binWriter, eventName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Meteor.Map.packets.send.events
|
|||
public const ushort OPCODE = 0x012F;
|
||||
public const uint PACKET_SIZE = 0x90;
|
||||
|
||||
public static SubPacket BuildPacket(uint sourcePlayerActorId, uint targetEventActorId, uint unknown, string conditionName, List<LuaParam> luaParams)
|
||||
public static SubPacket BuildPacket(uint triggerActorId, uint ownerActorId, string eventName, byte eventType, List<LuaParam> luaParams)
|
||||
{
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
|
||||
|
@ -42,11 +42,13 @@ namespace Meteor.Map.packets.send.events
|
|||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((UInt32)sourcePlayerActorId);
|
||||
binWriter.Write((UInt32)targetEventActorId);
|
||||
binWriter.Write((UInt32)unknown);
|
||||
binWriter.Write((UInt32)0x30400000);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(conditionName), 0, Encoding.ASCII.GetByteCount(conditionName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(conditionName));
|
||||
binWriter.Write((UInt32)triggerActorId);
|
||||
binWriter.Write((UInt32)ownerActorId);
|
||||
binWriter.Write((Byte)eventType);
|
||||
binWriter.Write((Byte)0x17); //?
|
||||
binWriter.Write((UInt16)0x75DC); //?
|
||||
binWriter.Write((UInt32)0x30400000); //ServerCodes
|
||||
Utils.WriteNullTermString(binWriter, eventName);
|
||||
|
||||
binWriter.Seek(0x30, SeekOrigin.Begin);
|
||||
|
||||
|
@ -54,7 +56,7 @@ namespace Meteor.Map.packets.send.events
|
|||
}
|
||||
}
|
||||
|
||||
return new SubPacket(OPCODE, sourcePlayerActorId, data);
|
||||
return new SubPacket(OPCODE, triggerActorId, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Meteor.Map.packets.send.events
|
|||
public const ushort OPCODE = 0x0130;
|
||||
public const uint PACKET_SIZE = 0x2B8;
|
||||
|
||||
public static SubPacket BuildPacket(uint sourcePlayerActorId, uint eventOwnerActorID, string eventStarter, string callFunction, List<LuaParam> luaParams)
|
||||
public static SubPacket BuildPacket(uint triggerActorID, uint ownerActorID, string eventName, byte eventType, string functionName, List<LuaParam> luaParams)
|
||||
{
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
int maxBodySize = data.Length - 0x80;
|
||||
|
@ -43,19 +43,19 @@ namespace Meteor.Map.packets.send.events
|
|||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((UInt32)sourcePlayerActorId);
|
||||
binWriter.Write((UInt32)eventOwnerActorID);
|
||||
binWriter.Write((Byte)5);
|
||||
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.Write((UInt32)triggerActorID);
|
||||
binWriter.Write((UInt32)ownerActorID);
|
||||
binWriter.Write((Byte)eventType);
|
||||
Utils.WriteNullTermString(binWriter, eventName);
|
||||
binWriter.Seek(0x29, SeekOrigin.Begin);
|
||||
Utils.WriteNullTermString(binWriter, functionName);
|
||||
binWriter.Seek(0x49, SeekOrigin.Begin);
|
||||
|
||||
LuaUtils.WriteLuaParams(binWriter, luaParams);
|
||||
}
|
||||
}
|
||||
|
||||
return new SubPacket(OPCODE, sourcePlayerActorId, data);
|
||||
return new SubPacket(OPCODE, triggerActorID, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace Meteor.Map.packets.send.player
|
|||
}
|
||||
}
|
||||
|
||||
return new SubPacket(OPCODE, sourceActorId, data);
|
||||
return new SubPacket(OPCODE, sourceActorId, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace Meteor.Map.packets.send.player
|
|||
{
|
||||
class SetCurrentMountGoobbuePacket
|
||||
{
|
||||
|
||||
public const ushort OPCODE = 0x01a0;
|
||||
public const uint PACKET_SIZE = 0x28;
|
||||
|
||||
|
|
|
@ -105,8 +105,7 @@ namespace Meteor.Map.packets.send.player
|
|||
Program.Log.Error("Failed making SetCutsceneBook packet. Bin Stream was too big!");
|
||||
|
||||
binWriter.Seek(0x109, SeekOrigin.Begin);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(sNpcName), 0, Encoding.ASCII.GetByteCount(sNpcName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sNpcName));
|
||||
|
||||
Utils.WriteNullTermString(binWriter, sNpcName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|||
|
||||
using Meteor.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Meteor.Map.packets.send.player
|
||||
{
|
||||
|
@ -31,8 +32,18 @@ namespace Meteor.Map.packets.send.player
|
|||
|
||||
public static SubPacket BuildPacket(uint sourceActorId, uint dreamID)
|
||||
{
|
||||
dreamID += 0x20E;
|
||||
return new SubPacket(OPCODE, sourceActorId, BitConverter.GetBytes((uint)dreamID));
|
||||
dreamID = 0x0216;
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((Int32)0x216);
|
||||
}
|
||||
}
|
||||
|
||||
return new SubPacket(OPCODE, sourceActorId, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue