Fixes for Last Moved (#194)

This commit is contained in:
Kamron Batman 2020-08-16 06:58:16 -07:00 • committed by GitHub
parent 3a081d5322
commit b476bcfd24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 155 additions and 398 deletions

View file

@ -545,10 +545,7 @@ namespace Server.Items
toKill.RemoveAt(kill);
amount -= 1;
LiveCreatures -= 1;
if (LiveCreatures < 0)
LiveCreatures = 0;
LiveCreatures = Math.Max(LiveCreatures - 1, 0);
Events.Add(1074366); // An unfortunate accident has left a creature floating upside-down. It is starting to smell.
}
@ -598,8 +595,8 @@ namespace Server.Items
if (OptimalState && LiveCreatures < MaxLiveCreatures)
if (Utility.RandomDouble() < 0.005 * LiveCreatures)
{
BaseFish fish = null;
int message = 0;
BaseFish fish;
int message;
switch (Utility.Random(6))
{
@ -745,7 +742,7 @@ namespace Server.Items
public virtual bool RemoveItem(Mobile from, int at)
{
if (at < 0 && at >= Items.Count)
if (at < 0 || at >= Items.Count)
return false;
Item item = Items[at];

View file

@ -136,7 +136,7 @@ namespace Server.Engines.Mahjong
int hand = tile.Dimensions.GetHandArea();
if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to ||
(game.SpectatorVision && players.IsSpectator(to)))
game.SpectatorVision && players.IsSpectator(to))
Stream.Write((byte)tile.Value);
else
Stream.Write((byte)0);
@ -176,7 +176,7 @@ namespace Server.Engines.Mahjong
int hand = tile.Dimensions.GetHandArea();
if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to ||
(game.SpectatorVision && players.IsSpectator(to)))
game.SpectatorVision && players.IsSpectator(to))
Stream.Write((byte)tile.Value);
else
Stream.Write((byte)0);
@ -206,4 +206,4 @@ namespace Server.Engines.Mahjong
Stream.Write((byte)0x1A);
}
}
}
}

View file

@ -368,12 +368,7 @@ namespace Server.Items
from.Send(new PlaySound(0x42, GetWorldLocation()));
string desc = rune.Description;
if (desc == null || (desc = desc.Trim()).Length == 0)
desc = "(indescript)";
from.SendMessage(desc);
from.SendMessage(rune.Description?.Trim().IsNullOrDefault("(indescript)"));
return true;
}

View file

@ -138,10 +138,7 @@ namespace Server.Items
check = m.FindItemOnLayer(Layer.TwoHanded);
if (check is BaseTool && check != tool && !(check is AncientSmithyHammer))
return false;
return true;
return !(check is BaseTool) || check == tool || check is AncientSmithyHammer;
}
public override void OnSingleClick(Mobile from)
@ -159,16 +156,11 @@ namespace Server.Items
int num = system.CanCraft(from, this, null);
if (num > 0 && (num != 1044267 || !Core.SE)) // Blacksmithing shows the gump regardless of proximity of an anvil and forge after SE
{
// Blacksmithing shows the gump regardless of proximity of an anvil and forge after SE
if (num > 0 && (num != 1044267 || !Core.SE))
from.SendLocalizedMessage(num);
}
else
{
CraftContext context = system.GetContext(from);
from.SendGump(new CraftGump(from, system, this, null));
}
}
else
{

View file

@ -31,10 +31,7 @@ namespace Server.Regions
BankBox bank = from.FindBankNoCreate();
if (bank != null && ContainsDeed(bank))
return true;
return false;
return bank != null && ContainsDeed(bank);
}
private bool ContainsDeed(Container cont)
@ -53,4 +50,4 @@ namespace Server.Regions
return base.OnTarget(m, t, o);
}
}
}
}

View file

