From 50430ce9a728216c8aba3b896102ee2e6e3b312b Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sat, 4 Jun 2011 10:59:16 +0800 Subject: [PATCH] Fixed bug where PvP would always stay on even if perma PvP was off. --- TShockAPI/TShock.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 2bb8dd55..90279ba6 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -112,9 +112,15 @@ namespace TShockAPI NetHooks.OnPreGetData += GetData; NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer); NpcHooks.OnStrikeNpc += new NpcHooks.StrikeNpcD(NpcHooks_OnStrikeNpc); + ServerHooks.OnCommand += new ServerHooks.CommandD(ServerHooks_OnCommand); Commands.InitCommands(); } + void ServerHooks_OnCommand(string cmd, HandledEventArgs e) + { + + } + public override void DeInitialize() { GameHooks.OnPreInitialize -= OnPreInit; @@ -164,7 +170,18 @@ namespace TShockAPI } else if (e.MsgID == 0x1e) { - Main.player[e.Msg.whoAmI].hostile = true; + byte id; + bool pvp; + using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))) + { + id = br.ReadByte(); + pvp = br.ReadBoolean(); + } + Main.player[e.Msg.whoAmI].hostile = pvp; + if (id != e.Msg.whoAmI) + Main.player[e.Msg.whoAmI].hostile = true; + if (ConfigurationManager.permaPvp) + Main.player[e.Msg.whoAmI].hostile = true; NetMessage.SendData(30, -1, -1, "", e.Msg.whoAmI); e.Handled = true; } @@ -574,11 +591,11 @@ namespace TShockAPI public static bool CheckInventory(int plr) { - /*for (int i = 0; i < 44; i++) + for (int i = 0; i < 44; i++) { if (Main.player[plr].inventory[i].stack > Main.player[plr].inventory[i].maxStack) return true; - }*/ + } return false; } }