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,159 +1,166 @@
using System;
using Server.Network;
namespace Server.Items
{
public class Sextant : Item
{
[Constructible]
public Sextant() : base( 0x1058 )
{
Weight = 2.0;
}
public class Sextant : Item
{
[Constructible]
public Sextant() : base(0x1058)
{
Weight = 2.0;
}
public Sextant( Serial serial ) : base( serial )
{
}
public Sextant(Serial serial) : base(serial)
{
}
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
}
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();
}
public override void OnDoubleClick( Mobile from )
{
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
public override void OnDoubleClick(Mobile from)
{
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
if ( Format( from.Location, from.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ) )
{
string location = $"{yLat}<7D> {yMins}'{(ySouth ? "S" : "N")}, {xLong}<7D> {xMins}'{(xEast ? "E" : "W")}";
from.LocalOverheadMessage( MessageType.Regular, from.SpeechHue, false, location );
}
}
if (Format(from.Location, from.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
{
string location = $"{yLat}<7D> {yMins}'{(ySouth ? "S" : "N")}, {xLong}<7D> {xMins}'{(xEast ? "E" : "W")}";
from.LocalOverheadMessage(MessageType.Regular, from.SpeechHue, false, location);
}
}
public static bool ComputeMapDetails( Map map, int x, int y, out int xCenter, out int yCenter, out int xWidth, out int yHeight )
{
xWidth = 5120; yHeight = 4096;
public static bool ComputeMapDetails(Map map, int x, int y, out int xCenter, out int yCenter, out int xWidth,
out int yHeight)
{
xWidth = 5120;
yHeight = 4096;
if ( map == Map.Trammel || map == Map.Felucca )
{
if ( x >= 0 && y >= 0 && x < 5120 && y < 4096 )
{
xCenter = 1323; yCenter = 1624;
}
else if ( x >= 5120 && y >= 2304 && x < 6144 && y < 4096 )
{
xCenter = 5936; yCenter = 3112;
}
else
{
xCenter = 0; yCenter = 0;
return false;
}
}
else if ( x >= 0 && y >= 0 && x < map.Width && y < map.Height )
{
xCenter = 1323; yCenter = 1624;
}
else
{
xCenter = 0; yCenter = 0;
return false;
}
if (map == Map.Trammel || map == Map.Felucca)
{
if (x >= 0 && y >= 0 && x < 5120 && y < 4096)
{
xCenter = 1323;
yCenter = 1624;
}
else if (x >= 5120 && y >= 2304 && x < 6144 && y < 4096)
{
xCenter = 5936;
yCenter = 3112;
}
else
{
xCenter = 0;
yCenter = 0;
return false;
}
}
else if (x >= 0 && y >= 0 && x < map.Width && y < map.Height)
{
xCenter = 1323;
yCenter = 1624;
}
else
{
xCenter = 0;
yCenter = 0;
return false;
}
return true;
}
return true;
}
public static Point3D ReverseLookup( Map map, int xLong, int yLat, int xMins, int yMins, bool xEast, bool ySouth )
{
if ( map == null || map == Map.Internal )
return Point3D.Zero;
public static Point3D ReverseLookup(Map map, int xLong, int yLat, int xMins, int yMins, bool xEast, bool ySouth)
{
if (map == null || map == Map.Internal)
return Point3D.Zero;
int xCenter, yCenter;
int xWidth, yHeight;
int xCenter, yCenter;
int xWidth, yHeight;
if ( !ComputeMapDetails( map, 0, 0, out xCenter, out yCenter, out xWidth, out yHeight ) )
return Point3D.Zero;
if (!ComputeMapDetails(map, 0, 0, out xCenter, out yCenter, out xWidth, out yHeight))
return Point3D.Zero;
double absLong = xLong + ((double)xMins / 60);
double absLat = yLat + ((double)yMins / 60);
double absLong = xLong + (double)xMins / 60;
double absLat = yLat + (double)yMins / 60;
if ( !xEast )
absLong = 360.0 - absLong;
if (!xEast)
absLong = 360.0 - absLong;
if ( !ySouth )
absLat = 360.0 - absLat;
if (!ySouth)
absLat = 360.0 - absLat;
int x, y, z;
int x, y, z;
x = xCenter + (int)((absLong * xWidth) / 360);
y = yCenter + (int)((absLat * yHeight) / 360);
x = xCenter + (int)(absLong * xWidth / 360);
y = yCenter + (int)(absLat * yHeight / 360);
if ( x < 0 )
x += xWidth;
else if ( x >= xWidth )
x -= xWidth;
if (x < 0)
x += xWidth;
else if (x >= xWidth)
x -= xWidth;
if ( y < 0 )
y += yHeight;
else if ( y >= yHeight )
y -= yHeight;
if (y < 0)
y += yHeight;
else if (y >= yHeight)
y -= yHeight;
z = map.GetAverageZ( x, y );
z = map.GetAverageZ(x, y);
return new Point3D( x, y, z );
}
return new Point3D(x, y, z);
}
public static bool Format( Point3D p, Map map, ref int xLong, ref int yLat, ref int xMins, ref int yMins, ref bool xEast, ref bool ySouth )
{
if ( map == null || map == Map.Internal )
return false;
public static bool Format(Point3D p, Map map, ref int xLong, ref int yLat, ref int xMins, ref int yMins,
ref bool xEast, ref bool ySouth)
{
if (map == null || map == Map.Internal)
return false;
int x = p.X, y = p.Y;
int xCenter, yCenter;
int xWidth, yHeight;
int x = p.X, y = p.Y;
int xCenter, yCenter;
int xWidth, yHeight;
if ( !ComputeMapDetails( map, x, y, out xCenter, out yCenter, out xWidth, out yHeight ) )
return false;
if (!ComputeMapDetails(map, x, y, out xCenter, out yCenter, out xWidth, out yHeight))
return false;
double absLong = (double)((x - xCenter) * 360) / xWidth;
double absLat = (double)((y - yCenter) * 360) / yHeight;
double absLong = (double)((x - xCenter) * 360) / xWidth;
double absLat = (double)((y - yCenter) * 360) / yHeight;
if ( absLong > 180.0 )
absLong = -180.0 + (absLong % 180.0);
if (absLong > 180.0)
absLong = -180.0 + absLong % 180.0;
if ( absLat > 180.0 )
absLat = -180.0 + (absLat % 180.0);
if (absLat > 180.0)
absLat = -180.0 + absLat % 180.0;
bool east = ( absLong >= 0 ), south = ( absLat >= 0 );
bool east = absLong >= 0, south = absLat >= 0;
if ( absLong < 0.0 )
absLong = -absLong;
if (absLong < 0.0)
absLong = -absLong;
if ( absLat < 0.0 )
absLat = -absLat;
if (absLat < 0.0)
absLat = -absLat;
xLong = (int)absLong;
yLat = (int)absLat;
xLong = (int)absLong;
yLat = (int)absLat;
xMins = (int)((absLong % 1.0) * 60);
yMins = (int)((absLat % 1.0) * 60);
xMins = (int)(absLong % 1.0 * 60);
yMins = (int)(absLat % 1.0 * 60);
xEast = east;
ySouth = south;
xEast = east;
ySouth = south;
return true;
}
}
return true;
}
}
}