Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -2,14 +2,14 @@ using System;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
[AttributeUsage( AttributeTargets.Class )]
|
||||
public class CorpseNameAttribute : Attribute
|
||||
{
|
||||
public string Name { get; }
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class CorpseNameAttribute : Attribute
|
||||
{
|
||||
public CorpseNameAttribute(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public CorpseNameAttribute( string name )
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
public string Name{ get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -2,111 +2,110 @@ using System;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class DecayedCorpse : Container
|
||||
{
|
||||
private Timer m_DecayTimer;
|
||||
private DateTime m_DecayTime;
|
||||
public class DecayedCorpse : Container
|
||||
{
|
||||
private static TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(7.0);
|
||||
private DateTime m_DecayTime;
|
||||
private Timer m_DecayTimer;
|
||||
|
||||
private static TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes( 7.0 );
|
||||
public DecayedCorpse(string name) : base(Utility.Random(0xECA, 9))
|
||||
{
|
||||
Movable = false;
|
||||
Name = name;
|
||||
|
||||
public DecayedCorpse( string name ) : base( Utility.Random( 0xECA, 9 ) )
|
||||
{
|
||||
Movable = false;
|
||||
Name = name;
|
||||
BeginDecay(m_DefaultDecayTime);
|
||||
}
|
||||
|
||||
BeginDecay( m_DefaultDecayTime );
|
||||
}
|
||||
public DecayedCorpse(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public void BeginDecay( TimeSpan delay )
|
||||
{
|
||||
m_DecayTimer?.Stop();
|
||||
// Do not display (x items, y stones)
|
||||
public override bool DisplaysContent => false;
|
||||
|
||||
m_DecayTime = DateTime.UtcNow + delay;
|
||||
public void BeginDecay(TimeSpan delay)
|
||||
{
|
||||
m_DecayTimer?.Stop();
|
||||
|
||||
m_DecayTimer = new InternalTimer( this, delay );
|
||||
m_DecayTimer.Start();
|
||||
}
|
||||
m_DecayTime = DateTime.UtcNow + delay;
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
m_DecayTimer?.Stop();
|
||||
m_DecayTimer = new InternalTimer(this, delay);
|
||||
m_DecayTimer.Start();
|
||||
}
|
||||
|
||||
m_DecayTimer = null;
|
||||
}
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
m_DecayTimer?.Stop();
|
||||
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private DecayedCorpse m_Corpse;
|
||||
m_DecayTimer = null;
|
||||
}
|
||||
|
||||
public InternalTimer( DecayedCorpse c, TimeSpan delay ) : base( delay )
|
||||
{
|
||||
m_Corpse = c;
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
// Do not display (x items, y stones)
|
||||
public override bool CheckContentDisplay(Mobile from)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_Corpse.Delete();
|
||||
}
|
||||
}
|
||||
public override void AddNameProperty(ObjectPropertyList list)
|
||||
{
|
||||
list.Add(1046414, Name); // the remains of ~1_NAME~
|
||||
}
|
||||
|
||||
// Do not display (x items, y stones)
|
||||
public override bool CheckContentDisplay( Mobile from )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
LabelTo(from, 1046414, Name); // the remains of ~1_NAME~
|
||||
}
|
||||
|
||||
// Do not display (x items, y stones)
|
||||
public override bool DisplaysContent => false;
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
public override void AddNameProperty( ObjectPropertyList list )
|
||||
{
|
||||
list.Add( 1046414, Name ); // the remains of ~1_NAME~
|
||||
}
|
||||
writer.Write(1); // version
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
LabelTo( from, 1046414, Name ); // the remains of ~1_NAME~
|
||||
}
|
||||
writer.Write(m_DecayTimer != null);
|
||||
|
||||
public DecayedCorpse( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
if (m_DecayTimer != null)
|
||||
writer.WriteDeltaTime(m_DecayTime);
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
int version = reader.ReadInt();
|
||||
|
||||
writer.Write( m_DecayTimer != null );
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
BeginDecay(m_DefaultDecayTime);
|
||||
|
||||
if ( m_DecayTimer != null )
|
||||
writer.WriteDeltaTime( m_DecayTime );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (reader.ReadBool())
|
||||
BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow);
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private DecayedCorpse m_Corpse;
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
BeginDecay( m_DefaultDecayTime );
|
||||
public InternalTimer(DecayedCorpse c, TimeSpan delay) : base(delay)
|
||||
{
|
||||
m_Corpse = c;
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if ( reader.ReadBool() )
|
||||
BeginDecay( reader.ReadDeltaTime() - DateTime.UtcNow );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_Corpse.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,198 +1,198 @@
|
|||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public sealed class CorpseEquip : Packet
|
||||
{
|
||||
public CorpseEquip( Mobile beholder, Corpse beheld ) : base( 0x89 )
|
||||
{
|
||||
List<Item> list = beheld.EquipItems;
|
||||
public sealed class CorpseEquip : Packet
|
||||
{
|
||||
public CorpseEquip(Mobile beholder, Corpse beheld) : base(0x89)
|
||||
{
|
||||
List<Item> list = beheld.EquipItems;
|
||||
|
||||
int count = list.Count;
|
||||
if ( beheld.Hair != null && beheld.Hair.ItemID > 0 )
|
||||
count++;
|
||||
if ( beheld.FacialHair != null && beheld.FacialHair.ItemID > 0 )
|
||||
count++;
|
||||
int count = list.Count;
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
|
||||
EnsureCapacity( 8 + (count * 5) );
|
||||
EnsureCapacity(8 + count * 5);
|
||||
|
||||
m_Stream.Write( (int) beheld.Serial );
|
||||
m_Stream.Write(beheld.Serial);
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
Item item = list[i];
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
Item item = list[i];
|
||||
|
||||
if ( !item.Deleted && beholder.CanSee( item ) && item.Parent == beheld )
|
||||
{
|
||||
m_Stream.Write( (byte) (item.Layer + 1) );
|
||||
m_Stream.Write( (int) item.Serial );
|
||||
}
|
||||
}
|
||||
if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
|
||||
{
|
||||
m_Stream.Write((byte)(item.Layer + 1));
|
||||
m_Stream.Write(item.Serial);
|
||||
}
|
||||
}
|
||||
|
||||
if ( beheld.Hair != null && beheld.Hair.ItemID > 0 )
|
||||
{
|
||||
m_Stream.Write( (byte)(Layer.Hair + 1) );
|
||||
m_Stream.Write( (int)HairInfo.FakeSerial( beheld.Owner ) - 2 );
|
||||
}
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write((byte)(Layer.Hair + 1));
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
}
|
||||
|
||||
if ( beheld.FacialHair != null && beheld.FacialHair.ItemID > 0 )
|
||||
{
|
||||
m_Stream.Write( (byte)(Layer.FacialHair + 1) );
|
||||
m_Stream.Write( (int)FacialHairInfo.FakeSerial( beheld.Owner ) - 2 );
|
||||
}
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write((byte)(Layer.FacialHair + 1));
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
}
|
||||
|
||||
m_Stream.Write( (byte) Layer.Invalid );
|
||||
}
|
||||
}
|
||||
m_Stream.Write((byte)Layer.Invalid);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CorpseContent : Packet
|
||||
{
|
||||
public CorpseContent( Mobile beholder, Corpse beheld )
|
||||
: base( 0x3C )
|
||||
{
|
||||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
public sealed class CorpseContent : Packet
|
||||
{
|
||||
public CorpseContent(Mobile beholder, Corpse beheld)
|
||||
: base(0x3C)
|
||||
{
|
||||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
|
||||
if ( beheld.Hair != null && beheld.Hair.ItemID > 0 )
|
||||
count++;
|
||||
if ( beheld.FacialHair != null && beheld.FacialHair.ItemID > 0 )
|
||||
count++;
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
|
||||
EnsureCapacity( 5 + (count * 19) );
|
||||
EnsureCapacity(5 + count * 19);
|
||||
|
||||
long pos = m_Stream.Position;
|
||||
long pos = m_Stream.Position;
|
||||
|
||||
int written = 0;
|
||||
int written = 0;
|
||||
|
||||
m_Stream.Write( (ushort)0 );
|
||||
m_Stream.Write((ushort)0);
|
||||
|
||||
for( int i = 0; i < items.Count; ++i )
|
||||
{
|
||||
Item child = items[i];
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
|
||||
if ( !child.Deleted && child.Parent == beheld && beholder.CanSee( child ) )
|
||||
{
|
||||
m_Stream.Write( (int)child.Serial );
|
||||
m_Stream.Write( (ushort)child.ItemID );
|
||||
m_Stream.Write( (byte)0 ); // signed, itemID offset
|
||||
m_Stream.Write( (ushort)child.Amount );
|
||||
m_Stream.Write( (short)child.X );
|
||||
m_Stream.Write( (short)child.Y );
|
||||
m_Stream.Write( (int)beheld.Serial );
|
||||
m_Stream.Write( (ushort)child.Hue );
|
||||
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
|
||||
{
|
||||
m_Stream.Write(child.Serial);
|
||||
m_Stream.Write((ushort)child.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)child.Amount);
|
||||
m_Stream.Write((short)child.X);
|
||||
m_Stream.Write((short)child.Y);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)child.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
}
|
||||
++written;
|
||||
}
|
||||
}
|
||||
|
||||
if ( beheld.Hair != null && beheld.Hair.ItemID > 0 )
|
||||
{
|
||||
m_Stream.Write( (int)HairInfo.FakeSerial( beheld.Owner ) - 2 );
|
||||
m_Stream.Write( (ushort)beheld.Hair.ItemID );
|
||||
m_Stream.Write( (byte)0 ); // signed, itemID offset
|
||||
m_Stream.Write( (ushort)1 );
|
||||
m_Stream.Write( (short)0 );
|
||||
m_Stream.Write( (short)0 );
|
||||
m_Stream.Write( (int)beheld.Serial );
|
||||
m_Stream.Write( (ushort)beheld.Hair.Hue );
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.Hair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
++written;
|
||||
}
|
||||
|
||||
if ( beheld.FacialHair != null && beheld.FacialHair.ItemID > 0 )
|
||||
{
|
||||
m_Stream.Write( (int)FacialHairInfo.FakeSerial( beheld.Owner ) - 2 );
|
||||
m_Stream.Write( (ushort)beheld.FacialHair.ItemID );
|
||||
m_Stream.Write( (byte)0 ); // signed, itemID offset
|
||||
m_Stream.Write( (ushort)1 );
|
||||
m_Stream.Write( (short)0 );
|
||||
m_Stream.Write( (short)0 );
|
||||
m_Stream.Write( (int)beheld.Serial );
|
||||
m_Stream.Write( (ushort)beheld.FacialHair.Hue );
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
++written;
|
||||
}
|
||||
|
||||
m_Stream.Seek( pos, SeekOrigin.Begin );
|
||||
m_Stream.Write( (ushort)written );
|
||||
}
|
||||
}
|
||||
m_Stream.Seek(pos, SeekOrigin.Begin);
|
||||
m_Stream.Write((ushort)written);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CorpseContent6017 : Packet
|
||||
{
|
||||
public CorpseContent6017(Mobile beholder, Corpse beheld)
|
||||
: base(0x3C)
|
||||
{
|
||||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
public sealed class CorpseContent6017 : Packet
|
||||
{
|
||||
public CorpseContent6017(Mobile beholder, Corpse beheld)
|
||||
: base(0x3C)
|
||||
{
|
||||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
|
||||
EnsureCapacity(5 + (count * 20));
|
||||
EnsureCapacity(5 + count * 20);
|
||||
|
||||
long pos = m_Stream.Position;
|
||||
long pos = m_Stream.Position;
|
||||
|
||||
int written = 0;
|
||||
int written = 0;
|
||||
|
||||
m_Stream.Write((ushort)0);
|
||||
m_Stream.Write((ushort)0);
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
|
||||
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
|
||||
{
|
||||
m_Stream.Write((int)child.Serial);
|
||||
m_Stream.Write((ushort)child.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)child.Amount);
|
||||
m_Stream.Write((short)child.X);
|
||||
m_Stream.Write((short)child.Y);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write((int)beheld.Serial);
|
||||
m_Stream.Write((ushort)child.Hue);
|
||||
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
|
||||
{
|
||||
m_Stream.Write(child.Serial);
|
||||
m_Stream.Write((ushort)child.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)child.Amount);
|
||||
m_Stream.Write((short)child.X);
|
||||
m_Stream.Write((short)child.Y);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)child.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
}
|
||||
++written;
|
||||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write((int)HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write((int)beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.Hair.Hue);
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.Hair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
++written;
|
||||
}
|
||||
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write((int)FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write((int)beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.Hue);
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
++written;
|
||||
}
|
||||
|
||||
m_Stream.Seek(pos, SeekOrigin.Begin);
|
||||
m_Stream.Write((ushort)written);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Stream.Seek(pos, SeekOrigin.Begin);
|
||||
m_Stream.Write((ushort)written);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue