Fixes #121 + Saner thread safety

This commit is contained in:
simon
2018-01-09 22:10:55 -05:00
parent 59fd620e4a
commit 54b72e89b3
13 changed files with 128 additions and 289 deletions

View File

@@ -74,7 +74,7 @@ public class Factory extends GameObject implements Updatable {
npc.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());
npc.setX(p.x);
npc.setY(p.y);
getWorld().getGameObjects().add(npc);
getWorld().addObject(npc);
getWorld().incUpdatable();
npc.setFactory(this);

View File

@@ -33,14 +33,9 @@ public class HarvestTask extends NPCTask {
if (pause == 0) {
//Get biomass
ArrayList<GameObject> biomass = new ArrayList<>(10);
for (GameObject object : npc.getWorld().getGameObjects()) {
//Plant MAP_INFO
if ((object.getMapInfo() & 0x4000) == 0x4000) {
biomass.add(object);
}
}
/* todo replace by some sort of .collect call with object
id (See https://github.com/simon987/Much-Assembly-Required/pull/66)*/
ArrayList<GameObject> biomass = npc.getWorld().findObjects(0x4000);
//Get closest one
int minDist = Integer.MAX_VALUE;

View File

@@ -53,7 +53,7 @@ public class WorldCreationListener implements GameEventListener {
continue;
}
world.getGameObjects().add(factory);
world.addObject(factory);
world.incUpdatable();
LogManager.LOGGER.info("Spawned Factory at (" + world.getX() + ", " + world.getY() +
@@ -84,7 +84,7 @@ public class WorldCreationListener implements GameEventListener {
if (radioTower.getAdjacentTile() != null) {
//Radio Tower has adjacent tiles
world.getGameObjects().add(radioTower);
world.addObject(radioTower);
world.incUpdatable(); //In case the Factory couldn't be spawned.
NpcPlugin.getRadioTowers().add(radioTower);