@ -68,13 +68,7 @@ namespace Server.Items
get => m_Charges;
set
{
if (value > MaxCharges)
m_Charges = MaxCharges;
else if (value < 0)
m_Charges = 0;
else
m_Charges = value;
m_Charges = Math.Clamp(value, 0, MaxCharges);
InvalidateProperties();
}
}
@ -85,13 +79,7 @@ namespace Server.Items
get => m_Recharges;
set
{
if (value > MaxRecharges)
m_Recharges = MaxRecharges;
else if (value < 0)
m_Recharges = 0;
else
m_Recharges = value;
m_Recharges = Math.Clamp(value, 0, MaxRecharges);
InvalidateProperties();
}
}
@ -278,4 +266,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Server.ContextMenus;
using Server.Engines.ConPVP;
using Server.Mobiles;
@ -61,13 +62,7 @@ namespace Server.Items
get => m_Charges;
set
{
if (value > MaxCharges)
m_Charges = MaxCharges;
else if (value < 0)
m_Charges = 0;
else
m_Charges = value;
m_Charges = Math.Clamp(value, 0, MaxCharges);
InvalidateProperties();
}
}
@ -78,13 +73,7 @@ namespace Server.Items
get => m_Recharges;
set
{
if (value > MaxRecharges)
m_Recharges = MaxRecharges;
else if (value < 0)
m_Recharges = 0;
else
m_Recharges = value;
m_Recharges = Math.Clamp(value, 0, MaxRecharges);
InvalidateProperties();
}
}
@ -100,17 +89,13 @@ namespace Server.Items
public override void AddNameProperty(ObjectPropertyList list)
{
list.Add(1054131,
m_Charges + (PetName.Length == 0
? "\t "
: $"\t{PetName}")); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~]
$"{m_Charges}\t{PetName.IsNullOrDefault(" ")}"); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~]
}
public override void OnSingleClick(Mobile from)
{
LabelTo(from, 1054131,
m_Charges + (PetName.Length == 0
? "\t "
: $"\t{PetName}")); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~]
$"{m_Charges}\t{PetName.IsNullOrDefault(" ")}"); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~]
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
@ -415,13 +400,8 @@ namespace Server.Items
Disturb(DisturbType.Hurt, false);
}
public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable)
{
if (type == DisturbType.EquipRequest || type == DisturbType.UseRequest /* || type == DisturbType.Hurt*/)
return false;
return true;
}
public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) =>
type != DisturbType.EquipRequest && type != DisturbType.UseRequest;
public override void DoHurtFizzle()
{

View file

@ -63,13 +63,7 @@ namespace Server.Items
get => m_Charges;
set
{
if (value > MaxCharges)
m_Charges = MaxCharges;
else if (value < 0)
m_Charges = 0;
else
m_Charges = value;
m_Charges = Math.Clamp(value, 0, MaxCharges);
InvalidateProperties();
}
}
@ -80,13 +74,7 @@ namespace Server.Items
get => m_Recharges;
set
{
if (value > MaxRecharges)
m_Recharges = MaxRecharges;
else if (value < 0)
m_Recharges = 0;
else
m_Recharges = value;
m_Recharges = Math.Clamp(value, 0, MaxRecharges);
InvalidateProperties();
}
}
@ -102,17 +90,13 @@ namespace Server.Items
public override void AddNameProperty(ObjectPropertyList list)
{
list.Add(1054000,
m_Charges + (m_Inscription.Length == 0
? "\t "
: $" :\t{m_Inscription}")); // a bracelet of binding : ~1_val~ ~2_val~
$"{m_Charges}\t{m_Inscription.IsNullOrDefault(" ")}"); // a bracelet of binding : ~1_val~ ~2_val~
}
public override void OnSingleClick(Mobile from)
{
LabelTo(from, 1054000,
m_Charges + (m_Inscription.Length == 0
? "\t "
: $" :\t{m_Inscription}")); // a bracelet of binding : ~1_val~ ~2_val~
$"{m_Charges}\t{m_Inscription.IsNullOrDefault(" ")}"); // a bracelet of binding : ~1_val~ ~2_val~
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)

View file

@ -138,7 +138,7 @@ namespace Server.Items
protected virtual bool CheckUse(Mobile from)
{
DateTime now = DateTime.UtcNow;
// DateTime now = DateTime.UtcNow;
PlayerMobile pm = from as PlayerMobile;