Skip to content

Commit

Permalink
Merge pull request #10 from alborrajo/feature/warp
Browse files Browse the repository at this point in the history
Basic Warp support from Portcrystals
  • Loading branch information
alborrajo authored Jan 22, 2022
2 parents be67526 + a8bfcb3 commit 39d5df2
Show file tree
Hide file tree
Showing 16 changed files with 322 additions and 64 deletions.
2 changes: 2 additions & 0 deletions Arrowgene.Ddon.GameServer/DdonGameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ private void LoadPacketHandler()
AddHandler(new WarpGetReleaseWarpPointListHandler(this));
AddHandler(new WarpGetStartPointListHandler(this));
AddHandler(new WarpGetWarpPointListHandler(this));
AddHandler(new WarpRegisterFavoriteWarpHandler(this));
AddHandler(new WarpWarpHandler(this));
}
}
}
11 changes: 6 additions & 5 deletions Arrowgene.Ddon.GameServer/Handler/LobbyLobbyChatMsgHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Arrowgene.Ddon.Shared.Entity;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Logging;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;

namespace Arrowgene.Ddon.GameServer.Handler
{
Expand All @@ -22,30 +23,30 @@ public LobbyLobbyChatMsgHandler(DdonGameServer server) : base(server)
public override void Handle(GameClient requestingClient, Packet request)
{
// Read request
CDataLobbyChatMsgReq req = EntitySerializer.Get<CDataLobbyChatMsgReq>().Read(request.AsBuffer());
C2SLobbyChatMsgReq req = EntitySerializer.Get<C2SLobbyChatMsgReq>().Read(request.AsBuffer());
Logger.Debug(requestingClient, $"{req.type}, {req.unk2}, {req.unk3}, {req.unk4}, {req.unk5}: {req.strMessage}"); // Log chat message

// Write response
IBuffer resBuffer = new StreamBuffer();
resBuffer.WriteInt32(0, Endianness.Big); // error
resBuffer.WriteInt32(0, Endianness.Big); // result

CDataLobbyChatMsgRes res = new CDataLobbyChatMsgRes();
EntitySerializer.Get<CDataLobbyChatMsgRes>().Write(resBuffer, res);
S2CLobbyChatMsgRes res = new S2CLobbyChatMsgRes();
EntitySerializer.Get<S2CLobbyChatMsgRes>().Write(resBuffer, res);
Packet response = new Packet(PacketId.S2C_LOBBY_LOBBY_CHAT_MSG_RES, resBuffer.GetAllBytes());
requestingClient.Send(response);

// Notify all players
foreach (GameClient client in Server.Clients)
{
IBuffer ntcBuffer = new StreamBuffer();
CDataLobbyChatMsgNotice ntc = new CDataLobbyChatMsgNotice();
S2CLobbyChatMsgNotice ntc = new S2CLobbyChatMsgNotice();
ntc.unk0 = (byte) req.type;
ntc.strMessage = req.strMessage;
ntc.characterBaseInfo.strFirstName = "FirstName";
ntc.characterBaseInfo.strLastName = "LastName";
ntc.characterBaseInfo.strClanName = "ClanName";
EntitySerializer.Get<CDataLobbyChatMsgNotice>().Write(ntcBuffer, ntc);
EntitySerializer.Get<S2CLobbyChatMsgNotice>().Write(ntcBuffer, ntc);
Packet notice = new Packet(PacketId.S2C_LOBBY_LOBBY_CHAT_MSG_NTC, ntcBuffer.GetAllBytes());
client.Send(notice);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Arrowgene.Buffers;
using Arrowgene.Ddon.GameServer.Dump;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Server.Network;
using Arrowgene.Ddon.Shared.Entity;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Network;
using Arrowgene.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
public class WarpRegisterFavoriteWarpHandler : PacketHandler<GameClient>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(WarpRegisterFavoriteWarpHandler));

public WarpRegisterFavoriteWarpHandler(DdonGameServer server) : base(server)
{
}

public override PacketId Id => PacketId.C2S_WARP_REGISTER_FAVORITE_WARP_REQ;

public override void Handle(GameClient client, Packet packet)
{
// Read request
C2SWarpRegisterFavoriteWarpReq req = EntitySerializer.Get<C2SWarpRegisterFavoriteWarpReq>().Read(packet.AsBuffer());

// Write response
IBuffer resBuffer = new StreamBuffer();
resBuffer.WriteInt32(0, Endianness.Big); // error
resBuffer.WriteInt32(0, Endianness.Big); // result

// TODO: Figure out what they do
S2CWarpRegisterFavoriteWarpRes res = new S2CWarpRegisterFavoriteWarpRes();
res.slotNo = 0;
res.warpPointID = 0;

EntitySerializer.Get<S2CWarpRegisterFavoriteWarpRes>().Write(resBuffer, res);
Packet resPacket = new Packet(PacketId.S2C_WARP_REGISTER_FAVORITE_WARP_RES, resBuffer.GetAllBytes());
client.Send(resPacket);
}
}
}
42 changes: 42 additions & 0 deletions Arrowgene.Ddon.GameServer/Handler/WarpWarpHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Arrowgene.Buffers;
using Arrowgene.Ddon.GameServer.Dump;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Server.Network;
using Arrowgene.Ddon.Shared.Entity;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Network;
using Arrowgene.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
public class WarpWarpHandler : PacketHandler<GameClient> {
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(WarpGetWarpPointListHandler));


