40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using KCM.Attributes;
|
|
using KCM.Packets.Game;
|
|
using System;
|
|
|
|
namespace KCM.Packets.Network
|
|
{
|
|
[NoServerRelay]
|
|
public class SpeedRestoreRequestPacket : Packet
|
|
{
|
|
public override ushort packetId => (ushort)Enums.Packets.SpeedRestoreRequest;
|
|
|
|
public string reason { get; set; }
|
|
|
|
public override void HandlePacketClient()
|
|
{
|
|
}
|
|
|
|
public override void HandlePacketServer()
|
|
{
|
|
try
|
|
{
|
|
if (!KCServer.IsRunning)
|
|
return;
|
|
|
|
int speed = Main.LastNonZeroSpeedIndex;
|
|
if (speed <= 0)
|
|
speed = 1;
|
|
|
|
Main.helper.Log($"Speed restore requested by client {clientId} ({reason ?? string.Empty}); broadcasting speed {speed}");
|
|
new SetSpeed { speed = speed }.SendToAll();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Main.helper.Log("Error handling SpeedRestoreRequestPacket on server");
|
|
Main.helper.Log(ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|