mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
I fixed the ingamerender-not-rendering bug??
This commit is contained in:
@@ -1246,7 +1246,7 @@ public class App implements ApplicationListener {
|
||||
printdbg(this, "PostInit done; took "+tms+" seconds");
|
||||
}
|
||||
|
||||
public static void renewAudioProcessor(int bufferSize) {
|
||||
public static void reloadAudioProcessor(int bufferSize) {
|
||||
// copy music tracks
|
||||
var dynaicTracks = audioMixer.getDynamicTracks();
|
||||
var staticTracks = audioMixer.getTracks();
|
||||
@@ -1280,6 +1280,7 @@ public class App implements ApplicationListener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -306,6 +306,8 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
var mousePrimaryJustDown = false; private set
|
||||
|
||||
override fun render(updateRate: Float) {
|
||||
IngameRenderer.setRenderedWorld(gameWorld)
|
||||
|
||||
super.render(updateRate)
|
||||
|
||||
|
||||
|
||||
@@ -180,27 +180,27 @@ object IngameRenderer : Disposable {
|
||||
* - When the game make transition to the new world (advancing to the next level/entering or exiting the room)
|
||||
*/
|
||||
fun setRenderedWorld(world: GameWorld) {
|
||||
printdbg(this, "Set new RenderedWorld (UUID=${world.worldIndex}) at time ${System.currentTimeMillis()}, called by:")
|
||||
printStackTrace(this)
|
||||
// printdbg(this, "Set new RenderedWorld (UUID=${world.worldIndex}) at time ${System.currentTimeMillis()} (disposed: ${world.disposed}), called by:")
|
||||
// printStackTrace(this)
|
||||
|
||||
try {
|
||||
|
||||
// change worlds from internal methods
|
||||
this.world = world
|
||||
LightmapRenderer.internalSetWorld(world)
|
||||
BlocksDrawer.world = world
|
||||
FeaturesDrawer.world = world
|
||||
|
||||
if (this.world != world) {
|
||||
// printdbg(this, "World change detected -- " +
|
||||
// "old world: ${this.world.hashCode()}, " +
|
||||
// "new world: ${world.hashCode()}")
|
||||
|
||||
// change worlds from internal methods
|
||||
this.world = world
|
||||
LightmapRenderer.internalSetWorld(world)
|
||||
BlocksDrawer.world = world
|
||||
FeaturesDrawer.world = world
|
||||
|
||||
newWorldLoadedLatch = true
|
||||
}
|
||||
}
|
||||
catch (e: UninitializedPropertyAccessException) {
|
||||
catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
// new init, do nothing
|
||||
this.world = world
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -810,6 +810,9 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
gameFullyLoaded = true
|
||||
}
|
||||
else {
|
||||
IngameRenderer.setRenderedWorld(world) // this doesn't slow down the game and prevents world-changing related bugs
|
||||
}
|
||||
|
||||
super.render(updateRate)
|
||||
|
||||
|
||||
@@ -309,6 +309,8 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
private var introUncoverDeltaCounter = 0f
|
||||
|
||||
override fun render(updateRate: Float) {
|
||||
IngameRenderer.setRenderedWorld(demoWorld)
|
||||
|
||||
super.render(updateRate)
|
||||
// async update and render
|
||||
gameUpdateGovernor.update(Gdx.graphics.deltaTime, App.UPDATE_RATE, updateScreen, renderScreen)
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.audio.AudioMixer
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
|
||||
@@ -48,7 +47,7 @@ class UISoundControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||
if (it != oldBufferSize) {
|
||||
oldBufferSize = it
|
||||
|
||||
App.renewAudioProcessor(it)
|
||||
App.reloadAudioProcessor(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user