diff --git a/.gitignore b/.gitignore index 77ea7028..12a9755b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,10 @@ *.exe *.o *.so -/bin/* -/obj/* +*/bin/* +*/obj/* +bin/* +obj/* # Packages # ############ @@ -41,7 +43,17 @@ Thumbs.db *.suo *.sdf *.opensdf +<<<<<<< HEAD +*.csproj.user +======= +>>>>>>> 3ccdba9f51710ccb56e021dd10e53eea3614f21f *.cache *.txt +<<<<<<< HEAD +======= *.pdb +<<<<<<< HEAD +>>>>>>> ef60c83b40be0a7948d3cb0381cc6e4526a9b2d6 +======= *.csproj.user +>>>>>>> 3ccdba9f51710ccb56e021dd10e53eea3614f21f diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 14c04dd1..bb3fd8a6 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -13,9 +13,9 @@ namespace TShockAPI { public class TShock : TerrariaPlugin { + private uint[] tileThreshold = new uint[Main.maxPlayers]; + public static string saveDir = "./tshock/"; - private static double version = 3; - private static bool shownVersion = false; public static bool killGuide = true; public static int invasionMultiplier = 1; @@ -56,19 +56,46 @@ namespace TShockAPI public TShock(Main game) : base (game) { - GameHooks.OnPreInitialize += OnPreInit; - GameHooks.OnPostInitialize += OnPostInit; - GameHooks.OnUpdate += new Action(OnUpdate); - GameHooks.OnLoadContent += new Action(OnLoadContent); - ServerHooks.OnChat += new Action(OnChat); - ServerHooks.OnJoin += new Action(OnJoin); - NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer); + GameHooks.OnPreInitialize += OnPreInit; + GameHooks.OnPostInitialize += OnPostInit; + GameHooks.OnUpdate += new Action(OnUpdate); + GameHooks.OnLoadContent += new Action(OnLoadContent); + ServerHooks.OnChat += new Action(OnChat); + NetHooks.OnPreGetData += GetData; + ServerHooks.OnJoin += new Action(OnJoin); + NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer); + NetHooks.OnPreGetData += new NetHooks.GetDataD(OnPreGetData); } /* * Hooks: * */ + void OnPreGetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e) + { + if (id == 0x1e && permaPvp) + { + e.Handled = true; + + } + } + + void GetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e) + { + int n = 5; + byte[] buf = msg.readBuffer; + if (id == 17) + { + byte type = buf[n]; + n++; + if (type == 0) + { + tileThreshold[msg.whoAmI]++; + } + } + return; + } + void OnGreetPlayer(int who, HandledEventArgs e) { int plr = who; //legacy support @@ -144,7 +171,22 @@ namespace TShockAPI void OnUpdate(GameTime time) { - + for (uint i = 0; i < Main.maxPlayers; i++) + { + if (tileThreshold[i] >= 5) + { + if (Main.player[i] != null) + { + WriteGrief((int)i); + Kick((int)i, "Fuck you bomb spam or some other fucking shit"); + } + tileThreshold[i] = 0; + } + else if (tileThreshold[i] > 0) + { + tileThreshold[i]--; + } + } } /* @@ -333,6 +375,7 @@ namespace TShockAPI string cheater = FindPlayer(ply); string ip = GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)); + WriteGrief(ply); WriteCheater(ply); if (!kickCheater) { return; } Netplay.serverSock[ply].kill = true; @@ -451,7 +494,7 @@ namespace TShockAPI } public static T Clamp(T value, T max, T min) - where T : System.IComparable + where T : System.IComparable { T result = value; if (value.CompareTo(max) > 0) @@ -477,7 +520,7 @@ namespace TShockAPI private static string GetPlayers() { string str = ""; - for (int i = 0; i < 8; i++) + for (int i = 0; i < Main.maxPlayers; i++) { if (Main.player[i].active) { @@ -493,6 +536,5 @@ namespace TShockAPI } return str; } - } } \ No newline at end of file diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 5b24c5bf..311283f9 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -17,7 +17,7 @@ true full false - bin\Debug\ + ..\..\Program Files %28x86%29\Steam\steamapps\common\terraria\plugins\ DEBUG;TRACE prompt 4 diff --git a/TShockAPI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/TShockAPI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 2a9ad2b0..15023adf 100644 Binary files a/TShockAPI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/TShockAPI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Terraria.csproj b/Terraria.csproj index a5c88c87..675ceb5f 100644 --- a/Terraria.csproj +++ b/Terraria.csproj @@ -30,7 +30,8 @@ 4 - lbolt.ico + +