Browse Source

Threadsafe is needed for the flag.

master
MagicBot 1 year ago
parent
commit
621d78172d
  1. 10
      src/engine/InterestManagement/InterestManager.java
  2. 3
      src/engine/objects/PlayerCharacter.java

10
src/engine/InterestManagement/InterestManager.java

@ -236,7 +236,7 @@ public enum InterestManager implements Runnable { @@ -236,7 +236,7 @@ public enum InterestManager implements Runnable {
if (distanceSquared > sqr(25))
player.setLastStaticLoc(player.getLoc());
else if (player.dirtyLoad == false)
else if (player.dirtyLoad.get() == false)
return;
// Get Statics in range
@ -314,7 +314,7 @@ public enum InterestManager implements Runnable { @@ -314,7 +314,7 @@ public enum InterestManager implements Runnable {
}
loadedStaticObjects.addAll(toLoad);
player.dirtyLoad = false;
player.dirtyLoad.set(false);
}
private void updateMobileList(PlayerCharacter player, ClientConnection origin) {
@ -522,7 +522,7 @@ public enum InterestManager implements Runnable { @@ -522,7 +522,7 @@ public enum InterestManager implements Runnable {
//Update static list
try {
player.dirtyLoad = true;
player.dirtyLoad.set(true);
updateStaticList(player, origin);
} catch (Exception e) {
Logger.error("InterestManager.updateAllStaticPlayers: " + player.getObjectUUID(), e);
@ -550,7 +550,7 @@ public enum InterestManager implements Runnable { @@ -550,7 +550,7 @@ public enum InterestManager implements Runnable {
//Update static list
try {
playerCharacter.dirtyLoad = true;
playerCharacter.dirtyLoad.set(true);
updateStaticList(playerCharacter, origin);
} catch (Exception e) {
Logger.error("InterestManager.updateAllStaticPlayers: " + playerCharacter.getObjectUUID(), e);
@ -575,7 +575,7 @@ public enum InterestManager implements Runnable { @@ -575,7 +575,7 @@ public enum InterestManager implements Runnable {
for (AbstractWorldObject playerObject : playerList) {
PlayerCharacter playerCharacter = (PlayerCharacter) playerObject;
playerCharacter.dirtyLoad = true;
playerCharacter.dirtyLoad.set(true);
}
}
}

3
src/engine/objects/PlayerCharacter.java

@ -49,6 +49,7 @@ import java.sql.SQLException; @@ -49,6 +49,7 @@ import java.sql.SQLException;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@ -180,7 +181,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -180,7 +181,7 @@ public class PlayerCharacter extends AbstractCharacter {
private float characterHeight = 0;
private boolean lastSwimming = false;
private boolean isTeleporting = false;
public boolean dirtyLoad = true;
public AtomicBoolean dirtyLoad = new AtomicBoolean(true);
/**
* No Id Constructor

Loading…
Cancel
Save