From 1808b8ee9719335fcf12d11608dfa03d5de17b85 Mon Sep 17 00:00:00 2001 From: Shank Date: Fri, 3 Jun 2011 22:00:52 -0600 Subject: [PATCH 1/7] Added release docs for artifact purposes. --- release-docs/changes.txt | 65 ++++++++++++++++++++++++++++++++++ release-docs/documentation.txt | 3 ++ release-docs/installation.txt | 3 ++ 3 files changed, 71 insertions(+) create mode 100644 release-docs/changes.txt create mode 100644 release-docs/documentation.txt create mode 100644 release-docs/installation.txt diff --git a/release-docs/changes.txt b/release-docs/changes.txt new file mode 100644 index 00000000..f7893fbb --- /dev/null +++ b/release-docs/changes.txt @@ -0,0 +1,65 @@ +For the full list of changes, please take a look at GitHub: +https://github.com/TShock/TShock/commits/master + +Changes in API release 1.5.0.1: + - Fixed cheat detection + +Changes in API release 1.5.0.0: + - Added /time + - Added /kill + - Fixed /item + - Added /slap [dmg] + - Added broadcast event for kill tile abuse + - Fixed teleport somewhat + - More cheat detection + - Extended new cheat protection to mana + - Update player exploit patched + - Fixed /spawn + - Made /invasion a toggle + +Changes in API release 1.4.0.0: + - The configuration file is now located at config.json + - Something else. + +Changes in API release 1.3.0.1: + - Re-coded the entire command system + - Re-coded the help command + - Implemented what seems to be the most recurring blacklist ever + +Changes in API release 1.3.0.0: + - Added /maxspawns + - Added /spawnrate + - Resetup the configuration file to read spawn rate information. + - Patched the ability for clients to spawn NPCs + - Patched the ability for clients to rewrite the server through SendSection + - Make sure to use this Terraria.exe for the server: (http://dl.dropbox.com/u/29760911/Terraria.exe) + -- Allows spawn rates to be changed + +Changes in API release 1.2.0.1: + - New update system + +Changes in API release 1.2: + - Added /butcher + - Added /heal + - /spawnmob now takes another argument for the amount + - /item now adds items to the inventory directly + - This update credit to Deathmax + +Changes in API release 1.1: + - Added /tp + - Added /tphere + - Added /spawnmob + - Added /item + - Fixed /spawn + - Updated /help + - Everything in this update credit to Deathmax, High, and Shank + +Changes in API release 0.1: + - Added /save to save the world + - Added /spawn to teleport to spawn + - Added broken teleport stuff + - Major re-write of the anti-tnt code (now uses a blacklist instead of a whitelist) + - Fixed server crashing bug of the anti-tnt code + - Made the anti-tnt code decrease the threshold instantaniously + + Re added the update checker. \ No newline at end of file diff --git a/release-docs/documentation.txt b/release-docs/documentation.txt new file mode 100644 index 00000000..ebee2aa4 --- /dev/null +++ b/release-docs/documentation.txt @@ -0,0 +1,3 @@ +Documentation, NPC lists, Spawn lists, and more can be found on GitHub at: + +https://github.com/TShock/TShock/wiki \ No newline at end of file diff --git a/release-docs/installation.txt b/release-docs/installation.txt new file mode 100644 index 00000000..26b88e24 --- /dev/null +++ b/release-docs/installation.txt @@ -0,0 +1,3 @@ +For installation instructions, please refer to: + +https://github.com/TShock/TShock/wiki/Installation-instructions \ No newline at end of file From 474498416d9e7e755bccb4ea6cfac0571b2d5617 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sat, 4 Jun 2011 12:17:12 +0800 Subject: [PATCH 2/7] Handled KillMe packet. --- TShockAPI/TShock.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 203d58f3..9ed1bcfe 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -176,6 +176,7 @@ namespace TShockAPI byte type = br.ReadByte(); int x = br.ReadInt32(); int y = br.ReadInt32(); + byte typetile = br.ReadByte(); if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active) { @@ -327,7 +328,8 @@ namespace TShockAPI } if (id != e.Msg.whoAmI) { - Tools.HandleCheater(e.Msg.whoAmI); + Tools.HandleGriefer(e.Msg.whoAmI); + e.Handled = true; } } } From 069c95e2cfcc079e01827652aa53345f1bf18a6f Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sat, 4 Jun 2011 14:21:41 +0800 Subject: [PATCH 3/7] Spawn protection. 5 block radius. /protectspawn - toggle spawn protection. --- TShockAPI/Commands.cs | 7 +++++ TShockAPI/ConfigFile.cs | 1 + TShockAPI/ConfigurationManager.cs | 3 ++ TShockAPI/TShock.cs | 51 ++++++++++++++++++++++++++++--- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index f9829ee1..599a27d8 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -55,6 +55,7 @@ namespace TShockAPI TShock.admincommandList.Add("help", new CommandDelegate(Help)); TShock.admincommandList.Add("slap", new CommandDelegate(Slap)); TShock.admincommandList.Add("off-nosave", new CommandDelegate(OffNoSave)); + TShock.admincommandList.Add("protectspawn", new CommandDelegate(ProtectSpawn)); TShock.commandList.Add("help", new CommandDelegate(Help)); TShock.commandList.Add("kill", new CommandDelegate(Kill)); } @@ -559,6 +560,12 @@ namespace TShockAPI else Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap [dmg]", new float[] { 255f, 0f, 0f }); } + + public static void ProtectSpawn(CommandArgs args) + { + ConfigurationManager.spawnProtect = (ConfigurationManager.spawnProtect == false); + Tools.SendMessage(args.PlayerID, "Spawn is now " + (ConfigurationManager.spawnProtect ? "protected" : "open") + "."); + } #endregion } } diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 1ce76424..72ed278c 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -23,5 +23,6 @@ namespace TShockAPI public bool KickKillTileAbusers = false; public bool BanExplosives = true; public bool KickExplosives = true; + public bool SpawnProtection = true; } } diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index aacce18c..a53db9de 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -29,6 +29,7 @@ namespace TShockAPI public static bool kickTnt = false; public static bool banBoom = true; public static bool kickBoom = true; + public static bool spawnProtect = true; public enum NPCList : int { @@ -58,6 +59,7 @@ namespace TShockAPI kickTnt = cfg.KickKillTileAbusers; banBoom = cfg.BanExplosives; kickBoom = cfg.KickExplosives; + spawnProtect = cfg.SpawnProtection; } public static void WriteJsonConfiguration() @@ -87,6 +89,7 @@ namespace TShockAPI cfg.KickKillTileAbusers = true; cfg.BanExplosives = true; cfg.KickExplosives = true; + cfg.SpawnProtection = true; string json = JsonConvert.SerializeObject(cfg, Formatting.Indented); TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json"); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 9ed1bcfe..d5292119 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -137,8 +137,6 @@ namespace TShockAPI NetHooks.OnPreGetData -= GetData; NetHooks.OnGreetPlayer -= new NetHooks.GreetPlayerD(OnGreetPlayer); NpcHooks.OnStrikeNpc -= new NpcHooks.StrikeNpcD(NpcHooks_OnStrikeNpc); - ConfigurationManager.WriteJsonConfiguration(); - Log.Info("Shutting down..."); } /* @@ -178,10 +176,20 @@ namespace TShockAPI int y = br.ReadInt32(); byte typetile = br.ReadByte(); + if (type == 0 || type == 1) + if (ConfigurationManager.spawnProtect) + if (!players[e.Msg.whoAmI].IsAdmin()) + { + var flag = CheckSpawn(x, y); + if (flag) + { + Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new float[] { 255f, 0f, 0f }); + e.Handled = true; + } + } + if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active) - { players[e.Msg.whoAmI].tileThreshold++; - } } return; } @@ -332,6 +340,30 @@ namespace TShockAPI e.Handled = true; } } + else if (e.MsgID == 0x30) + { + int x; + int y; + byte liquid; + bool lava; + using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))) + { + x = br.ReadInt32(); + y = br.ReadInt32(); + liquid = br.ReadByte(); + lava = br.ReadBoolean(); + } + if (ConfigurationManager.spawnProtect) + if (!players[e.Msg.whoAmI].IsAdmin()) + { + var flag = CheckSpawn(x, y); + if (flag) + { + Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new float[] { 255f, 0f, 0f }); + e.Handled = true; + } + } + } } catch (Exception ex) { @@ -683,5 +715,16 @@ namespace TShockAPI } return false; } + + public static bool CheckSpawn(int x, int y) + { + Vector2 tile = new Vector2((float)x, (float)y); + Vector2 spawn = new Vector2((float)Main.spawnTileX, (float)Main.spawnTileY); + var distance = Vector2.Distance(spawn, tile); + if (distance > 5) + return false; + else + return true; + } } } \ No newline at end of file From 767268e1f7ffb1a0817329e2bd9b1e15b7e242d6 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sat, 4 Jun 2011 14:26:25 +0800 Subject: [PATCH 4/7] Added spawn protection radius to config. --- TShockAPI/ConfigFile.cs | 1 + TShockAPI/ConfigurationManager.cs | 3 +++ TShockAPI/TShock.cs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 72ed278c..868bcb2b 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -24,5 +24,6 @@ namespace TShockAPI public bool BanExplosives = true; public bool KickExplosives = true; public bool SpawnProtection = true; + public int SpawnProtectionRadius = 5; } } diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index a53db9de..800d03a2 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -30,6 +30,7 @@ namespace TShockAPI public static bool banBoom = true; public static bool kickBoom = true; public static bool spawnProtect = true; + public static int spawnProtectRadius = 5; public enum NPCList : int { @@ -60,6 +61,7 @@ namespace TShockAPI banBoom = cfg.BanExplosives; kickBoom = cfg.KickExplosives; spawnProtect = cfg.SpawnProtection; + spawnProtectRadius = cfg.SpawnProtectionRadius; } public static void WriteJsonConfiguration() @@ -90,6 +92,7 @@ namespace TShockAPI cfg.BanExplosives = true; cfg.KickExplosives = true; cfg.SpawnProtection = true; + cfg.SpawnProtectionRadius = 5; string json = JsonConvert.SerializeObject(cfg, Formatting.Indented); TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json"); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index d5292119..351b0faf 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -721,7 +721,7 @@ namespace TShockAPI Vector2 tile = new Vector2((float)x, (float)y); Vector2 spawn = new Vector2((float)Main.spawnTileX, (float)Main.spawnTileY); var distance = Vector2.Distance(spawn, tile); - if (distance > 5) + if (distance > (float)ConfigurationManager.spawnProtectRadius) return false; else return true; From d255fa60bf7192c95f91949289c03648ba65d448 Mon Sep 17 00:00:00 2001 From: Shank Date: Sat, 4 Jun 2011 12:41:14 -0600 Subject: [PATCH 5/7] Version tick: 1.6.0.0 --- TShockAPI/TShock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 351b0faf..9ae7be08 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -15,7 +15,7 @@ namespace TShockAPI public static string saveDir = "./tshock/"; - public static Version VersionNum = new Version(1, 5, 0, 1); + public static Version VersionNum = new Version(1, 6, 0, 0); public static bool shownVersion = false; From ea18dec85760fb3860924e37309750edf0e8d663 Mon Sep 17 00:00:00 2001 From: Shank Date: Sat, 4 Jun 2011 12:42:46 -0600 Subject: [PATCH 6/7] Change list --- release-docs/changes.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/release-docs/changes.txt b/release-docs/changes.txt index f7893fbb..bc454cba 100644 --- a/release-docs/changes.txt +++ b/release-docs/changes.txt @@ -1,6 +1,11 @@ For the full list of changes, please take a look at GitHub: https://github.com/TShock/TShock/commits/master +Changes in API release 1.6.0.0: + - Added spawn protection + - Fixed numerous bugs + - Added a few commands + Changes in API release 1.5.0.1: - Fixed cheat detection From 95c1710b55ed241d4f872c6e6ec28c0c88bbc272 Mon Sep 17 00:00:00 2001 From: Shank Date: Sat, 4 Jun 2011 13:21:40 -0600 Subject: [PATCH 7/7] Configuration now loads up prior to the files being accessed. --- TShockAPI/ConfigurationManager.cs | 4 ++++ TShockAPI/TShock.cs | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index 800d03a2..980791fc 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -66,6 +66,10 @@ namespace TShockAPI public static void WriteJsonConfiguration() { + if (!System.IO.Directory.Exists(FileTools.SaveDir)) + { + System.IO.Directory.CreateDirectory(FileTools.SaveDir); + } if (System.IO.File.Exists(FileTools.SaveDir + "config.json")) { return; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 9ae7be08..9e283a61 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -103,6 +103,14 @@ namespace TShockAPI public override void Initialize() { + try + { + FileTools.SetupConfig(); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } Log.Initialize(FileTools.SaveDir + "log.txt", LogLevel.All, true); Log.Info("Starting..."); GameHooks.OnPreInitialize += OnPreInit; @@ -471,14 +479,6 @@ namespace TShockAPI void OnPreInit() { - try - { - FileTools.SetupConfig(); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } } void OnPostInit()