diff --git a/DBEditor/CommandList.cs b/DBEditor/CommandList.cs index 50fd8003..c49c067c 100644 --- a/DBEditor/CommandList.cs +++ b/DBEditor/CommandList.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/DbExt.cs b/DBEditor/DbExt.cs index 112d5161..226a8971 100644 --- a/DBEditor/DbExt.cs +++ b/DBEditor/DbExt.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/Group.cs b/DBEditor/Group.cs index 8dd3f44e..581b90ca 100644 --- a/DBEditor/Group.cs +++ b/DBEditor/Group.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/Itemlist.cs b/DBEditor/Itemlist.cs index f73a51f8..e3372fd8 100644 --- a/DBEditor/Itemlist.cs +++ b/DBEditor/Itemlist.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/Main.Designer.cs b/DBEditor/Main.Designer.cs index 38128155..a5824913 100644 --- a/DBEditor/Main.Designer.cs +++ b/DBEditor/Main.Designer.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/Main.cs b/DBEditor/Main.cs index b0afd2ed..81d21f04 100644 --- a/DBEditor/Main.cs +++ b/DBEditor/Main.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/Program.cs b/DBEditor/Program.cs index 87c58708..e0f7ef00 100644 --- a/DBEditor/Program.cs +++ b/DBEditor/Program.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/Properties/AssemblyInfo.cs b/DBEditor/Properties/AssemblyInfo.cs index c8be0e19..80567a20 100644 --- a/DBEditor/Properties/AssemblyInfo.cs +++ b/DBEditor/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/Properties/Resources.Designer.cs b/DBEditor/Properties/Resources.Designer.cs index 2ec43f10..ef2100a0 100644 --- a/DBEditor/Properties/Resources.Designer.cs +++ b/DBEditor/Properties/Resources.Designer.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/Properties/Settings.Designer.cs b/DBEditor/Properties/Settings.Designer.cs index d6ca6768..0288467b 100644 --- a/DBEditor/Properties/Settings.Designer.cs +++ b/DBEditor/Properties/Settings.Designer.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/DBEditor/TShockDBEditor.licenseheader b/DBEditor/TShockDBEditor.licenseheader index 32579142..12ed0ea9 100644 --- a/DBEditor/TShockDBEditor.licenseheader +++ b/DBEditor/TShockDBEditor.licenseheader @@ -1,7 +1,7 @@ extensions: .cs /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/LuaBins/LuaInterface.dll b/LuaBins/LuaInterface.dll deleted file mode 100644 index 5e0b7b10..00000000 Binary files a/LuaBins/LuaInterface.dll and /dev/null differ diff --git a/LuaBins/lua51.dll b/LuaBins/lua51.dll deleted file mode 100644 index 86d15597..00000000 Binary files a/LuaBins/lua51.dll and /dev/null differ diff --git a/LuaBins/luanet.dll b/LuaBins/luanet.dll deleted file mode 100644 index 2772ba4b..00000000 Binary files a/LuaBins/luanet.dll and /dev/null differ diff --git a/TShockAPI/BackupManager.cs b/TShockAPI/BackupManager.cs index b871c6c1..bb51336e 100644 --- a/TShockAPI/BackupManager.cs +++ b/TShockAPI/BackupManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs old mode 100755 new mode 100644 index b0c6e68e..7238528f --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -135,7 +135,6 @@ namespace TShockAPI add(Permissions.maintenance, CheckUpdates, "checkupdates"); add(Permissions.causeevents, DropMeteor, "dropmeteor"); add(Permissions.causeevents, Star, "star"); - add(Permissions.causeevents, Ore, "genore"); add(Permissions.causeevents, Fullmoon, "fullmoon"); add(Permissions.causeevents, Bloodmoon, "bloodmoon"); add(Permissions.causeevents, Invade, "invade"); @@ -182,7 +181,7 @@ namespace TShockAPI add(Permissions.manageregion, Region, "region"); add(Permissions.manageregion, DebugRegions, "debugreg"); add(null, Help, "help"); - add(null, Playing, "playing", "online", "who", "version"); + add(null, ListConnectedPlayers, "playing", "online", "who", "version"); add(null, AuthToken, "auth"); add(Permissions.cantalkinthird, ThirdPerson, "me"); add(Permissions.canpartychat, PartyChat, "p"); @@ -193,7 +192,7 @@ namespace TShockAPI ChatCommands.Add(new Command(Permissions.canchangepassword, PasswordUser, "password") {DoLog = false}); ChatCommands.Add(new Command(Permissions.canregister, RegisterUser, "register") {DoLog = false}); ChatCommands.Add(new Command(Permissions.rootonly, ManageUsers, "user") {DoLog = false}); - add(Permissions.rootonly, GrabUserUserInfo, "userinfo", "ui"); + add(Permissions.userinfo, GrabUserUserInfo, "userinfo", "ui"); add(Permissions.rootonly, AuthVerify, "auth-verify"); ChatCommands.Add(new Command(Permissions.canlogin, AttemptLogin, "login") {DoLog = false}); add(Permissions.cfg, Broadcast, "broadcast", "bc", "say"); @@ -216,6 +215,8 @@ namespace TShockAPI add(Permissions.converthardmode, ConvertCorruption, "convertcorruption"); add(Permissions.converthardmode, ConvertHallow, "converthallow"); add(Permissions.converthardmode, RemoveSpecial, "removespecial"); + add(Permissions.savessi, SaveSSI, "savessi"); + add(Permissions.savessi, OverrideSSI, "overridessi", "ossi"); } public static bool HandleCommand(TSPlayer player, string text) @@ -877,7 +878,7 @@ namespace TShockAPI var ban = TShock.Bans.GetBanByName(plStr); if (ban != null) { - if (TShock.Bans.RemoveBan(ban.IP, true)) + if (TShock.Bans.RemoveBan(ban.Name, true)) args.Player.SendMessage(string.Format("Unbanned {0} ({1})!", ban.Name, ban.IP), Color.Red); else args.Player.SendMessage(string.Format("Failed to unban {0} ({1})!", ban.Name, ban.IP), Color.Red); @@ -976,6 +977,48 @@ namespace TShockAPI args.Player.SendMessage("You now " + (args.Player.DisplayLogs ? "receive" : "stopped receiving") + " logs"); } + public static void SaveSSI(CommandArgs args ) + { + if (TShock.Config.ServerSideInventory) + { + args.Player.SendMessage("SSI has been saved.", Color.Green); + foreach (TSPlayer player in TShock.Players) + { + if (player != null && player.IsLoggedIn && !player.IgnoreActionsForClearingTrashCan) + { + TShock.InventoryDB.InsertPlayerData(player); + } + } + } + } + + public static void OverrideSSI( CommandArgs args ) + { + if( args.Parameters.Count < 1 ) + { + args.Player.SendMessage("Correct usage: /overridessi(/ossi) ", Color.Red); + return; + } + + var players = TShock.Utils.FindPlayer(args.Parameters[0]); + if( players.Count < 1 ) + { + args.Player.SendMessage("No players match " + args.Parameters[0], Color.Red); + } + else if( players.Count > 1 ) + { + args.Player.SendMessage( players.Count + " players matched " + args.Parameters[0], Color.Red); + } + else if (TShock.Config.ServerSideInventory) + { + if( players[0] != null && players[0].IsLoggedIn && !players[0].IgnoreActionsForClearingTrashCan) + { + args.Player.SendMessage( players[0].Name + " has been exempted and updated.", Color.Green); + TShock.InventoryDB.InsertPlayerData(players[0]); + } + } + } + #endregion Player Management Commands #region Server Maintenence Commands @@ -1002,12 +1045,13 @@ namespace TShockAPI { if (player != null && player.IsLoggedIn && !player.IgnoreActionsForClearingTrashCan) { - TShock.InventoryDB.InsertPlayerData(player); + player.SaveServerInventory(); } } } - TShock.Utils.StopServer(); + string reason = ((args.Parameters.Count > 0) ? "Server shutting down: " + String.Join(" ", args.Parameters) : "Server shutting down!"); + TShock.Utils.StopServer(true, reason); } //Added restart command private static void Restart(CommandArgs args) @@ -1029,7 +1073,8 @@ namespace TShockAPI } } - TShock.Utils.StopServer(); + string reason = ((args.Parameters.Count > 0) ? "Server shutting down: " + String.Join(" ", args.Parameters) : "Server shutting down!"); + TShock.Utils.StopServer(true, reason); System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); Environment.Exit(0); } @@ -1037,7 +1082,8 @@ namespace TShockAPI private static void OffNoSave(CommandArgs args) { - TShock.Utils.StopServer(false); + string reason = ((args.Parameters.Count > 0) ? "Server shutting down: " + String.Join(" ", args.Parameters) : "Server shutting down!"); + TShock.Utils.StopServer(false, reason); } private static void CheckUpdates(CommandArgs args) @@ -1071,181 +1117,6 @@ namespace TShockAPI Projectile.NewProjectile(vector.X, vector.Y, speedX, speedY, 12, 0x3e8, 10f, Main.myPlayer); } - private static void Ore(CommandArgs args) - { - if (WorldGen.genRand == null) - WorldGen.genRand = new Random(); - - TSPlayer ply = args.Player; - - - - int num = WorldGen.altarCount % 3; - int num2 = WorldGen.altarCount / 3 + 1; - float num3 = (float)(Main.maxTilesX / 4200); - int num4 = 1 - num; - num3 = num3 * 310f - (float)(85 * num); - num3 *= 0.85f; - num3 /= (float)num2; - - if (args.Parameters.Count < 1) - { - ply.SendMessage("Picking a random ore!", Color.Green); //should this be a help message instead? - num = WorldGen.genRand.Next(6); - } - else if (args.Parameters[0] == "cobalt") - { - num = 0; - } - else if (args.Parameters[0] == "mythril") - { - num = 1; - } - else if (args.Parameters[0] == "copper") - { - num = 3; - } - else if (args.Parameters[0] == "iron") - { - num = 4; - } - else if (args.Parameters[0] == "silver") - { - num = 6; - } - else if (args.Parameters[0] == "gold") - { - num = 5; - } - else if (args.Parameters[0] == "demonite") - { - num = 7; - } - else if (args.Parameters[0] == "sapphire") - { - num = 8; - } - else if (args.Parameters[0] == "ruby") - { - num = 9; - } - else if (args.Parameters[0] == "emerald") - { - num = 10; - } - else if (args.Parameters[0] == "topaz") - { - num = 11; - } - else if (args.Parameters[0] == "amethyst") - { - num = 12; - } - else if (args.Parameters[0] == "diamond") - { - num = 13; - } - else - { - num = 2; - } - - if (num == 0) - { - num = 107; - num3 *= 1.05f; - } - else if (num == 1) - { - num = 108; - } - else if (num == 3) - { - num = 7; - num3 *= 1.1f; - } - else if (num == 4) - { - num = 6; - num3 *= 1.1f; - } - else if (num == 5) - { - num = 8; - num3 *= 1.1f; - } - else if (num == 6) - { - num = 9; - num3 *= 1.1f; - } - else if (num == 7) - { - num = 22; - num3 *= 1; - } - else if (num == 8) - { - num = 63; - num3 *= .80f; - } - else if (num == 9) - { - num = 64; - num3 *=1; - } - else if (num == 10) - { - num = 65; - num3 *= 1; - } - else if (num == 11) - { - num = 66; - num3 *= 1; - } - else if (num == 12) - { - num = 67; - num3 *= 1; - } - else if (num == 13) - { - num = 68; - num3 *= 1; - } - else - { - num = 111; - } - - - if (args.Parameters.Count > 1) - { - float.TryParse(args.Parameters[1], out num3); - num3 = Math.Min(num3, 1000f); - } - - int num5 = 0; - while ((float)num5 < num3) - { - int i2 = WorldGen.genRand.Next(100, Main.maxTilesX - 100); - double num6 = Main.worldSurface; - if ((num == 108) || (num == 6) || (num == 7) || (num == 8) || (num == 9) ||((num > 62) && (num < 69))) - { - num6 = Main.rockLayer; - } - if ((num == 111) || (num == 22) || (num == 68)) - { - num6 = (Main.rockLayer + Main.rockLayer + (double)Main.maxTilesY) / 3.0; - } - int j2 = WorldGen.genRand.Next((int)num6, Main.maxTilesY - 150); - WorldGen.OreRunner(i2, j2, (double)WorldGen.genRand.Next(5, 9 + num4), WorldGen.genRand.Next(5, 9 + num4), num); - num5++; - } - ply.SendMessage(String.Format("Spawned {0} tiles of {1}", Math.Floor(num3), num), Color.Green ); - } - private static void Fullmoon(CommandArgs args) { TSPlayer.Server.SetFullMoon(true); @@ -1984,16 +1855,42 @@ namespace TShockAPI String groupname = args.Parameters[0]; args.Parameters.RemoveAt(0); + string response = ""; if (com.Equals("add")) { - String response = TShock.Groups.AddPermissions(groupname, args.Parameters); + if( groupname == "*" ) + { + int count = 0; + foreach( Group g in TShock.Groups ) + { + response = TShock.Groups.AddPermissions(g.Name, args.Parameters); + if (!response.StartsWith("Error:")) + count++; + } + args.Player.SendMessage(String.Format("{0} groups were modified.", count ), Color.Green ); + return; + } + response = TShock.Groups.AddPermissions(groupname, args.Parameters); if (response.Length > 0) args.Player.SendMessage(response, Color.Green); return; } - else if (com.Equals("del") || com.Equals("delete")) - { - String response = TShock.Groups.DeletePermissions(groupname, args.Parameters); + + if (com.Equals("del") || com.Equals("delete")) + { + if (groupname == "*") + { + int count = 0; + foreach (Group g in TShock.Groups) + { + response = TShock.Groups.DeletePermissions(g.Name, args.Parameters); + if (!response.StartsWith("Error:")) + count++; + } + args.Player.SendMessage(String.Format("{0} groups were modified.", count), Color.Green); + return; + } + response = TShock.Groups.DeletePermissions(groupname, args.Parameters); if (response.Length > 0) args.Player.SendMessage(response, Color.Green); return; @@ -2285,6 +2182,10 @@ namespace TShockAPI private static void Save(CommandArgs args) { SaveManager.Instance.SaveWorld(false); + foreach (TSPlayer tsply in TShock.Players) + { + tsply.SaveServerInventory(); + } } private static void Settle(CommandArgs args) @@ -2813,6 +2714,26 @@ namespace TShockAPI break; } + case "z": + { + if (args.Parameters.Count == 3) + { + string regionName = args.Parameters[1]; + int z = 0; + if (int.TryParse(args.Parameters[2], out z ) ) + { + if (TShock.Regions.SetZ(regionName, z)) + args.Player.SendMessage("Region's z is now " + z, Color.Yellow); + else + args.Player.SendMessage("Could not find specified region", Color.Red); + } + else + args.Player.SendMessage("Invalid syntax! Proper syntax: /region z [name] [#]", Color.Red); + } + else + args.Player.SendMessage("Invalid syntax! Proper syntax: /region z [name] [#]", Color.Red); + break; + } case "resize": case "expand": { @@ -2930,7 +2851,7 @@ namespace TShockAPI } } - private static void Playing(CommandArgs args) + private static void ListConnectedPlayers(CommandArgs args) { string response = args.Player.Group.HasPermission(Permissions.seeids) ? TShock.Utils.GetPlayersWithIds() @@ -3190,20 +3111,20 @@ namespace TShockAPI private static void Butcher(CommandArgs args) { - if (args.Parameters.Count > 1) + if (args.Parameters.Count > 2) { - args.Player.SendMessage("Invalid syntax! Proper syntax: /butcher [killFriendly(true/false)]", Color.Red); + args.Player.SendMessage("Invalid syntax! Proper syntax: /butcher [killTownNPCs(true/false)]", Color.Red); return; } - bool killFriendly = true; - if (args.Parameters.Count == 1) - bool.TryParse(args.Parameters[0], out killFriendly); + bool killTownNPCs = false; + if (args.Parameters.Count == 2) + bool.TryParse(args.Parameters[1], out killTownNPCs); int killcount = 0; for (int i = 0; i < Main.npc.Length; i++) { - if (Main.npc[i].active && Main.npc[i].type != 0 && !Main.npc[i].townNPC && (!Main.npc[i].friendly || killFriendly)) + if (Main.npc[i].active && Main.npc[i].type != 0 && (!Main.npc[i].townNPC || killTownNPCs)) { TSPlayer.Server.StrikeNPC(i, 99999, 90f, 1); killcount++; @@ -3211,7 +3132,7 @@ namespace TShockAPI } TShock.Utils.Broadcast(string.Format("Killed {0} NPCs.", killcount)); } - + private static void Item(CommandArgs args) { if (args.Parameters.Count < 1) @@ -3254,8 +3175,14 @@ namespace TShockAPI { if (itemAmount == 0 || itemAmount > item.maxStack) itemAmount = item.maxStack; - args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix); - args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name)); + if (args.Player.GiveItemCheck(item.type, item.name, item.width, item.height, itemAmount, prefix)) + { + args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name)); + } + else + { + args.Player.SendMessage("The item is banned and the config prevents you from spawning banned items.", Color.Red); + } } else { @@ -3332,9 +3259,16 @@ namespace TShockAPI { if (itemAmount == 0 || itemAmount > item.maxStack) itemAmount = item.maxStack; - plr.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix); - args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount, item.name)); - plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name)); + if (plr.GiveItemCheck(item.type, item.name, item.width, item.height, itemAmount, prefix)) + { + args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount, item.name)); + plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name)); + } + else + { + args.Player.SendMessage("The item is banned and the config prevents spawning banned items.", Color.Red); + } + } else { diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index d03ff4f7..858210ca 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -118,6 +118,8 @@ namespace TShockAPI [Description("String that is used when kicking people when the server is full.")] public string ServerFullReason = "Server is full"; + [Description("String that is used when a user is kicked due to not being on the whitelist.")] public string WhitelistKickReason = "You are not on the whitelist."; + [Description("String that is used when kicking people when the server is full with no reserved slots.")] public string ServerFullNoReservedReason = "Server is full. No reserved slots open."; @@ -214,7 +216,21 @@ namespace TShockAPI [Description("Allow Ice placement even when user does not have canbuild")] public bool AllowIce = false; - public static ConfigFile Read(string path) + [Description("Allows corrutption to spread when a world is hardmode.")] public bool AllowCorruptionCreep = true; + + [Description("Allows hallow to spread when a world is hardmode.")] public bool AllowHallowCreep = true; + + [Description("How many things a statue can spawn within 200 pixels(?) before it stops spawning. Default = 3")] public int StatueSpawn200 = 3; + + [Description("How many things a statue can spawn within 600 pixels(?) before it stops spawning. Default = 6")] public int StatueSpawn600 = 6; + + [Description("How many things a statue spawns can exist in the world before it stops spawning. Default = 10")] public int StatueSpawnWorld = 10; + + [Description("Prevent banned items from being /i or /give")] public bool PreventBannedItemSpawn = false; + + [Description("Prevent banks on SSI")] public bool DisablePiggybanksOnSSI = false; + + public static ConfigFile Read(string path) { if (!File.Exists(path)) return new ConfigFile(); diff --git a/TShockAPI/DB/BanManager.cs b/TShockAPI/DB/BanManager.cs index d00e8264..7ace1584 100644 --- a/TShockAPI/DB/BanManager.cs +++ b/TShockAPI/DB/BanManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/GroupManager.cs b/TShockAPI/DB/GroupManager.cs index 573f7ac7..de3f0db4 100644 --- a/TShockAPI/DB/GroupManager.cs +++ b/TShockAPI/DB/GroupManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/IQueryBuilder.cs b/TShockAPI/DB/IQueryBuilder.cs index b5f84105..2d4a8662 100644 --- a/TShockAPI/DB/IQueryBuilder.cs +++ b/TShockAPI/DB/IQueryBuilder.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/InventoryManager.cs b/TShockAPI/DB/InventoryManager.cs index 65b192bc..92f8a6bf 100644 --- a/TShockAPI/DB/InventoryManager.cs +++ b/TShockAPI/DB/InventoryManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/ItemManager.cs b/TShockAPI/DB/ItemManager.cs index 0ab9a539..6ef11b6b 100644 --- a/TShockAPI/DB/ItemManager.cs +++ b/TShockAPI/DB/ItemManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs index c384cf66..b3eef5fe 100644 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +46,8 @@ namespace TShockAPI.DB new SqlColumn("UserIds", MySqlDbType.Text), new SqlColumn("Protected", MySqlDbType.Int32), new SqlColumn("Groups", MySqlDbType.Text), - new SqlColumn("Owner", MySqlDbType.VarChar, 50) + new SqlColumn("Owner", MySqlDbType.VarChar, 50), + new SqlColumn("Z", MySqlDbType.Int32){ DefaultValue = "0" } ); var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite @@ -75,10 +76,11 @@ namespace TShockAPI.DB string name = reader.Get("RegionName"); string owner = reader.Get("Owner"); string groups = reader.Get("Groups"); + int z = reader.Get("Z"); string[] splitids = mergedids.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); - Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString()); + Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString(), z); r.SetAllowedGroups(groups); try { @@ -127,8 +129,9 @@ namespace TShockAPI.DB string[] SplitIDs = MergedIDs.Split(','); string owner = reader.Get("Owner"); string groups = reader.Get("Groups"); + int z = reader.Get("Z"); - Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString()); + Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString(), z); r.SetAllowedGroups(groups); try { @@ -156,7 +159,7 @@ namespace TShockAPI.DB } } - public bool AddRegion(int tx, int ty, int width, int height, string regionname, string owner, string worldid) + public bool AddRegion(int tx, int ty, int width, int height, string regionname, string owner, string worldid, int z = 0) { if (GetRegionByName(regionname) != null) { @@ -165,9 +168,9 @@ namespace TShockAPI.DB try { database.Query( - "INSERT INTO Regions (X1, Y1, width, height, RegionName, WorldID, UserIds, Protected, Groups, Owner) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9);", - tx, ty, width, height, regionname, worldid, "", 1, "", owner); - Regions.Add(new Region(new Rectangle(tx, ty, width, height), regionname, owner, true, worldid)); + "INSERT INTO Regions (X1, Y1, width, height, RegionName, WorldID, UserIds, Protected, Groups, Owner, Z) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10);", + tx, ty, width, height, regionname, worldid, "", 1, "", owner, z); + Regions.Add(new Region(new Rectangle(tx, ty, width, height), regionname, owner, true, worldid, z)); return true; } catch (Exception ex) @@ -234,14 +237,21 @@ namespace TShockAPI.DB { return false; } + Region top = null; for (int i = 0; i < Regions.Count; i++) { - if (Regions[i].InArea(x,y) && !Regions[i].HasPermissionToBuildInRegion(ply)) + if (Regions[i].InArea(x,y) ) { - return false; + if (top == null) + top = Regions[i]; + else + { + if (Regions[i].Z > top.Z) + top = Regions[i]; + } } } - return true; + return top == null || top.HasPermissionToBuildInRegion(ply); } public bool InArea(int x, int y) @@ -490,6 +500,41 @@ namespace TShockAPI.DB } return false; } + + public Region GetTopRegion( List regions ) + { + Region ret = null; + foreach( Region r in regions) + { + if (ret == null) + ret = r; + else + { + if (r.Z > ret.Z) + ret = r; + } + } + return ret; + } + + public bool SetZ( string name, int z ) + { + try + { + database.Query("UPDATE Regions SET Z=@0 WHERE RegionName=@1 AND WorldID=@2", z, name, + Main.worldID.ToString()); + + var region = GetRegionByName(name); + if (region != null) + region.Z = z; + return true; + } + catch (Exception ex) + { + Log.Error(ex.ToString()); + return false; + } + } } public class Region @@ -501,8 +546,9 @@ namespace TShockAPI.DB public string WorldID { get; set; } public List AllowedIDs { get; set; } public List AllowedGroups { get; set; } + public int Z { get; set; } - public Region(Rectangle region, string name, string owner, bool disablebuild, string RegionWorldIDz) + public Region(Rectangle region, string name, string owner, bool disablebuild, string RegionWorldIDz, int z) : this() { Area = region; @@ -510,6 +556,7 @@ namespace TShockAPI.DB Owner = owner; DisableBuild = disablebuild; WorldID = RegionWorldIDz; + Z = z; } public Region() @@ -520,6 +567,7 @@ namespace TShockAPI.DB WorldID = string.Empty; AllowedIDs = new List(); AllowedGroups = new List(); + Z = 0; } public bool InArea(Rectangle point) diff --git a/TShockAPI/DB/RememberPosManager.cs b/TShockAPI/DB/RememberPosManager.cs index 429437ea..ee06db63 100644 --- a/TShockAPI/DB/RememberPosManager.cs +++ b/TShockAPI/DB/RememberPosManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -52,7 +52,14 @@ namespace TShockAPI.DB { if (reader.Read()) { - return new Vector2(reader.Get("X"), reader.Get("Y")); + int checkX=reader.Get("X"); + int checkY=reader.Get("Y"); + //fix leftover inconsistancies + if (checkX==0) + checkX++; + if (checkY==0) + checkY++; + return new Vector2(checkX, checkY); } } } @@ -92,6 +99,7 @@ namespace TShockAPI.DB { try { + if ((X != 0) && ( Y !=0)) //invalid pos! 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) @@ -103,6 +111,7 @@ namespace TShockAPI.DB { try { + if ((X != 0) && ( Y !=0)) //invalid pos! 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) diff --git a/TShockAPI/DB/SqlColumn.cs b/TShockAPI/DB/SqlColumn.cs index 75860f79..efc94649 100644 --- a/TShockAPI/DB/SqlColumn.cs +++ b/TShockAPI/DB/SqlColumn.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/SqlTable.cs b/TShockAPI/DB/SqlTable.cs index ce3b527a..0b4024c6 100644 --- a/TShockAPI/DB/SqlTable.cs +++ b/TShockAPI/DB/SqlTable.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/SqlValue.cs b/TShockAPI/DB/SqlValue.cs index 35f998b6..0efd78bf 100644 --- a/TShockAPI/DB/SqlValue.cs +++ b/TShockAPI/DB/SqlValue.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index 68ade122..db360518 100644 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/WarpsManager.cs b/TShockAPI/DB/WarpsManager.cs index 1627a15c..67d1afe8 100644 --- a/TShockAPI/DB/WarpsManager.cs +++ b/TShockAPI/DB/WarpsManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Extensions/DbExt.cs b/TShockAPI/Extensions/DbExt.cs index 4cc774d0..42bcc6f1 100644 --- a/TShockAPI/Extensions/DbExt.cs +++ b/TShockAPI/Extensions/DbExt.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Extensions/LinqExt.cs b/TShockAPI/Extensions/LinqExt.cs index 15b26fbf..25d06b7e 100644 --- a/TShockAPI/Extensions/LinqExt.cs +++ b/TShockAPI/Extensions/LinqExt.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Extensions/RandomExt.cs b/TShockAPI/Extensions/RandomExt.cs index 1c702af2..2e4d2681 100644 --- a/TShockAPI/Extensions/RandomExt.cs +++ b/TShockAPI/Extensions/RandomExt.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Extensions/StringExt.cs b/TShockAPI/Extensions/StringExt.cs index 95f3f20c..e70be35b 100644 --- a/TShockAPI/Extensions/StringExt.cs +++ b/TShockAPI/Extensions/StringExt.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/FileTools.cs b/TShockAPI/FileTools.cs index ac4dfd31..b353bf9a 100644 --- a/TShockAPI/FileTools.cs +++ b/TShockAPI/FileTools.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/GeoIPCountry.cs b/TShockAPI/GeoIPCountry.cs index 445b348a..c09ccffc 100644 --- a/TShockAPI/GeoIPCountry.cs +++ b/TShockAPI/GeoIPCountry.cs @@ -19,7 +19,7 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index bb595a5c..46d7e92f 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -472,11 +472,19 @@ namespace TShockAPI { num4 = Main.maxTilesY; } + for (int c = num; c < num2; c++) + { + for (int d = num3; d< num4; d++) + { + if (Main.tile[c,d].liquid != 0) + return false; + } + } for (int i = num; i < num2; i++) { for (int j = num3; j < num4; j++) { - if (Main.tile[i, j] != null && Main.tile[i, j].active && Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type] &&(((int)Main.tile[i,j].type !=53) && ((int)Main.tile[i,j].type !=112) && ((int)Main.tile[i,j].type !=116) && ((int)Main.tile[i,j].type !=123)) && ((Main.tile[i,j].liquid == 0 )&& !Main.tile[i,j].lava)) + if (Main.tile[i, j] != null && Main.tile[i, j].active && Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type] &&(((int)Main.tile[i,j].type !=53) && ((int)Main.tile[i,j].type !=112) && ((int)Main.tile[i,j].type !=116) && ((int)Main.tile[i,j].type !=123)) && !Main.tile[i,j].lava) { Vector2 vector; vector.X = (float)(i * 16); @@ -1214,7 +1222,7 @@ namespace TShockAPI if (max > 400 && max > args.Player.FirstMaxHP) { - TShock.Utils.ForceKick(args.Player, "Hacked Client Detected."); + TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.", true); return false; } @@ -1240,7 +1248,7 @@ namespace TShockAPI if (max > 400 && max > args.Player.FirstMaxMP) { - TShock.Utils.ForceKick(args.Player, "Hacked Client Detected."); + TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.", true); return false; } @@ -1258,7 +1266,7 @@ namespace TShockAPI if (OnPlayerInfo(playerid, hair, male, difficulty, name)) { - TShock.Utils.ForceKick(args.Player, "A plugin cancelled the event."); + TShock.Utils.ForceKick(args.Player, "A plugin cancelled the event.", true); return true; } @@ -1269,13 +1277,13 @@ namespace TShockAPI }*/ if (name.Trim().Length == 0) { - TShock.Utils.ForceKick(args.Player, "Empty Name."); + TShock.Utils.ForceKick(args.Player, "Empty Name.", true); return true; } var ban = TShock.Bans.GetBanByName(name); if (ban != null) { - TShock.Utils.ForceKick(args.Player, string.Format("You are banned: {0}", ban.Reason)); + TShock.Utils.ForceKick(args.Player, string.Format("You are banned: {0}", ban.Reason), true); return true; } if (args.Player.ReceivedInfo) @@ -1284,12 +1292,12 @@ namespace TShockAPI } if (TShock.Config.MediumcoreOnly && difficulty < 1) { - TShock.Utils.ForceKick(args.Player, "Server is set to mediumcore and above characters only!"); + TShock.Utils.ForceKick(args.Player, "Server is set to mediumcore and above characters only!", true); return true; } if (TShock.Config.HardcoreOnly && difficulty < 2) { - TShock.Utils.ForceKick(args.Player, "Server is set to hardcore characters only!"); + TShock.Utils.ForceKick(args.Player, "Server is set to hardcore characters only!", true); return true; } args.Player.Difficulty = difficulty; @@ -1328,7 +1336,7 @@ namespace TShockAPI string password = Encoding.UTF8.GetString(args.Data.ReadBytes((int) (args.Data.Length - args.Data.Position - 1))); var user = TShock.Users.GetUserByName(args.Player.Name); - if (user != null) + if (user != null && !TShock.Config.DisableLoginBeforeJoin) { string encrPass = TShock.Utils.HashPassword(password); if (user.Password.ToUpper() == encrPass.ToUpper()) @@ -1390,11 +1398,11 @@ namespace TShockAPI NetMessage.SendData((int) PacketTypes.WorldInfo, args.Player.Index); return true; } - TShock.Utils.ForceKick(args.Player, "Incorrect Server Password"); + TShock.Utils.ForceKick(args.Player, "Incorrect Server Password", true); return true; } - TShock.Utils.ForceKick(args.Player, "Bad Password Attempt"); + TShock.Utils.ForceKick(args.Player, "Bad Password Attempt", true); return true; } @@ -1406,7 +1414,7 @@ namespace TShockAPI args.Player.RequestedSection = true; if (TShock.HackedHealth(args.Player) && !args.Player.Group.HasPermission(Permissions.ignorestathackdetection)) { - TShock.Utils.ForceKick(args.Player, "You have Hacked Health/Mana, Please use a different character."); + TShock.Utils.ForceKick(args.Player, "You have Hacked Health/Mana, Please use a different character.", true); } if (!args.Player.Group.HasPermission(Permissions.ignorestackhackdetection)) @@ -1417,8 +1425,7 @@ namespace TShockAPI if (TShock.Utils.ActivePlayers() + 1 > TShock.Config.MaxSlots && !args.Player.Group.HasPermission(Permissions.reservedslot)) { - args.Player.SilentKickInProgress = true; - TShock.Utils.ForceKick(args.Player, TShock.Config.ServerFullReason); + TShock.Utils.ForceKick(args.Player, TShock.Config.ServerFullReason, true); return true; } @@ -1675,29 +1682,29 @@ namespace TShockAPI { return true; } - if (tiletype == 29 && tiletype == 97 && TShock.Config.ServerSideInventory) + if ((tiletype == 29 || tiletype == 97) && TShock.Config.ServerSideInventory && TShock.Config.DisablePiggybanksOnSSI) { - args.Player.SendMessage("You cannot place this tile, Server side inventory is enabled.", Color.Red); + args.Player.SendMessage("You cannot place this tile, server side inventory is enabled.", Color.Red); args.Player.SendTileSquare(tileX, tileY); return true; } if (tiletype == 48 && !args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned("Spike", args.Player)) { - args.Player.Disable("Using banned spikes without permissions"); + args.Player.Disable("Used banned spikes without permission."); args.Player.SendTileSquare(tileX, tileY); return true; } if (type == 1 && tiletype == 21 && TShock.Utils.MaxChests()) { - args.Player.SendMessage("Reached world's max chest limit, unable to place more!", Color.Red); + args.Player.SendMessage("Reached the world's max chest limit, unable to place more.", Color.Red); args.Player.SendTileSquare(tileX, tileY); return true; } if (tiletype == 141 && !args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned("Explosives", args.Player)) { - args.Player.Disable("Using banned explosives tile without permissions"); + args.Player.Disable("Used banned explosives tile without permission."); args.Player.SendTileSquare(tileX, tileY); return true; } @@ -1728,14 +1735,14 @@ namespace TShockAPI if (args.Player.TileKillThreshold >= TShock.Config.TileKillThreshold) { - args.Player.Disable("Reached TileKill threshold"); + args.Player.Disable("Reached TileKill threshold."); args.Player.SendTileSquare(tileX, tileY); return true; } if (args.Player.TilePlaceThreshold >= TShock.Config.TilePlaceThreshold) { - args.Player.Disable("Reached TilePlace threshold"); + args.Player.Disable("Reached TilePlace threshold."); args.Player.SendTileSquare(tileX, tileY); return true; } @@ -2259,7 +2266,7 @@ namespace TShockAPI if (TShock.Config.BanOnMediumcoreDeath) { if (!TShock.Utils.Ban(args.Player, TShock.Config.MediumcoreBanReason)) - TShock.Utils.ForceKick(args.Player, "Death results in a ban, but can't ban you"); + TShock.Utils.ForceKick(args.Player, "Death results in a ban, but can't ban you.", true); } else { diff --git a/TShockAPI/Group.cs b/TShockAPI/Group.cs index 264570fe..f6d41630 100644 --- a/TShockAPI/Group.cs +++ b/TShockAPI/Group.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/HandlerList.cs b/TShockAPI/HandlerList.cs index 32ae94e6..12822962 100644 --- a/TShockAPI/HandlerList.cs +++ b/TShockAPI/HandlerList.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/IPackable.cs b/TShockAPI/IPackable.cs index 40480fae..8523aeff 100644 --- a/TShockAPI/IPackable.cs +++ b/TShockAPI/IPackable.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Log.cs b/TShockAPI/Log.cs index 77e8ff86..9e54c53a 100644 --- a/TShockAPI/Log.cs +++ b/TShockAPI/Log.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Net/BaseMsg.cs b/TShockAPI/Net/BaseMsg.cs index 8362f9c5..8e0ce232 100644 --- a/TShockAPI/Net/BaseMsg.cs +++ b/TShockAPI/Net/BaseMsg.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Net/DisconnectMsg.cs b/TShockAPI/Net/DisconnectMsg.cs index ae9b34e6..d62775a4 100644 --- a/TShockAPI/Net/DisconnectMsg.cs +++ b/TShockAPI/Net/DisconnectMsg.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Net/NetTile.cs b/TShockAPI/Net/NetTile.cs index 54a4b6eb..78d53be7 100644 --- a/TShockAPI/Net/NetTile.cs +++ b/TShockAPI/Net/NetTile.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Net/ProjectileRemoveMsg.cs b/TShockAPI/Net/ProjectileRemoveMsg.cs index 66723f93..bc119dcc 100644 --- a/TShockAPI/Net/ProjectileRemoveMsg.cs +++ b/TShockAPI/Net/ProjectileRemoveMsg.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Net/SpawnMsg.cs b/TShockAPI/Net/SpawnMsg.cs index 3a503a5a..36258396 100644 --- a/TShockAPI/Net/SpawnMsg.cs +++ b/TShockAPI/Net/SpawnMsg.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Net/WorldInfoMsg.cs b/TShockAPI/Net/WorldInfoMsg.cs index 211a7ad4..7b64f2a8 100644 --- a/TShockAPI/Net/WorldInfoMsg.cs +++ b/TShockAPI/Net/WorldInfoMsg.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/PacketBufferer.cs b/TShockAPI/PacketBufferer.cs index fa057a64..e2ea8e94 100644 --- a/TShockAPI/PacketBufferer.cs +++ b/TShockAPI/PacketBufferer.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 9933b95b..70e8867a 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,8 @@ namespace TShockAPI { //Permissions with blank descriptions basically means its described by the commands it gives access to. + [Description("Allows player to get user info")] public static readonly string userinfo; + [Description("")] public static readonly string causeevents; [Description("Required to be able to build (modify tiles and liquid)")] public static readonly string canbuild; @@ -161,12 +163,21 @@ namespace TShockAPI [Description("User can see the id of players with /who")] public static readonly string seeids; + [Description("User can save all the players SSI state.")] + public static readonly string savessi; + + [Description("User can use rest api calls.")] + public static readonly string restapi; + static Permissions() { foreach (var field in typeof (Permissions).GetFields()) { field.SetValue(null, field.Name); } + + //Backwards compatability. + restapi = "api"; } private static List GetCommands(string perm) diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index ef64ab0f..f6c1764b 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,5 +48,5 @@ using System.Runtime.InteropServices; // Build Number // MMdd of the build -[assembly: AssemblyVersion("3.8.0.0304")] -[assembly: AssemblyFileVersion("3.8.0.0304")] +[assembly: AssemblyVersion("3.9.0.0526")] +[assembly: AssemblyFileVersion("3.9.0.0526")] diff --git a/TShockAPI/RconHandler.cs b/TShockAPI/RconHandler.cs index 539e87b7..3d314f24 100644 --- a/TShockAPI/RconHandler.cs +++ b/TShockAPI/RconHandler.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Resources.Designer.cs b/TShockAPI/Resources.Designer.cs index 2d3489cd..99b8a890 100644 --- a/TShockAPI/Resources.Designer.cs +++ b/TShockAPI/Resources.Designer.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Rest/Rest.cs b/TShockAPI/Rest/Rest.cs index 0875b3b4..3f2ae2e2 100644 --- a/TShockAPI/Rest/Rest.cs +++ b/TShockAPI/Rest/Rest.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Rest/RestCommand.cs b/TShockAPI/Rest/RestCommand.cs index 3e54a673..334752de 100644 --- a/TShockAPI/Rest/RestCommand.cs +++ b/TShockAPI/Rest/RestCommand.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index e653bffe..98543d6d 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Rest/RestObject.cs b/TShockAPI/Rest/RestObject.cs index c2593f44..0133ff6f 100644 --- a/TShockAPI/Rest/RestObject.cs +++ b/TShockAPI/Rest/RestObject.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Rest/RestVerbs.cs b/TShockAPI/Rest/RestVerbs.cs index ddd9a2cd..ea155fcb 100644 --- a/TShockAPI/Rest/RestVerbs.cs +++ b/TShockAPI/Rest/RestVerbs.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Rest/SecureRest.cs b/TShockAPI/Rest/SecureRest.cs index 976d6aae..987cd295 100644 --- a/TShockAPI/Rest/SecureRest.cs +++ b/TShockAPI/Rest/SecureRest.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/StatTracker.cs b/TShockAPI/StatTracker.cs index 353c8f19..81df0c50 100644 --- a/TShockAPI/StatTracker.cs +++ b/TShockAPI/StatTracker.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 3610af2f..d7cd86af 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -119,6 +119,29 @@ namespace TShockAPI } } + /// + /// Saves the player's inventory to SSI + /// + /// bool - True/false if it saved successfully + public bool SaveServerInventory() + { + if (!TShock.Config.ServerSideInventory) + { + return false; + } + try + { + PlayerData.CopyInventory(this); + TShock.InventoryDB.InsertPlayerData(this); + return true; + } catch (Exception e) + { + Log.Error(e.Message); + return false; + } + + } + /// /// Terraria Player /// @@ -359,9 +382,19 @@ namespace TShockAPI return false; } + public bool GiveItemCheck(int type, string name, int width, int height, int stack, int prefix = 0) + { + if (TShock.Itembans.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn) + return false; + + GiveItem(type,name,width,height,stack,prefix); + return true; + } + public virtual void GiveItem(int type, string name, int width, int height, int stack, int prefix = 0) { int itemid = Item.NewItem((int) X, (int) Y, width, height, type, stack, true, prefix); + // This is for special pickaxe/hammers/swords etc Main.item[itemid].SetDefaults(name); // The set default overrides the wet and stack set by NewItem diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs old mode 100755 new mode 100644 index 9fc3aabb..c2ca92d5 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,14 +37,14 @@ using TShockAPI.Net; namespace TShockAPI { - [APIVersion(1, 11)] + [APIVersion(1, 12)] public class TShock : TerrariaPlugin { private const string LogFormatDefault = "yyyyMMddHHmmss"; private static string LogFormat = LogFormatDefault; private static bool LogClear = false; public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; - public static readonly string VersionCodename = "Squashing bugs, and adding suggestions"; + public static readonly string VersionCodename = "Zack time: 1 week = 3 months"; public static string SavePath = "tshock"; @@ -77,6 +77,7 @@ namespace TShockAPI /// public static event Action Initialized; + public static List TakenPlayerIDs = new List(); public override Version Version { @@ -203,6 +204,8 @@ namespace TShockAPI GameHooks.PostInitialize += OnPostInit; GameHooks.Update += OnUpdate; + GameHooks.HardUpdate += OnHardUpdate; + GameHooks.StatueSpawn += OnStatueSpawn; ServerHooks.Connect += OnConnect; ServerHooks.Join += OnJoin; ServerHooks.Leave += OnLeave; @@ -256,7 +259,7 @@ namespace TShockAPI {Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair."}; } - if (!Utils.GetGroup(userAccount.Group).HasPermission("api") && userAccount.Group != "superadmin") + if (!Utils.GetGroup(userAccount.Group).HasPermission(Permissions.restapi) && userAccount.Group != "superadmin") { return new RestObject("403") { @@ -281,6 +284,8 @@ namespace TShockAPI GameHooks.PostInitialize -= OnPostInit; GameHooks.Update -= OnUpdate; + GameHooks.HardUpdate -= OnHardUpdate; + GameHooks.StatueSpawn -= OnStatueSpawn; ServerHooks.Connect -= OnConnect; ServerHooks.Join -= OnJoin; ServerHooks.Leave -= OnLeave; @@ -623,6 +628,36 @@ namespace TShockAPI Config.MaxSlots, Netplay.serverListenIP, Config.ServerPort, Version); } + private void OnHardUpdate( HardUpdateEventArgs args ) + { + if (args.Handled) + return; + + if (!Config.AllowCorruptionCreep && ( args.Type == 23 || args.Type == 25 || args.Type == 0 || + args.Type == 112 || args.Type == 23 || args.Type == 32 ) ) + { + args.Handled = true; + return; + } + + if (!Config.AllowHallowCreep && (args.Type == 109 || args.Type == 117 || args.Type == 116 ) ) + { + args.Handled = true; + } + } + + private void OnStatueSpawn( StatueSpawnEventArgs args ) + { + if( args.Within200 < Config.StatueSpawn200 && args.Within600 < Config.StatueSpawn600 && args.WorldWide < Config.StatueSpawnWorld ) + { + args.Handled = true; + } + else + { + args.Handled = false; + } + } + private void OnConnect(int ply, HandledEventArgs handler) { var player = new TSPlayer(ply); @@ -656,7 +691,7 @@ namespace TShockAPI if (!FileTools.OnWhitelist(player.IP)) { - Utils.ForceKick(player, "Not on whitelist."); + Utils.ForceKick(player, Config.WhitelistKickReason); handler.Handled = true; return; } diff --git a/TShockAPI/TShockAPI.licenseheader b/TShockAPI/TShockAPI.licenseheader index 32579142..12ed0ea9 100644 --- a/TShockAPI/TShockAPI.licenseheader +++ b/TShockAPI/TShockAPI.licenseheader @@ -1,7 +1,7 @@ extensions: .cs /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/UpdateManager.cs b/TShockAPI/UpdateManager.cs index cf0b375b..c518aa76 100644 --- a/TShockAPI/UpdateManager.cs +++ b/TShockAPI/UpdateManager.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index f6ead281..697ae2f9 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -86,7 +86,7 @@ namespace TShockAPI sb.Append(", "); } sb.Append(player.Name); - string id = "( " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + " )"; + string id = "(ID: " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + ", IX:" + player.Index + ")"; sb.Append(id); } } @@ -187,7 +187,7 @@ namespace TShockAPI } /// - /// Finds a player ID based on name + /// Finds a TSPlayer based on name or id /// /// Player name /// @@ -203,6 +203,18 @@ namespace TShockAPI if (player == null) continue; + try + { + if (Convert.ToInt32(ply) == player.Index && player.Active) + { + return new List { player }; + } + } + catch (Exception e) + { + // Conversion failed + } + string name = player.Name.ToLower(); if (name.Equals(ply)) return new List {player}; @@ -543,9 +555,9 @@ namespace TShockAPI /// int player /// string reason /// bool silent (default: false) - public void ForceKick(TSPlayer player, string reason, bool silent = false) + public void ForceKick(TSPlayer player, string reason, bool silent = false, bool saveSSI = false) { - Kick(player, reason, true, silent); + Kick(player, reason, true, silent, null, saveSSI); } #if COMPAT_SIGS @@ -556,14 +568,15 @@ namespace TShockAPI } #endif /// - /// Kicks a player from the server. + /// Kicks a player from the server.. /// /// int player /// string reason /// bool force (default: false) /// bool silent (default: false) - /// bool silent (default: null) - public bool Kick(TSPlayer player, string reason, bool force = false, bool silent = false, string adminUserName = null) + /// string adminUserName (default: null) + /// bool saveSSI (default: false) + public bool Kick(TSPlayer player, string reason, bool force = false, bool silent = false, string adminUserName = null, bool saveSSI = false) { if (!player.ConnectionAlive) return true; @@ -571,13 +584,18 @@ namespace TShockAPI { string playerName = player.Name; player.SilentKickInProgress = silent; + if (player.IsLoggedIn && saveSSI) + player.SaveServerInventory(); player.Disconnect(string.Format("Kicked: {0}", reason)); Log.ConsoleInfo(string.Format("Kicked {0} for : {1}", playerName, reason)); string verb = force ? "force " : ""; - if (string.IsNullOrWhiteSpace(adminUserName)) - Broadcast(string.Format("{0} was {1}kicked for {2}", playerName, verb, reason.ToLower())); - else - Broadcast(string.Format("{0} {1}kicked {2} for {3}", adminUserName, verb, playerName, reason.ToLower())); + if (!silent) + { + if (string.IsNullOrWhiteSpace(adminUserName)) + Broadcast(string.Format("{0} was {1}kicked for {2}", playerName, verb, reason.ToLower())); + else + Broadcast(string.Format("{0} {1}kicked {2} for {3}", adminUserName, verb, playerName, reason.ToLower())); + } return true; } return false; diff --git a/TerrariaServerBins/TerrariaServer.exe b/TerrariaServerBins/TerrariaServer.exe index 253a7e1f..1e0dba51 100644 Binary files a/TerrariaServerBins/TerrariaServer.exe and b/TerrariaServerBins/TerrariaServer.exe differ diff --git a/UnitTests/BanManagerTest.cs b/UnitTests/BanManagerTest.cs index 2f4daa67..730f11f0 100644 --- a/UnitTests/BanManagerTest.cs +++ b/UnitTests/BanManagerTest.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/UnitTests/GroupManagerTest.cs b/UnitTests/GroupManagerTest.cs index 7029717d..64d23622 100644 --- a/UnitTests/GroupManagerTest.cs +++ b/UnitTests/GroupManagerTest.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/UnitTests/ItemManagerTest.cs b/UnitTests/ItemManagerTest.cs index 1fe904f1..febd62ab 100644 --- a/UnitTests/ItemManagerTest.cs +++ b/UnitTests/ItemManagerTest.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/UnitTests/Properties/AssemblyInfo.cs b/UnitTests/Properties/AssemblyInfo.cs index 42b70b09..9f57e16a 100644 --- a/UnitTests/Properties/AssemblyInfo.cs +++ b/UnitTests/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/UnitTests/RegionManagerTest.cs b/UnitTests/RegionManagerTest.cs index 9e9dbf51..6c4d3ed9 100644 --- a/UnitTests/RegionManagerTest.cs +++ b/UnitTests/RegionManagerTest.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,12 +54,12 @@ namespace UnitTests [TestMethod] public void AddRegion() { - Region r = new Region( new Rectangle(100,100,100,100), "test", "test", true, "test"); + Region r = new Region( new Rectangle(100,100,100,100), "test", "test", true, "test", 0); Assert.IsTrue(manager.AddRegion(r.Area.X, r.Area.Y, r.Area.Width, r.Area.Height, r.Name, r.Owner, r.WorldID)); Assert.AreEqual(1, manager.Regions.Count); Assert.IsNotNull(manager.ZacksGetRegionByName("test")); - Region r2 = new Region(new Rectangle(201, 201, 100, 100), "test2", "test2", true, "test"); + Region r2 = new Region(new Rectangle(201, 201, 100, 100), "test2", "test2", true, "test", 0); manager.AddRegion(r2.Area.X, r2.Area.Y, r2.Area.Width, r2.Area.Height, r2.Name, r2.Owner, r2.WorldID); Assert.AreEqual(2, manager.Regions.Count); Assert.IsNotNull(manager.ZacksGetRegionByName("test2")); diff --git a/UnitTests/UnitTests.licenseheader b/UnitTests/UnitTests.licenseheader index 32579142..12ed0ea9 100644 --- a/UnitTests/UnitTests.licenseheader +++ b/UnitTests/UnitTests.licenseheader @@ -1,7 +1,7 @@ extensions: .cs /* TShock, a server mod for Terraria -Copyright (C) 2011 The TShock Team +Copyright (C) 2011-2012 The TShock Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by