Don't allow players to sync loadout index whilst disabled

This commit is contained in:
James Puleo 2022-10-06 12:22:26 -04:00
parent 4382cd8086
commit 40b07fdc7b
No known key found for this signature in database
GPG key ID: 3E16C7EFA34FB15D

View file

@ -162,7 +162,8 @@ namespace TShockAPI
{ PacketTypes.LandGolfBallInCup, HandleLandGolfBallInCup },
{ PacketTypes.FishOutNPC, HandleFishOutNPC },
{ PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing },
{ PacketTypes.SyncCavernMonsterType, HandleSyncCavernMonsterType }
{ PacketTypes.SyncCavernMonsterType, HandleSyncCavernMonsterType },
{ PacketTypes.SyncLoadout, HandleSyncLoadout }
};
}
@ -4325,6 +4326,27 @@ namespace TShockAPI
return true;
}
private static bool HandleSyncLoadout(GetDataHandlerArgs args)
{
var playerIndex = args.Data.ReadInt8();
var loadoutIndex = args.Data.ReadInt8();
// When syncing a player's own loadout index, they then sync it back to us...
// So let's only care if the index has actually changed, otherwise we might end up in a loop...
if (loadoutIndex == args.TPlayer.CurrentLoadoutIndex)
return false;
if (args.Player.IsBeingDisabled())
{
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncLoadout rejected loadout index sync {0}", args.Player.Name);
NetMessage.SendData((int)PacketTypes.SyncLoadout, number: args.Player.Index, number2: args.TPlayer.CurrentLoadoutIndex);
return true;
}
return false;
}
public enum DoorAction
{
OpenDoor = 0,