mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Merge branch 'revert-dynamic-region-changes' into 'master'
Revert the dynamic region based parts of sc-backports, which seem to have... See merge request 2009scape/2009scape!378
This commit is contained in:
commit
11eaa9f3a8
8 changed files with 51 additions and 98 deletions
|
|
@ -389,16 +389,17 @@ public final class HouseManager {
|
|||
for (int x = 0; x < 8; x++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
if(z == 3){
|
||||
region.replaceChunk(z, x, y, defaultSkyChunk/*.copy(region.getPlanes()[z])*/, from);
|
||||
continue;
|
||||
region.replaceChunk(z, x, y, defaultSkyChunk.copy(region.getPlanes()[z]), from);
|
||||
continue;
|
||||
}
|
||||
Room room = rooms[z][x][y];
|
||||
if (room != null) {
|
||||
if (room.getProperties().isRoof() && buildingMode) {
|
||||
continue;
|
||||
}
|
||||
region.replaceChunk(z, x, y, room.getChunk(), from);
|
||||
room.loadDecorations(z, (BuildRegionChunk)region.getPlanes()[z].getChunks()[x][y], this);
|
||||
BuildRegionChunk copy = room.getChunk().copy(region.getPlanes()[z]);
|
||||
region.replaceChunk(z, x, y, copy, from);
|
||||
room.loadDecorations(z, copy, this);
|
||||
} else {
|
||||
region.replaceChunk(z, x, y, z != 0 ? defaultSkyChunk.copy(region.getPlanes()[z]) : defaultChunk.copy(region.getPlanes()[0]), from);
|
||||
}
|
||||
|
|
@ -830,4 +831,4 @@ public final class HouseManager {
|
|||
public HouseZone getZone() {
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import kotlin.Pair;
|
||||
|
||||
/**
|
||||
* Represents a region.
|
||||
|
|
@ -46,7 +45,7 @@ public class Region {
|
|||
/**
|
||||
* The region planes.
|
||||
*/
|
||||
protected final RegionPlane[] planes = new RegionPlane[4];
|
||||
private final RegionPlane[] planes = new RegionPlane[4];
|
||||
|
||||
/**
|
||||
* The activity pulse.
|
||||
|
|
@ -227,15 +226,6 @@ public class Region {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void sendUpdateSceneGraph(boolean login) {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (Player p : this.getPlanes()[z].getPlayers()) {
|
||||
p.updateSceneGraph(login);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if this region has the inactivity flagging pulse running.
|
||||
* @return {@code True} if so.
|
||||
|
|
@ -556,10 +546,4 @@ public class Region {
|
|||
public void setUpdateAllPlanes(boolean updateAllPlanes) {
|
||||
this.updateAllPlanes = updateAllPlanes;
|
||||
}
|
||||
|
||||
public void transformAllSceneryById(Pair<Integer, Integer>[] ids, boolean clip, boolean permanent) {
|
||||
for(RegionPlane rp : getPlanes()) {
|
||||
rp.transformAllSceneryById(ids, clip, permanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import core.game.node.entity.player.Player;
|
|||
import core.game.node.item.GroundItem;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.node.scenery.SceneryBuilder;
|
||||
import rs09.game.system.SystemLogger;
|
||||
import core.game.world.map.build.DynamicRegion;
|
||||
import core.game.world.map.build.LandscapeParser;
|
||||
|
|
@ -16,9 +15,7 @@ import core.net.packet.out.ConstructScenery;
|
|||
import core.net.packet.out.UpdateAreaPosition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Function;
|
||||
import java.util.List;
|
||||
import kotlin.Pair;
|
||||
|
||||
/**
|
||||
* Represents a region chunk.
|
||||
|
|
@ -368,38 +365,4 @@ public class RegionChunk {
|
|||
this.currentBase = currentBase;
|
||||
}
|
||||
|
||||
public void transformAllSceneryById(Pair<Integer, Integer>[] ids, boolean clip, boolean permanent) {
|
||||
/*for(int i = 0; i < 8; i++) {
|
||||
for(int j = 0; j < 8; j++) {
|
||||
for(Scenery s : getObjects(i, j)) {
|
||||
for(Pair<Integer, Integer> id : ids) {
|
||||
if(s != null && s.getId() == id.getFirst()) {
|
||||
SceneryBuilder.replace(s, s.transform(id.getSecond()), clip, permanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
transformAllSceneryByFunction(clip, permanent, (Scenery s) -> {
|
||||
for(Pair<Integer, Integer> id : ids) {
|
||||
if(s != null && s.getId() == id.getFirst()) {
|
||||
return s.transform(id.getSecond());
|
||||
}
|
||||
}
|
||||
return s;
|
||||
});
|
||||
}
|
||||
|
||||
public void transformAllSceneryByFunction(boolean clip, boolean permanent, Function<Scenery, Scenery> f) {
|
||||
for(int i = 0; i < 8; i++) {
|
||||
for(int j = 0; j < 8; j++) {
|
||||
for(Scenery s : getObjects(i, j)) {
|
||||
Scenery t = f.apply(s);
|
||||
if(s != t) {
|
||||
SceneryBuilder.replace(s, t, clip, permanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import kotlin.Pair;
|
||||
|
||||
/**
|
||||
* Represents one of the 4 planes of a region.
|
||||
|
|
@ -419,12 +418,4 @@ public final class RegionPlane {
|
|||
return chunks;
|
||||
}
|
||||
|
||||
public void transformAllSceneryById(Pair<Integer, Integer>[] ids, boolean clip, boolean permanent) {
|
||||
for(int x = 0; x < 8; x++) {
|
||||
for(int y = 0; y < 8; y++) {
|
||||
RegionChunk rc = getChunks()[x][y];
|
||||
rc.transformAllSceneryById(ids, clip, permanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,11 @@ public final class DynamicRegion extends Region {
|
|||
*/
|
||||
private final int regionId;
|
||||
|
||||
/**
|
||||
* The region chunks.
|
||||
*/
|
||||
private final RegionChunk[][][] chunks;
|
||||
|
||||
/**
|
||||
* The zone borders.
|
||||
*/
|
||||
|
|
@ -70,6 +75,7 @@ public final class DynamicRegion extends Region {
|
|||
public DynamicRegion(int regionId, int x, int y) {
|
||||
super(x, y);
|
||||
this.regionId = regionId;
|
||||
this.chunks = new RegionChunk[4][SIZE >> 3][SIZE >> 3];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -89,12 +95,12 @@ public final class DynamicRegion extends Region {
|
|||
* @param regionTwo The second/last region.
|
||||
* @return The new region.
|
||||
*/
|
||||
public static DynamicRegion[] create(int regionOne, int regionTwo) {
|
||||
public static DynamicRegion create(int regionOne, int regionTwo) {
|
||||
int x = (regionOne >> 8) << 6;
|
||||
int y = (regionOne & 0xFF) << 6;
|
||||
int x1 = (regionTwo >> 8) << 6;
|
||||
int y1 = (regionTwo & 0xFF) << 6;
|
||||
return create(new ZoneBorders(x, y, x1 + SIZE, y1 + SIZE));
|
||||
return create(new ZoneBorders(x, y, x1 + SIZE, y1 + SIZE))[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,7 +134,11 @@ public final class DynamicRegion extends Region {
|
|||
}
|
||||
}
|
||||
for (Region r : regions) {
|
||||
r.sendUpdateSceneGraph(false);
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (Player p : r.getPlanes()[z].getPlayers()) {
|
||||
p.updateSceneGraph(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return regions.toArray(new DynamicRegion[regions.size()]);
|
||||
}
|
||||
|
|
@ -201,13 +211,12 @@ public final class DynamicRegion extends Region {
|
|||
int x = regionX + (offsetX << 3);
|
||||
int y = regionY + (offsetY << 3);
|
||||
for (int plane = 0; plane < 4; plane++) {
|
||||
RegionChunk c = region.planes[plane].getChunks()[offsetX][offsetY];
|
||||
RegionChunk c = region.chunks[plane][offsetX][offsetY];
|
||||
if (c == null) {
|
||||
region.planes[plane].getChunks()[offsetX][offsetY] = c = new RegionChunk(Location.create(0, 0, 0), 0, region.getPlanes()[plane]);
|
||||
region.chunks[plane][offsetX][offsetY] = c = new RegionChunk(Location.create(0, 0, 0), 0, region.getPlanes()[plane]);
|
||||
}
|
||||
c.setRotation(0);
|
||||
c.setBase(Location.create(x, y, plane));
|
||||
c.setCurrentBase(region.getBaseLocation().transform(offsetX << 3, offsetY << 3, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -258,10 +267,10 @@ public final class DynamicRegion extends Region {
|
|||
*/
|
||||
public void rotate() {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
RegionChunk[][] c = Arrays.copyOf(planes[z].getChunks(), 8);
|
||||
RegionChunk[][] c = Arrays.copyOf(chunks[z], 8);
|
||||
for (int x = 0; x < 8; x++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
RegionChunk r = planes[z].getChunks()[x][y] = c[8 - y - 1][x].copy(planes[z]);
|
||||
RegionChunk r = chunks[z][x][y] = c[8 - y - 1][x];
|
||||
if (r != null) {
|
||||
r.setRotation(r.getRotation() + 1);
|
||||
}
|
||||
|
|
@ -278,7 +287,8 @@ public final class DynamicRegion extends Region {
|
|||
* @param chunk The chunk to set.
|
||||
*/
|
||||
public void setChunk(int z, int x, int y, RegionChunk chunk) {
|
||||
planes[z].getChunks()[x][y] = chunk.copy(planes[z]);
|
||||
chunks[z][x][y] = chunk;
|
||||
getPlanes()[z].getChunks()[x][y] = chunk;
|
||||
if (chunk != null) {
|
||||
chunk.setCurrentBase(getBaseLocation().transform(x << 3, y << 3, 0));
|
||||
}
|
||||
|
|
@ -293,18 +303,16 @@ public final class DynamicRegion extends Region {
|
|||
* @param fromRegion The region the chunk is copied from.
|
||||
*/
|
||||
public void replaceChunk(int z, int x, int y, RegionChunk chunk, Region fromRegion) {
|
||||
if(fromRegion instanceof DynamicRegion) {
|
||||
fromRegion = RegionManager.forId(fromRegion.getRegionId());
|
||||
}
|
||||
Region.load(DynamicRegion.this);
|
||||
RegionPlane p = planes[z];
|
||||
RegionPlane p = getPlanes()[z];
|
||||
chunks[z][x][y] = chunk;
|
||||
p.getChunks()[x][y] = chunk;
|
||||
if (chunk == null) {
|
||||
p.getChunks()[x][y] = null;
|
||||
for (int i = x << 3; i < (x + 1) << 3; i++) {
|
||||
for (int j = y << 3; j < (y + 1) << 3; j++) {
|
||||
p.getFlags().getClippingFlags()[i][j] = -1;
|
||||
p.getProjectileFlags().getClippingFlags()[i][j] = -1;
|
||||
Scenery object = p.getChunkObject(i, j);
|
||||
Scenery object = p.getObjects()[i][j];
|
||||
if (object != null) {
|
||||
LandscapeParser.removeScenery(object);
|
||||
} else {
|
||||
|
|
@ -313,11 +321,10 @@ public final class DynamicRegion extends Region {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
RegionChunk newChunk = p.getChunks()[x][y] = chunk.copy(p);
|
||||
newChunk.clear();
|
||||
chunk.clear();
|
||||
Region.load(fromRegion);
|
||||
Location l = newChunk.getBase();
|
||||
newChunk.setCurrentBase(getBaseLocation().transform(x << 3, y << 3, 0));
|
||||
Location l = chunk.getBase();
|
||||
chunk.setCurrentBase(getBaseLocation().transform(x << 3, y << 3, 0));
|
||||
Location regionBase = fromRegion.getBaseLocation();
|
||||
RegionPlane rp = fromRegion.getPlanes()[l.getZ()];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
|
@ -372,7 +379,7 @@ public final class DynamicRegion extends Region {
|
|||
NPC npc = plane.getNpcs().get(0);
|
||||
npc.clear();
|
||||
}
|
||||
for (RegionChunk[] chunks : getPlanes()[plane.getPlane()].getChunks()) {
|
||||
for (RegionChunk[] chunks : getChunks()[plane.getPlane()]) {
|
||||
for (RegionChunk chunk : chunks) {
|
||||
if (chunk != null) {
|
||||
for (Iterator<GroundItem> it = chunk.getItems().iterator(); it.hasNext();) {
|
||||
|
|
@ -399,6 +406,14 @@ public final class DynamicRegion extends Region {
|
|||
return regionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the chunks.
|
||||
* @return The chunks.
|
||||
*/
|
||||
public RegionChunk[][][] getChunks() {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the borders.
|
||||
* @return The borders.
|
||||
|
|
@ -461,4 +476,4 @@ public final class DynamicRegion extends Region {
|
|||
}
|
||||
NPCs.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,8 +75,7 @@ public final class LandscapeParser {
|
|||
*/
|
||||
public static void addScenery(Scenery object, boolean landscape) {
|
||||
Location l = object.getLocation();
|
||||
RegionPlane rp = RegionManager.getRegionPlane(l);
|
||||
flagScenery(rp, l.getLocalX(), l.getLocalY(), object, landscape, false);
|
||||
flagScenery(RegionManager.getRegionPlane(l), l.getLocalX(), l.getLocalY(), object, landscape, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -215,4 +214,4 @@ public final class LandscapeParser {
|
|||
}
|
||||
return current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,4 +52,4 @@ public class ObjectUpdateFlag extends UpdateFlag<Object> {
|
|||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ public final class BuildDynamicScene implements OutgoingPacket<DynamicSceneConte
|
|||
r = RegionManager.forId((x >> 3) << 8 | (y >> 3));
|
||||
if (r instanceof DynamicRegion) {
|
||||
DynamicRegion dr = (DynamicRegion) r;
|
||||
chunks[z][x - baseX][y - baseY] = dr.getPlanes()[z].getChunks()[x - (dr.getX() << 3)][y - (dr.getY() << 3)];
|
||||
chunks[z][x - baseX][y - baseY] = dr.getChunks()[z][x - (dr.getX() << 3)][y - (dr.getY() << 3)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,4 +75,4 @@ public final class BuildDynamicScene implements OutgoingPacket<DynamicSceneConte
|
|||
player.getPlayerFlags().setLastSceneGraph(player.getLocation());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue