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 {
if (distanceSquared > sqr(25)) if (distanceSquared > sqr(25))
player.setLastStaticLoc(player.getLoc()); player.setLastStaticLoc(player.getLoc());
else if (player.dirtyLoad == false) else if (player.dirtyLoad.get() == false)
return; return;
// Get Statics in range // Get Statics in range
@ -314,7 +314,7 @@ public enum InterestManager implements Runnable {
} }
loadedStaticObjects.addAll(toLoad); loadedStaticObjects.addAll(toLoad);
player.dirtyLoad = false; player.dirtyLoad.set(false);
} }
private void updateMobileList(PlayerCharacter player, ClientConnection origin) { private void updateMobileList(PlayerCharacter player, ClientConnection origin) {
@ -522,7 +522,7 @@ public enum InterestManager implements Runnable {
//Update static list //Update static list
try { try {
player.dirtyLoad = true; player.dirtyLoad.set(true);
updateStaticList(player, origin); updateStaticList(player, origin);
} catch (Exception e) { } catch (Exception e) {
Logger.error("InterestManager.updateAllStaticPlayers: " + player.getObjectUUID(), e); Logger.error("InterestManager.updateAllStaticPlayers: " + player.getObjectUUID(), e);
@ -550,7 +550,7 @@ public enum InterestManager implements Runnable {
//Update static list //Update static list
try { try {
playerCharacter.dirtyLoad = true; playerCharacter.dirtyLoad.set(true);
updateStaticList(playerCharacter, origin); updateStaticList(playerCharacter, origin);
} catch (Exception e) { } catch (Exception e) {
Logger.error("InterestManager.updateAllStaticPlayers: " + playerCharacter.getObjectUUID(), e); Logger.error("InterestManager.updateAllStaticPlayers: " + playerCharacter.getObjectUUID(), e);
@ -575,7 +575,7 @@ public enum InterestManager implements Runnable {
for (AbstractWorldObject playerObject : playerList) { for (AbstractWorldObject playerObject : playerList) {
PlayerCharacter playerCharacter = (PlayerCharacter) playerObject; 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;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
@ -180,7 +181,7 @@ public class PlayerCharacter extends AbstractCharacter {
private float characterHeight = 0; private float characterHeight = 0;
private boolean lastSwimming = false; private boolean lastSwimming = false;
private boolean isTeleporting = false; private boolean isTeleporting = false;
public boolean dirtyLoad = true; public AtomicBoolean dirtyLoad = new AtomicBoolean(true);
/** /**
* No Id Constructor * No Id Constructor

Loading…
Cancel
Save