Revert "Updates Packets & Randomizer (#43)" (#61)

This reverts commit 179cb50557.
This commit is contained in:
Kamron Batman 2019-11-11 08:46:11 -08:00 • committed by GitHub
parent 179cb50557
commit c2ecc76457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
588 changed files with 16260 additions and 10926 deletions

View file

@ -22,7 +22,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
@ -119,8 +118,8 @@ namespace Server
private static Stack<ConsoleColor> m_ConsoleColors = new Stack<ConsoleColor>();
public static Encoding UTF8 => m_UTF8 ??= new UTF8Encoding(false, false);
public static Encoding UTF8WithEncoding => m_UTF8WithEncoding ??= new UTF8Encoding(true, false);
public static Encoding UTF8 => m_UTF8 ?? (m_UTF8 = new UTF8Encoding(false, false));
public static Encoding UTF8WithEncoding => m_UTF8WithEncoding ?? (m_UTF8WithEncoding = new UTF8Encoding(true, false));
public static void Separate(StringBuilder sb, string value, string separator)
{
@ -139,7 +138,8 @@ namespace Server
public static IPAddress Intern(IPAddress ipAddress)
{
_ipAddressTable ??= new Dictionary<IPAddress, IPAddress>();
if (_ipAddressTable == null)
_ipAddressTable = new Dictionary<IPAddress, IPAddress>();
if (!_ipAddressTable.TryGetValue(ipAddress, out IPAddress interned))
{
@ -518,15 +518,79 @@ namespace Server
int adx = Math.Abs(dx);
int ady = Math.Abs(dy);
if (adx >= ady * 3) return dx > 0 ? Direction.East : Direction.West;
if (adx >= ady * 3)
{
if (dx > 0)
return Direction.East;
return Direction.West;
}
if (ady >= adx * 3) return dy > 0 ? Direction.South : Direction.North;
if (ady >= adx * 3)
{
if (dy > 0)
return Direction.South;
return Direction.North;
}
if (dx > 0) return dy > 0 ? Direction.Down : Direction.Right;
if (dx > 0)
{
if (dy > 0)
return Direction.Down;
return Direction.Right;
}
return dy > 0 ? Direction.Left : Direction.Up;
}
/* Should probably be rewritten to use an ITile interface
public static bool CanMobileFit( int z, StaticTile[] tiles )
{
int checkHeight = 15;
int checkZ = z;
for ( int i = 0; i < tiles.Length; ++i )
{
StaticTile tile = tiles[i];
if ( ((checkZ + checkHeight) > tile.Z && checkZ < (tile.Z + tile.Height))*/
/* || (tile.Z < (checkZ + checkHeight) && (tile.Z + tile.Height) > checkZ)*/ /* )
{
return false;
}
else if ( checkHeight == 0 && tile.Height == 0 && checkZ == tile.Z )
{
return false;
}
}
return true;
}
public static bool IsInContact( StaticTile check, StaticTile[] tiles )
{
int checkHeight = check.Height;
int checkZ = check.Z;
for ( int i = 0; i < tiles.Length; ++i )
{
StaticTile tile = tiles[i];
if ( ((checkZ + checkHeight) > tile.Z && checkZ < (tile.Z + tile.Height))*/
/* || (tile.Z < (checkZ + checkHeight) && (tile.Z + tile.Height) > checkZ)*/ /* )
{
return true;
}
else if ( checkHeight == 0 && tile.Height == 0 && checkZ == tile.Z )
{
return true;
}
}
return false;
}
*/
public static object GetArrayCap(Array array, int index, object emptyValue = null)
{
if (array.Length > 0)
@ -729,7 +793,14 @@ namespace Server
public static List<TOutput> SafeConvertList<TInput, TOutput>(List<TInput> list) where TOutput : class
{
List<TOutput> output = new List<TOutput>(list.Capacity);
output.AddRange(list.OfType<TOutput>());
for (int i = 0; i < list.Count; i++)
{
TOutput t = list[i] as TOutput;
if (t != null)
output.Add(t);
}
return output;
}
@ -960,8 +1031,6 @@ namespace Server
public static double RandomDouble() => RandomImpl.NextDouble();
public static double RandomDouble() => RandomImpl.NextDouble();
#endregion
#region Random Hues