Bonjour, j'aimerais compresser un path et l'envoyer au client, qui n'accepte plus les path non compressé depuis la 2.34.
Donc j'ai crus comprendre qu'une donnée compressée correspondait a un changement de direction, et a la cellule ou le personnage changait de direction, je trouve ça bien pensé. Cependant je n'arrive pas a récupérer un path que le client considère valide. Je l’envoie a mon serveur, il ne s'agit pas d'un bot Dofus officiel.
Character.MoveOnMap(short)
public void MoveOnMap(short destinationCellId)
{
Pathfinder pathfinder = new Pathfinder(Map, (short)CellId);
short[] cells = pathfinder.FindPath().ToArray(); // contient la cellule de départ et d'arrivée.
PathParser.CompressPath(cells);
MoveOnMap(cells); // call la fonction handler du GameMapMovementRequestMessage
}
PathParser.CompressPath(short[])
public static short[] CompressPath(short[] path)
{
List<short> compressed = new List<short>();
DirectionsEnum lastDirection = 0;
for (int i = 0; i < path.Length; i++)
{
if (i + 1 < path.Length)
{
var point = new MapPoint(path);
var nextPoint = new MapPoint(path[i + 1]);
DirectionsEnum direction = point.OrientationTo(nextPoint, true);
if (direction != lastDirection) // Y a t-il un changement de direction?
{
lastDirection = direction;
short value = (short)(((int)direction & 7) << 12 | path & 4095);
compressed.Add(value);
}
}
}
return compressed.ToArray();
}