protected SpoutColumn getColumn(int x, int z, LoadOption loadopt, boolean sync) { long key = IntPairHashed.key(x, z); SpoutColumn column = columns.get(key); if (column != null || !loadopt.loadIfNeeded()) { return column; } column = loadColumn(x, z); if (column != null || !loadopt.generateIfNeeded()) { return column; } int[][] height = this.getGenerator().getSurfaceHeight(this, x, z); int h = (height[7][7] >> Chunk.BLOCKS.BITS); SpoutRegion r = getRegionFromChunk(x, h, z, loadopt); if (r == null) { throw new IllegalStateException( "Unable to generate region for new column and load option " + loadopt); } r.getRegionGenerator().generateColumn(x, z, sync, true); column = getColumn(x, z, LoadOption.LOAD_ONLY); if (column == null) { throw new IllegalStateException("Unable to generate column " + x + ", " + z); } return column; }
/** * Removes a column corresponding to the given Column coordinates * * @param x the x coordinate * @param z the z coordinate */ public void removeColumn(int x, int z, SpoutColumn column) { long key = IntPairHashed.key(x, z); if (columns.remove(key, column)) { synchronized (columnSet) { columnSet.remove(column); } } }
@Override public void preSnapshot() { super.preSnapshot(); Long key; while ((key = this.emptyColumns.poll()) != null) { int x = IntPairHashed.key1(key); int z = IntPairHashed.key2(key); TIntSet column = initializedChunks.get(x, z); if (column.isEmpty()) { column = initializedChunks.remove(x, z); activeChunks.remove(x, z); session.send( false, new ChunkDataMessage(x, z, true, null, null, null, true, player.getSession())); } } }
public SpoutColumn setColumn(int x, int z, SpoutColumn col) { long key = IntPairHashed.key(x, z); SpoutColumn old = columns.putIfAbsent(key, col); if (old != null) { return old; } synchronized (columnSet) { columnSet.add(col); } return col; }
public SetQueue<SpoutColumn> getColumnDirtyQueue(int x, int z) { long key = IntPairHashed.key(x, z); SetQueue<SpoutColumn> setQueue; synchronized (regionColumnDirtyQueueMap) { setQueue = regionColumnDirtyQueueMap.get(key); if (setQueue == null) { setQueue = new SetQueue<SpoutColumn>(Region.CHUNKS.SIZE * Region.CHUNKS.SIZE); regionColumnDirtyQueueMap.put(key, setQueue); } } return setQueue; }
@Override protected void freeChunk(Point p) { int x = (int) p.getX() >> Chunk.BLOCKS.BITS; int y = (int) p.getY() >> Chunk.BLOCKS.BITS; // + SEALEVEL_CHUNK; int z = (int) p.getZ() >> Chunk.BLOCKS.BITS; if (y < 0 || y >= p.getWorld().getHeight() >> Chunk.BLOCKS.BITS) { return; } TIntSet column = initializedChunks.get(x, z); if (column != null) { column.remove(y); if (column.isEmpty()) { emptyColumns.add(IntPairHashed.key(x, z)); } // TODO - is this required? /* else { CCMsg = new ChunkDataMessage(x, z, false, null, null, null, true); }*/ } }
@Override protected void freeChunk(Point p) { int x = (int) p.getX() >> Chunk.BLOCKS.BITS; int y = (int) p.getY() >> Chunk.BLOCKS.BITS; // + SEALEVEL_CHUNK; int z = (int) p.getZ() >> Chunk.BLOCKS.BITS; RepositionManager rm = getRepositionManager(); int cY = rm.convertChunkY(y); if (cY < 0 || cY >= p.getWorld().getHeight() >> Chunk.BLOCKS.BITS) { return; } TIntSet column = initializedChunks.get(x, z); if (column != null) { column.remove(y); if (column.isEmpty()) { emptyColumns.add(IntPairHashed.key(x, z)); } } }