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

@ -1,17 +1,19 @@
using System.Collections;
using Server.Mobiles;
using CalcMoves = Server.Movement.Movement;
using MoveImpl = Server.Movement.MovementImpl;
namespace Server.PathAlgorithms
namespace Server.PathAlgorithms.FastAStar
{
public struct PathNode
{
public int cost, total;
public int parent, next, prev;
public int z;
}
public class FastAStarAlgorithm : PathAlgorithm
{
public struct PathNode
{
public int cost, total;
public int parent, next, prev;
public int z;
}
private const int MaxDepth = 300;
private const int AreaSize = 38;
@ -132,18 +134,18 @@ namespace Server.PathAlgorithms
if (bc != null)
{
MovementImpl.AlwaysIgnoreDoors = bc.CanOpenDoors;
MovementImpl.IgnoreMovableImpassables = bc.CanMoveOverObstacles;
MoveImpl.AlwaysIgnoreDoors = bc.CanOpenDoors;
MoveImpl.IgnoreMovableImpassables = bc.CanMoveOverObstacles;
}
MovementImpl.Goal = goal;
MoveImpl.Goal = goal;
int[] vals = m_Successors;
int count = GetSuccessors(bestNode, m, map);
MovementImpl.AlwaysIgnoreDoors = false;
MovementImpl.IgnoreMovableImpassables = false;
MovementImpl.Goal = Point3D.Zero;
MoveImpl.AlwaysIgnoreDoors = false;
MoveImpl.IgnoreMovableImpassables = false;
MoveImpl.Goal = Point3D.Zero;
if (count == 0)
break;
@ -156,26 +158,26 @@ namespace Server.PathAlgorithms
if (wasTouched)
continue;
int newCost = m_Nodes[bestNode].cost + 1;
int newTotal = newCost + Heuristic(newNode % AreaSize, newNode / AreaSize % AreaSize,
m_Nodes[newNode].z);
if (m_Nodes[newNode].total <= newTotal)
continue;
m_Nodes[newNode].parent = bestNode;
m_Nodes[newNode].cost = newCost;
m_Nodes[newNode].total = newTotal;
if (m_OnOpen[newNode])
continue;
AddToChain(newNode);
if (newNode != destNode)
continue;
int pathCount = 0;
int parent = m_Nodes[newNode].parent;
@ -294,7 +296,7 @@ namespace Server.PathAlgorithms
if (x < 0 || x >= AreaSize || y < 0 || y >= AreaSize)
continue;
if (Movement.CheckMovement(m, map, p3D, (Direction)i, out int z))
if (CalcMoves.CheckMovement(m, map, p3D, (Direction)i, out int z))
{
int idx = GetIndex(x + m_xOffset, y + m_yOffset, z);
@ -309,4 +311,4 @@ namespace Server.PathAlgorithms
return count;
}
}
}
}

View file

