Code Cleanup & Fixes Warnings (#74)

This commit is contained in:
Kamron Batman 2020-01-18 14:56:45 -08:00 committed by GitHub
parent e11d1f3ad9
commit 57b14ad690
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
143 changed files with 2960 additions and 3427 deletions

View file

@ -995,8 +995,7 @@ namespace Server.Multis
public void DropToMovingCrate(Item item)
{
if (MovingCrate == null)
MovingCrate = new MovingCrate(this);
MovingCrate ??= new MovingCrate(this);
MovingCrate.DropItem(item);
}
@ -2594,32 +2593,16 @@ namespace Server.Multis
Account acct = mob.Account as Account;
Mobile trans = null;
for (int i = 0; i < acct.Length; ++i)
if (acct[i] != null && acct[i] != mob)
trans = acct[i];
if (acct != null)
for (int i = 0; i < acct.Length; ++i)
if (acct[i] != null && acct[i] != mob)
trans = acct[i];
for (int i = 0; i < houses.Count; ++i)
{
BaseHouse house = houses[i];
bool canClaim = false;
if (trans == null)
canClaim = house.CoOwners.Count > 0;
/*{
for ( int j = 0; j < house.CoOwners.Count; ++j )
{
Mobile check = house.CoOwners[j] as Mobile;
if ( check != null && !check.Deleted && !HasAccountHouse( check ) )
{
canClaim = true;
break;
}
}
}*/
if (trans == null && !canClaim)
if (trans == null && house.CoOwners.Count == 0)
Timer.DelayCall(TimeSpan.Zero, house.Delete);
else
house.Owner = trans;
@ -2801,21 +2784,8 @@ namespace Server.Multis
AllHouses.Remove(this);
}
public static bool HasHouse(Mobile m)
{
if (m == null || !m_Table.TryGetValue(m, out List<BaseHouse> list))
return false;
for (int i = 0; i < list.Count; ++i)
{
BaseHouse h = list[i];
if (!h.Deleted)
return true;
}
return false;
}
public static bool HasHouse(Mobile m) =>
m != null && m_Table.TryGetValue(m, out List<BaseHouse> list) && list.Any(h => !h.Deleted);
public static bool HasAccountHouse(Mobile m)
{
@ -2829,35 +2799,15 @@ namespace Server.Multis
return false;
}
public bool IsOwner(Mobile m)
{
if (m == null)
return false;
public bool IsOwner(Mobile m) =>
m != null && (m == m_Owner || m.AccessLevel >= AccessLevel.GameMaster ||
IsAosRules && AccountHandler.CheckAccount(m, m_Owner));
if (m == m_Owner || m.AccessLevel >= AccessLevel.GameMaster)
return true;
public bool IsCoOwner(Mobile m) =>
m != null && CoOwners != null &&
(IsOwner(m) || CoOwners.Contains(m) || !IsAosRules && AccountHandler.CheckAccount(m, m_Owner));
return IsAosRules && AccountHandler.CheckAccount(m, m_Owner);
}
public bool IsCoOwner(Mobile m)
{
if (m == null || CoOwners == null)
return false;
if (IsOwner(m) || CoOwners.Contains(m))
return true;
return !IsAosRules && AccountHandler.CheckAccount(m, m_Owner);
}
public bool IsGuildMember(Mobile m)
{
if (m == null || Owner?.Guild == null)
return false;
return m.Guild == Owner.Guild;
}
public bool IsGuildMember(Mobile m) => m != null && Owner?.Guild != null && m.Guild == Owner.Guild;
public void RemoveKeys(Mobile m)
{
@ -2866,8 +2816,7 @@ namespace Server.Multis
uint keyValue = 0;
for (int i = 0; keyValue == 0 && i < Doors.Count; ++i)
if (Doors[i] is BaseDoor door)
keyValue = door.KeyValue;
keyValue = Doors[i].KeyValue;
Key.RemoveKeys(m, keyValue);
}
@ -2879,30 +2828,23 @@ namespace Server.Multis
if (Doors != null)
for (int i = 0; i < Doors.Count; ++i)
if (Doors[i] is BaseDoor door)
door.KeyValue = keyValue;
Doors[i].KeyValue = keyValue;
}
public void RemoveLocks()
{
if (Doors != null)
for (int i = 0; i < Doors.Count; ++i)
if (Doors[i] is BaseDoor door)
{
door.KeyValue = 0;
door.Locked = false;
}
{
BaseDoor door = Doors[i];
door.KeyValue = 0;
door.Locked = false;
}
}
public virtual HouseDeed GetDeed() => null;
public bool IsFriend(Mobile m)
{
if (m == null || Friends == null)
return false;
return IsCoOwner(m) || Friends.Contains(m);
}
public bool IsFriend(Mobile m) => m != null && Friends != null && (IsCoOwner(m) || Friends.Contains(m));
public bool IsBanned(Mobile m)
{

View file

@ -1185,44 +1185,44 @@ namespace Server.Multis
MultiComponentList newComponents = MultiData.GetComponents(itemID);
for (int x = 0; x < newComponents.Width; ++x)
for (int y = 0; y < newComponents.Height; ++y)
for (int y = 0; y < newComponents.Height; ++y)
{
int tx = p.X + newComponents.Min.X + x;
int ty = p.Y + newComponents.Min.Y + y;
if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty))
continue;
LandTile landTile = map.Tiles.GetLandTile(tx, ty);
StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true);
bool hasWater = landTile.Z == p.Z &&
(landTile.ID >= 168 && landTile.ID <= 171 || landTile.ID >= 310 && landTile.ID <= 311);
// int z = p.Z;
//int landZ = 0, landAvg = 0, landTop = 0;
//map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop );
//if ( !landTile.Ignored && top > landZ && landTop > z )
// return false;
for (int i = 0; i < tiles.Length; ++i)
{
int tx = p.X + newComponents.Min.X + x;
int ty = p.Y + newComponents.Min.Y + y;
StaticTile tile = tiles[i];
bool isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2;
if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty))
continue;
LandTile landTile = map.Tiles.GetLandTile(tx, ty);
StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true);
bool hasWater = landTile.Z == p.Z &&
(landTile.ID >= 168 && landTile.ID <= 171 || landTile.ID >= 310 && landTile.ID <= 311);
// int z = p.Z;
//int landZ = 0, landAvg = 0, landTop = 0;
//map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop );
//if ( !landTile.Ignored && top > landZ && landTop > z )
// return false;
for (int i = 0; i < tiles.Length; ++i)
{
StaticTile tile = tiles[i];
bool isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2;
if (tile.Z == p.Z && isWater)
hasWater = true;
else if (tile.Z >= p.Z && !isWater)
return false;
}
if (!hasWater)
if (tile.Z == p.Z && isWater)
hasWater = true;
else if (tile.Z >= p.Z && !isWater)
return false;
}
if (!hasWater)
return false;
}
IPooledEnumerable<Item> eable = map.GetItemsInBounds(new Rectangle2D(p.X + newComponents.Min.X,
p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height));

View file

@ -300,8 +300,7 @@ namespace Server.Multis
public void AddFixtures(Mobile from, MultiTileEntry[] list)
{
if (Fixtures == null)
Fixtures = new List<Item>();
Fixtures ??= new List<Item>();
uint keyValue = 0;
@ -530,7 +529,6 @@ namespace Server.Multis
switch (door.Facing)
{
default:
case DoorFacing.WestCW:
linkFacing = DoorFacing.EastCCW;
xOffset = 1;
yOffset = 0;
@ -618,7 +616,6 @@ namespace Server.Multis
switch (type)
{
default:
case FoundationType.DarkWood:
corner = 0x0014;
east = 0x0015;
south = 0x0016;
@ -1284,7 +1281,6 @@ namespace Server.Multis
switch (dir)
{
default:
case 0: // North
{
xStart = x;
yStart = y + height;