diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index ae652224d..000000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Terrarum_renewed \ No newline at end of file diff --git a/COPYING.md b/COPYING.md index 38c227e9a..d9adde496 100644 --- a/COPYING.md +++ b/COPYING.md @@ -1,6 +1,6 @@ *Terrarum* -Copyright (C) 2013-2022 Minjae Song ("CuriousTorvald") +Copyright (C) 2013-2023 Minjae Song ("CuriousTorvald") This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/net/torvald/terrarum/App.java b/src/net/torvald/terrarum/App.java index a15aadf96..8d2fd8d03 100644 --- a/src/net/torvald/terrarum/App.java +++ b/src/net/torvald/terrarum/App.java @@ -39,6 +39,9 @@ import net.torvald.terrarum.utils.JsonFetcher; import net.torvald.terrarum.worlddrawer.CreateTileAtlas; import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap; import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack; +import net.torvald.unsafe.AddressOverflowException; +import net.torvald.unsafe.DanglingPointerException; +import net.torvald.unsafe.UnsafeHelper; import net.torvald.util.DebugTimers; import java.io.File; @@ -71,12 +74,6 @@ public class App implements ApplicationListener { */ public static boolean IS_DEVELOPMENT_BUILD = false; - { - // if -ea flag is set, turn on all the debug prints - try { assert (false); } - catch (AssertionError e) { IS_DEVELOPMENT_BUILD = true; } - } - /** * Singleton instance */ @@ -314,23 +311,23 @@ public class App implements ApplicationListener { } public static void main(String[] args) { + + // if -ea flag is set, turn on all the debug prints + try { + assert false; + } + catch (AssertionError e) { + IS_DEVELOPMENT_BUILD = true; + } + + // print copyright message System.out.println(csiB+GAME_NAME+" "+csiG+getVERSION_STRING()+" "+csiK+"\u2014"+" "+csi0+TerrarumAppConfiguration.COPYRIGHT_DATE_NAME); System.out.println(csiG+TerrarumAppConfiguration.COPYRIGHT_LICENSE_TERMS_SHORT+csi0); - + System.out.println("IS_DEVELOPMENT_BUILD = " + IS_DEVELOPMENT_BUILD); try { - - // load configs - getDefaultDirectory(); - createDirs(); - initialiseConfig(); - readConfigJson(); - - setGamepadButtonLabels(); - - try { processor = GetCpuName.getModelName(); } @@ -345,6 +342,26 @@ public class App implements ApplicationListener { } + if (!IS_DEVELOPMENT_BUILD) { + var p = UnsafeHelper.INSTANCE.allocate(64); + p.destroy(); + try { + p.get(0); + } + catch (DanglingPointerException | AddressOverflowException e) { + throw new RuntimeException("Build Error: App is not Development Build but pointer check is still installed. If the game is a production release, please report this to the developers."); + } + } + + + // load configs + getDefaultDirectory(); + createDirs(); + initialiseConfig(); + readConfigJson(); + setGamepadButtonLabels(); + + ShaderProgram.pedantic = false; scr = new TerrarumScreenSize(getConfigInt("screenwidth"), getConfigInt("screenheight")); diff --git a/src/net/torvald/terrarum/CreditSingleton.kt b/src/net/torvald/terrarum/CreditSingleton.kt index 7f6f3a6d2..7a52dfb57 100644 --- a/src/net/torvald/terrarum/CreditSingleton.kt +++ b/src/net/torvald/terrarum/CreditSingleton.kt @@ -16,7 +16,7 @@ object CreditSingleton { $BULLET Terrarum -Copyright (C) 2013-2022 CuriousTorvald (minjaesong) +Copyright (C) 2013-2023 CuriousTorvald (minjaesong) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/net/torvald/terrarum/TerrarumPostProcessor.kt b/src/net/torvald/terrarum/TerrarumPostProcessor.kt index d924afc06..dc44b7678 100644 --- a/src/net/torvald/terrarum/TerrarumPostProcessor.kt +++ b/src/net/torvald/terrarum/TerrarumPostProcessor.kt @@ -332,7 +332,7 @@ object TerrarumPostProcessor : Disposable { private val currentResStr = "${App.scr.width}x${App.scr.height}" private val safeAreaStr = "TV Safe Area" private val versionStr = "Version ${App.getVERSION_STRING()}" - internal val thisIsDebugStr = "${App.GAME_NAME} Develoment Build $versionStr" + internal val thisIsDebugStr = "${App.GAME_NAME} Development Build $versionStr" /** * Camera will be moved so that (newX, newY) would be sit on the top-left edge. diff --git a/src/net/torvald/terrarum/modulebasegame/TitleScreen.kt b/src/net/torvald/terrarum/modulebasegame/TitleScreen.kt index 5da9a4e47..19ad96373 100644 --- a/src/net/torvald/terrarum/modulebasegame/TitleScreen.kt +++ b/src/net/torvald/terrarum/modulebasegame/TitleScreen.kt @@ -326,6 +326,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) { ) } + batch.color = if (App.IS_DEVELOPMENT_BUILD) Toolkit.Theme.COL_MOUSE_UP else Color.LIGHT_GRAY App.fontGame.draw(batch, TerrarumPostProcessor.thisIsDebugStr, 5f, App.scr.height - 24f) diff --git a/src/net/torvald/unsafe/UnsafePtr.kt b/src/net/torvald/unsafe/UnsafePtr.kt index 7479857cf..a3e127287 100644 --- a/src/net/torvald/unsafe/UnsafePtr.kt +++ b/src/net/torvald/unsafe/UnsafePtr.kt @@ -112,8 +112,9 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) { // You may break the glass and use this tool when some fucking incomprehensible bugs ("vittujen vitun bugit") // appear (e.g. getting garbage values when it fucking shouldn't) - assert(!destroyed) { throw DanglingPointerException("The pointer is already destroyed ($this)") } - assert(index in 0 until size) { throw AddressOverflowException("Index: $index; alloc size: $size") } + // using ifs instead of assertions: inactive assert statements still slows down the app + if (destroyed) { throw DanglingPointerException("The pointer is already destroyed ($this)") } + if (index !in 0 until size) { throw AddressOverflowException("Index: $index; alloc size: $size") } } operator fun get(index: Long): Byte {