feat(CS): on-map siege countdown timer (S6 client protocol C1 B2 17/1E)
Some checks failed
.NET Core / build (push) Has been cancelled

Client already renders the siege-map countdown but never received the packets.
New ICastleSiegeStatusViewPlugIn + RemoteView impl send the raw S6 packets:
C1 B2 17 (battle start/stop flag, arms the countdown) and C1 B2 1E (remaining
hour/minute). CastleSiegeEventPlugIn broadcasts them to players on the battle map
every 10s during Siege and sends stop at Settlement. No client changes. +1 test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Acentech Dev
2026-07-15 13:45:01 +03:00
parent ac6700a356
commit 7cf790c2a8
5 changed files with 167 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
// <copyright file="CastleSiegeStatusViewPlugIn.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>
namespace MUnique.OpenMU.GameServer.RemoteView.CastleSiege;
using System.Runtime.InteropServices;
using MUnique.OpenMU.GameLogic.Views.CastleSiege;
using MUnique.OpenMU.Network;
using MUnique.OpenMU.PlugIns;
/// <summary>
/// The default implementation of <see cref="ICastleSiegeStatusViewPlugIn"/> which sends the Season 6
/// Castle Siege countdown packets straight to the game client as raw bytes (no packet-struct exists yet).
/// </summary>
[PlugIn]
[Display(Name = "Castle Siege Status View", Description = "Sends the Castle Siege on-map countdown/state packets (C1 B2 17 / C1 B2 1E).")]
[Guid("CA5710A0-7A1B-4C2D-8E3F-0000000017E0")]
public class CastleSiegeStatusViewPlugIn : ICastleSiegeStatusViewPlugIn
{
private readonly RemotePlayer _player;
/// <summary>
/// Initializes a new instance of the <see cref="CastleSiegeStatusViewPlugIn"/> class.
/// </summary>
/// <param name="player">The player.</param>
public CastleSiegeStatusViewPlugIn(RemotePlayer player) => this._player = player;
/// <inheritdoc />
public async ValueTask SetBattleStateAsync(bool started)
{
var connection = this._player.Connection;
if (connection is null)
{
return;
}
int WritePacket()
{
// C1 09 B2 17 <started> <crownAccessTime:4 bytes = 0>
var span = connection.Output.GetSpan(9)[..9];
span.Clear();
span[0] = 0xC1;
span[1] = 0x09;
span[2] = 0xB2;
span[3] = 0x17;
span[4] = (byte)(started ? 1 : 0);
return span.Length;
}
await connection.SendAsync(WritePacket).ConfigureAwait(false);
}
/// <inheritdoc />
public async ValueTask SetTimerAsync(byte hour, byte minute)
{
var connection = this._player.Connection;
if (connection is null)
{
return;
}
int WritePacket()
{
// C1 06 B2 1E <hour> <minute>
var span = connection.Output.GetSpan(6)[..6];
span[0] = 0xC1;
span[1] = 0x06;
span[2] = 0xB2;
span[3] = 0x1E;
span[4] = hour;
span[5] = minute;
return span.Length;
}
await connection.SendAsync(WritePacket).ConfigureAwait(false);
}
}