mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Revert "Lock the piss out of the parallax layer "
This reverts commit 229f3dc061a6663df0fff6b5a180425f2d3698d7.
This commit is contained in:
parent
229f3dc061
commit
1923ae6f4b
@ -22,8 +22,6 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.object.tile.TileData;
|
import com.volmit.iris.engine.object.tile.TileData;
|
||||||
import com.volmit.iris.engine.parallel.GridLock;
|
|
||||||
import com.volmit.iris.engine.parallel.HyperLock;
|
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
@ -40,14 +38,12 @@ import java.io.IOException;
|
|||||||
public class ParallaxWorld implements ParallaxAccess {
|
public class ParallaxWorld implements ParallaxAccess {
|
||||||
private final KMap<Long, ParallaxRegion> loadedRegions;
|
private final KMap<Long, ParallaxRegion> loadedRegions;
|
||||||
private final KList<Long> save;
|
private final KList<Long> save;
|
||||||
private final HyperLock hlock;
|
|
||||||
private final File folder;
|
private final File folder;
|
||||||
private final MultiBurst burst;
|
private final MultiBurst burst;
|
||||||
private final int height;
|
private final int height;
|
||||||
|
|
||||||
public ParallaxWorld(MultiBurst burst, int height, File folder) {
|
public ParallaxWorld(MultiBurst burst, int height, File folder) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.hlock = new HyperLock(1024);
|
|
||||||
this.burst = burst;
|
this.burst = burst;
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
save = new KList<>();
|
save = new KList<>();
|
||||||
@ -85,7 +81,7 @@ public class ParallaxWorld implements ParallaxAccess {
|
|||||||
|
|
||||||
public void save(ParallaxRegion region) {
|
public void save(ParallaxRegion region) {
|
||||||
try {
|
try {
|
||||||
hlock.withIO(region.getX(), region.getZ(), () -> region.save());
|
region.save();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -99,70 +95,60 @@ public class ParallaxWorld implements ParallaxAccess {
|
|||||||
|
|
||||||
@RegionCoordinates
|
@RegionCoordinates
|
||||||
public void save(int x, int z) {
|
public void save(int x, int z) {
|
||||||
hlock.with(x, z, () -> {
|
if (isLoaded(x, z)) {
|
||||||
if (isLoaded(x, z)) {
|
save(getR(x, z));
|
||||||
save(getR(x, z));
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RegionCoordinates
|
@RegionCoordinates
|
||||||
public int unload(int x, int z) {
|
public int unload(int x, int z) {
|
||||||
return hlock.withResult(x, z, () -> {
|
long key = key(x, z);
|
||||||
long key = key(x, z);
|
int v = 0;
|
||||||
int v = 0;
|
if (isLoaded(x, z)) {
|
||||||
if (isLoaded(x, z)) {
|
if (save.contains(key)) {
|
||||||
if (save.contains(key)) {
|
save(x, z);
|
||||||
save(x, z);
|
save.remove(key);
|
||||||
save.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
ParallaxRegion lr = loadedRegions.remove(key);
|
|
||||||
|
|
||||||
if (lr != null) {
|
|
||||||
v += lr.unload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
ParallaxRegion lr = loadedRegions.remove(key);
|
||||||
});
|
|
||||||
|
if (lr != null) {
|
||||||
|
v += lr.unload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RegionCoordinates
|
@RegionCoordinates
|
||||||
public ParallaxRegion load(int x, int z) {
|
public ParallaxRegion load(int x, int z) {
|
||||||
return hlock.withResult(x, z, () -> {
|
if (isLoaded(x, z)) {
|
||||||
if (isLoaded(x, z)) {
|
return loadedRegions.get(key(x, z));
|
||||||
return loadedRegions.get(key(x, z));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ParallaxRegion v = new ParallaxRegion(burst, height, folder, x, z);
|
ParallaxRegion v = new ParallaxRegion(burst, height, folder, x, z);
|
||||||
loadedRegions.put(key(x, z), v);
|
loadedRegions.put(key(x, z), v);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RegionCoordinates
|
@RegionCoordinates
|
||||||
public ParallaxRegion getR(int x, int z) {
|
public ParallaxRegion getR(int x, int z) {
|
||||||
return hlock.withResult(x, z, () -> {
|
long key = key(x, z);
|
||||||
long key = key(x, z);
|
|
||||||
|
|
||||||
ParallaxRegion region = loadedRegions.get(key);
|
ParallaxRegion region = loadedRegions.get(key);
|
||||||
|
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
region = load(x, z);
|
region = load(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
return region;
|
return region;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RegionCoordinates
|
@RegionCoordinates
|
||||||
public ParallaxRegion getRW(int x, int z) {
|
public ParallaxRegion getRW(int x, int z) {
|
||||||
return hlock.withResult(x, z, () -> {
|
save.addIfMissing(key(x, z));
|
||||||
save.addIfMissing(key(x, z));
|
return getR(x, z);
|
||||||
return getR(x, z);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RegionCoordinates
|
@RegionCoordinates
|
||||||
|
Loading…
x
Reference in New Issue
Block a user