mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-24 03:45:13 -06:00
A nicer fix involving tracking dirty chunks.
This commit is contained in:
parent
81faf292cc
commit
4d9243884f
6 changed files with 37 additions and 17 deletions
|
|
@ -18,7 +18,9 @@ import core.ServerStore
|
|||
import core.auth.AuthProvider
|
||||
import core.auth.Auth
|
||||
import core.game.system.config.ConfigParser
|
||||
import core.game.world.map.RegionChunk
|
||||
import core.game.world.repository.Repository
|
||||
import core.game.world.update.ChunkUpdateTracker
|
||||
import core.plugin.ClassScanner
|
||||
import core.storage.AccountStorageProvider
|
||||
import core.tools.Log
|
||||
|
|
@ -164,6 +166,7 @@ object GameWorld {
|
|||
fun prompt(run: Boolean, directory: String?){
|
||||
log(GameWorld::class.java, Log.FINE, "Prompting ${settings?.name} Game World...")
|
||||
Cache.init(ServerConstants.CACHE_PATH)
|
||||
RegionChunk.dirtyListener = ChunkUpdateTracker
|
||||
//go overboard with checks to make sure dev mode authenticator never triggers on live
|
||||
Auth.configure()
|
||||
ConfigParser().prePlugin()
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import core.game.node.scenery.Constructed;
|
|||
import core.game.node.scenery.Scenery;
|
||||
import core.game.node.scenery.SceneryBuilder;
|
||||
import core.game.world.map.build.ChunkFlags;
|
||||
import core.game.world.update.ChunkDirtyListener;
|
||||
import core.game.world.update.flag.chunk.ItemUpdateFlag;
|
||||
import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.BuildItemContext;
|
||||
|
|
@ -41,6 +42,11 @@ public class RegionChunk {
|
|||
*/
|
||||
public static final int SIZE = 8;
|
||||
|
||||
/**
|
||||
* Notified whenever a chunk is flagged, so the rendering pipeline can reset only the chunks that were actually touched.
|
||||
*/
|
||||
public static ChunkDirtyListener dirtyListener = chunk -> {};
|
||||
|
||||
/**
|
||||
* The base location of the copied region chunk.
|
||||
*/
|
||||
|
|
@ -345,6 +351,7 @@ public class RegionChunk {
|
|||
*/
|
||||
public void flag(UpdateFlag<?> flag) {
|
||||
updateFlags.add(flag);
|
||||
dirtyListener.onFlagged(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -62,22 +62,6 @@ object RegionManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pulses the active regions.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun pulse() {
|
||||
apply { r ->
|
||||
for (x in 0 until 8) {
|
||||
for (y in 0 until 8) {
|
||||
for (z in 0 until 4) {
|
||||
r.chunks[x][y][z]?.resetFlags()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the clipping flag.
|
||||
* @param z The plane.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package core.game.world.update
|
||||
|
||||
import core.game.world.map.RegionChunk
|
||||
|
||||
fun interface ChunkDirtyListener {
|
||||
fun onFlagged(chunk: RegionChunk)
|
||||
}
|
||||
19
Server/src/main/core/game/world/update/ChunkUpdateTracker.kt
Normal file
19
Server/src/main/core/game/world/update/ChunkUpdateTracker.kt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package core.game.world.update
|
||||
|
||||
import core.game.world.map.RegionChunk
|
||||
import java.util.Collections
|
||||
import java.util.IdentityHashMap
|
||||
|
||||
object ChunkUpdateTracker : ChunkDirtyListener {
|
||||
private val dirty = Collections.newSetFromMap(IdentityHashMap<RegionChunk, Boolean>())
|
||||
|
||||
override fun onFlagged(chunk: RegionChunk) {
|
||||
dirty.add(chunk)
|
||||
}
|
||||
|
||||
/** Resets flags on exactly the chunks flagged this tick. Must run after all per-player flushes. */
|
||||
fun resetAll() {
|
||||
dirty.forEach { it.resetFlags() }
|
||||
dirty.clear()
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ class UpdateSequence
|
|||
playersList!!.forEach(Player::reset)
|
||||
npcList!!.forEach(NPC::reset)
|
||||
renderablePlayers.sync()
|
||||
RegionManager.pulse()
|
||||
ChunkUpdateTracker.resetAll()
|
||||
GroundItemManager.pulse()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue