-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added a new handler for RPC packet contents. - Identified a few new RPC packets and added their definitions which can be used by the new handler.
- Loading branch information
1 parent
a752656
commit f5272df
Showing
9 changed files
with
262 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.RpcPacketStructure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class RpcHandler | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(RpcHandler)); | ||
|
||
public static void Handle(GameClient client, byte packetType, byte[] rpcData) | ||
{ | ||
IBuffer buffer = new StreamBuffer(rpcData); | ||
buffer.SetPositionStart(); | ||
|
||
RpcPacketHeader Header = new RpcPacketHeader().Read(buffer); | ||
if (gRpcPacketHandlers.ContainsKey(Header.MsgIdFull)) | ||
{ | ||
gRpcPacketHandlers[Header.MsgIdFull].Handle(client.Character, buffer); | ||
} | ||
} | ||
|
||
public static readonly Dictionary<RpcMessageId, IRpcPacket> gRpcPacketHandlers = new Dictionary<RpcMessageId, IRpcPacket>() | ||
{ | ||
{RpcMessageId.HeartBeat1, new RpcHeartbeatPacket()}, | ||
}; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Arrowgene.Ddon.Shared/Entity/RpcPacketStructure/IRpcPacket.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using System; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.RpcPacketStructure | ||
{ | ||
public interface IRpcPacket | ||
{ | ||
public void Handle(Character character, IBuffer buffer); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
Arrowgene.Ddon.Shared/Entity/RpcPacketStructure/RpcHeartbeatPacket.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using System; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.RpcPacketStructure | ||
{ | ||
public class RpcHeartbeatPacket : RpcPacketBase | ||
{ | ||
public RpcHeartbeatPacket() | ||
{ | ||
} | ||
|
||
public UInt64 Unk0 { get; set; } | ||
public bool IsEnemy { get; set; } | ||
public bool IsCharacter { get; set; } | ||
public bool IsHuman { get; set; } | ||
public bool IsEnemyLarge { get; set; } | ||
|
||
public double PosX { get; set; } | ||
public float PosY { get; set; } | ||
public double PosZ { get; set; } | ||
|
||
public UInt32 Unk1 { get; set; } | ||
public UInt32 Unk2 { get; set; } | ||
public UInt32 Unk3 { get; set; } | ||
|
||
public UInt16 GreenHP { get; set; } | ||
public UInt16 WhiteHP { get; set; } | ||
public UInt16 Unk4 { get; set; } | ||
public UInt16 Stamina { get; set; } | ||
|
||
public override void Handle(Character character, IBuffer buffer) | ||
{ | ||
RpcHeartbeatPacket obj = Read(buffer); | ||
|
||
if (obj.IsCharacter) | ||
{ | ||
character.X = obj.PosX; | ||
character.Y = obj.PosY; | ||
character.Z = obj.PosZ; | ||
} | ||
} | ||
|
||
private RpcHeartbeatPacket Read(IBuffer buffer) | ||
{ | ||
RpcHeartbeatPacket obj = new RpcHeartbeatPacket(); | ||
obj.Unk0 = ReadUInt64(buffer); // nNetMsgData::CtrlBase::stMsgCtrlBaseData.mUniqueId ? | ||
obj.IsEnemy = ReadBool(buffer); | ||
obj.IsCharacter = ReadBool(buffer); | ||
obj.IsHuman = ReadBool(buffer); | ||
obj.IsEnemyLarge = ReadBool(buffer); | ||
obj.PosX = ReadDouble(buffer); | ||
obj.PosY = ReadFloat(buffer); | ||
obj.PosZ = ReadDouble(buffer); | ||
obj.Unk1 = ReadUInt32(buffer); | ||
obj.Unk2 = ReadUInt32(buffer); | ||
obj.Unk3 = ReadUInt32(buffer); | ||
obj.GreenHP = ReadUInt16(buffer); | ||
obj.WhiteHP = ReadUInt16(buffer); | ||
obj.Unk4 = ReadUInt16(buffer); | ||
obj.Stamina = ReadUInt16(buffer); | ||
return obj; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Arrowgene.Ddon.Shared/Entity/RpcPacketStructure/RpcLoginPacket.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.RpcPacketStructure | ||
{ | ||
public class RpcLoginPacket : RpcPacketBase | ||
{ | ||
public RpcLoginPacket() | ||
{ | ||
Unk0 = new byte[6]; | ||
} | ||
|
||
public byte[] Unk0 { get; set; } | ||
public UInt16 StageNo { get; set; } | ||
|
||
public override void Handle(Character character, IBuffer buffer) | ||
{ | ||
RpcLoginPacket obj = Read(buffer); | ||
} | ||
private RpcLoginPacket Read(IBuffer buffer) | ||
{ | ||
RpcLoginPacket obj = new RpcLoginPacket(); | ||
obj.Unk0 = ReadBytes(buffer, Unk0.Length); | ||
obj.StageNo = ReadUInt16(buffer); | ||
return obj; | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Arrowgene.Ddon.Shared/Entity/RpcPacketStructure/RpcPacketBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using System; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.RpcPacketStructure | ||
{ | ||
public abstract class RpcPacketBase : IRpcPacket | ||
{ | ||
public RpcPacketBase() | ||
{ | ||
} | ||
|
||
public abstract void Handle(Character character, IBuffer buffer); | ||
|
||
public byte[] ReadBytes(IBuffer buffer, int length) | ||
{ | ||
return buffer.ReadBytes(length); | ||
} | ||
|
||
public byte ReadByte(IBuffer buffer) | ||
{ | ||
return buffer.ReadByte(); | ||
} | ||
|
||
public UInt16 ReadUInt16(IBuffer buffer) | ||
{ | ||
return buffer.ReadUInt16(Endianness.Big); | ||
} | ||
|
||
public UInt32 ReadUInt32(IBuffer buffer) | ||
{ | ||
return buffer.ReadUInt32(Endianness.Big); | ||
} | ||
|
||
public UInt64 ReadUInt64(IBuffer buffer) | ||
{ | ||
return buffer.ReadUInt64(Endianness.Big); | ||
} | ||
|
||
public bool ReadBool(IBuffer buffer) | ||
{ | ||
return buffer.ReadBool(); | ||
} | ||
|
||
public double ReadDouble(IBuffer buffer) | ||
{ | ||
return buffer.ReadDouble(Endianness.Big); | ||
} | ||
public float ReadFloat(IBuffer buffer) | ||
{ | ||
return buffer.ReadFloat(Endianness.Big); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Arrowgene.Ddon.Shared/Entity/RpcPacketStructure/RpcPacketHeader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.RpcPacketStructure | ||
{ | ||
public class RpcPacketHeader : RpcPacketBase | ||
{ | ||
public RpcPacketHeader() | ||
{ | ||
} | ||
|
||
public UInt32 SessionId { get; set; } | ||
public UInt64 RpcId { get; set; } | ||
public RpcMessageId MsgIdFull { get; set; } | ||
public UInt32 SearchId { get; set; } | ||
|
||
public override void Handle(Character character, IBuffer buffer) | ||
{ | ||
/* special case nothing to do */ | ||
} | ||
|
||
public RpcPacketHeader Read(IBuffer buffer) | ||
{ | ||
RpcPacketHeader obj = new RpcPacketHeader(); | ||
obj.SessionId = ReadUInt32(buffer); // NetMsgData.Head.SessionId | ||
obj.RpcId = ReadUInt64(buffer); // NetMsgData.Head.RpcId | ||
obj.MsgIdFull = (RpcMessageId) ReadUInt32(buffer); // NetMsgData.Head.MsgIdFull | ||
obj.SearchId = ReadUInt32(buffer); // NetMsgData.Head.SearchId, seems to either a PawnId or 0 | ||
return obj; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
|
||
namespace Arrowgene.Ddon.Shared.Model | ||
{ | ||
public enum RpcMessageId : UInt32 | ||
{ | ||
Login = 0x41000001, | ||
HeartBeat0 = 0x40010002, | ||
HeartBeat1 = 0x40010015, | ||
HeartBeat2 = 0x4001001A, | ||
Combat1 = 0x40010037, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Arrowgene.Ddon.Shared.Model | ||
{ | ||
public enum RpcPacketType : byte | ||
{ | ||
Ping = 2, // See this while in town and out in the field | ||
Combat = 4, // See this when fighting monsters | ||
} | ||
} |