From b72bef5c6168d9040a40c392e56b0c137bc4dc34 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 28 Mar 2021 14:47:27 +0000 Subject: [PATCH] Removal of CoordSynchronize configuration. --- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/main/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 14 --- .../clientpackets/ValidatePosition.java | 84 ++++---------- .../dist/game/config/main/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 14 --- .../clientpackets/ValidatePosition.java | 84 ++++---------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- .../dist/game/config/GeoEngine.ini | 6 - .../java/org/l2jmobius/Config.java | 4 - .../gameserver/geoengine/GeoEngine.java | 14 +-- .../gameserver/model/actor/Creature.java | 30 ++--- .../model/actor/instance/PlayerInstance.java | 8 -- .../clientpackets/ValidatePosition.java | 105 ++++-------------- 138 files changed, 780 insertions(+), 3031 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/config/GeoEngine.ini b/L2J_Mobius_1.0_Ertheia/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_1.0_Ertheia/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java index bc2579288a..4fc625ef73 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java @@ -938,8 +938,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2477,8 +2475,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java index 828917115a..13f92b73e6 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 4c48d54701..dc80a2f708 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12699,14 +12699,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_2.5_Underground/dist/game/config/GeoEngine.ini b/L2J_Mobius_2.5_Underground/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_2.5_Underground/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java index 5b8a52a0d8..1ecc5b7454 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java @@ -948,8 +948,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2499,8 +2497,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java index 828917115a..13f92b73e6 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 26b897c7f8..b5c030e80a 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12706,14 +12706,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_3.0_Helios/dist/game/config/GeoEngine.ini b/L2J_Mobius_3.0_Helios/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_3.0_Helios/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java index c544ed61c5..18eb5bd9a3 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java @@ -961,8 +961,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2521,8 +2519,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java index b0fbd2480a..2175603a36 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index eb6e792671..1d154188d1 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12708,14 +12708,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/GeoEngine.ini b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java index a980269fe9..e4678dc60a 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java @@ -948,8 +948,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2496,8 +2494,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java index b0fbd2480a..2175603a36 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 1d8f31bb58..bd6a0736ac 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12688,14 +12688,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_5.0_Salvation/dist/game/config/GeoEngine.ini b/L2J_Mobius_5.0_Salvation/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_5.0_Salvation/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java index 87dacfcd8c..46f17605d9 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java @@ -943,8 +943,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2496,8 +2494,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java index a8b2736739..ef4231e356 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 1c1694014d..abb8e70180 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12675,14 +12675,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/config/GeoEngine.ini b/L2J_Mobius_5.5_EtinasFate/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java index cc81e2f355..5751a2bf60 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java @@ -950,8 +950,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2508,8 +2506,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java index a8b2736739..ef4231e356 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 8b08ac9a89..142253b774 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12678,14 +12678,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/config/GeoEngine.ini b/L2J_Mobius_6.0_Fafurion/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_6.0_Fafurion/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java index 6537b57355..b187261fde 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java @@ -962,8 +962,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2551,8 +2549,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java index a8b2736739..ef4231e356 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index effd38b23d..a607769ef7 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12684,14 +12684,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/GeoEngine.ini b/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java index 1811311ae0..027534e34f 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java @@ -973,8 +973,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2575,8 +2573,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java index e85607aed9..168a436ed4 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3038,32 +3038,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index e011ce37d1..29b05143a1 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12692,14 +12692,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/config/GeoEngine.ini b/L2J_Mobius_8.0_Homunculus/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_8.0_Homunculus/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java index 45fb87b795..a11d851ac7 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java @@ -973,8 +973,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2575,8 +2573,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java index ed51250c1e..b5ce72f6c1 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3038,32 +3038,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 74537fa06c..ba4c469cbe 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12733,14 +12733,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/config/GeoEngine.ini b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java index 45fb87b795..a11d851ac7 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java @@ -973,8 +973,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2575,8 +2573,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java index ed51250c1e..b5ce72f6c1 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3038,32 +3038,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 74537fa06c..ba4c469cbe 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12733,14 +12733,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/main/GeoEngine.ini b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/main/GeoEngine.ini index 51dd237ca8..4adfbea760 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/main/GeoEngine.ini +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/main/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java index 6b68a08eee..1037d1b146 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java @@ -937,8 +937,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; public static boolean FALL_DAMAGE; public static boolean ALLOW_WATER; @@ -2502,8 +2500,6 @@ public class Config MEDIUM_WEIGHT = geoengineConfig.getFloat("MediumWeight", 2); HIGH_WEIGHT = geoengineConfig.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = geoengineConfig.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = geoengineConfig.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = geoengineConfig.getBoolean("CorrectPlayerZ", false); FALL_DAMAGE = geoengineConfig.getBoolean("FallDamage", false); ALLOW_WATER = geoengineConfig.getBoolean("AllowWater", false); } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index ccafb3803f..b561f7dbed 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -108,18 +108,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java index cab928b53f..1adcf93e5b 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -5078,32 +5078,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder double dy; double dz; double distFraction; - // the only method that can modify x,y while moving (otherwise _move would/should be set null) - if (Config.COORD_SYNCHRONIZE == 1) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 2d12af8883..04ef216c73 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12688,12 +12688,6 @@ public class PlayerInstance extends Playable @Override public boolean updatePosition(int gameTicks) { - // Disables custom movement for PlayerInstance when Old Synchronization is selected - if (Config.COORD_SYNCHRONIZE == -1) - { - return super.updatePosition(gameTicks); - } - // Get movement data final MoveData m = _move; if (_move == null) @@ -15471,14 +15465,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ), false); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1f50c12..1d93093e3d 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,12 +16,11 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -import org.l2jmobius.gameserver.network.serverpackets.ValidateLocationInVehicle; public class ValidatePosition extends GameClientPacket { @@ -29,8 +28,6 @@ public class ValidatePosition extends GameClientPacket private int _y; private int _z; private int _heading; - @SuppressWarnings("unused") - private int _data; @Override protected void readImpl() @@ -39,7 +36,7 @@ public class ValidatePosition extends GameClientPacket _y = readD(); _z = readD(); _heading = readD(); - _data = readD(); + readD(); // vehicle id } @Override @@ -65,23 +62,12 @@ public class ValidatePosition extends GameClientPacket double diffSq; if (player.isInBoat()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getBoatPosition().getX(); - dy = _y - player.getBoatPosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - sendPacket(new ValidateLocationInVehicle(player)); - } - } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -89,13 +75,6 @@ public class ValidatePosition extends GameClientPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } if (player.isFlying() || player.isInsideZone(ZoneId.WATER)) { player.setXYZ(realX, realY, _z); @@ -104,40 +83,8 @@ public class ValidatePosition extends GameClientPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -147,15 +94,30 @@ public class ValidatePosition extends GameClientPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_C6_Interlude/dist/game/config/main/GeoEngine.ini b/L2J_Mobius_C6_Interlude/dist/game/config/main/GeoEngine.ini index 51dd237ca8..4adfbea760 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/config/main/GeoEngine.ini +++ b/L2J_Mobius_C6_Interlude/dist/game/config/main/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java index f56d668cd9..7af2ea32b3 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java @@ -971,8 +971,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; public static boolean FALL_DAMAGE; public static boolean ALLOW_WATER; @@ -2567,8 +2565,6 @@ public class Config MEDIUM_WEIGHT = geoengineConfig.getFloat("MediumWeight", 2); HIGH_WEIGHT = geoengineConfig.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = geoengineConfig.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = geoengineConfig.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = geoengineConfig.getBoolean("CorrectPlayerZ", false); FALL_DAMAGE = geoengineConfig.getBoolean("FallDamage", false); ALLOW_WATER = geoengineConfig.getBoolean("AllowWater", false); } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index ccafb3803f..b561f7dbed 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -108,18 +108,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java index c0b73876e0..0d60b2f808 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -5124,32 +5124,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder double dy; double dz; double distFraction; - // the only method that can modify x,y while moving (otherwise _move would/should be set null) - if (Config.COORD_SYNCHRONIZE == 1) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index c2daed0e0b..c103046708 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12998,12 +12998,6 @@ public class PlayerInstance extends Playable @Override public boolean updatePosition(int gameTicks) { - // Disables custom movement for PlayerInstance when Old Synchronization is selected - if (Config.COORD_SYNCHRONIZE == -1) - { - return super.updatePosition(gameTicks); - } - // Get movement data final MoveData m = _move; if (_move == null) @@ -15837,14 +15831,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ), false); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1f50c12..1d93093e3d 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,12 +16,11 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -import org.l2jmobius.gameserver.network.serverpackets.ValidateLocationInVehicle; public class ValidatePosition extends GameClientPacket { @@ -29,8 +28,6 @@ public class ValidatePosition extends GameClientPacket private int _y; private int _z; private int _heading; - @SuppressWarnings("unused") - private int _data; @Override protected void readImpl() @@ -39,7 +36,7 @@ public class ValidatePosition extends GameClientPacket _y = readD(); _z = readD(); _heading = readD(); - _data = readD(); + readD(); // vehicle id } @Override @@ -65,23 +62,12 @@ public class ValidatePosition extends GameClientPacket double diffSq; if (player.isInBoat()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getBoatPosition().getX(); - dy = _y - player.getBoatPosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - sendPacket(new ValidateLocationInVehicle(player)); - } - } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -89,13 +75,6 @@ public class ValidatePosition extends GameClientPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } if (player.isFlying() || player.isInsideZone(ZoneId.WATER)) { player.setXYZ(realX, realY, _z); @@ -104,40 +83,8 @@ public class ValidatePosition extends GameClientPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -147,15 +94,30 @@ public class ValidatePosition extends GameClientPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/GeoEngine.ini b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java index 936bb8c87b..9f8c953e75 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java @@ -1066,8 +1066,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; // -------------------------------------------------- // Custom Settings @@ -2593,8 +2591,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 143a5e0124..7b814dd4fd 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -109,18 +109,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java index 49998df74d..2c94fdba1c 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3973,32 +3973,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index ec4d442887..27da7474e8 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -13500,14 +13500,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 3d280f64b9..3e9c72f851 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/GeoEngine.ini b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java index f95c21ddc7..8eb6817633 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java @@ -1066,8 +1066,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; // -------------------------------------------------- // Custom Settings @@ -2602,8 +2600,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 143a5e0124..7b814dd4fd 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -109,18 +109,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java index fec2e05ca6..bf0e5e1f0e 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3975,32 +3975,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index b32fbc644c..f80c165743 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -13393,14 +13393,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 3d280f64b9..3e9c72f851 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/GeoEngine.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java index ec523f674e..759f0e6ecc 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java @@ -895,8 +895,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2394,8 +2392,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java index 94345d8380..6835bc380e 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 974f7bd923..af80f8f177 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12483,14 +12483,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/GeoEngine.ini b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java index 5d0300239a..356cab0845 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java @@ -899,8 +899,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2400,8 +2398,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java index 94345d8380..6835bc380e 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index c457d440ad..47f14712f4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12483,14 +12483,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/GeoEngine.ini b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java index 5d0300239a..356cab0845 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java @@ -899,8 +899,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2400,8 +2398,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java index d472dd4445..96ac2b419f 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index e87fad7616..793de5189e 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12469,14 +12469,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/GeoEngine.ini b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java index 4edd504306..297b3a4ccf 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java @@ -899,8 +899,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2401,8 +2399,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java index c4c9734dfa..f4bdba4313 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3052,32 +3052,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index b7078ef22f..83b9340410 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12518,14 +12518,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/GeoEngine.ini b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java index 685a274f9d..4853969bce 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java @@ -904,8 +904,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2410,8 +2408,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java index c4c9734dfa..f4bdba4313 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3052,32 +3052,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 8dd39b694e..74d26d6683 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12518,14 +12518,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/GeoEngine.ini b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java index 0536c45953..7ef488bf94 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java @@ -912,8 +912,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2427,8 +2425,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java index 215bceb9ee..46b6e98a5b 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3051,32 +3051,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 8ec9ddd575..d6e00e47ef 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12496,14 +12496,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Classic_Interlude/dist/game/config/GeoEngine.ini b/L2J_Mobius_Classic_Interlude/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Classic_Interlude/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java index f884d4d24b..155890bbb4 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java @@ -913,8 +913,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2425,8 +2423,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java index 94345d8380..6835bc380e 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3039,32 +3039,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 77a2bafdc4..cbdff2d077 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12504,14 +12504,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/GeoEngine.ini b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java index 8917bc2596..465af5b620 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java @@ -934,8 +934,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2475,8 +2473,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java index 8c7b8a1089..3f20e2dc63 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3054,32 +3054,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 0fe6c62d6c..4d59beb38b 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12687,14 +12687,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z); diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/config/GeoEngine.ini b/L2J_Mobius_Essence_5.0_Sylph/dist/game/config/GeoEngine.ini index a76d42edd1..609e8a89a7 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/game/config/GeoEngine.ini +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/config/GeoEngine.ini @@ -6,12 +6,6 @@ # at different folder/harddrive ("C:/Program Files/Lineage II/system/geodata/"), default: ./data/geodata/ GeoDataPath = ./data/geodata/ -# Player coordinates synchronization, default: 2 -# 1 - partial synchronization Client --> Server ; don't use it with geodata -# 2 - partial synchronization Server --> Client ; use this setting with geodata -# -1 - Old system: will synchronize Z only -CoordSynchronize = 2 - # ================================================================= # Path finding # ================================================================= diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/Config.java index b97139ab55..f96967cac1 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/Config.java @@ -934,8 +934,6 @@ public class Config public static float MEDIUM_WEIGHT; public static float HIGH_WEIGHT; public static float DIAGONAL_WEIGHT; - public static int COORD_SYNCHRONIZE; - public static boolean CORRECT_PLAYER_Z; /** Attribute System */ public static int S_WEAPON_STONE; @@ -2475,8 +2473,6 @@ public class Config MEDIUM_WEIGHT = GeoEngine.getFloat("MediumWeight", 2); HIGH_WEIGHT = GeoEngine.getFloat("HighWeight", 3); DIAGONAL_WEIGHT = GeoEngine.getFloat("DiagonalWeight", 0.707f); - COORD_SYNCHRONIZE = GeoEngine.getInt("CoordSynchronize", -1); - CORRECT_PLAYER_Z = GeoEngine.getBoolean("CorrectPlayerZ", false); // Load AllowedPlayerRaces config file (if exists) final PropertiesParser AllowedPlayerRaces = new PropertiesParser(CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE); diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java index 9f4604a29f..9d255a5f54 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -110,18 +110,10 @@ public class GeoEngine LOGGER.info("GeoEngine: Loaded " + loaded + " geodata files."); // Avoid wrong configs when no files are loaded. - if (loaded == 0) + if ((loaded == 0) && Config.PATHFINDING) { - if (Config.PATHFINDING) - { - Config.PATHFINDING = false; - LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); - } - if (Config.COORD_SYNCHRONIZE == 2) - { - Config.COORD_SYNCHRONIZE = -1; - LOGGER.info("GeoEngine: Forcing CoordSynchronize setting to -1."); - } + Config.PATHFINDING = false; + LOGGER.info("GeoEngine: Forcing PathFinding setting to false."); } } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Creature.java index fc384ebdff..28819a7c9c 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -3061,32 +3061,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe double dx; double dy; double dz; - if (Config.COORD_SYNCHRONIZE == 1) - // the only method that can modify x,y while moving (otherwise _move would/should be set null) + // Save temporary values to avoid rounding errors. + if (target != null) { - if (target != null) - { - dx = target.getX() - xPrev; - dy = target.getY() - yPrev; - } - else - { - dx = m._xDestination - xPrev; - dy = m._yDestination - yPrev; - } + dx = target.getX() - m._xAccurate; + dy = target.getY() - m._yAccurate; } - else // otherwise we need saved temporary values to avoid rounding errors + else { - if (target != null) - { - dx = target.getX() - m._xAccurate; - dy = target.getY() - m._yAccurate; - } - else - { - dx = m._xDestination - m._xAccurate; - dy = m._yDestination - m._yAccurate; - } + dx = m._xDestination - m._xAccurate; + dy = m._yDestination - m._yAccurate; } // Z coordinate will follow client values diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index b0412543cf..d1d33cdca6 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -12691,14 +12691,6 @@ public class PlayerInstance extends Playable } if (_fallingDamageTask != null) { - if (Config.CORRECT_PLAYER_Z) - { - final int nearestZ = GeoEngine.getInstance().getHigherHeight(getX(), getY(), getZ()); - if (getZ() < nearestZ) - { - teleToLocation(new Location(getX(), getY(), nearestZ)); - } - } _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index f4d1ba3564..c62c821f44 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -16,26 +16,21 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.gameserver.data.xml.DoorData; +import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.GameClient; -import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; -/** - * @version $Revision: 1.13.4.7 $ $Date: 2005/03/27 15:29:30 $ - */ public class ValidatePosition implements IClientIncomingPacket { private int _x; private int _y; private int _z; private int _heading; - private int _data; // vehicle id @Override public boolean read(GameClient client, PacketReader packet) @@ -44,7 +39,7 @@ public class ValidatePosition implements IClientIncomingPacket _y = packet.readD(); _z = packet.readD(); _heading = packet.readD(); - _data = packet.readD(); + packet.readD(); // vehicle id return true; } @@ -69,41 +64,14 @@ public class ValidatePosition implements IClientIncomingPacket int dy; int dz; double diffSq; - if (player.isInBoat()) + if (player.isInVehicle()) { - if (Config.COORD_SYNCHRONIZE == 2) - { - dx = _x - player.getInVehiclePosition().getX(); - dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - diffSq = ((dx * dx) + (dy * dy)); - if (diffSq > 250000) - { - client.sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInVehiclePosition())); - } - } - return; - } - if (player.isInAirShip()) - { - // Zoey76: TODO: Implement or cleanup. - // if (Config.COORD_SYNCHRONIZE == 2) - // { - // dx = _x - player.getInVehiclePosition().getX(); - // dy = _y - player.getInVehiclePosition().getY(); - // dz = _z - player.getInVehiclePosition().getZ(); - // diffSq = ((dx * dx) + (dy * dy)); - // if (diffSq > 250000) - // { - // sendPacket(new GetOnVehicle(player.getObjectId(), _data, player.getInBoatPosition())); - // } - // } return; } if (player.isFalling(_z)) { - return; // disable validations during fall to avoid "jumping" + return; // Disable validations during fall to avoid "jumping". } dx = _x - realX; @@ -111,14 +79,6 @@ public class ValidatePosition implements IClientIncomingPacket dz = _z - realZ; diffSq = ((dx * dx) + (dy * dy)); - // Zoey76: TODO: Implement or cleanup. - // Party party = player.getParty(); - // if ((party != null) && (player.getLastPartyPositionDistance(_x, _y, _z) > 150)) - // { - // player.setLastPartyPosition(_x, _y, _z); - // party.broadcastToPartyMembers(player, new PartyMemberPosition(player)); - // } - // Don't allow flying transformations outside gracia area! if (player.isFlyingMounted() && (_x > World.GRACIA_MAX_X)) { @@ -133,40 +93,8 @@ public class ValidatePosition implements IClientIncomingPacket player.sendPacket(new ValidateLocation(player)); } } - else if (diffSq < 360000) // if too large, messes observation + else if (diffSq < 360000) // If too large, messes observation. { - if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server, mainly used when no geodata but can be used also with geodata - { - player.setXYZ(realX, realY, _z); - return; - } - if (Config.COORD_SYNCHRONIZE == 1) // Trusting also client x,y coordinates (should not be used with geodata) - { - if (!player.isMoving() || !player.validateMovementHeading(_heading)) // Heading changed on client = possible obstacle - { - // character is not moving, take coordinates from client - if (diffSq < 2500) - { - player.setXYZ(realX, realY, _z); - } - else - { - player.setXYZ(_x, _y, _z); - } - } - else - { - player.setXYZ(realX, realY, _z); - } - - player.setHeading(_heading); - return; - } - // Sync 2 (or other), - // intended for geodata. Sends a validation packet to client - // when too far from server calculated true coordinate. - // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution) - // Important: this code part must work together with Creature.updatePosition if ((diffSq > 250000) || (Math.abs(dz) > 200)) { if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - player.getClientZ()) < 800)) @@ -176,15 +104,30 @@ public class ValidatePosition implements IClientIncomingPacket } else { - if (player.isFalling(_z)) - { - player.setXYZ(realX, realY, _z); - } player.sendPacket(new ValidateLocation(player)); } } } + // Check out of sync. + if (player.calculateDistance3D(_x, _y, _z) > player.getStat().getMoveSpeed()) + { + if (player.isFalling(_z)) + { + final int nearestZ = GeoEngine.getInstance().getHigherHeight(_x, _y, _z); + if (player.getZ() < nearestZ) + { + player.setXYZ(_x, _y, nearestZ); + player.stopMove(null); + } + } + else + { + player.setXYZ(_x, _y, _z); + } + player.sendPacket(new ValidateLocation(player)); + } + player.setClientX(_x); player.setClientY(_y); player.setClientZ(_z);