Skip to content

Commit

Permalink
Merge pull request #519 from pacampbell/investigate_pawn_issues
Browse files Browse the repository at this point in the history
fix: Fix issue with random pawns
  • Loading branch information
pacampbell authored Sep 2, 2024
2 parents 68b4587 + d1c59bf commit e2cbd2a
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 7 deletions.
19 changes: 15 additions & 4 deletions Arrowgene.Ddon.GameServer/Handler/PawnGetNoraPawnListHandler.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using Arrowgene.Ddon.GameServer.Dump;
using Arrowgene.Ddon.GameServer.Dump;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Server.Network;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Network;
using Arrowgene.Logging;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;

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

Expand All @@ -17,9 +23,14 @@ public PawnGetNoraPawnListHandler(DdonGameServer server) : base(server)

public override PacketId Id => PacketId.C2S_PAWN_GET_NORA_PAWN_LIST_REQ;

public override void Handle(GameClient client, IPacket packet)
public override S2CPawnGetNoraPawnListRes Handle(GameClient client, C2SPawnGetNoraPawnListReq request)
{
client.Send(GameFull.Dump_118);
// client.Send(GameFull.Dump_118);
var result = new S2CPawnGetNoraPawnListRes();

List<uint> pawnIds = Server.Database.SelectAllPlayerPawns(uint.MaxValue);
result.NoraPawnList = pawnIds.OrderBy(x => Random.Shared.Next()).Take(100).Select(x => new CDataRegisterdPawnList() { PawnId = x }).ToList();
return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ public PawnGetRentedPawnListHandler(DdonGameServer server) : base(server)

public override void Handle(GameClient client, IPacket packet)
{
//client.Send(InGameDump.Dump_35);
//client.Send(new Packet(PacketId.S2C_PAWN_GET_RENTED_PAWN_LIST_RES, new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xB6, 0x58, 0xA9, 0x0, 0x0, 0x0, 0x1, 0x0, 0x4, 0x49, 0x72, 0x69, 0x73, 0x2, 0x0, 0x9, 0x5, 0x6, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x0, 0x46, 0x0, 0x0, 0x0, 0xA, 0x1, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x45, 0x3, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0, 0xE6, 0x1, 0x7A, 0x80, 0x0, 0x0, 0x0, 0x45, 0xAE, 0xFC}));
// client.Send(InGameDump.Dump_35);
// client.Send(new Packet(PacketId.S2C_PAWN_GET_RENTED_PAWN_LIST_RES, new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xB6, 0x58, 0xA9, 0x0, 0x0, 0x0, 0x1, 0x0, 0x4, 0x49, 0x72, 0x69, 0x73, 0x2, 0x0, 0x9, 0x5, 0x6, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x0, 0x46, 0x0, 0x0, 0x0, 0xA, 0x1, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x45, 0x3, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0, 0xE6, 0x1, 0x7A, 0x80, 0x0, 0x0, 0x0, 0x45, 0xAE, 0xFC}));
// client.Send(new Packet(PacketId.S2C_PAWN_GET_RENTED_PAWN_LIST_RES, new byte[12]));

// var pcap = new S2CPawnGetRentedPawnListRes.Serializer().Read(InGameDump.Dump_35.AsBuffer());

var response = new S2CPawnGetRentedPawnListRes();
Expand Down
2 changes: 2 additions & 0 deletions Arrowgene.Ddon.Shared/Entity/EntitySerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ static EntitySerializer()
Create(new C2SPawnGetRentedPawnDataReq.Serializer());
Create(new C2SPawnJoinPartyRentedPawnReq.Serializer());
Create(new C2SPawnReturnRentedPawnReq.Serializer());
Create(new C2SPawnGetNoraPawnListReq.Serializer());

Create(new C2SProfileGetCharacterProfileReq.Serializer());
Create(new C2SProfileGetMyCharacterProfileReq.Serializer());
Expand Down Expand Up @@ -1006,6 +1007,7 @@ static EntitySerializer()
Create(new S2CPawnGetRentedPawnDataRes.Serializer());
Create(new S2CPawnJoinPartyRentedPawnRes.Serializer());
Create(new S2CPawnReturnRentedPawnRes.Serializer());
Create(new S2CPawnGetNoraPawnListRes.Serializer());

Create(new S2CProfileGetCharacterProfileRes.Serializer());
Create(new S2CProfileGetMyCharacterProfileRes.Serializer());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Arrowgene.Buffers;
using Arrowgene.Ddon.Shared.Network;

namespace Arrowgene.Ddon.Shared.Entity.PacketStructure
{
public class C2SPawnGetNoraPawnListReq : IPacketStructure
{
public PacketId Id => PacketId.C2S_PAWN_GET_NORA_PAWN_LIST_REQ;

public class Serializer : PacketEntitySerializer<C2SPawnGetNoraPawnListReq>
{
public override void Write(IBuffer buffer, C2SPawnGetNoraPawnListReq obj)
{
}

public override C2SPawnGetNoraPawnListReq Read(IBuffer buffer)
{
return new C2SPawnGetNoraPawnListReq();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using Arrowgene.Buffers;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Network;

namespace Arrowgene.Ddon.Shared.Entity.PacketStructure
{
public class S2CPawnGetNoraPawnListRes : ServerResponse
{
public override PacketId Id => PacketId.S2C_PAWN_GET_NORA_PAWN_LIST_RES;

public S2CPawnGetNoraPawnListRes()
{
NoraPawnList = new List<CDataRegisterdPawnList>();
}

public List<CDataRegisterdPawnList> NoraPawnList { get; set; }


public class Serializer : PacketEntitySerializer<S2CPawnGetNoraPawnListRes>
{
public override void Write(IBuffer buffer, S2CPawnGetNoraPawnListRes obj)
{
WriteServerResponse(buffer, obj);
WriteEntityList(buffer, obj.NoraPawnList);
}

public override S2CPawnGetNoraPawnListRes Read(IBuffer buffer)
{
S2CPawnGetNoraPawnListRes obj = new S2CPawnGetNoraPawnListRes();
ReadServerResponse(buffer, obj);
obj.NoraPawnList = ReadEntityList<CDataRegisterdPawnList>(buffer);
return obj;
}
}
}
}

0 comments on commit e2cbd2a

Please sign in to comment.