public WarpWarpHandler(DdonGameServer server) : base(server)
{
}

public override PacketId Id => PacketId.C2S_WARP_WARP_REQ;

public override void Handle(GameClient client, Packet packet)
{
// Read request
C2SWarpReq req = EntitySerializer.Get<C2SWarpReq>().Read(packet.AsBuffer());

// Write response
IBuffer resBuffer = new StreamBuffer();
resBuffer.WriteInt32(0, Endianness.Big); // error
resBuffer.WriteInt32(0, Endianness.Big); // result

// TODO: Figure out what they do
S2CWarpRes res = new S2CWarpRes();
res.warpPointID = 0;
res.rim = 0;

EntitySerializer.Get<S2CWarpRes>().Write(resBuffer, res);
Packet resPacket = new Packet(PacketId.S2C_WARP_WARP_RES, resBuffer.GetAllBytes());
client.Send(resPacket);
}
}
}
13 changes: 9 additions & 4 deletions Arrowgene.Ddon.Shared/Entity/EntitySerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public abstract class EntitySerializer
Create(new CDataGameServerListInfoSerializer()),
Create(new CDataGPCourseValidSerializer()),
Create(new CDataJobPlayPointSerializer()),
Create(new CDataLobbyChatMsgNoticeSerializer()),
Create(new CDataLobbyChatMsgNoticeCharacterSerializer()),
Create(new CDataLobbyChatMsgReqSerializer()),
Create(new CDataLobbyChatMsgResSerializer()),
Create(new CDataLoginSettingSerializer()),
Create(new CDataMatchingProfileSerializer()),
Create(new CDataOrbCategoryStatusSerializer()),
Expand All @@ -45,6 +41,7 @@ public abstract class EntitySerializer
Create(new CDataShortCutSerializer()),
Create(new CDataStatusInfoSerializer()),
Create(new CDataURLInfoSerializer()),
Create(new CDataWarpPointSerializer()),
Create(new DoubleByteThingSerializer()),
Create(new UnkownCharacterData0Serializer()),
Create(new UnkownCharacterData1Serializer()),
Expand All @@ -57,6 +54,9 @@ public abstract class EntitySerializer
Create(new C2SConnectionLoginReq.Serializer()),
Create(new C2SConnectionMoveInServerReq.Serializer()),
Create(new C2SConnectionMoveOutServerReq.Serializer()),
Create(new C2SLobbyChatMsgReqSerializer()),
Create(new C2SWarpRegisterFavoriteWarpReqSerializer()),
Create(new C2SWarpReqSerializer()),
Create(new L2CCreateCharacterDataNtc.Serializer()),
Create(new L2CCreateCharacterDataRes.Serializer()),
Create(new L2CGetErrorMessageListNtc.Serializer()),
Expand All @@ -70,6 +70,11 @@ public abstract class EntitySerializer
Create(new S2CConnectionLoginRes.Serializer()),
Create(new S2CConnectionLogoutRes.Serializer()),
Create(new S2CConnectionMoveOutServerRes.Serializer()),
Create(new S2CLobbyChatMsgResSerializer()),
Create(new S2CLobbyChatMsgNoticeSerializer()),
Create(new S2CLobbyChatMsgNoticeCharacterSerializer()),
Create(new S2CWarpRegisterFavoriteWarpResSerializer()),
Create(new S2CWarpResSerializer()),

