Replace references to Main.max*whatever*count

All of the Main.maxwhatever fields have been replaced with
Terraria.ID.WhateverID.Count fields.
This commit is contained in:
Lucas Nicodemus 2022-11-09 22:53:29 -08:00
parent afb966dcff
commit b322c4c1e0
No known key found for this signature in database
4 changed files with 30 additions and 30 deletions

View file

@ -255,7 +255,7 @@ namespace TShockAPI
#region PlayerAddBuff Whitelist
PlayerAddBuffWhitelist = new BuffLimit[Main.maxBuffTypes];
PlayerAddBuffWhitelist = new BuffLimit[Terraria.ID.BuffID.Count];
PlayerAddBuffWhitelist[BuffID.Poisoned] = new BuffLimit
{
MaxTicks = 60 * 60
@ -600,8 +600,8 @@ namespace TShockAPI
}
if (editData < 0 ||
((action == EditAction.PlaceTile || action == EditAction.ReplaceTile) && editData >= Main.maxTileSets) ||
((action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && editData >= Main.maxWallTypes))
((action == EditAction.PlaceTile || action == EditAction.ReplaceTile) && editData >= Terraria.ID.TileID.Count) ||
((action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && editData >= Terraria.ID.WallID.Count))
{
TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from editData out of bounds {0} {1} {2}", args.Player.Name, action, editData));
args.Player.SendTileSquareCentered(tileX, tileY, 4);
@ -1050,7 +1050,7 @@ namespace TShockAPI
short type = args.Type;
// player is attempting to crash clients
if (type < -48 || type >= Main.maxItemTypes)
if (type < -48 || type >= Terraria.ID.ItemID.Count)
{
// Causes item duplications. Will be re added later if necessary
//args.Player.SendData(PacketTypes.ItemDrop, "", id);
@ -1881,7 +1881,7 @@ namespace TShockAPI
return;
}
if (type >= Main.maxBuffTypes)
if (type >= Terraria.ID.BuffID.Count)
{
TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerBuff rejected invalid buff type {0}", args.Player.Name));
args.Player.SendData(PacketTypes.PlayerBuff, "", id);
@ -2209,7 +2209,7 @@ namespace TShockAPI
return;
}
if (type < 0 || type >= Main.maxTileSets)
if (type < 0 || type >= Terraria.ID.TileID.Count)
{
TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlaceObject rejected out of bounds tile from {0}", args.Player.Name));
args.Handled = true;

View file

@ -2862,7 +2862,7 @@ namespace TShockAPI
else
{
var npc = npcs[0];
if (npc.type >= 1 && npc.type < Main.maxNPCTypes && npc.type != 113)
if (npc.type >= 1 && npc.type < Terraria.ID.NPCID.Count && npc.type != 113)
{
TSPlayer.Server.SpawnNPC(npc.netID, npc.FullName, amount, args.Player.TileX, args.Player.TileY, 50, 20);
if (args.Silent)
@ -4027,7 +4027,7 @@ namespace TShockAPI
return;
}
short id;
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Main.maxProjectileTypes)
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count)
{
TShock.ProjectileBans.AddNewBan(id);
args.Player.SendSuccessMessage(GetString("Banned projectile {0}.", id));
@ -4047,7 +4047,7 @@ namespace TShockAPI
}
short id;
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Main.maxProjectileTypes)
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count)
{
if (!TShock.Groups.GroupExists(args.Parameters[2]))
{
@ -4084,7 +4084,7 @@ namespace TShockAPI
}
short id;
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Main.maxProjectileTypes)
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count)
{
TShock.ProjectileBans.RemoveBan(id);
args.Player.SendSuccessMessage(GetString("Unbanned projectile {0}.", id));
@ -4105,7 +4105,7 @@ namespace TShockAPI
}
short id;
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Main.maxProjectileTypes)
if (Int16.TryParse(args.Parameters[1], out id) && id > 0 && id < Terraria.ID.ProjectileID.Count)
{
if (!TShock.Groups.GroupExists(args.Parameters[2]))
{
@ -4203,7 +4203,7 @@ namespace TShockAPI
return;
}
short id;
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Main.maxTileSets)
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count)
{
TShock.TileBans.AddNewBan(id);
args.Player.SendSuccessMessage(GetString("Banned tile {0}.", id));
@ -4223,7 +4223,7 @@ namespace TShockAPI
}
short id;
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Main.maxTileSets)
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count)
{
if (!TShock.Groups.GroupExists(args.Parameters[2]))
{
@ -4260,7 +4260,7 @@ namespace TShockAPI
}
short id;
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Main.maxTileSets)
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count)
{
TShock.TileBans.RemoveBan(id);
args.Player.SendSuccessMessage(GetString("Unbanned tile {0}.", id));
@ -4281,7 +4281,7 @@ namespace TShockAPI
}
short id;
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Main.maxTileSets)
if (Int16.TryParse(args.Parameters[1], out id) && id >= 0 && id < Terraria.ID.TileID.Count)
{
if (!TShock.Groups.GroupExists(args.Parameters[2]))
{
@ -6088,7 +6088,7 @@ namespace TShockAPI
{
item = matchedItems[0];
}
if (item.type < 1 && item.type >= Main.maxItemTypes)
if (item.type < 1 && item.type >= Terraria.ID.ItemID.Count)
{
args.Player.SendErrorMessage(GetString("The item type {0} is invalid.", itemNameOrId));
return;
@ -6251,7 +6251,7 @@ namespace TShockAPI
prefix = prefixIds[0];
}
if (item.type >= 1 && item.type < Main.maxItemTypes)
if (item.type >= 1 && item.type < Terraria.ID.ItemID.Count)
{
var players = TSPlayer.FindByNameOrID(plStr);
if (players.Count == 0)
@ -6393,7 +6393,7 @@ namespace TShockAPI
if (args.Parameters.Count == 2)
int.TryParse(args.Parameters[1], out time);
if (id > 0 && id < Main.maxBuffTypes)
if (id > 0 && id < Terraria.ID.BuffID.Count)
{
// Max possible buff duration as of Terraria 1.4.2.3 is 35791393 seconds (415 days).
if (time < 0 || time > timeLimit)
@ -6449,7 +6449,7 @@ namespace TShockAPI
}
if (args.Parameters.Count == 3)
int.TryParse(args.Parameters[2], out time);
if (id > 0 && id < Main.maxBuffTypes)
if (id > 0 && id < Terraria.ID.BuffID.Count)
{
var target = foundplr[0];
if (time < 0 || time > timeLimit)

View file

@ -48,12 +48,12 @@ namespace TShockAPI.Localization
LanguageManager.Instance.SetLanguage(GameCulture.FromCultureName(GameCulture.CultureName.English));
}
for (var i = -48; i < Main.maxItemTypes; i++)
for (var i = -48; i < Terraria.ID.ItemID.Count; i++)
{
ItemNames.Add(i, Lang.GetItemNameValue(i));
}
for (var i = -17; i < Main.maxNPCTypes; i++)
for (var i = -17; i < Terraria.ID.NPCID.Count; i++)
{
NpcNames.Add(i, Lang.GetNPCNameValue(i));
}

View file

@ -251,7 +251,7 @@ namespace TShockAPI
int type = -1;
if (Int32.TryParse(text, out type))
{
if (type >= Main.maxItemTypes)
if (type >= Terraria.ID.ItemID.Count)
return new List<Item>();
return new List<Item> {GetItemById(type)};
}
@ -285,7 +285,7 @@ namespace TShockAPI
string nameLower = name.ToLowerInvariant();
var checkEnglish = Language.ActiveCulture != GameCulture.FromCultureName(GameCulture.CultureName.English);
for (int i = 1; i < Main.maxItemTypes; i++)
for (int i = 1; i < Terraria.ID.ItemID.Count; i++)
{
item.netDefaults(i);
if (!String.IsNullOrWhiteSpace(item.Name))
@ -343,7 +343,7 @@ namespace TShockAPI
int type = -1;
if (int.TryParse(idOrName, out type))
{
if (type >= Main.maxNPCTypes)
if (type >= Terraria.ID.NPCID.Count)
return new List<NPC>();
return new List<NPC> { GetNPCById(type) };
}
@ -372,7 +372,7 @@ namespace TShockAPI
var found = new List<NPC>();
NPC npc = new NPC();
string nameLower = name.ToLowerInvariant();
for (int i = -17; i < Main.maxNPCTypes; i++)
for (int i = -17; i < Terraria.ID.NPCID.Count; i++)
{
string englishName = EnglishLanguage.GetNpcNameById(i).ToLowerInvariant();
@ -394,7 +394,7 @@ namespace TShockAPI
/// <returns>name</returns>
public string GetBuffName(int id)
{
return (id > 0 && id < Main.maxBuffTypes) ? Lang.GetBuffName(id) : null;
return (id > 0 && id < Terraria.ID.BuffID.Count) ? Lang.GetBuffName(id) : null;
}
/// <summary>
@ -404,7 +404,7 @@ namespace TShockAPI
/// <returns>description</returns>
public string GetBuffDescription(int id)
{
return (id > 0 && id < Main.maxBuffTypes) ? Lang.GetBuffDescription(id) : null;
return (id > 0 && id < Terraria.ID.BuffID.Count) ? Lang.GetBuffDescription(id) : null;
}
/// <summary>
@ -416,14 +416,14 @@ namespace TShockAPI
{
string nameLower = name.ToLower();
string buffname;
for (int i = 1; i < Main.maxBuffTypes; i++)
for (int i = 1; i < Terraria.ID.BuffID.Count; i++)
{
buffname = Lang.GetBuffName(i);
if (!String.IsNullOrWhiteSpace(buffname) && buffname.ToLower() == nameLower)
return new List<int> {i};
}
var found = new List<int>();
for (int i = 1; i < Main.maxBuffTypes; i++)
for (int i = 1; i < Terraria.ID.BuffID.Count; i++)
{
buffname = Lang.GetBuffName(i);
if (!String.IsNullOrWhiteSpace(buffname) && buffname.ToLower().StartsWith(nameLower))
@ -1096,7 +1096,7 @@ namespace TShockAPI
internal void ComputeMaxStyles()
{
var item = new Item();
for (int i = 0; i < Main.maxItemTypes; i++)
for (int i = 0; i < Terraria.ID.ItemID.Count; i++)
{
item.netDefaults(i);
if (item.placeStyle >= 0)