From a02f959f5841a3376ec18df2b494cf2fe2e0fb40 Mon Sep 17 00:00:00 2001 From: Patrikkk Date: Mon, 18 May 2020 02:02:02 +0200 Subject: [PATCH] Update Buff related packets Buff IDs no longer fit in a byte. Vanilla reads/writes ushorts but they get converted to int. - Added helptip for Zone4 in playerzones eventargs. --- TShockAPI/Bouncer.cs | 6 +++--- TShockAPI/GetDataHandlers.cs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index a5f132ac..17c1a92e 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -1285,7 +1285,7 @@ namespace TShockAPI internal void OnPlayerBuff(object sender, GetDataHandlers.PlayerBuffEventArgs args) { byte id = args.ID; - byte type = args.Type; + int type = args.Type; int time = args.Time; if (TShock.Players[id] == null) @@ -1342,7 +1342,7 @@ namespace TShockAPI internal void OnNPCAddBuff(object sender, GetDataHandlers.NPCAddBuffEventArgs args) { short id = args.ID; - byte type = args.Type; + int type = args.Type; short time = args.Time; if (id >= Main.npc.Length) @@ -1857,7 +1857,7 @@ namespace TShockAPI } - private static Dictionary NPCAddBuffTimeMax = new Dictionary() + private static Dictionary NPCAddBuffTimeMax = new Dictionary() { { BuffID.Poisoned, 3600 }, { BuffID.OnFire, 1200 }, diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 570c020c..a1fc937d 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -944,7 +944,7 @@ namespace TShockAPI /// public BitsByte Zone3 { get; set; } /// - /// 0 = Old One's Army + /// 0 = Old One's Army, 1 = Granite, 2 = Marble, 3 = Hive, 4 = Gem Cave, 5 = Lihzhard Temple, 6 = Graveyard /// public BitsByte Zone4 { get; set; } } @@ -1215,7 +1215,7 @@ namespace TShockAPI /// /// Buff Type /// - public byte Type { get; set; } + public int Type { get; set; } /// /// Time the buff lasts /// @@ -1225,7 +1225,7 @@ namespace TShockAPI /// NPCAddBuff - Called when a npc is buffed /// public static HandlerList NPCAddBuff = new HandlerList(); - private static bool OnNPCAddBuff(TSPlayer player, MemoryStream data, short id, byte type, short time) + private static bool OnNPCAddBuff(TSPlayer player, MemoryStream data, short id, int type, short time) { if (NPCAddBuff == null) return false; @@ -1254,7 +1254,7 @@ namespace TShockAPI /// /// Buff Type /// - public byte Type { get; set; } + public int Type { get; set; } /// /// Time the buff lasts /// @@ -1264,7 +1264,7 @@ namespace TShockAPI /// PlayerBuff - Called when a player is buffed /// public static HandlerList PlayerBuff = new HandlerList(); - private static bool OnPlayerBuff(TSPlayer player, MemoryStream data, byte id, byte type, int time) + private static bool OnPlayerBuff(TSPlayer player, MemoryStream data, byte id, int type, int time) { if (PlayerBuff == null) return false; @@ -2714,7 +2714,7 @@ namespace TShockAPI for (int i = 0; i < Terraria.Player.maxBuffs; i++) { - var buff = args.Data.ReadInt8(); + var buff = args.Data.ReadUInt16(); if (buff == 10 && TShock.Config.DisableInvisPvP && args.TPlayer.hostile) buff = 0; @@ -2765,7 +2765,7 @@ namespace TShockAPI private static bool HandleNPCAddBuff(GetDataHandlerArgs args) { var id = args.Data.ReadInt16(); - var type = args.Data.ReadInt8(); + var type = args.Data.ReadUInt16(); var time = args.Data.ReadInt16(); if (OnNPCAddBuff(args.Player, args.Data, id, type, time)) @@ -2777,7 +2777,7 @@ namespace TShockAPI private static bool HandlePlayerAddBuff(GetDataHandlerArgs args) { var id = args.Data.ReadInt8(); - var type = args.Data.ReadInt8(); + var type = args.Data.ReadUInt16(); var time = args.Data.ReadInt32(); if (OnPlayerBuff(args.Player, args.Data, id, type, time))