mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-11 15:04:42 +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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue