From d5527ade4266cdd01625c21283c16e32a96dc3e6 Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Mon, 15 Sep 2014 09:05:28 -0400 Subject: [PATCH] Add length to database primary keys. Tweak some of the itembans code to be less inefficient. Removed a chunk of code from the buff code that prevented users from being buffed with a buff that comes from an item. This code seemed to cause max cpu usage when being disabled. I don't think this code is useful, but I leave that to people who own servers. IMO all buff code should be removed. --- TShockAPI/DB/ItemManager.cs | 14 +++++--------- TShockAPI/DB/RegionManager.cs | 2 +- TShockAPI/DB/WarpsManager.cs | 2 +- TShockAPI/GetDataHandlers.cs | 4 ++-- TShockAPI/TShock.cs | 1 + 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/TShockAPI/DB/ItemManager.cs b/TShockAPI/DB/ItemManager.cs index 58a27269..9ef62d47 100644 --- a/TShockAPI/DB/ItemManager.cs +++ b/TShockAPI/DB/ItemManager.cs @@ -101,12 +101,8 @@ namespace TShockAPI.DB public bool ItemIsBanned(string name, TSPlayer ply) { - if (ItemBans.Contains(new ItemBan(name))) - { - ItemBan b = GetItemBanByName(name); - return !b.HasPermissionToUseItem(ply); - } - return false; + ItemBan b = GetItemBanByName(name); + return b != null &&!b.HasPermissionToUseItem(ply); } public bool AllowGroup(string item, string name) @@ -162,11 +158,11 @@ namespace TShockAPI.DB public ItemBan GetItemBanByName(String name) { - foreach (ItemBan b in ItemBans) + for (int i = 0; i < ItemBans.Count; i++) { - if (b.Name == name) + if (ItemBans[i].Name == name) { - return b; + return ItemBans[i]; } } return null; diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs index 7fc6173d..dd66c20d 100644 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -44,7 +44,7 @@ namespace TShockAPI.DB new SqlColumn("width", MySqlDbType.Int32), new SqlColumn("height", MySqlDbType.Int32), new SqlColumn("RegionName", MySqlDbType.VarChar, 50) {Unique = true}, - new SqlColumn("WorldID", MySqlDbType.Text) {Unique = true}, + new SqlColumn("WorldID", MySqlDbType.VarChar, 50) { Unique = true }, new SqlColumn("UserIds", MySqlDbType.Text), new SqlColumn("Protected", MySqlDbType.Int32), new SqlColumn("Groups", MySqlDbType.Text), diff --git a/TShockAPI/DB/WarpsManager.cs b/TShockAPI/DB/WarpsManager.cs index 317f1730..709298f2 100644 --- a/TShockAPI/DB/WarpsManager.cs +++ b/TShockAPI/DB/WarpsManager.cs @@ -44,7 +44,7 @@ namespace TShockAPI.DB new SqlColumn("WarpName", MySqlDbType.VarChar, 50) {Unique = true}, new SqlColumn("X", MySqlDbType.Int32), new SqlColumn("Y", MySqlDbType.Int32), - new SqlColumn("WorldID", MySqlDbType.Text) {Unique = true}, + new SqlColumn("WorldID", MySqlDbType.VarChar, 50) { Unique = true }, new SqlColumn("Private", MySqlDbType.Text) ); var creator = new SqlTableCreator(db, diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index ff7885f6..4ab5a2e8 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3292,7 +3292,7 @@ namespace TShockAPI { var buff = args.Data.ReadInt8(); - if (TShock.Itembans.ItemBans.Any(s => + /*if (TShock.Itembans.ItemBans.Any(s => { Item item = new Item(); item.SetDefaults(s.Name); @@ -3300,7 +3300,7 @@ namespace TShockAPI })) { buff = 0; - } + }*/ if (buff == 10 && TShock.Config.DisableInvisPvP && args.TPlayer.hostile) buff = 0; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 206ead01..688773bc 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -804,6 +804,7 @@ namespace TShockAPI } player.IgnoreActionsForCheating = check; check = "none"; + //todo: pretty sure we check every place a players inventory can change, so do we really need to do this? foreach (Item item in player.TPlayer.armor) { if (Itembans.ItemIsBanned(item.name, player))