Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -1,240 +1,265 @@
using System;
using Server.Multis;
using Server.Gumps;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;
using Server.Multis;
namespace Server.Items
{
public class MetalHouseDoor : BaseHouseDoor
{
[Constructible]
public MetalHouseDoor( DoorFacing facing ) : base( facing, 0x675 + (2 * (int)facing), 0x676 + (2 * (int)facing), 0xEC, 0xF3, GetOffset( facing ) )
{
}
public class MetalHouseDoor : BaseHouseDoor
{
[Constructible]
public MetalHouseDoor(DoorFacing facing) : base(facing, 0x675 + 2 * (int)facing, 0x676 + 2 * (int)facing, 0xEC, 0xF3,
GetOffset(facing))
{
}
public MetalHouseDoor( Serial serial ) : base( serial )
{
}
public MetalHouseDoor(Serial serial) : base(serial)
{
}
public override void Serialize( GenericWriter writer ) // Default Serialize method
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
}
writer.Write(0); // version
}
public override void Deserialize( GenericReader reader ) // Default Deserialize method
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
int version = reader.ReadInt();
}
}
public class DarkWoodHouseDoor : BaseHouseDoor
{
[Constructible]
public DarkWoodHouseDoor( DoorFacing facing ) : base( facing, 0x6A5 + (2 * (int)facing), 0x6A6 + (2 * (int)facing), 0xEA, 0xF1, GetOffset( facing ) )
{
}
public class DarkWoodHouseDoor : BaseHouseDoor
{
[Constructible]
public DarkWoodHouseDoor(DoorFacing facing) : base(facing, 0x6A5 + 2 * (int)facing, 0x6A6 + 2 * (int)facing, 0xEA,
0xF1, GetOffset(facing))
{
}
public DarkWoodHouseDoor( Serial serial ) : base( serial )
{
}
public DarkWoodHouseDoor(Serial serial) : base(serial)
{
}
public override void Serialize( GenericWriter writer ) // Default Serialize method
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
}
writer.Write(0); // version
}
public override void Deserialize( GenericReader reader ) // Default Deserialize method
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
int version = reader.ReadInt();
}
}
public class GenericHouseDoor : BaseHouseDoor
{
[Constructible]
public GenericHouseDoor( DoorFacing facing, int baseItemID, int openedSound, int closedSound ) : this( facing, baseItemID, openedSound, closedSound, true )
{
}
public class GenericHouseDoor : BaseHouseDoor
{
[Constructible]
public GenericHouseDoor(DoorFacing facing, int baseItemID, int openedSound, int closedSound) : this(facing,
baseItemID, openedSound, closedSound, true)
{
}
[Constructible]
public GenericHouseDoor( DoorFacing facing, int baseItemID, int openedSound, int closedSound, bool autoAdjust )
: base( facing, baseItemID + (autoAdjust ? (2 * (int)facing) : 0), baseItemID + 1 + (autoAdjust ? (2 * (int)facing) : 0), openedSound, closedSound, GetOffset( facing ) )
{
}
[Constructible]
public GenericHouseDoor(DoorFacing facing, int baseItemID, int openedSound, int closedSound, bool autoAdjust)
: base(facing, baseItemID + (autoAdjust ? 2 * (int)facing : 0),
baseItemID + 1 + (autoAdjust ? 2 * (int)facing : 0), openedSound, closedSound, GetOffset(facing))
{
}
public GenericHouseDoor( Serial serial ) : base( serial )
{
}
public GenericHouseDoor(Serial serial) : base(serial)
{
}
public override void Serialize( GenericWriter writer ) // Default Serialize method
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
}
writer.Write(0); // version
}
public override void Deserialize( GenericReader reader ) // Default Deserialize method
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
int version = reader.ReadInt();
}
}
public abstract class BaseHouseDoor : BaseDoor, ISecurable
{
[CommandProperty( AccessLevel.GameMaster )]
public DoorFacing Facing { get; set; }
public abstract class BaseHouseDoor : BaseDoor, ISecurable
{
public BaseHouseDoor(DoorFacing facing, int closedID, int openedID, int openedSound, int closedSound, Point3D offset)
: base(closedID, openedID, openedSound, closedSound, offset)
{
Facing = facing;
Level = SecureLevel.Anyone;
}
[CommandProperty( AccessLevel.GameMaster )]
public SecureLevel Level { get; set; }
public BaseHouseDoor(Serial serial) : base(serial)
{
}
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
{
base.GetContextMenuEntries( from, list );
SetSecureLevelEntry.AddTo( from, this, list );
}
[CommandProperty(AccessLevel.GameMaster)]
public DoorFacing Facing{ get; set; }
public BaseHouseDoor( DoorFacing facing, int closedID, int openedID, int openedSound, int closedSound, Point3D offset ) : base( closedID, openedID, openedSound, closedSound, offset )
{
Facing = facing;
Level = SecureLevel.Anyone;
}
[CommandProperty(AccessLevel.GameMaster)]
public SecureLevel Level{ get; set; }
public BaseHouse FindHouse()
{
Point3D loc;
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
SetSecureLevelEntry.AddTo(from, this, list);
}
if ( Open )
loc = new Point3D( X - Offset.X, Y - Offset.Y, Z - Offset.Z );
else
loc = Location;
public BaseHouse FindHouse()
{
Point3D loc;
return BaseHouse.FindHouseAt( loc, Map, 20 );
}
if (Open)
loc = new Point3D(X - Offset.X, Y - Offset.Y, Z - Offset.Z);
else
loc = Location;
public bool CheckAccess( Mobile m )
{
BaseHouse house = FindHouse();
return BaseHouse.FindHouseAt(loc, Map, 20);
}
if ( house == null )
return false;
public bool CheckAccess(Mobile m)
{
BaseHouse house = FindHouse();
if ( !house.IsAosRules )
return true;
if (house == null)
return false;
if ( house.Public ? house.IsBanned( m ) : !house.HasAccess( m ) )
return false;
if (!house.IsAosRules)
return true;
return house.HasSecureAccess( m, Level );
}
if (house.Public ? house.IsBanned(m) : !house.HasAccess(m))
return false;
public override void OnOpened( Mobile from )
{
BaseHouse house = FindHouse();
return house.HasSecureAccess(m, Level);
}
if ( house != null && house.IsFriend( from ) && from.AccessLevel == AccessLevel.Player && house.RefreshDecay() )
from.SendLocalizedMessage( 1043293 ); // Your house's age and contents have been refreshed.
public override void OnOpened(Mobile from)
{
BaseHouse house = FindHouse();
if ( house != null && house.Public && !house.IsFriend( from ) )
house.Visits++;
}
if (house != null && house.IsFriend(from) && from.AccessLevel == AccessLevel.Player && house.RefreshDecay())
from.SendLocalizedMessage(1043293); // Your house's age and contents have been refreshed.
public override bool UseLocks()
{
BaseHouse house = FindHouse();
if (house != null && house.Public && !house.IsFriend(from))
house.Visits++;
}
return ( house == null || !house.IsAosRules );
}
public override bool UseLocks()
{
BaseHouse house = FindHouse();
public override void Use( Mobile from )
{
if ( !CheckAccess( from ) )
from.SendLocalizedMessage( 1061637 ); // You are not allowed to access this.
else
base.Use( from );
}
return house == null || !house.IsAosRules;
}
public BaseHouseDoor( Serial serial ) : base( serial )
{
}
public override void Use(Mobile from)
{
if (!CheckAccess(from))
from.SendLocalizedMessage(1061637); // You are not allowed to access this.
else
base.Use(from);
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 1 ); // version
writer.Write(1); // version
writer.Write( (int) Level );
writer.Write((int)Level);
writer.Write( (int) Facing );
}
writer.Write((int)Facing);
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
int version = reader.ReadInt();
switch ( version )
{
case 1:
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
if ( version < 1 )
Level = SecureLevel.Anyone;
switch (version)
{
case 1:
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
if (version < 1)
Level = SecureLevel.Anyone;
Facing = (DoorFacing)reader.ReadInt();
break;
}
}
}
Facing = (DoorFacing)reader.ReadInt();
break;
}
}
}
public override bool IsInside( Mobile from )
{
int x,y,w,h;
public override bool IsInside(Mobile from)
{
int x, y, w, h;
const int r = 2;
const int bs = r*2+1;
const int ss = r+1;
const int r = 2;
const int bs = r * 2 + 1;
const int ss = r + 1;
switch ( Facing )
{
case DoorFacing.WestCW:
case DoorFacing.EastCCW: x = -r; y = -r; w = bs; h = ss; break;
switch (Facing)
{
case DoorFacing.WestCW:
case DoorFacing.EastCCW:
x = -r;
y = -r;
w = bs;
h = ss;
break;
case DoorFacing.EastCW:
case DoorFacing.WestCCW: x = -r; y = 0; w = bs; h = ss; break;
case DoorFacing.EastCW:
case DoorFacing.WestCCW:
x = -r;
y = 0;
w = bs;
h = ss;
break;
case DoorFacing.SouthCW:
case DoorFacing.NorthCCW: x = -r; y = -r; w = ss; h = bs; break;
case DoorFacing.SouthCW:
case DoorFacing.NorthCCW:
x = -r;
y = -r;
w = ss;
h = bs;
break;
case DoorFacing.NorthCW:
case DoorFacing.SouthCCW: x = 0; y = -r; w = ss; h = bs; break;
case DoorFacing.NorthCW:
case DoorFacing.SouthCCW:
x = 0;
y = -r;
w = ss;
h = bs;
break;
//No way to test the 'insideness' of SE Sliding doors on OSI, so leaving them default to false until furthur information gained
//No way to test the 'insideness' of SE Sliding doors on OSI, so leaving them default to false until furthur information gained
default: return false;
}
default: return false;
}
int rx = from.X - X;
int ry = from.Y - Y;
int az = Math.Abs( from.Z - Z );
int rx = from.X - X;
int ry = from.Y - Y;
int az = Math.Abs(from.Z - Z);
return ( rx >= x && rx < (x+w) && ry >= y && ry < (y+h) && az <= 4 );
}
}
return rx >= x && rx < x + w && ry >= y && ry < y + h && az <= 4;
}
}
}