@ -8,7 +8,7 @@ using Server.Mobiles;
#endregion
namespace Server
namespace Server.Movement
{
public class FastMovementImpl : IMovementImpl
{
@ -179,7 +179,7 @@ namespace Server
private static bool Check(
Map map,
Mobile m,
IReadOnlyCollection<Item> items,
List<Item> items,
int x,
int y,
int startTop,

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;
namespace Server
namespace Server.Movement
{
public class MovementImpl : IMovementImpl
{
@ -316,7 +316,7 @@ namespace Server
return true;
}
private bool Check(Map map, Mobile m, List<Item> items, IReadOnlyList<Mobile> mobiles, int x, int y, int startTop, int startZ,
private bool Check(Map map, Mobile m, List<Item> items, List<Mobile> mobiles, int x, int y, int startTop, int startZ,
bool canSwim, bool cantWalk, out int newZ)
{
newZ = 0;
@ -500,7 +500,7 @@ namespace Server
!t.Alive || !m.Alive || t.IsDeadBondedPet || m.IsDeadBondedPet ||
t.Hidden && t.AccessLevel > AccessLevel.Player;
private void GetStartZ(Mobile m, Map map, Point3D loc, IReadOnlyList<Item> itemList, out int zLow, out int zTop)
private void GetStartZ(Mobile m, Map map, Point3D loc, List<Item> itemList, out int zLow, out int zTop)
{
int xCheck = loc.X, yCheck = loc.Y;

View file

@ -1,6 +1,8 @@
using System;
using Server.Items;
using Server.PathAlgorithms;
using Server.PathAlgorithms.FastAStar;
using Server.PathAlgorithms.SlowAStar;
using Server.Spells;
using Server.Targeting;
@ -82,7 +84,7 @@ namespace Server
for (int i = 0; i < path.Directions.Length; ++i)
{
Movement.Offset(path.Directions[i], ref x, ref y);
Movement.Movement.Offset(path.Directions[i], ref x, ref y);
new RecallRune().MoveToWorld(new Point3D(x, y, z + zOffset), from.Map);
}

View file

@ -2,7 +2,7 @@ namespace Server.PathAlgorithms
{
public abstract class PathAlgorithm
{
private static readonly Direction[] m_CalcDirections = {
private static Direction[] m_CalcDirections = {
Direction.Up,
Direction.North,
Direction.Right,
@ -29,4 +29,4 @@ namespace Server.PathAlgorithms
return m_CalcDirections[v];
}
}
}
}

View file

@ -1,4 +1,5 @@
using System;
using CalcMoves = Server.Movement.Movement;
namespace Server
{
@ -51,7 +52,7 @@ namespace Server
{
int x = p.X, y = p.Y;
Movement.Offset(dirs[index], ref x, ref y);
CalcMoves.Offset(dirs[index], ref x, ref y);
p.X = x;
p.Y = y;

View file

@ -1,18 +1,20 @@
using System;
using Server.Mobiles;
using CalcMoves = Server.Movement.Movement;
using MoveImpl = Server.Movement.MovementImpl;
namespace Server.PathAlgorithms
namespace Server.PathAlgorithms.SlowAStar
{
public struct PathNode
{
public int x, y, z;
public int g, h;
public int px, py, pz;
public int dir;
}
public class SlowAStarAlgorithm : PathAlgorithm
{
public struct PathNode
{
public int x, y, z;
public int g, h;
public int px, py, pz;
public int dir;
}
private const int MaxDepth = 300;
private const int MaxNodes = MaxDepth * 16;
public static PathAlgorithm Instance = new SlowAStarAlgorithm();
@ -146,11 +148,11 @@ namespace Server.PathAlgorithms
if (bc != null)
{
MovementImpl.AlwaysIgnoreDoors = bc.CanOpenDoors;
MovementImpl.IgnoreMovableImpassables = bc.CanMoveOverObstacles;
MoveImpl.AlwaysIgnoreDoors = bc.CanOpenDoors;
MoveImpl.IgnoreMovableImpassables = bc.CanMoveOverObstacles;
}
MovementImpl.Goal = goal;
MoveImpl.Goal = goal;
int x;
int y;
@ -160,6 +162,7 @@ namespace Server.PathAlgorithms
switch (i)
{
default:
case 0:
x = 0;
y = -1;
break;
@ -193,7 +196,7 @@ namespace Server.PathAlgorithms
break;
}
if (Movement.CheckMovement(m, map, new Point3D(curNode.x, curNode.y, curNode.z), (Direction)i, out z))
if (CalcMoves.CheckMovement(m, map, new Point3D(curNode.x, curNode.y, curNode.z), (Direction)i, out z))
{
successors[sucCount].x = x + curNode.x;
successors[sucCount].y = y + curNode.y;
@ -201,9 +204,9 @@ namespace Server.PathAlgorithms
}
}
MovementImpl.AlwaysIgnoreDoors = false;
MovementImpl.IgnoreMovableImpassables = false;
MovementImpl.Goal = Point3D.Zero;
MoveImpl.AlwaysIgnoreDoors = false;
MoveImpl.IgnoreMovableImpassables = false;
MoveImpl.Goal = Point3D.Zero;
if (sucCount == 0 || ++depth > MaxDepth)
break;
@ -269,4 +272,4 @@ namespace Server.PathAlgorithms
return null;
}
}
}
}