Create(new ServerRes.Serializer()),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using Arrowgene.Buffers;

namespace Arrowgene.Ddon.Shared.Entity.Structure
namespace Arrowgene.Ddon.Shared.Entity.PacketStructure
{
public class CDataLobbyChatMsgReq {
public class C2SLobbyChatMsgReq {

public CDataLobbyChatMsgReq() {
public C2SLobbyChatMsgReq() {
type = 0;
unk2 = 0;
unk3 = 0;
Expand All @@ -14,16 +14,16 @@ public CDataLobbyChatMsgReq() {
strMessage = string.Empty;
}

public CDataLobbyChatMsgType.Type type;
public Structure.CDataLobbyChatMsgType.Type type;
public uint unk2; // Target ID?
public byte unk3;
public uint unk4;
public uint unk5;
public string strMessage;
}

public class CDataLobbyChatMsgReqSerializer : EntitySerializer<CDataLobbyChatMsgReq> {
public override void Write(IBuffer buffer, CDataLobbyChatMsgReq obj)
public class C2SLobbyChatMsgReqSerializer : EntitySerializer<C2SLobbyChatMsgReq> {
public override void Write(IBuffer buffer, C2SLobbyChatMsgReq obj)
{
WriteByte(buffer, (byte) obj.type);
WriteUInt32(buffer, obj.unk2);
Expand All @@ -33,10 +33,10 @@ public override void Write(IBuffer buffer, CDataLobbyChatMsgReq obj)
WriteMtString(buffer, obj.strMessage);
}

public override CDataLobbyChatMsgReq Read(IBuffer buffer)
public override C2SLobbyChatMsgReq Read(IBuffer buffer)
{
CDataLobbyChatMsgReq obj = new CDataLobbyChatMsgReq();
obj.type = (CDataLobbyChatMsgType.Type) buffer.ReadByte();
C2SLobbyChatMsgReq obj = new C2SLobbyChatMsgReq();
obj.type = (Structure.CDataLobbyChatMsgType.Type) buffer.ReadByte();
obj.unk2 = buffer.ReadUInt32();
obj.unk3 = buffer.ReadByte();
obj.unk4 = buffer.ReadUInt32();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Arrowgene.Buffers;

namespace Arrowgene.Ddon.Shared.Entity.PacketStructure
{
public class C2SWarpRegisterFavoriteWarpReq
{
public C2SWarpRegisterFavoriteWarpReq() {
slotNo = 0;
warpPointID = 0;
}

public uint slotNo;
public uint warpPointID;
}

public class C2SWarpRegisterFavoriteWarpReqSerializer : EntitySerializer<C2SWarpRegisterFavoriteWarpReq>
{
public override void Write(IBuffer buffer, C2SWarpRegisterFavoriteWarpReq obj)
{
WriteUInt32(buffer, obj.slotNo);
WriteUInt32(buffer, obj.warpPointID);
}

public override C2SWarpRegisterFavoriteWarpReq Read(IBuffer buffer)
{
C2SWarpRegisterFavoriteWarpReq obj = new C2SWarpRegisterFavoriteWarpReq();
obj.slotNo = ReadUInt32(buffer);
obj.warpPointID = ReadUInt32(buffer);
return obj;
}
}
}
36 changes: 36 additions & 0 deletions Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SWarpReq.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Arrowgene.Buffers;

namespace Arrowgene.Ddon.Shared.Entity.PacketStructure
{
public class C2SWarpReq {

public C2SWarpReq() {
currentPointID = 0;
destPointID = 0;
price = 0;
}

public uint currentPointID;
public uint destPointID;
public uint price;

}

public class C2SWarpReqSerializer : EntitySerializer<C2SWarpReq> {
public override void Write(IBuffer buffer, C2SWarpReq obj)
{
WriteUInt32(buffer, obj.currentPointID);
WriteUInt32(buffer, obj.destPointID);
WriteUInt32(buffer, obj.price);
}

public override C2SWarpReq Read(IBuffer buffer)
{
C2SWarpReq obj = new C2SWarpReq();
obj.currentPointID = ReadUInt32(buffer);
obj.destPointID = ReadUInt32(buffer);
obj.price = ReadUInt32(buffer);
return obj;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Arrowgene.Buffers;

namespace Arrowgene.Ddon.Shared.Entity.Structure
namespace Arrowgene.Ddon.Shared.Entity.PacketStructure
{
public class CDataLobbyChatMsgNotice {
public class S2CLobbyChatMsgNotice {

// Unidentified variables from the PS4 version:
// ucType (u8) (use CDataLobbyChatMsgType when identified)
// unHandleId (u32)

public CDataLobbyChatMsgNotice() {
public S2CLobbyChatMsgNotice() {
unk0 = 0;
unk1 = 0;
characterBaseInfo = new CDataLobbyChatMsgNoticeCharacterBaseInfo();
characterBaseInfo = new S2CLobbyChatMsgNoticeCharacterBaseInfo();
unk2 = 0;
unk3 = 0;
unk4 = 0;
Expand All @@ -20,31 +20,31 @@ public CDataLobbyChatMsgNotice() {

public byte unk0;
public uint unk1;
public CDataLobbyChatMsgNoticeCharacterBaseInfo characterBaseInfo;
public S2CLobbyChatMsgNoticeCharacterBaseInfo characterBaseInfo;
public byte unk2;
public uint unk3;
public uint unk4;
public string strMessage;
}

public class CDataLobbyChatMsgNoticeSerializer : EntitySerializer<CDataLobbyChatMsgNotice> {
public override void Write(IBuffer buffer, CDataLobbyChatMsgNotice obj)
public class S2CLobbyChatMsgNoticeSerializer : EntitySerializer<S2CLobbyChatMsgNotice> {
public override void Write(IBuffer buffer, S2CLobbyChatMsgNotice obj)
{
WriteByte(buffer, obj.unk0);
WriteUInt32(buffer, obj.unk1);
WriteEntity<CDataLobbyChatMsgNoticeCharacterBaseInfo>(buffer, obj.characterBaseInfo);
WriteEntity<S2CLobbyChatMsgNoticeCharacterBaseInfo>(buffer, obj.characterBaseInfo);
WriteByte(buffer, obj.unk2);
WriteUInt32(buffer, obj.unk3);
WriteUInt32(buffer, obj.unk4);
WriteMtString(buffer, obj.strMessage);
}

public override CDataLobbyChatMsgNotice Read(IBuffer buffer)
public override S2CLobbyChatMsgNotice Read(IBuffer buffer)
{
CDataLobbyChatMsgNotice obj = new CDataLobbyChatMsgNotice();
S2CLobbyChatMsgNotice obj = new S2CLobbyChatMsgNotice();
obj.unk0 = ReadByte(buffer);
obj.unk1 = ReadUInt32(buffer);
obj.characterBaseInfo = ReadEntity<CDataLobbyChatMsgNoticeCharacterBaseInfo>(buffer);
obj.characterBaseInfo = ReadEntity<S2CLobbyChatMsgNoticeCharacterBaseInfo>(buffer);
obj.unk2 = ReadByte(buffer);
obj.unk3 = ReadUInt32(buffer);
obj.unk4 = ReadUInt32(buffer);
Expand Down
Loading

0 comments on commit 39d5df2

Please sign in to comment.