fix(core): Removes some uses of Linq (#421)

- [X] Removes some uses of linq
- [X] Creates struct based enumerator for Skills
- [X] Creates a struct based enumerator for TypeCache
- [X] Changes HarvestDefinition to an init array instead of List
- [X] Changes HeritageTokenGump Response from List to Array
This commit is contained in:
Kamron Batman 2021-01-18 21:05:11 -08:00 • committed by GitHub
parent 52356866ed
commit b921c38879
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 1006 additions and 507 deletions

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Network;
@ -278,303 +277,441 @@ namespace Server.Gumps
return;
}
var types = new List<Type>();
var cliloc = 0;
Type[] types;
int cliloc;
switch (info.ButtonID)
{
default:
{
types = null;
cliloc = 0;
break;
}
// 7th anniversary
case 0x64:
types.Add(typeof(LeggingsOfEmbers));
cliloc = 1078147;
break;
{
types = new [] { typeof(LeggingsOfEmbers) };
cliloc = 1078147;
break;
}
case 0x65:
types.Add(typeof(RoseOfTrinsic));
cliloc = 1062913;
break;
{
types = new [] { typeof(RoseOfTrinsic) };
cliloc = 1062913;
break;
}
case 0x66:
types.Add(typeof(ShaminoCrossbow));
cliloc = 1062915;
break;
{
types = new [] { typeof(ShaminoCrossbow) };
cliloc = 1062915;
break;
}
case 0x67:
types.Add(typeof(TapestryOfSosaria));
cliloc = 1062917;
break;
{
types = new [] { typeof(TapestryOfSosaria) };
cliloc = 1062917;
break;
}
case 0x68:
types.Add(typeof(HearthOfHomeFireDeed));
cliloc = 1062919;
break;
{
types = new [] { typeof(HearthOfHomeFireDeed) };
cliloc = 1062919;
break;
}
case 0x69:
types.Add(typeof(HolySword));
cliloc = 1062921;
break;
{
types = new [] { typeof(HolySword) };
cliloc = 1062921;
break;
}
case 0x6A:
types.Add(typeof(SamuraiHelm));
cliloc = 1062923;
break;
{
types = new [] { typeof(SamuraiHelm) };
cliloc = 1062923;
break;
}
// 8th anniversary
/*case 0x6B: types.Add( typeof( SpiritualityHelm ) ); cliloc = 1075188; break;
case 0x6C: types.Add( typeof( ValorGauntlets ) ); cliloc = 1075192; break;*/
/*case 0x6B: types = new [] { typeof( SpiritualityHelm ) }; cliloc = 1075188; break;
case 0x6C: types = new [] { typeof( ValorGauntlets ) }; cliloc = 1075192; break;*/
case 0x6D:
types.Add(typeof(DupresShield));
cliloc = 1075196;
break;
{
types = new [] { typeof(DupresShield) };
cliloc = 1075196;
break;
}
case 0x6E:
types.Add(typeof(FountainOfLifeDeed));
cliloc = 1075197;
break;
{
types = new [] { typeof(FountainOfLifeDeed) };
cliloc = 1075197;
break;
}
case 0x6F:
types.Add(typeof(DawnsMusicBox));
cliloc = 1075198;
break;
{
types = new [] { typeof(DawnsMusicBox) };
cliloc = 1075198;
break;
}
case 0x70:
types.Add(typeof(OssianGrimoire));
cliloc = 1078148;
break;
{
types = new [] { typeof(OssianGrimoire) };
cliloc = 1078148;
break;
}
case 0x71:
types.Add(typeof(FerretFormTalisman));
cliloc = 1078142;
break;
{
types = new [] { typeof(FerretFormTalisman) };
cliloc = 1078142;
break;
}
case 0x72:
types.Add(typeof(SquirrelFormTalisman));
cliloc = 1078143;
break;
{
types = new [] { typeof(SquirrelFormTalisman) };
cliloc = 1078143;
break;
}
case 0x73:
types.Add(typeof(CuSidheFormTalisman));
cliloc = 1078144;
break;
{
types = new [] { typeof(CuSidheFormTalisman) };
cliloc = 1078144;
break;
}
case 0x74:
types.Add(typeof(ReptalonFormTalisman));
cliloc = 1078145;
break;
{
types = new [] { typeof(ReptalonFormTalisman) };
cliloc = 1078145;
break;
}
case 0x75:
types.Add(typeof(QuiverOfInfinity));
cliloc = 1075201;
break;
{
types = new [] { typeof(QuiverOfInfinity) };
cliloc = 1075201;
break;
}
// evil home decor
case 0x76:
types.Add(typeof(BoneThroneDeed));
types.Add(typeof(BoneCouchDeed));
types.Add(typeof(BoneTableDeed));
cliloc = 1074797;
break;
{
types = new [] { typeof(BoneThroneDeed), typeof(BoneCouchDeed), typeof(BoneTableDeed) };
cliloc = 1074797;
break;
}
case 0x77:
types.Add(typeof(CreepyPortraitDeed));
types.Add(typeof(DisturbingPortraitDeed));
types.Add(typeof(UnsettlingPortraitDeed));
cliloc = 1078146;
break;
{
types = new []
{
typeof(CreepyPortraitDeed),
typeof(DisturbingPortraitDeed),
typeof(UnsettlingPortraitDeed)
};
cliloc = 1078146;
break;
}
case 0x78:
types.Add(typeof(MountedPixieBlueDeed));
types.Add(typeof(MountedPixieGreenDeed));
types.Add(typeof(MountedPixieLimeDeed));
types.Add(typeof(MountedPixieOrangeDeed));
types.Add(typeof(MountedPixieWhiteDeed));
cliloc = 1074799;
break;
{
types = new []
{
typeof(MountedPixieBlueDeed),
typeof(MountedPixieGreenDeed),
typeof(MountedPixieLimeDeed),
typeof(MountedPixieOrangeDeed),
typeof(MountedPixieWhiteDeed)
};
cliloc = 1074799;
break;
}
case 0x79:
types.Add(typeof(HaunterMirrorDeed));
cliloc = 1074800;
break;
{
types = new [] { typeof(HaunterMirrorDeed) };
cliloc = 1074800;
break;
}
case 0x7A:
types.Add(typeof(BedOfNailsDeed));
cliloc = 1074801;
break;
{
types = new [] { typeof(BedOfNailsDeed) };
cliloc = 1074801;
break;
}
case 0x7B:
types.Add(typeof(SacrificialAltarDeed));
cliloc = 1074818;
break;
{
types = new [] { typeof(SacrificialAltarDeed) };
cliloc = 1074818;
break;
}
// broken furniture
case 0x7C:
types.Add(typeof(BrokenCoveredChairDeed));
cliloc = 1076257;
break;
{
types = new [] { typeof(BrokenCoveredChairDeed) };
cliloc = 1076257;
break;
}
case 0x7D:
types.Add(typeof(BrokenBookcaseDeed));
cliloc = 1076258;
break;
{
types = new [] { typeof(BrokenBookcaseDeed) };
cliloc = 1076258;
break;
}
case 0x7E:
types.Add(typeof(StandingBrokenChairDeed));
cliloc = 1076259;
break;
{
types = new [] { typeof(StandingBrokenChairDeed) };
cliloc = 1076259;
break;
}
case 0x7F:
types.Add(typeof(BrokenVanityDeed));
cliloc = 1076260;
break;
{
types = new [] { typeof(BrokenVanityDeed) };
cliloc = 1076260;
break;
}
case 0x80:
types.Add(typeof(BrokenChestOfDrawersDeed));
cliloc = 1076261;
break;
{
types = new [] { typeof(BrokenChestOfDrawersDeed) };
cliloc = 1076261;
break;
}
case 0x81:
types.Add(typeof(BrokenArmoireDeed));
cliloc = 1076262;
break;
{
types = new [] { typeof(BrokenArmoireDeed) };
cliloc = 1076262;
break;
}
case 0x82:
types.Add(typeof(BrokenBedDeed));
cliloc = 1076263;
break;
{
types = new [] { typeof(BrokenBedDeed) };
cliloc = 1076263;
break;
}
case 0x83:
types.Add(typeof(BrokenFallenChairDeed));
cliloc = 1076264;
break;
{
types = new [] { typeof(BrokenFallenChairDeed) };
cliloc = 1076264;
break;
}
// other
case 0x84:
types.Add(typeof(SuitOfGoldArmorDeed));
cliloc = 1076265;
break;
{
types = new [] { typeof(SuitOfGoldArmorDeed) };
cliloc = 1076265;
break;
}
case 0x85:
types.Add(typeof(SuitOfSilverArmorDeed));
cliloc = 1076266;
break;
{
types = new [] { typeof(SuitOfSilverArmorDeed) };
cliloc = 1076266;
break;
}
case 0x86:
types.Add(typeof(BoilingCauldronDeed));
cliloc = 1076267;
break;
{
types = new [] { typeof(BoilingCauldronDeed) };
cliloc = 1076267;
break;
}
case 0x87:
types.Add(typeof(GuillotineDeed));
cliloc = 1024656;
break;
{
types = new [] { typeof(GuillotineDeed) };
cliloc = 1024656;
break;
}
case 0x88:
types.Add(typeof(CherryBlossomTreeDeed));
cliloc = 1076268;
break;
{
types = new [] { typeof(CherryBlossomTreeDeed) };
cliloc = 1076268;
break;
}
case 0x89:
types.Add(typeof(AppleTreeDeed));
cliloc = 1076269;
break;
{
types = new [] { typeof(AppleTreeDeed) };
cliloc = 1076269;
break;
}
case 0x8A:
types.Add(typeof(PeachTreeDeed));
cliloc = 1076270;
break;
{
types = new [] { typeof(PeachTreeDeed) };
cliloc = 1076270;
break;
}
case 0x8B:
types.Add(typeof(HangingAxesDeed));
cliloc = 1076271;
break;
{
types = new [] { typeof(HangingAxesDeed) };
cliloc = 1076271;
break;
}
case 0x8C:
types.Add(typeof(HangingSwordsDeed));
cliloc = 1076272;
break;
{
types = new [] { typeof(HangingSwordsDeed) };
cliloc = 1076272;
break;
}
case 0x8D:
types.Add(typeof(BlueFancyRugDeed));
cliloc = 1076273;
break;
{
types = new [] { typeof(BlueFancyRugDeed) };
cliloc = 1076273;
break;
}
case 0x8E:
types.Add(typeof(WoodenCoffinDeed));
cliloc = 1076274;
break;
{
types = new [] { typeof(WoodenCoffinDeed) };
cliloc = 1076274;
break;
}
case 0x8F:
types.Add(typeof(VanityDeed));
cliloc = 1074027;
break;
{
types = new [] { typeof(VanityDeed) };
cliloc = 1074027;
break;
}
case 0x90:
types.Add(typeof(TableWithPurpleClothDeed));
cliloc = 1076635;
break;
{
types = new [] { typeof(TableWithPurpleClothDeed) };
cliloc = 1076635;
break;
}
case 0x91:
types.Add(typeof(TableWithBlueClothDeed));
cliloc = 1076636;
break;
{
types = new [] { typeof(TableWithBlueClothDeed) };
cliloc = 1076636;
break;
}
case 0x92:
types.Add(typeof(TableWithRedClothDeed));
cliloc = 1076637;
break;
{
types = new [] { typeof(TableWithRedClothDeed) };
cliloc = 1076637;
break;
}
case 0x93:
types.Add(typeof(TableWithOrangeClothDeed));
cliloc = 1076638;
break;
{
types = new [] { typeof(TableWithOrangeClothDeed) };
cliloc = 1076638;
break;
}
case 0x94:
types.Add(typeof(UnmadeBedDeed));
cliloc = 1076279;
break;
{
types = new [] { typeof(UnmadeBedDeed) };
cliloc = 1076279;
break;
}
case 0x95:
types.Add(typeof(CurtainsDeed));
cliloc = 1076280;
break;
{
types = new [] { typeof(CurtainsDeed) };
cliloc = 1076280;
break;
}
case 0x96:
types.Add(typeof(ScarecrowDeed));
cliloc = 1076281;
break;
{
types = new [] { typeof(ScarecrowDeed) };
cliloc = 1076281;
break;
}
case 0x97:
types.Add(typeof(WallTorchDeed));
cliloc = 1076282;
break;
{
types = new [] { typeof(WallTorchDeed) };
cliloc = 1076282;
break;
}
case 0x98:
types.Add(typeof(FountainDeed));
cliloc = 1076283;
break;
{
types = new [] { typeof(FountainDeed) };
cliloc = 1076283;
break;
}
case 0x99:
types.Add(typeof(StoneStatueDeed));
cliloc = 1076284;
break;
{
types = new [] { typeof(StoneStatueDeed) };
cliloc = 1076284;
break;
}
case 0x9A:
types.Add(typeof(LargeFishingNetDeed));
cliloc = 1076285;
break;
{
types = new [] { typeof(LargeFishingNetDeed) };
cliloc = 1076285;
break;
}
case 0x9B:
types.Add(typeof(SmallFishingNetDeed));
cliloc = 1076286;
break;
{
types = new [] { typeof(SmallFishingNetDeed) };
cliloc = 1076286;
break;
}
case 0x9C:
types.Add(typeof(HouseLadderDeed));
cliloc = 1076287;
break;
{
types = new [] { typeof(HouseLadderDeed) };
cliloc = 1076287;
break;
}
case 0x9D:
types.Add(typeof(IronMaidenDeed));
cliloc = 1076288;
break;
{
types = new [] { typeof(IronMaidenDeed) };
cliloc = 1076288;
break;
}
case 0x9E:
types.Add(typeof(BluePlainRugDeed));
cliloc = 1076585;
break;
{
types = new [] { typeof(BluePlainRugDeed) };
cliloc = 1076585;
break;
}
case 0x9F:
types.Add(typeof(GoldenDecorativeRugDeed));
cliloc = 1076586;
break;
{
types = new [] { typeof(GoldenDecorativeRugDeed) };
cliloc = 1076586;
break;
}
case 0xA0:
types.Add(typeof(CinnamonFancyRugDeed));
cliloc = 1076587;
break;
{
types = new [] { typeof(CinnamonFancyRugDeed) };
cliloc = 1076587;
break;
}
case 0xA1:
types.Add(typeof(RedPlainRugDeed));
cliloc = 1076588;
break;
{
types = new [] { typeof(RedPlainRugDeed) };
cliloc = 1076588;
break;
}
case 0xA2:
types.Add(typeof(BlueDecorativeRugDeed));
cliloc = 1076589;
break;
{
types = new [] { typeof(BlueDecorativeRugDeed) };
cliloc = 1076589;
break;
}
case 0xA3:
types.Add(typeof(PinkFancyRugDeed));
cliloc = 1076590;
break;
{
types = new [] { typeof(PinkFancyRugDeed) };
cliloc = 1076590;
break;
}
case 0xA4:
types.Add(typeof(CherryBlossomTrunkDeed));
cliloc = 1076784;
break;
{
types = new [] { typeof(CherryBlossomTrunkDeed) };
cliloc = 1076784;
break;
}
case 0xA5:
types.Add(typeof(AppleTrunkDeed));
cliloc = 1076785;
break;
{
types = new [] { typeof(AppleTrunkDeed) };
cliloc = 1076785;
break;
}
case 0xA6:
types.Add(typeof(PeachTrunkDeed));
cliloc = 1076786;
break;
{
types = new [] { typeof(PeachTrunkDeed) };
cliloc = 1076786;
break;
}
}
if (types.Count > 0 && cliloc > 0)
if (types?.Length > 0 && cliloc > 0)
{
sender.Mobile.CloseGump<ConfirmHeritageGump>();
sender.Mobile.SendGump(new ConfirmHeritageGump(m_Token, types.ToArray(), cliloc));
sender.Mobile.SendGump(new ConfirmHeritageGump(m_Token, types, cliloc));
}
else
{
sender.Mobile
.SendLocalizedMessage(
501311
); // This option is currently disabled, while we evaluate it for game balance.
// This option is currently disabled, while we evaluate it for game balance.
sender.Mobile.SendLocalizedMessage(501311);
}
}
}