Originally Posted by
WH:II:DOW
You're either not updating the other guy or you have the wrong player id for the other guy so he doesn't know who/what to face.
I think it's the first, however, i'm not sure what exactly is wrong with it? I've compared it and I think i'm either blind or really stupid lol
Code:
@Override
public AsynchronousBuffer dispatch(Player player) {
if (player.getUpdateFlags().contains("map-region")) {
player.send(new RegionalUpdatePacket());
}
AsynchronousBuffer packet = new AsynchronousBuffer(ByteBuffer.allocate(16384));
AsynchronousBuffer update = new AsynchronousBuffer(ByteBuffer.allocate(8192));
packet.writeVariableShortPacketHeader(player.getConnection().getCryptionPair().getWriter(), getOpcode());
packet.startBitAccess();
player.getListener().updateThisPlayerMovement(player, packet);
if (player.isUpdateRequired()) {
player.getListener().updatePlayerState(player, update, false, true);
}
packet.writeBits(8, player.getLocalPlayers().size());
for(Iterator<Player> iterator = player.getLocalPlayers().iterator(); iterator.hasNext();) {
Player otherPlayer = iterator.next();
if (World.getSingleton().getPlayers().containsValue(otherPlayer) && otherPlayer.getPosition().isWithinDistance(player.getPosition(), 15) && !otherPlayer.getUpdateFlags().contains("teleporting")) {
player.getListener().updateOtherPlayerMovement(otherPlayer, packet);
if (otherPlayer.isUpdateRequired()) {
player.getListener().updatePlayerState(otherPlayer, update, false, false);
}
} else {
iterator.remove();
packet.writeBits(1, 1);
packet.writeBits(2, 3);
}
}
for (Player otherPlayer : World.getSingleton().getPlayers().values()) {
if (otherPlayer.getLocalPlayers().size() >= 255) {
break;
}
if (otherPlayer == player || player.getLocalPlayers().contains(otherPlayer)) {
continue;
}
if (otherPlayer.getPosition().isWithinDistance(player.getPosition(), 15)) {
player.getLocalPlayers().add(otherPlayer);
packet.writeBits(11, otherPlayer.getIndex());
packet.writeBits(1, 1);
packet.writeBits(1, 1);
packet.writeBits(5, otherPlayer.getPosition().getY() - player.getPosition().getY());
packet.writeBits(5, otherPlayer.getPosition().getX() - player.getPosition().getX());
player.getListener().updatePlayerState(otherPlayer, update, true, false);
}
}
if (update.getBuffer().position() > 0) {
packet.writeBits(11, 2047);
packet.startByteAcces();
packet.writeBytes(update.getBuffer());
} else {
packet.startByteAcces();
}
packet.finishVariableShortPacketHeader();
return packet;
}