mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 00:38:46 +00:00
Fix #136
This also fixes a related issue where changes to the region were not being sent on login.
This commit is contained in:
@@ -58,13 +58,18 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
Position old = player.getPosition();
|
Position old = player.getPosition();
|
||||||
player.getWalkingQueue().pulse();
|
player.getWalkingQueue().pulse();
|
||||||
|
|
||||||
|
boolean local = true;
|
||||||
|
|
||||||
if (player.isTeleporting()) {
|
if (player.isTeleporting()) {
|
||||||
player.resetViewingDistance();
|
player.resetViewingDistance();
|
||||||
|
local = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position position = player.getPosition();
|
Position position = player.getPosition();
|
||||||
|
|
||||||
if (!player.hasLastKnownRegion() || isRegionUpdateRequired()) {
|
if (!player.hasLastKnownRegion() || isRegionUpdateRequired()) {
|
||||||
player.setRegionChanged(true);
|
player.setRegionChanged(true);
|
||||||
|
local = false;
|
||||||
|
|
||||||
player.setLastKnownRegion(position);
|
player.setLastKnownRegion(position);
|
||||||
player.send(new RegionChangeMessage(position));
|
player.send(new RegionChangeMessage(position));
|
||||||
@@ -78,7 +83,9 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
differences.retainAll(oldViewable);
|
differences.retainAll(oldViewable);
|
||||||
|
|
||||||
Set<RegionCoordinates> full = new HashSet<>(newViewable);
|
Set<RegionCoordinates> full = new HashSet<>(newViewable);
|
||||||
full.removeAll(oldViewable);
|
if (local) {
|
||||||
|
full.removeAll(oldViewable);
|
||||||
|
}
|
||||||
|
|
||||||
sendUpdates(player.getLastKnownRegion(), differences, full);
|
sendUpdates(player.getLastKnownRegion(), differences, full);
|
||||||
}
|
}
|
||||||
@@ -96,7 +103,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
int deltaY = current.getLocalY(last);
|
int deltaY = current.getLocalY(last);
|
||||||
|
|
||||||
return deltaX <= Position.MAX_DISTANCE || deltaX >= Region.VIEWPORT_WIDTH - Position.MAX_DISTANCE - 1
|
return deltaX <= Position.MAX_DISTANCE || deltaX >= Region.VIEWPORT_WIDTH - Position.MAX_DISTANCE - 1
|
||||||
|| deltaY <= Position.MAX_DISTANCE || deltaY >= Region.VIEWPORT_WIDTH - Position.MAX_DISTANCE - 1;
|
|| deltaY <= Position.MAX_DISTANCE || deltaY >= Region.VIEWPORT_WIDTH - Position.MAX_DISTANCE - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,7 +119,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
|
|
||||||
for (RegionCoordinates coordinates : differences) {
|
for (RegionCoordinates coordinates : differences) {
|
||||||
Set<RegionUpdateMessage> messages = updates.computeIfAbsent(coordinates,
|
Set<RegionUpdateMessage> messages = updates.computeIfAbsent(coordinates,
|
||||||
coords -> repository.get(coords).getUpdates(height));
|
coords -> repository.get(coords).getUpdates(height));
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
player.send(new GroupedRegionUpdateMessage(position, coordinates, messages));
|
player.send(new GroupedRegionUpdateMessage(position, coordinates, messages));
|
||||||
@@ -121,7 +128,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
|
|
||||||
for (RegionCoordinates coordinates : full) {
|
for (RegionCoordinates coordinates : full) {
|
||||||
Set<RegionUpdateMessage> messages = encodes.computeIfAbsent(coordinates,
|
Set<RegionUpdateMessage> messages = encodes.computeIfAbsent(coordinates,
|
||||||
coords -> repository.get(coords).encode(height));
|
coords -> repository.get(coords).encode(height));
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
player.send(new ClearRegionMessage(position, coordinates));
|
player.send(new ClearRegionMessage(position, coordinates));
|
||||||
|
|||||||
Reference in New Issue
Block a user