Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -105,24 +105,12 @@ namespace Server.Items
|
|||
|
||||
public static bool ValidateDefault(Mobile from, BaseBoard board)
|
||||
{
|
||||
if (from.AccessLevel >= AccessLevel.GameMaster)
|
||||
return true;
|
||||
|
||||
if (!from.Alive)
|
||||
return false;
|
||||
|
||||
if (board.IsChildOf(from.Backpack))
|
||||
return true;
|
||||
|
||||
IEntity root = board.RootParent;
|
||||
|
||||
if (root is Mobile && root != from)
|
||||
return false;
|
||||
|
||||
if (board.Deleted || board.Map != from.Map || !from.InRange(board.GetWorldLocation(), 1))
|
||||
return false;
|
||||
|
||||
return BaseHouse.FindHouseAt(board)?.IsOwner(from) == true;
|
||||
// Fixed this because it implies you can use it from your bank, if you can access your bank
|
||||
// while in your house. (!(board.RootParent is Mobile) || board.RootParent == from)
|
||||
return !board.Deleted && (from.AccessLevel >= AccessLevel.GameMaster || from.Alive &&
|
||||
(board.IsChildOf(from.Backpack) || !(board.RootParent is Mobile) &&
|
||||
board.Map == from.Map && from.InRange(board.GetWorldLocation(), 1) &&
|
||||
BaseHouse.FindHouseAt(board)?.IsOwner(from) == true));
|
||||
}
|
||||
|
||||
public class DefaultEntry : ContextMenuEntry
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Server.Items
|
|||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
if (Board == null || Board.Deleted)
|
||||
if (Board?.Deleted != false)
|
||||
Delete();
|
||||
else if (!IsChildOf(Board))
|
||||
Board.DropItem(this);
|
||||
|
|
@ -57,7 +57,7 @@ namespace Server.Items
|
|||
|
||||
public override bool OnDragLift(Mobile from)
|
||||
{
|
||||
if (Board == null || Board.Deleted)
|
||||
if (Board?.Deleted != false)
|
||||
{
|
||||
Delete();
|
||||
return false;
|
||||
|
|
@ -92,4 +92,4 @@ namespace Server.Items
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,47 +144,47 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
Mobile player = m_Players[i];
|
||||
|
||||
if (player != null)
|
||||
if (player == null)
|
||||
continue;
|
||||
|
||||
if (player.Deleted)
|
||||
{
|
||||
if (player.Deleted)
|
||||
m_Players[i] = null;
|
||||
|
||||
SendPlayerExitMessage(player);
|
||||
UpdateDealer(true);
|
||||
|
||||
removed = true;
|
||||
}
|
||||
else if (m_InGame[i])
|
||||
{
|
||||
if (player.NetState == null)
|
||||
{
|
||||
m_Players[i] = null;
|
||||
m_InGame[i] = false;
|
||||
|
||||
SendPlayerExitMessage(player);
|
||||
UpdateDealer(true);
|
||||
|
||||
removed = true;
|
||||
}
|
||||
else if (m_InGame[i])
|
||||
else if (!Game.IsAccessibleTo(player) || player.Map != Game.Map ||
|
||||
!player.InRange(Game.GetWorldLocation(), 5))
|
||||
{
|
||||
if (player.NetState == null)
|
||||
{
|
||||
m_InGame[i] = false;
|
||||
m_InGame[i] = false;
|
||||
|
||||
SendPlayerExitMessage(player);
|
||||
UpdateDealer(true);
|
||||
player.Send(new MahjongRelieve(Game));
|
||||
|
||||
removed = true;
|
||||
}
|
||||
else if (!Game.IsAccessibleTo(player) || player.Map != Game.Map ||
|
||||
!player.InRange(Game.GetWorldLocation(), 5))
|
||||
{
|
||||
m_InGame[i] = false;
|
||||
SendPlayerExitMessage(player);
|
||||
UpdateDealer(true);
|
||||
|
||||
player.Send(new MahjongRelieve(Game));
|
||||
|
||||
SendPlayerExitMessage(player);
|
||||
UpdateDealer(true);
|
||||
|
||||
removed = true;
|
||||
}
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_Spectators.Count;)
|
||||
{
|
||||
Mobile mobile = (Mobile)m_Spectators[i];
|
||||
Mobile mobile = m_Spectators[i];
|
||||
|
||||
if (mobile.NetState == null || mobile.Deleted)
|
||||
{
|
||||
|
|
@ -257,7 +257,7 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
if (nextSeat >= 0)
|
||||
{
|
||||
Mobile newPlayer = (Mobile)m_Spectators[0];
|
||||
Mobile newPlayer = m_Spectators[0];
|
||||
|
||||
m_Spectators.RemoveAt(0);
|
||||
|
||||
|
|
@ -502,4 +502,4 @@ namespace Server.Engines.Mahjong
|
|||
writer.Write(DealerPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue