From d1320e434c506df5e193ee0a6970b3c2cc672b0d Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 18 Dec 2011 07:28:52 +0800 Subject: [PATCH] Cache the IP so that things don't shit bricks when Mono closes the socket. --- TShockAPI/Properties/AssemblyInfo.cs | 4 ++-- TShockAPI/TSPlayer.cs | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index 9943e676..22671a01 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.3.4.1217")] -[assembly: AssemblyFileVersion("3.3.4.1217")] +[assembly: AssemblyVersion("3.3.4.1218")] +[assembly: AssemblyFileVersion("3.3.4.1218")] diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 7d9897b0..7b051294 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -62,6 +62,7 @@ namespace TShockAPI public bool ForceSpawn = false; public string Country = "??"; public int Difficulty; + private string CacheIP; public bool RealPlayer { @@ -75,7 +76,10 @@ namespace TShockAPI { get { - return RealPlayer ? (Netplay.serverSock[Index].tcpClient.Connected ? TShock.Utils.GetRealIP(Netplay.serverSock[Index].tcpClient.Client.RemoteEndPoint.ToString()) : "") : ""; + if (string.IsNullOrEmpty(CacheIP)) + return CacheIP = RealPlayer ? (Netplay.serverSock[Index].tcpClient.Connected ? TShock.Utils.GetRealIP(Netplay.serverSock[Index].tcpClient.Client.RemoteEndPoint.ToString()) : "") : ""; + else + return CacheIP; } } ///