Skip to content

Commit

Permalink
Fixed display issues with moving players entering visibility range
Browse files Browse the repository at this point in the history
Players moving in a straight line would be displayed as stationary when entering the 100m visibility radius of other players.
This issue could cause significant discrepancies between the displayed and the actual position, as the server only broadcasts SM_MOVE packets when stopping or changing direction.
  • Loading branch information
neon-dev committed Aug 8, 2024
1 parent b73d306 commit f288326
Showing 1 changed file with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.aionemu.gameserver.network.aion.serverpackets;

import com.aionemu.gameserver.controllers.movement.MovementMask;
import com.aionemu.gameserver.controllers.movement.PlayerMoveController;
import com.aionemu.gameserver.geoEngine.math.Vector3f;
import com.aionemu.gameserver.model.actions.PlayerMode;
import com.aionemu.gameserver.model.gameobjects.player.CustomPlayerState;
import com.aionemu.gameserver.model.gameobjects.player.Player;
Expand Down Expand Up @@ -162,7 +165,8 @@ protected void writeImpl(AionConnection con) {
writeF(playerAppearance.getHeight());
writeF(0.25f); // scale
writeF(2.0f); // gravity or slide surface o_O
writeF(player.getGameStats().getMovementSpeedFloat()); // move speed
float movementSpeed = player.getGameStats().getMovementSpeedFloat();
writeF(movementSpeed);

Stat2 attackSpeed = player.getGameStats().getAttackSpeed();
writeH(attackSpeed.getBase());
Expand All @@ -171,15 +175,25 @@ protected void writeImpl(AionConnection con) {

writeS(player.hasStore() ? player.getStore().getStoreMessage() : ""); // private store message

// Movement
writeF(0);
writeF(0);
writeF(0);

writeF(player.getX());// x
writeF(player.getY());// y
writeF(player.getZ());// z
writeC(0x00); // move type
PlayerMoveController pmc = player.getMoveController();
byte movementMask = pmc.getMovementMask();
if ((pmc.movementMask & MovementMask.ABSOLUTE) == MovementMask.ABSOLUTE) {
// calculate the vector, as click to move and target coords are not supported here
Vector3f vector = new Vector3f(pmc.getTargetX2() - player.getX(), pmc.getTargetY2() - player.getY(),
pmc.getTargetZ2() - player.getZ()).normalizeLocal().multLocal(movementSpeed);
writeF(vector.getX());
writeF(vector.getY());
writeF(vector.getZ());
movementMask &= ~MovementMask.ABSOLUTE;
} else {
writeF(pmc.vectorX);
writeF(pmc.vectorY);
writeF(pmc.vectorZ);
}
writeF(player.getX());
writeF(player.getY());
writeF(player.getZ());
writeC(movementMask);

if (player.isUsingFlyTeleport()) {
writeD(player.getFlightTeleportId());
Expand Down

0 comments on commit f288326

Please sign in to comment.