Skip to content

Commit

Permalink
Rename PerPlayer packets
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-r-elp committed Jul 13, 2024
1 parent 57bcd69 commit b8d96fe
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override void Handle(IPlayer player, SetPerPlayerDifficulties command)
{
Text = "Per player difficulties: " + command.Enabled
}, IgnoranceChannelTypes.Reliable);
_packetDisapatcher.SendToNearbyPlayers(new PerPlayer()
_packetDisapatcher.SendToNearbyPlayers(new MpPerPlayerPacket()
{
PPDEnabled = _Configuration.AllowPerPlayerDifficulties,
PPMEnabled = _Configuration.AllowPerPlayerModifiers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override void Handle(IPlayer player, SetPerPlayerModifiers command)
{
Text = "Per player modifiers: " + command.Enabled
}, IgnoranceChannelTypes.Reliable);
_packetDisapatcher.SendToNearbyPlayers(new PerPlayer()
_packetDisapatcher.SendToNearbyPlayers(new MpPerPlayerPacket()
{
PPDEnabled = _Configuration.AllowPerPlayerDifficulties,
PPMEnabled = _Configuration.AllowPerPlayerModifiers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@

namespace BeatTogether.DedicatedServer.Kernel.PacketHandlers.MultiplayerSession.MenuRpc
{
class GetPerPlayerHandler : BasePacketHandler<GetPerPlayer>
class GetMpPerPlayerPacketHandler : BasePacketHandler<GetMpPerPlayerPacket>
{
private readonly InstanceConfiguration _configuration;
private readonly IPacketDispatcher _PacketDispatcher;
private readonly ILogger _logger = Log.ForContext<GetPerPlayerHandler>();
private readonly ILogger _logger = Log.ForContext<GetMpPerPlayerPacketHandler>();

public GetPerPlayerHandler(
public GetMpPerPlayerPacketHandler(
IPacketDispatcher PacketDispatcher,
InstanceConfiguration configuration)
{
_PacketDispatcher = PacketDispatcher;
_configuration = configuration;
}

public override void Handle(IPlayer sender, GetPerPlayer packet)
public override void Handle(IPlayer sender, GetMpPerPlayerPacket packet)
{

_logger.Debug(
$"Handling packet of type '{nameof(GetPerPlayer)}' " +
$"Handling packet of type '{nameof(GetMpPerPlayerPacket)}' " +
$"(SenderId={sender.ConnectionId})."
);
_PacketDispatcher.SendToPlayer(sender, new PerPlayer()
_PacketDispatcher.SendToPlayer(sender, new MpPerPlayerPacket()
{
PPDEnabled = _configuration.AllowPerPlayerDifficulties,
PPMEnabled = _configuration.AllowPerPlayerModifiers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@

namespace BeatTogether.DedicatedServer.Kernel.PacketHandlers.MultiplayerSession.MenuRpc
{
class PerPlayerHandler : BasePacketHandler<PerPlayer>
class MpPerPlayerPacketHandler : BasePacketHandler<MpPerPlayerPacket>
{
private readonly InstanceConfiguration _configuration;
private readonly IPacketDispatcher _PacketDispatcher;
private readonly ILogger _logger = Log.ForContext<GetPerPlayerHandler>();
private readonly ILogger _logger = Log.ForContext<GetMpPerPlayerPacketHandler>();

public PerPlayerHandler(
public MpPerPlayerPacketHandler(
IPacketDispatcher PacketDispatcher,
InstanceConfiguration configuration)
{
_PacketDispatcher = PacketDispatcher;
_configuration = configuration;
}

public override void Handle(IPlayer sender, PerPlayer packet)
public override void Handle(IPlayer sender, MpPerPlayerPacket packet)
{

_logger.Debug(
$"Handling packet of type '{nameof(PerPlayer)}' " +
$"Handling packet of type '{nameof(MpPerPlayerPacket)}' " +
$"(SenderId={sender.ConnectionId})."
);
if(sender.IsServerOwner)
{
_configuration.AllowPerPlayerDifficulties = packet.PPDEnabled;
_configuration.AllowPerPlayerModifiers = packet.PPMEnabled;
_PacketDispatcher.SendToNearbyPlayers(new PerPlayer()
_PacketDispatcher.SendToNearbyPlayers(new MpPerPlayerPacket()
{
PPDEnabled = _configuration.AllowPerPlayerDifficulties,
PPMEnabled = _configuration.AllowPerPlayerModifiers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MpCorePackets
{
public sealed class GetPerPlayer : INetSerializable
public sealed class GetMpPerPlayerPacket : INetSerializable
{
public void ReadFrom(ref SpanBuffer bufferReader)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MpCorePackets
{
public sealed class PerPlayer : INetSerializable
public sealed class MpPerPlayerPacket : INetSerializable
{
public bool PPDEnabled;
public bool PPMEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public override void Register()
AddPacket<GetMpPlayerData>();
AddPacket<MpPlayerData>();
AddPacket<MpNodePoseSyncStatePacket>();
AddPacket<PerPlayer>();
AddPacket<GetPerPlayer>();
AddPacket<MpPerPlayerPacket>();
AddPacket<GetMpPerPlayerPacket>();
}

public bool TryCreatePacket(string packetId, [MaybeNullWhen(false)] out INetSerializable packet)
Expand Down

0 comments on commit b8d96fe

Please sign in to comment.