From ec0477587e1b23712b9b7f5dd27fd924b9933b96 Mon Sep 17 00:00:00 2001 From: fredboy Date: Wed, 17 Apr 2024 16:18:34 +0700 Subject: [PATCH] Fix process not finishing when exited --- core/src/ru/deadsoftware/cavedroid/CaveGame.java | 3 +++ .../deadsoftware/cavedroid/game/GameScreen.java | 3 +++ .../cavedroid/game/world/GameFluidsThread.java | 15 +-------------- .../cavedroid/game/world/GameWorld.java | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/core/src/ru/deadsoftware/cavedroid/CaveGame.java b/core/src/ru/deadsoftware/cavedroid/CaveGame.java index 8b2d66b..8aa6f28 100644 --- a/core/src/ru/deadsoftware/cavedroid/CaveGame.java +++ b/core/src/ru/deadsoftware/cavedroid/CaveGame.java @@ -67,6 +67,9 @@ public class CaveGame extends Game { } public void quitGame() { + if (screen != null) { + screen.dispose(); + } setScreen(mMainComponent.getMenuScreen()); } diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameScreen.java b/core/src/ru/deadsoftware/cavedroid/game/GameScreen.java index 370d8bd..4a7d613 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameScreen.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameScreen.java @@ -85,6 +85,9 @@ public class GameScreen implements Screen { @Override public void dispose() { + if (mGameProc != null) { + mGameProc.dispose(); + } } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameFluidsThread.java b/core/src/ru/deadsoftware/cavedroid/game/world/GameFluidsThread.java index 7d80855..c5eb833 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/world/GameFluidsThread.java +++ b/core/src/ru/deadsoftware/cavedroid/game/world/GameFluidsThread.java @@ -1,6 +1,5 @@ package ru.deadsoftware.cavedroid.game.world; -import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavedroid.game.mobs.MobsController; import java.util.Arrays; @@ -21,14 +20,10 @@ class GameFluidsThread extends TimerTask { private final GameWorld mGameWorld; private final MobsController mMobsController; - private final Thread mMainThread; - GameFluidsThread(GameWorld gameWorld, - MobsController mobsController, - Thread mainThread) { + MobsController mobsController) { mGameWorld = gameWorld; mMobsController = mobsController; - mMainThread = mainThread; } private int getBlockState(int id) { @@ -135,14 +130,6 @@ class GameFluidsThread extends TimerTask { } } - private boolean timeToUpdate() { - if (TimeUtils.timeSinceMillis(mFluidLastUpdateTimestamp) >= FLUID_UPDATE_INTERVAL_MS) { - mFluidLastUpdateTimestamp = TimeUtils.millis(); - return true; - } - return false; - } - @Override public void run() { fluidUpdater(); diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java index b5ac7ee..a908971 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java +++ b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java @@ -63,7 +63,7 @@ public class GameWorld implements Disposable { mHeight = mForeMap[0].length; } - mGameFluidsThread = new GameFluidsThread(this, mMobsController, Thread.currentThread()); + mGameFluidsThread = new GameFluidsThread(this, mMobsController); mGameFluidsTimer = new Timer(); mGameFluidsTimer.scheduleAtFixedRate(mGameFluidsThread, 0, GameFluidsThread.FLUID_UPDATE_INTERVAL_MS); -- 2.29.2