mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
q&d hack to circumvent the dangling pointer issue #26
This commit is contained in:
@@ -253,7 +253,9 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
||||
gdxClearAndSetBlend(.64f, .754f, .84f, 1f)
|
||||
|
||||
|
||||
IngameRenderer.invoke(gamePaused = false, world = demoWorld, uisToDraw = uiContainer)
|
||||
if (!demoWorld.disposed) { // FIXME q&d hack to circumvent the dangling pointer issue #26
|
||||
IngameRenderer.invoke(gamePaused = false, world = demoWorld, uisToDraw = uiContainer)
|
||||
}
|
||||
|
||||
|
||||
batch.inUse {
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.torvald.terrarum.AppLoader.printdbg
|
||||
*/
|
||||
open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
||||
|
||||
// using unsafe pointer gets you 100 fps, whereas using directbytebuffer gets you 90
|
||||
private val ptr = UnsafeHelper.allocate(width * height * BYTES_PER_BLOCK)
|
||||
|
||||
//private val directByteBuffer: ByteBuffer
|
||||
|
||||
@@ -93,6 +93,9 @@ open class GameWorld : Disposable {
|
||||
var generatorSeed: Long = 0
|
||||
internal set
|
||||
|
||||
var disposed = false
|
||||
private set
|
||||
|
||||
|
||||
constructor(worldIndex: Int, width: Int, height: Int, creationTIME_T: Long, lastPlayTIME_T: Long, totalPlayTime: Int) {
|
||||
if (width <= 0 || height <= 0) throw IllegalArgumentException("Non-positive width/height: ($width, $height)")
|
||||
@@ -461,6 +464,8 @@ open class GameWorld : Disposable {
|
||||
layerWall.dispose()
|
||||
layerTerrain.dispose()
|
||||
//nullWorldInstance?.dispose() // must be called ONLY ONCE; preferably when the app exits
|
||||
|
||||
disposed = true
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user