public static void HandleGameMapMovementCancelMessage(Bot bot, GameMapMovementCancelMessage message) { if (!AllowComparer) return; bot.SendToClient(new DebugHighlightCellsMessage(Color.Violet.ToArgb(), new short[] { message.cellId })); }
public static void HandleGameMapMovementCancelMessage(Bot bot, GameMapMovementCancelMessage message) { // always check, the client can send bad things :) if (!bot.Character.IsMoving()) return; var attemptElement = bot.Character.Movement.TimedPath.GetCurrentElement(); if (attemptElement.CurrentCell.Id != message.cellId) { var clientCell = bot.Character.Movement.TimedPath.Elements.First(entry => entry.CurrentCell.Id == message.cellId); // the difference is the time elapsed until the client analyse the path and start moving (~160ms) it depends also on computer hardware logger.Warn("Warning the client has canceled the movement but the given cell ({0}) is not the attempted one ({1})." + "Estimated difference : {2}ms", message.cellId, attemptElement.CurrentCell.Id, (attemptElement.EndTime - clientCell.EndTime).TotalMilliseconds); } bot.Character.NotifyStopMoving(true); }