From e663698497401400e94e9b8cf21d84f9c5b7a9e4 Mon Sep 17 00:00:00 2001 From: ricky Date: Sat, 11 Jun 2011 09:43:23 +1000 Subject: [PATCH] Using the maxNPCTypes and maxItemTypes constants from Terraria.Main so we don't have to update everytime new things are added --- TShockAPI/Commands.cs | 6 +++--- TShockAPI/TShock.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index f21b3a13..5c612da0 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -649,7 +649,7 @@ namespace TShockAPI return; } - if (type >= 1 && type <= 45) + if (type >= 1 && type < Main.maxNPCTypes) { int npcid = -1; for (int i = 0; i < amount; i++) @@ -679,7 +679,7 @@ namespace TShockAPI if (!int.TryParse(args.Parameters[0], out type)) type = TShock.GetItemID(String.Join(" ", args.Parameters)); - if (type < 1 || type > 238) + if (type < 1 || type >= Main.maxItemTypes) { Tools.SendMessage(adminplr, "Invalid item type!", Color.Red); return; @@ -732,7 +732,7 @@ namespace TShockAPI if (!int.TryParse(args.Parameters[0], out type)) type = TShock.GetItemID(args.Parameters[0]); - if (type < 1 || type > 238) + if (type < 1 || type >= Main.maxItemTypes) { Tools.SendMessage(args.PlayerID, "Invalid item type!", Color.Red); return; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 7c61da1f..41aa9fa9 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -816,7 +816,7 @@ namespace TShockAPI public static int GetNPCID(string name, bool exact = false) { NPC npc = new NPC(); - for (int i = 1; i <= 45; i++) + for (int i = 1; i < Main.maxNPCTypes; i++) { if (exact) { @@ -841,7 +841,7 @@ namespace TShockAPI { Item item = new Item(); name = name.ToLower(); - for (int i = 1; i <= 238; i++) + for (int i = 1; i < Main.maxItemTypes; i++) { item.SetDefaults(i); if (item.name.ToLower().StartsWith(name))