From 05f0e9d7175d8892ee0f18bf6cdae2c47db77cd9 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 21 Aug 2011 00:47:39 +0800 Subject: [PATCH] bounds check for noclip detection --- TShockAPI/TShock.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 5da2406e..02fb234b 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -815,14 +815,20 @@ namespace TShockAPI public static bool CheckPlayerCollision(int x, int y) { - for (int i = x; i < x + 2; i++) + if (x + 1 <= Main.maxTilesX && y + 3 <= Main.maxTilesY + && x >= 0 && y >= 0) { - for (int h = y; h < y + 4; h++) + for (int i = x; i < x + 2; i++) { - if (!Main.tile[i, h].active || !GetDataHandlers.BlacklistTiles[Main.tile[i, h].type]) - return false; + for (int h = y; h < y + 4; h++) + { + if (!Main.tile[i, h].active || !GetDataHandlers.BlacklistTiles[Main.tile[i, h].type]) + return false; + } } } + else + return false; return true; }