From 1e8cb04fdd75f51d79960e41711a492f8f9fc463 Mon Sep 17 00:00:00 2001 From: k0rd Date: Sat, 28 Jan 2012 05:19:15 -0500 Subject: [PATCH] allow teleporting and warps at edges of the map --- TShockAPI/TSPlayer.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index ce1f3261..dfa932ce 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -313,11 +313,35 @@ namespace TShockAPI try { int num = (size - 1)/2; - SendData(PacketTypes.TileSendSquare, "", size, (x - num), (y - num)); + int m_x=0; + int m_y=0; + + if (x - num <0){ + m_x=0; + }else{ + m_x = x - num; + } + + if (y - num <0){ + m_y=0; + }else{ + m_y = y - num; + } + + if (m_x + size > Main.maxTilesX){ + m_x=Main.maxTilesX - size; + } + + if (m_y + size > Main.maxTilesY){ + m_y=Main.maxTilesY - size; + } + + SendData(PacketTypes.TileSendSquare, "", size, m_x, m_y); return true; } catch (IndexOutOfRangeException) { + // This is expected if square exceeds array. } catch (Exception ex)