public static void EventSink_Login( LoginEventArgs e )
{
Mobile from = e.Mobile;
if ( !IsStranded( from ) )
return;
Map map = from.Map;
Point2D[] list;
if( map == Map.Felucca )
list = m_Felucca;
else
return;
Point2D p = Point2D.Zero;
double pdist = double.MaxValue;
for ( int i = 0; i < list.Length; ++i )
{
double dist = from.GetDistanceToSqrt( list[i] );
if ( dist < pdist )
{
p = list[i];
pdist = dist;
}
}
int x = p.X, y = p.Y;
int z;
bool canFit = false;
z = map.GetAverageZ( x, y );
canFit = map.CanSpawnMobile( x, y, z );
for ( int i = 1; !canFit && i <= 40; i += 2 )
{
for ( int xo = -1; !canFit && xo <= 1; ++xo )
{
for ( int yo = -1; !canFit && yo <= 1; ++yo )
{
if ( xo == 0 && yo == 0 )
continue;
x = p.X + (xo * i);
y = p.Y + (yo * i);
z = map.GetAverageZ( x, y );
canFit = map.CanSpawnMobile( x, y, z );
}
}
}
if ( canFit )
from.Location = new Point3D( x, y, z );
}
}