From 44afc6d8ddc1b0344703e3fe3a6aa0ab015ee79d Mon Sep 17 00:00:00 2001 From: Darkvengance aka Sildaekar Date: Wed, 1 Feb 2012 12:00:31 -0600 Subject: [PATCH 1/6] Updated Local Files --- TShockAPI/Commands.cs | 8 +++++--- TShockAPI/DB/RememberPosManager.cs | 32 ++++++++++++++++++++++++------ TShockAPI/TShock.cs | 3 ++- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index ce920f03..5eb46e83 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1007,7 +1007,9 @@ namespace TShockAPI //Added restart command private static void Restart(CommandArgs args) { - + if (Main.runningMono){ + Log.ConsoleInfo("Sorry, this command has not yet been implemented in Mono"); + }else{ if (TShock.Config.ServerSideInventory) { foreach (TSPlayer player in TShock.Players) @@ -1024,7 +1026,7 @@ namespace TShockAPI Netplay.disconnect = true; System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); Environment.Exit(0); - } + }} private static void OffNoSave(CommandArgs args) { @@ -3452,4 +3454,4 @@ namespace TShockAPI #endregion Cheat Comamnds } -} \ No newline at end of file +} diff --git a/TShockAPI/DB/RememberPosManager.cs b/TShockAPI/DB/RememberPosManager.cs index 4cc4d441..50df4110 100644 --- a/TShockAPI/DB/RememberPosManager.cs +++ b/TShockAPI/DB/RememberPosManager.cs @@ -44,6 +44,28 @@ namespace TShockAPI.DB creator.EnsureExists(table); } + public Vector2 CheckLeavePos(string name) + { + try + { + using (var reader = database.QueryReader("SELECT * FROM RememberedPos WHERE Name=@0", name)) + { + if (reader.Read()) + { + return new Vector2(reader.Get("X"), reader.Get("Y")); + } + } + } + catch (Exception ex) + { + Log.Error(ex.ToString()); + } + + return new Vector2(); + } + + + public Vector2 GetLeavePos(string name, string IP) { try @@ -66,12 +88,11 @@ namespace TShockAPI.DB public void InsertLeavePos(string name, string IP, int X, int Y) { - if (GetLeavePos(name, IP) == Vector2.Zero) + if (CheckLeavePos(name) == Vector2.Zero) { try { - database.Query("INSERT INTO RememberedPos (Name, IP, X, Y, WorldID) VALUES (@0, @1, @2, @3, @4);", name, IP, X, - Y + 3, Main.worldID.ToString()); + database.Query("INSERT INTO RememberedPos (Name, IP, X, Y, WorldID) VALUES (@0, @1, @2, @3, @4);", name, IP, X, Y , Main.worldID.ToString()); } catch (Exception ex) { @@ -82,8 +103,7 @@ namespace TShockAPI.DB { try { - database.Query("UPDATE RememberedPos SET X = @0, Y = @1 WHERE Name = @2 AND IP = @3 AND WorldID = @4;", X, Y + 3, - name, IP, Main.worldID.ToString()); + database.Query("UPDATE RememberedPos SET X = @0, Y = @1, IP = @2 WHERE Name = @3 AND WorldID = @4;", X, Y, IP, name, Main.worldID.ToString()); } catch (Exception ex) { @@ -92,4 +112,4 @@ namespace TShockAPI.DB } } } -} \ No newline at end of file +} diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index eec78456..2f4394e8 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -854,10 +854,11 @@ namespace TShockAPI if (Config.RememberLeavePos) { + if (RememberedPos.GetLeavePos(player.Name, player.IP) != Vector2.Zero){ var pos = RememberedPos.GetLeavePos(player.Name, player.IP); player.LastNetPosition = pos; player.Teleport((int) pos.X, (int) pos.Y + 3); - } + }} e.Handled = true; } From 5a6b59cbad23d66f504ab792d299b098920b1811 Mon Sep 17 00:00:00 2001 From: Darkvengance aka Sildaekar Date: Wed, 1 Feb 2012 13:44:05 -0600 Subject: [PATCH 2/6] Added removespecial command --- TShockAPI/Commands.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 5eb46e83..05adacb6 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -215,6 +215,7 @@ namespace TShockAPI add(Permissions.cfg, WorldInfo, "world"); add(Permissions.converthardmode, ConvertCorruption, "convertcorruption"); add(Permissions.converthardmode, ConvertHallow, "converthallow"); + add(Permissions.converthardmode, RemoveSpecial, "removespecial"); } public static bool HandleCommand(TSPlayer player, string text) @@ -1488,6 +1489,45 @@ namespace TShockAPI TShock.Utils.Broadcast("Hallow conversion done."); } + private static void RemoveSpecial(CommandArgs args) + { + TShock.Utils.Broadcast("Server may lag for a moment.", Color.Red); + for (int x = 0; x < Main.maxTilesX; x++) + { + for (int y = 0; y < Main.maxTilesY; y++) + { + switch (Main.tile[x, y].type) + { + case 22: + case 117: + case 25: + Main.tile[x, y].type = 1; + break; + case 109: + case 23: + Main.tile[x, y].type = 2; + break; + case 32: + Main.tile[x, y].type = 0; + Main.tile[x, y].active = false; + break; + case 24: + Main.tile[x, y].type = 3; + break; + case 112: + case 116: + Main.tile[x, y].type = 169; + break; + default: + continue; + } + } + } + WorldGen.CountTiles(0); + TSPlayer.All.SendData(PacketTypes.UpdateGoodEvil); + Netplay.ResetSections(); + TShock.Utils.Broadcast("Special tile conversion done."); + } #endregion Cause Events and Spawn Monsters Commands #region Teleport Commands From accdb03d191d97342ef15e8554b9afb28fa346d3 Mon Sep 17 00:00:00 2001 From: Darkvengance aka Sildaekar Date: Wed, 1 Feb 2012 13:48:56 -0600 Subject: [PATCH 3/6] Removed demonite ore from the "removespecial" and "convertcorruption" commands. --- TShockAPI/Commands.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 05adacb6..3b1dfb1b 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1432,7 +1432,6 @@ namespace TShockAPI { switch (Main.tile[x, y].type) { - case 22: case 25: Main.tile[x, y].type = 117; break; @@ -1498,7 +1497,6 @@ namespace TShockAPI { switch (Main.tile[x, y].type) { - case 22: case 117: case 25: Main.tile[x, y].type = 1; From 99fb24c82accb291bf733b4ec21b40a6f99fd351 Mon Sep 17 00:00:00 2001 From: Darkvengance aka Sildaekar Date: Wed, 1 Feb 2012 14:55:41 -0600 Subject: [PATCH 4/6] removespecial now removes pearlstone bricks --- TShockAPI/Commands.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 3b1dfb1b..9f28db34 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1516,6 +1516,9 @@ namespace TShockAPI case 116: Main.tile[x, y].type = 169; break; + case 113: + Main.tile[x, y].type = 38; + break; default: continue; } From da87682719e8e97aac73d62df676c1df22753ccf Mon Sep 17 00:00:00 2001 From: Darkvengance aka Sildaekar Date: Wed, 1 Feb 2012 14:59:25 -0600 Subject: [PATCH 5/6] removespecial now removes pearlstone bricks --- TShockAPI/Commands.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 3b1dfb1b..0667a7d6 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1516,6 +1516,9 @@ namespace TShockAPI case 116: Main.tile[x, y].type = 169; break; + case 118: + Main.tile[x, y].type = 38; + break; default: continue; } From 9d18ab3ce028792d265ac9de19608890b49b0752 Mon Sep 17 00:00:00 2001 From: Darkvengance aka Sildaekar Date: Wed, 1 Feb 2012 15:14:04 -0600 Subject: [PATCH 6/6] pearlstone brick now changed to grey brick --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 0667a7d6..9f28db34 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1516,7 +1516,7 @@ namespace TShockAPI case 116: Main.tile[x, y].type = 169; break; - case 118: + case 113: Main.tile[x, y].type = 38; break; default: