diff --git a/BLHX.Server.Common/Data/Model/ChapterTemplate.cs b/BLHX.Server.Common/Data/Model/ChapterTemplate.cs index 8e8bc53..aa3fe00 100644 --- a/BLHX.Server.Common/Data/Model/ChapterTemplate.cs +++ b/BLHX.Server.Common/Data/Model/ChapterTemplate.cs @@ -1,9 +1,19 @@ -using System.Text.Json.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; namespace BLHX.Server.Common.Data; public class ChapterTemplate : Model { + [JsonIgnore] + public List GridItems + { + get + { + return Grids.Select(x => new GridItem() { Row = x[0].GetUInt32(), Column = x[1].GetUInt32(), Blocking = x[2].GetBoolean(), Flag = x[3].GetInt32() }).ToList(); + } + } + [JsonPropertyName("ItemTransformPattern")] public object ItemTransformPattern { get; set; } [JsonPropertyName("act_id")] @@ -85,7 +95,7 @@ public class ChapterTemplate : Model [JsonPropertyName("friendly_id")] public int FriendlyId { get; set; } [JsonPropertyName("grids")] - public object[][] Grids { get; set; } + public List> Grids { get; set; } [JsonPropertyName("group_num")] public int GroupNum { get; set; } [JsonPropertyName("guarder_expedition_list")] @@ -203,3 +213,11 @@ public class ChapterTemplate : Model [JsonPropertyName("win_condition_display")] public string WinConditionDisplay { get; set; } } + +public readonly struct GridItem +{ + public uint Row { get; init; } + public uint Column { get; init; } + public bool Blocking { get; init; } + public int Flag { get; init; } +} \ No newline at end of file diff --git a/BLHX.Server.Game/Connection.cs b/BLHX.Server.Game/Connection.cs index 7898c0a..279f041 100644 --- a/BLHX.Server.Game/Connection.cs +++ b/BLHX.Server.Game/Connection.cs @@ -122,7 +122,7 @@ namespace BLHX.Server.Game ns.Write(sendBuf); } - void SendPacket(Packet packet) + void Send(Packet packet) { c.Log(packet.command.ToString()); var ns = tcpClient.GetStream(); diff --git a/BLHX.Server.Game/Handlers/P12.cs b/BLHX.Server.Game/Handlers/P12.cs index 7812d9a..ef2d81d 100644 --- a/BLHX.Server.Game/Handlers/P12.cs +++ b/BLHX.Server.Game/Handlers/P12.cs @@ -1,6 +1,4 @@ -using BLHX.Server.Common.Data; -using BLHX.Server.Common.Proto; -using BLHX.Server.Common.Proto.common; +using BLHX.Server.Common.Proto; using BLHX.Server.Common.Proto.p12; namespace BLHX.Server.Game.Handlers diff --git a/BLHX.Server.Game/Handlers/P13.cs b/BLHX.Server.Game/Handlers/P13.cs index c71db5d..71b92e0 100644 --- a/BLHX.Server.Game/Handlers/P13.cs +++ b/BLHX.Server.Game/Handlers/P13.cs @@ -1,10 +1,34 @@ -using BLHX.Server.Common.Proto; +using BLHX.Server.Common.Data; +using BLHX.Server.Common.Proto; using BLHX.Server.Common.Proto.p13; namespace BLHX.Server.Game.Handlers { internal static class P13 { + [PacketHandler(Command.Cs13101)] + static void TrackingHandler(Connection connection, Packet packet) + { + var req = packet.Decode(); + var rsp = new Sc13102(); + if (!Data.ChapterTemplate.TryGetValue((int)req.Id, out var chapterTemplate)) + { + rsp.Result = 1; + connection.Send(rsp); + return; + } + + // TODO: Populate values, pls make managers + connection.Send(new Sc13102() + { + CurrentChapter = new() + { + Id = req.Id, + Time = (uint)(DateTimeOffset.Now.ToUnixTimeSeconds() + chapterTemplate.Time) + } + }); + } + [PacketHandler(Command.Cs13505)] static void RemasterInfoRequestHandler(Connection connection, Packet packet) { @@ -16,7 +40,7 @@ namespace BLHX.Server.Game.Handlers { public static void NotifyChapterData(this Connection connection) { - connection.Send(new Sc13001() { ReactChapter = new() }); + connection.Send(new Sc13001() { ReactChapter = new() }); } } }