cleanup: Fixes bugs and cleans up code (#660)

This commit is contained in:
Kamron Batman 2021-07-19 20:49:59 -07:00 • committed by GitHub
parent 1de0b656a9
commit 679e8100f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 160 additions and 346 deletions

View file

@ -35,7 +35,7 @@ namespace Server.Engines.BulkOrders
return BulkGenericType.Iron;
}
return itemType == null || itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes))
return itemType?.IsSubclassOf(typeof(BaseArmor)) != false || itemType.IsSubclassOf(typeof(BaseShoes))
? BulkGenericType.Leather
: BulkGenericType.Cloth;
}

View file

@ -18,7 +18,7 @@ namespace Server.Engines.CannedEvil
public class DungeonChampionSpawn : ChampionSpawn
{
[Constructible]
public DungeonChampionSpawn() : base()
public DungeonChampionSpawn()
{
CannedEvilTimer.AddSpawn(this);
}

View file

@ -772,11 +772,7 @@ namespace Server.Engines.ConPVP
{
var pe = prefs.Find(players[j]);
if (pe.Disliked.Contains(ae.m_Arena.Name))
{
++ae.m_VotesAgainst;
}
else
if (!pe.Disliked.Contains(ae.m_Arena.Name))
{
++ae.m_VotesFor;
}
@ -827,7 +823,6 @@ namespace Server.Engines.ConPVP
private class ArenaEntry
{
public readonly Arena m_Arena;
public int m_VotesAgainst;
public int m_VotesFor;
public ArenaEntry(Arena arena) => m_Arena = arena;

View file

@ -1924,24 +1924,7 @@ namespace Server.Engines.ConPVP
var rx = dx - dy;
var ry = dx + dy;
bool eastToWest;
if (rx >= 0 && ry >= 0)
{
eastToWest = false;
}
else if (rx >= 0)
{
eastToWest = true;
}
else if (ry >= 0)
{
eastToWest = true;
}
else
{
eastToWest = false;
}
bool eastToWest = rx == 0 && ry >= 0 || rx >= 0 && ry == 0;
Effects.PlaySound(wall, Arena.Facet, 0x1F6);

View file

@ -456,8 +456,7 @@ namespace Server.Engines.ConPVP
var point = m_Path[i];
var landTile = Map.Tiles.GetLandTile(point.X, point.Y);
int landZ = 0, landAvg = 0, landTop = 0;
Map.GetAverageZ(point.X, point.Y, ref landZ, ref landAvg, ref landTop);
Map.GetAverageZ(point.X, point.Y, out var landZ, out _, out var landTop);
if (landZ <= point.Z && landTop >= point.Z && !landTile.Ignored)
{

View file

@ -23,7 +23,6 @@ namespace Server.Engines.ConPVP
public class TournamentBracketGump : Gump
{
private const int BlackColor32 = 0x000008;
private const int LabelColor32 = 0xFFFFFF;
private readonly Mobile m_From;
private List<object> m_List;
private readonly object m_Object;

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;

View file

@ -143,9 +143,9 @@ namespace Server.Engines.Craft
{
return expansion switch
{
Expansion.SE => (TextDefinition)1063363, // * Requires the "Samurai Empire" expansion
Expansion.ML => (TextDefinition)1072651, // * Requires the "Mondain's Legacy" expansion
_ => (TextDefinition)$"* Requires the \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion"
Expansion.SE => 1063363, // * Requires the "Samurai Empire" expansion
Expansion.ML => 1072651, // * Requires the "Mondain's Legacy" expansion
_ => $"* Requires the \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion"
};
}

View file

@ -876,7 +876,7 @@ namespace Server.Engines.Craft
}
public bool CheckSkills(
Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, ref bool allRequiredSkills
Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, out bool allRequiredSkills
) =>
CheckSkills(from, typeRes, craftSystem, ref quality, out allRequiredSkills, true);
@ -1132,9 +1132,7 @@ namespace Server.Engines.Craft
var ignored = 1;
var endquality = 1;
var allRequiredSkills = true;
if (CheckSkills(from, typeRes, craftSystem, ref ignored, ref allRequiredSkills))
if (CheckSkills(from, typeRes, craftSystem, ref ignored, out var allRequiredSkills))
{
// Resource
var resHue = 0;

View file

@ -84,7 +84,7 @@ namespace Server.Engines.Craft
public override void InitCraftList()
{
var index = -1;
int index;
// Other Items
if (Core.Expansion == Expansion.AOS || Core.Expansion == Expansion.SE)

View file

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;
using Server.Regions;
using Server.Utilities;
namespace Server.Engines.Doom

View file

@ -123,7 +123,7 @@ namespace Server.Engines.Doom
m_Tiles = new List<LeverPuzzleRegion>();
for (; i < 9; i++)
{
m_Tiles.Add(new LeverPuzzleRegion(this, TA[i]));
m_Tiles.Add(new LeverPuzzleRegion(TA[i]));
}
m_Teles = new List<Item>();
@ -400,7 +400,7 @@ namespace Server.Engines.Doom
{
if ((player = GetOccupant(i)) != null)
{
new RockTimer(player, this).Start();
new RockTimer(player).Start();
}
}
}
@ -570,7 +570,7 @@ namespace Server.Engines.Doom
m_Tiles = new List<LeverPuzzleRegion>();
for (var i = 4; i < 9; i++)
{
m_Tiles.Add(new LeverPuzzleRegion(this, TA[i]));
m_Tiles.Add(new LeverPuzzleRegion(TA[i]));
}
m_LampRoom = new LampRoomRegion(this);
@ -584,14 +584,12 @@ namespace Server.Engines.Doom
{
private readonly Mobile m_Player;
private int Count;
private LeverPuzzleController m_Controller;
public RockTimer(Mobile player, LeverPuzzleController controller)
public RockTimer(Mobile player)
: base(TimeSpan.Zero, TimeSpan.FromSeconds(.25))
{
Count = 0;
m_Player = player;
m_Controller = controller;
}
private int Rock() => 0x1363 + Utility.Random(0, 11);

View file

@ -88,7 +88,7 @@ namespace Server.Engines.Doom
{
public Mobile m_Occupant;
public LeverPuzzleRegion(LeverPuzzleController controller, int[] loc)
public LeverPuzzleRegion(int[] loc)
: base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), new Rectangle2D(loc[0], loc[1], 1, 1))
{
Register();

View file

@ -1,4 +1,3 @@
using System;
using Server.Mobiles;
using Server.Network;

View file

@ -1,4 +1,3 @@
using System;
using Server.Gumps;
using Server.Mobiles;
using Server.Multis;

View file

@ -30,7 +30,7 @@ namespace Server.Factions
{
base.InitOutfit();
AddItem(Utility.RandomBool() ? new QuarterStaff() : (Item)new ShepherdsCrook());
AddItem(Utility.RandomBool() ? new QuarterStaff() : new ShepherdsCrook());
}
public override void VendorBuy(Mobile from)

View file

@ -168,8 +168,6 @@ namespace Server.Engines.Harvest
return type;
}
private static Map SafeMap(Map map) => map == null || map == Map.Internal ? Map.Trammel : map;
public override bool CheckResources(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed)
{
return from?.Backpack?.FindItemsByType<SOS>()

View file

@ -87,7 +87,7 @@ namespace Server.Engines.MLQuests.Items
writer.Write(0); // version
writer.Write(m_QuestType != null ? m_QuestType.FullName : null);
writer.Write(m_QuestType?.FullName);
TextDefinition.Serialize(writer, Message);
}

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Items;
@ -212,8 +211,8 @@ namespace Server.Movement
var tiles = map.Tiles.GetStaticTiles(x, y, true);
var landTile = map.Tiles.GetLandTile(x, y);
var landData = TileData.LandTable[landTile.ID & TileData.MaxLandValue];
var landBlocks = (landData.Flags & TileFlag.Impassable) != 0;
var considerLand = !landTile.Ignored;
var landBlocks = (landData.Flags & TileFlag.Impassable) != 0;
if (landBlocks && canSwim && (landData.Flags & TileFlag.Wet) != 0)
{
@ -224,9 +223,7 @@ namespace Server.Movement
landBlocks = true;
}
int landZ = 0, landCenter = 0, landTop = 0;
map.GetAverageZ(x, y, ref landZ, ref landCenter, ref landTop);
map.GetAverageZ(x, y, out var landZ, out var landCenter, out _);
var moveIsOk = false;
@ -490,9 +487,7 @@ namespace Server.Movement
landBlocks = true;
}
int landZ = 0, landCenter = 0, landTop = 0;
map.GetAverageZ(xCheck, yCheck, ref landZ, ref landCenter, ref landTop);
map.GetAverageZ(xCheck, yCheck, out var landZ, out var landCenter, out var landTop);
var considerLand = !landTile.Ignored;

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;
@ -429,9 +428,7 @@ namespace Server.Movement
var considerLand = !landTile.Ignored;
int landZ = 0, landCenter = 0, landTop = 0;
map.GetAverageZ(x, y, ref landZ, ref landCenter, ref landTop);
map.GetAverageZ(x, y, out var landZ, out var landCenter, out _);
var moveIsOk = false;
@ -630,14 +627,13 @@ namespace Server.Movement
int xCheck = loc.X, yCheck = loc.Y;
var landTile = map.Tiles.GetLandTile(xCheck, yCheck);
int landZ = 0, landCenter = 0, landTop = 0;
var flags = TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags;
var impassable = (flags & TileFlag.Impassable) != 0;
// Impassable + swim on water is ok, otherwise block if cannot walk or impassable
var landBlocks = (m.CantWalk || impassable) && !(impassable && m.CanSwim && (flags & TileFlag.Wet) != 0);
map.GetAverageZ(xCheck, yCheck, ref landZ, ref landCenter, ref landTop);
map.GetAverageZ(xCheck, yCheck, out var landZ, out var landCenter, out var landTop);
var considerLand = !landTile.Ignored;

View file

@ -63,8 +63,6 @@ namespace Server.Engines.Quests.Collector
Y = y;
}
public ImageType Image { get; }
public int Figurine { get; }
public Type Type { get; }

View file

@ -16,8 +16,6 @@
using System;
using System.Collections.Generic;
using Server.Commands.Generic;
using Server.Network;
using static Server.Types;
namespace Server.Engines.Spawners

View file

@ -14,7 +14,6 @@
*************************************************************************/
using System.Collections.Generic;
using System.Reflection;
using Server.Buffers;
using Server.Commands.Generic;
using Server.Engines.Spawners;

View file

@ -331,7 +331,7 @@ namespace Server.Gumps
public ItemTileButtonInfo(Item i) : base(
i.ItemID,
i.Hue,
i.Name == null || i.Name.Length <= 0 ? (TextDefinition)i.LabelNumber : (TextDefinition)i.Name
i.Name == null || i.Name.Length <= 0 ? i.LabelNumber : i.Name
) =>
Item = i;

View file

@ -683,7 +683,7 @@ namespace Server.Mobiles
return AddonFitResult.Blocked;
}
if (!BaseAddon.CheckHouse(from, p, map, 20, ref house))
if (!BaseAddon.CheckHouse(from, p, map, 20, out house))
{
return AddonFitResult.NotInHouse;
}