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

@ -2,232 +2,243 @@ using System;
namespace Server.Items
{
public class MiniHouseAddon : BaseAddon
{
private MiniHouseType m_Type;
public class MiniHouseAddon : BaseAddon
{
private MiniHouseType m_Type;
[CommandProperty( AccessLevel.GameMaster )]
public MiniHouseType Type
{
get => m_Type;
set{ m_Type = value; Construct(); }
}
[Constructible]
public MiniHouseAddon() : this(MiniHouseType.StoneAndPlaster)
{
}
public override BaseAddonDeed Deed => new MiniHouseDeed( m_Type );
[Constructible]
public MiniHouseAddon(MiniHouseType type)
{
m_Type = type;
[Constructible]
public MiniHouseAddon() : this( MiniHouseType.StoneAndPlaster )
{
}
Construct();
}
[Constructible]
public MiniHouseAddon( MiniHouseType type )
{
m_Type = type;
public MiniHouseAddon(Serial serial) : base(serial)
{
}
Construct();
}
[CommandProperty(AccessLevel.GameMaster)]
public MiniHouseType Type
{
get => m_Type;
set
{
m_Type = value;
Construct();
}
}
public void Construct()
{
foreach ( AddonComponent c in Components )
{
c.Addon = null;
c.Delete();
}
public override BaseAddonDeed Deed => new MiniHouseDeed(m_Type);
Components.Clear();
public void Construct()
{
foreach (AddonComponent c in Components)
{
c.Addon = null;
c.Delete();
}
MiniHouseInfo info = MiniHouseInfo.GetInfo( m_Type );
Components.Clear();
int size = (int)Math.Sqrt( info.Graphics.Length );
int num = 0;
MiniHouseInfo info = MiniHouseInfo.GetInfo(m_Type);
for ( int y = 0; y < size; ++y )
for ( int x = 0; x < size; ++x )
if ( info.Graphics[num] != 0x1 ) // Veteran Rewards Mod
AddComponent( new AddonComponent( info.Graphics[num++] ), size - x - 1, size - y - 1, 0 );
}
int size = (int)Math.Sqrt(info.Graphics.Length);
int num = 0;
public MiniHouseAddon( Serial serial ) : base( serial )
{
}
for (int y = 0; y < size; ++y)
for (int x = 0; x < size; ++x)
if (info.Graphics[num] != 0x1) // Veteran Rewards Mod
AddComponent(new AddonComponent(info.Graphics[num++]), size - x - 1, size - y - 1, 0);
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
writer.Write(0); // version
writer.Write( (int) m_Type );
}
writer.Write((int)m_Type);
}
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 0:
{
m_Type = (MiniHouseType)reader.ReadInt();
break;
}
}
}
}
switch (version)
{
case 0:
{
m_Type = (MiniHouseType)reader.ReadInt();
break;
}
}
}
}
public class MiniHouseDeed : BaseAddonDeed
{
private MiniHouseType m_Type;
public class MiniHouseDeed : BaseAddonDeed
{
private MiniHouseType m_Type;
[CommandProperty( AccessLevel.GameMaster )]
public MiniHouseType Type
{
get => m_Type;
set{ m_Type = value; InvalidateProperties(); }
}
[Constructible]
public MiniHouseDeed() : this(MiniHouseType.StoneAndPlaster)
{
}
public override BaseAddon Addon => new MiniHouseAddon( m_Type );
public override int LabelNumber => 1062096; // a mini house deed
[Constructible]
public MiniHouseDeed(MiniHouseType type)
{
m_Type = type;
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
Weight = 1.0;
LootType = LootType.Blessed;
}
list.Add( MiniHouseInfo.GetInfo( m_Type ).LabelNumber );
}
public MiniHouseDeed(Serial serial) : base(serial)
{
}
[Constructible]
public MiniHouseDeed() : this( MiniHouseType.StoneAndPlaster )
{
}
[CommandProperty(AccessLevel.GameMaster)]
public MiniHouseType Type
{
get => m_Type;
set
{
m_Type = value;
InvalidateProperties();
}
}
[Constructible]
public MiniHouseDeed( MiniHouseType type )
{
m_Type = type;
public override BaseAddon Addon => new MiniHouseAddon(m_Type);
public override int LabelNumber => 1062096; // a mini house deed
Weight = 1.0;
LootType = LootType.Blessed;
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
public MiniHouseDeed( Serial serial ) : base( serial )
{
}
list.Add(MiniHouseInfo.GetInfo(m_Type).LabelNumber);
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
writer.Write(0); // version
writer.Write( (int) m_Type );
}
writer.Write((int)m_Type);
}
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 0:
{
m_Type = (MiniHouseType)reader.ReadInt();
break;
}
}
switch (version)
{
case 0:
{
m_Type = (MiniHouseType)reader.ReadInt();
break;
}
}
if ( Weight == 0.0 )
Weight = 1.0;
}
}
if (Weight == 0.0)
Weight = 1.0;
}
}
public enum MiniHouseType
{
StoneAndPlaster,
FieldStone,
SmallBrick,
Wooden,
WoodAndPlaster,
ThatchedRoof,
Brick,
TwoStoryWoodAndPlaster,
TwoStoryStoneAndPlaster,
Tower,
SmallStoneKeep,
Castle,
LargeHouseWithPatio,
MarbleHouseWithPatio,
SmallStoneTower,
TwoStoryLogCabin,
TwoStoryVilla,
SandstoneHouseWithPatio,
SmallStoneWorkshop,
SmallMarbleWorkshop,
MalasMountainPass, //Veteran reward house
ChurchAtNight //Veteran reward house
}
public enum MiniHouseType
{
StoneAndPlaster,
FieldStone,
SmallBrick,
Wooden,
WoodAndPlaster,
ThatchedRoof,
Brick,
TwoStoryWoodAndPlaster,
TwoStoryStoneAndPlaster,
Tower,
SmallStoneKeep,
Castle,
LargeHouseWithPatio,
MarbleHouseWithPatio,
SmallStoneTower,
TwoStoryLogCabin,
TwoStoryVilla,
SandstoneHouseWithPatio,
SmallStoneWorkshop,
SmallMarbleWorkshop,
MalasMountainPass, //Veteran reward house
ChurchAtNight //Veteran reward house
}
public class MiniHouseInfo
{
public int[] Graphics { get; }
public class MiniHouseInfo
{
private static MiniHouseInfo[] m_Info =
{
/* Stone and plaster house */ new MiniHouseInfo(0x22C4, 1, 1011303),
/* Field stone house */ new MiniHouseInfo(0x22DE, 1, 1011304),
/* Small brick house */ new MiniHouseInfo(0x22DF, 1, 1011305),
/* Wooden house */ new MiniHouseInfo(0x22C9, 1, 1011306),
/* Wood and plaster house */ new MiniHouseInfo(0x22E0, 1, 1011307),
/* Thatched-roof cottage */ new MiniHouseInfo(0x22E1, 1, 1011308),
/* Brick house */ new MiniHouseInfo(1011309, 0x22CD, 0x22CB, 0x22CC, 0x22CA),
/* Two-story wood and plaster house */ new MiniHouseInfo(1011310, 0x2301, 0x2302, 0x2304, 0x2303),
/* Two-story stone and plaster house */ new MiniHouseInfo(1011311, 0x22FC, 0x22FD, 0x22FF, 0x22FE),
/* Tower */ new MiniHouseInfo(1011312, 0x22F7, 0x22F8, 0x22FA, 0x22F9),
/* Small stone keep */ new MiniHouseInfo(0x22E6, 9, 1011313),
/* Castle */
new MiniHouseInfo(1011314, 0x22CE, 0x22D0, 0x22D2, 0x22D7, 0x22CF, 0x22D1, 0x22D4, 0x22D9, 0x22D3, 0x22D5,
0x22D6, 0x22DB, 0x22D8, 0x22DA, 0x22DC, 0x22DD),
/* Large house with patio */ new MiniHouseInfo(0x22E2, 4, 1011315),
/* Marble house with patio */ new MiniHouseInfo(0x22EF, 4, 1011316),
/* Small stone tower */ new MiniHouseInfo(0x22F5, 1, 1011317),
/* Two-story log cabin */ new MiniHouseInfo(0x22FB, 1, 1011318),
/* Two-story villa */ new MiniHouseInfo(0x2300, 1, 1011319),
/* Sandstone house with patio */ new MiniHouseInfo(0x22F3, 1, 1011320),
/* Small stone workshop */ new MiniHouseInfo(0x22F6, 1, 1011321),
/* Small marble workshop */ new MiniHouseInfo(0x22F4, 1, 1011322),
/* Malas Mountain Pass */ new MiniHouseInfo(1062692, 0x2316, 0x2315, 0x2314, 0x2313),
/* Church At Night */ new MiniHouseInfo(1072215, 0x2318, 0x2317, 0x2319, 0x1)
};
public int LabelNumber { get; }
public MiniHouseInfo(int start, int count, int labelNumber)
{
Graphics = new int[count];
public MiniHouseInfo( int start, int count, int labelNumber )
{
Graphics = new int[count];
for (int i = 0; i < count; ++i)
Graphics[i] = start + i;
for ( int i = 0; i < count; ++i )
Graphics[i] = start + i;
LabelNumber = labelNumber;
}
LabelNumber = labelNumber;
}
public MiniHouseInfo(int labelNumber, params int[] graphics)
{
LabelNumber = labelNumber;
Graphics = graphics;
}
public MiniHouseInfo( int labelNumber, params int[] graphics )
{
LabelNumber = labelNumber;
Graphics = graphics;
}
public int[] Graphics{ get; }
private static MiniHouseInfo[] m_Info = {
/* Stone and plaster house */ new MiniHouseInfo( 0x22C4, 1, 1011303 ),
/* Field stone house */ new MiniHouseInfo( 0x22DE, 1, 1011304 ),
/* Small brick house */ new MiniHouseInfo( 0x22DF, 1, 1011305 ),
/* Wooden house */ new MiniHouseInfo( 0x22C9, 1, 1011306 ),
/* Wood and plaster house */ new MiniHouseInfo( 0x22E0, 1, 1011307 ),
/* Thatched-roof cottage */ new MiniHouseInfo( 0x22E1, 1, 1011308 ),
/* Brick house */ new MiniHouseInfo( 1011309, 0x22CD, 0x22CB, 0x22CC, 0x22CA ),
/* Two-story wood and plaster house */ new MiniHouseInfo( 1011310, 0x2301, 0x2302, 0x2304, 0x2303 ),
/* Two-story stone and plaster house */ new MiniHouseInfo( 1011311, 0x22FC, 0x22FD, 0x22FF, 0x22FE ),
/* Tower */ new MiniHouseInfo( 1011312, 0x22F7, 0x22F8, 0x22FA, 0x22F9 ),
/* Small stone keep */ new MiniHouseInfo( 0x22E6, 9, 1011313 ),
/* Castle */ new MiniHouseInfo( 1011314, 0x22CE, 0x22D0, 0x22D2, 0x22D7, 0x22CF, 0x22D1, 0x22D4, 0x22D9, 0x22D3, 0x22D5, 0x22D6, 0x22DB, 0x22D8, 0x22DA, 0x22DC, 0x22DD ),
/* Large house with patio */ new MiniHouseInfo( 0x22E2, 4, 1011315 ),
/* Marble house with patio */ new MiniHouseInfo( 0x22EF, 4, 1011316 ),
/* Small stone tower */ new MiniHouseInfo( 0x22F5, 1, 1011317 ),
/* Two-story log cabin */ new MiniHouseInfo( 0x22FB, 1, 1011318 ),
/* Two-story villa */ new MiniHouseInfo( 0x2300, 1, 1011319 ),
/* Sandstone house with patio */ new MiniHouseInfo( 0x22F3, 1, 1011320 ),
/* Small stone workshop */ new MiniHouseInfo( 0x22F6, 1, 1011321 ),
/* Small marble workshop */ new MiniHouseInfo( 0x22F4, 1, 1011322 ),
/* Malas Mountain Pass */ new MiniHouseInfo( 1062692, 0x2316, 0x2315, 0x2314, 0x2313 ),
/* Church At Night */ new MiniHouseInfo( 1072215, 0x2318, 0x2317, 0x2319, 0x1 )
};
public int LabelNumber{ get; }
public static MiniHouseInfo GetInfo( MiniHouseType type )
{
int v = (int)type;
public static MiniHouseInfo GetInfo(MiniHouseType type)
{
int v = (int)type;
if ( v < 0 || v >= m_Info.Length )
v = 0;
if (v < 0 || v >= m_Info.Length)
v = 0;
return m_Info[v];
}
}
}
return m_Info[v];
}
}
}