diff --git a/.gitignore b/.gitignore index 0281722e..77ea7028 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ *.exe *.o *.so +/bin/* +/obj/* # Packages # ############ @@ -32,8 +34,6 @@ ehthumbs.db Icon? Thumbs.db -/bin -/obj # Visual Studio shit Motherfucka # @@ -43,4 +43,5 @@ Thumbs.db *.opensdf *.cache *.txt -*.pdb \ No newline at end of file +*.pdb +*.csproj.user diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 768d6e7c..8321ad45 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -63,6 +63,16 @@ namespace TShockAPI ServerHooks.OnChat += new Action(OnChat); ServerHooks.OnJoin += new Action(OnJoin); NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer); + NetHooks.OnPreGetData += new NetHooks.GetDataD(OnPreGetData); + } + + void OnPreGetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e) + { + if (id == 0x1e && permaPvp) + { + e.Handled = true; + + } } /* @@ -330,15 +340,15 @@ namespace TShockAPI public static void HandleCheater(int ply) { - string cheater = ShankShock.FindPlayer(ply); - string ip = ShankShock.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)); + string cheater = FindPlayer(ply); + string ip = GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)); - _writecheater(ply); + WriteCheater(ply); if (!kickCheater) { return; } Netplay.serverSock[ply].kill = true; Netplay.serverSock[ply].Reset(); NetMessage.syncPlayers(); - ShankShock.Broadcast(cheater + " was " + (banCheater ? "banned " : "kicked ") + "for cheating."); + Broadcast(cheater + " was " + (banCheater ? "banned " : "kicked ") + "for cheating."); } @@ -441,7 +451,7 @@ namespace TShockAPI } catch (Exception e) { - _writeError(e.Message); + WriteError(e.Message); } } } @@ -449,5 +459,50 @@ namespace TShockAPI } tr.Close(); } + + public static T Clamp(T value, T max, T min) + where T : System.IComparable + { + T result = value; + if (value.CompareTo(max) > 0) + result = max; + if (value.CompareTo(min) < 0) + result = min; + return result; + } + + public static void WriteCheater(int ply) + { + string ip = GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)); + string cheaters = ""; + TextReader tr = new StreamReader(saveDir + "cheaters.txt"); + cheaters = tr.ReadToEnd(); + tr.Close(); + if (cheaters.Contains(Main.player[ply].name) && cheaters.Contains(ip)) { return; } + TextWriter sw = new StreamWriter(saveDir + "cheaters.txt", true); + sw.WriteLine("[" + Main.player[ply].name + "] " + "[" + ip + "]"); + sw.Close(); + } + + private static string GetPlayers() + { + string str = ""; + for (int i = 0; i < 8; i++) + { + if (Main.player[i].active) + { + if (str == "") + { + str = str + Main.player[i].name; + } + else + { + str = str + ", " + Main.player[i].name; + } + } + } + return str; + } + } } \ No newline at end of file diff --git a/Terraria.csproj b/Terraria.csproj index 096af038..a5c88c87 100644 --- a/Terraria.csproj +++ b/Terraria.csproj @@ -6,7 +6,7 @@ 2.0 {1528EA3F-A6D2-49F6-BF75-7A842CF4D97B} Debug - Terraria + TShock WinExe v4.0 @@ -29,6 +29,9 @@ prompt 4 + + lbolt.ico + @@ -65,8 +68,10 @@ + + diff --git a/Terraria/lbolt.ico b/Terraria/lbolt.ico new file mode 100644 index 00000000..a0f55f40 Binary files /dev/null and b/Terraria/lbolt.ico differ