From d343983f2c8fd98b3adb264d9e52b54070b0c1ab Mon Sep 17 00:00:00 2001 From: Zidonuke Date: Tue, 20 Dec 2011 19:59:55 -0500 Subject: [PATCH] Fix possible null references. Remove noclip check, I bypassed it in 5 seconds in zidomod... So useless --- TShockAPI/GetDataHandlers.cs | 7 ------- TShockAPI/TSPlayer.cs | 26 +++++++++++++++++++++----- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 373a291a..8f513192 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -582,13 +582,6 @@ namespace TShockAPI args.Player.Spawn(); return true; } - if (TShock.CheckPlayerCollision((int)(pos.X / 16f), (int)(pos.Y / 16f))) //NoClipping or possible errors - { - args.Player.SendMessage("You got stuck in a solid object! Sent you to the spawn point.", Color.Red); - args.Player.SendTileSquare((int)(pos.X / 16f), (int)(pos.X / 16f)); - args.Player.Spawn(); - return true; - } } args.Player.LastNetPosition = pos; diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index f4ad452e..b44b8e0f 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -444,15 +444,15 @@ namespace TShockAPI { this.inventory[0].netID = -15; this.inventory[0].stack = 1; - if(player.TPlayer.inventory[0].netID == -15) + if(player.TPlayer.inventory[0] != null && player.TPlayer.inventory[0].netID == -15) this.inventory[0].prefix = player.TPlayer.inventory[0].prefix; this.inventory[1].netID = -13; this.inventory[1].stack = 1; - if (player.TPlayer.inventory[1].netID == -13) + if (player.TPlayer.inventory[1] != null && player.TPlayer.inventory[1].netID == -13) this.inventory[1].prefix = player.TPlayer.inventory[1].prefix; this.inventory[2].netID = -16; this.inventory[2].stack = 1; - if (player.TPlayer.inventory[2].netID == -16) + if (player.TPlayer.inventory[2] != null && player.TPlayer.inventory[2].netID == -16) this.inventory[2].prefix = player.TPlayer.inventory[2].prefix; } @@ -479,7 +479,15 @@ namespace TShockAPI { if (i < 49) { - this.inventory[i].netID = inventory[i].netID; + if (player.TPlayer.inventory[i] != null) + { + this.inventory[i].netID = inventory[i].netID; + } + else + { + this.inventory[i].netID = 0; + } + if (this.inventory[i].netID != 0) { this.inventory[i].stack = inventory[i].stack; @@ -493,7 +501,15 @@ namespace TShockAPI } else { - this.inventory[i].netID = armor[i].netID; + if (player.TPlayer.armor[i] != null) + { + this.inventory[i].netID = armor[i].netID; + } + else + { + this.inventory[i].netID = 0; + } + if (this.inventory[i].netID != 0) { this.inventory[i].stack = armor[i].stack;