mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-23 19:35:10 -06:00
This breaks map rendering more
This commit is contained in:
parent
445281776e
commit
20d26e67e0
3 changed files with 25 additions and 47 deletions
|
|
@ -856,7 +856,7 @@ public class Player extends Entity {
|
|||
getZoneMonitor().getZones().clear();
|
||||
playerFlags.setLastSceneGraph(null);
|
||||
playerFlags.setUpdateSceneGraph(false);
|
||||
playerFlags.setLastViewport(new RegionChunk[13][13]);
|
||||
playerFlags.setLastViewport(new LinkedList<>());
|
||||
renderInfo.getLocalNpcs().clear();
|
||||
renderInfo.getLocalPlayers().clear();
|
||||
renderInfo.setLastLocation(null);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import kotlin.math.abs
|
|||
* @author Emperor
|
||||
*/
|
||||
object MapChunkRenderer {
|
||||
const val buildAreaDepth = 6
|
||||
|
||||
/**
|
||||
* Sends the map chunk rendering packet.
|
||||
* @param player The player.
|
||||
|
|
@ -21,61 +23,35 @@ object MapChunkRenderer {
|
|||
fun render(player: Player) {
|
||||
val last = player.playerFlags.lastViewport
|
||||
val updated: MutableList<RegionChunk> = ArrayList()
|
||||
val current: MutableList<MutableList<RegionChunk>> = ArrayList()
|
||||
val current: MutableList<RegionChunk> = ArrayList()
|
||||
|
||||
val buildAreaDepth = 6
|
||||
for (dcx in -buildAreaDepth..+buildAreaDepth) {
|
||||
val addX = ArrayList<RegionChunk>()
|
||||
for (dcy in -buildAreaDepth..+buildAreaDepth) {
|
||||
val newloc = player.location.chunkBase.transform(dcx*8, dcy*8, 0)
|
||||
addX.add(newloc.chunk)
|
||||
current.add(newloc.chunk)
|
||||
}
|
||||
current.add(addX)
|
||||
}
|
||||
|
||||
var sizeX = last.size
|
||||
for (x in 0 until sizeX) {
|
||||
val sizeY: Int = last[x].size
|
||||
for (y in 0 until sizeY) {
|
||||
val previous = last[x][y] ?: continue
|
||||
if (!containsChunk(current, previous)) {
|
||||
PacketRepository.send(ClearRegionChunk::class.java, ClearChunkContext(player, previous))
|
||||
} else {
|
||||
updated.add(previous)
|
||||
}
|
||||
val removeList = LinkedList<RegionChunk>()
|
||||
for (chunk in last) {
|
||||
if (current.contains(chunk)) {
|
||||
updated.add(chunk)
|
||||
} else {
|
||||
PacketRepository.send(ClearRegionChunk::class.java, ClearChunkContext(player, chunk))
|
||||
removeList.add(chunk)
|
||||
}
|
||||
}
|
||||
sizeX = current.size
|
||||
for (x in 0 until sizeX) {
|
||||
val sizeY: Int = current[x].size
|
||||
for (y in 0 until sizeY) {
|
||||
val chunk = current[x][y]
|
||||
if (!updated.contains(chunk)) {
|
||||
chunk.synchronize(player)
|
||||
} else {
|
||||
chunk.update(player)
|
||||
}
|
||||
last[x][y] = current[x][y]
|
||||
}
|
||||
for (chunk in removeList) {
|
||||
last.remove(chunk)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the chunks list contains the specified region chunk.
|
||||
* @param list The list to search.
|
||||
* @param c The region chunk.
|
||||
* @return `True` if so.
|
||||
*/
|
||||
private fun containsChunk(list: MutableList<MutableList<RegionChunk>>, c: RegionChunk): Boolean {
|
||||
val sizeList = list.size
|
||||
for (x in 0 until sizeList) {
|
||||
val chunkSize: Int = list[x].size
|
||||
for (y in 0 until chunkSize) {
|
||||
if (list[x][y] === c) {
|
||||
return true
|
||||
}
|
||||
for (chunk in current) {
|
||||
if (updated.contains(chunk)) {
|
||||
chunk.update(player)
|
||||
} else {
|
||||
chunk.synchronize(player)
|
||||
}
|
||||
last.add(chunk)
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@ package core.game.world.update.flag;
|
|||
import core.game.world.map.Location;
|
||||
import core.game.world.map.RegionChunk;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* A class holding a player's updating flags.
|
||||
* @author Emperor
|
||||
|
|
@ -17,7 +19,7 @@ public final class PlayerFlags {
|
|||
/**
|
||||
* The last viewport.
|
||||
*/
|
||||
private RegionChunk[][] lastViewport = new RegionChunk[13][13];
|
||||
private LinkedList<RegionChunk> lastViewport = new LinkedList<>();
|
||||
|
||||
/**
|
||||
* The location the player was standing on when last scene graph update
|
||||
|
|
@ -70,7 +72,7 @@ public final class PlayerFlags {
|
|||
* Gets the lastViewport.
|
||||
* @return The lastViewport.
|
||||
*/
|
||||
public RegionChunk[][] getLastViewport() {
|
||||
public LinkedList<RegionChunk> getLastViewport() {
|
||||
return lastViewport;
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +80,7 @@ public final class PlayerFlags {
|
|||
* Sets the lastViewport.
|
||||
* @param lastViewport The lastViewport to set.
|
||||
*/
|
||||
public void setLastViewport(RegionChunk[][] lastViewport) {
|
||||
public void setLastViewport(LinkedList<RegionChunk> lastViewport) {
|
||||
this.lastViewport = lastViewport;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue