check if pointer-checker is still there on non dev build

This commit is contained in:
minjaesong
2023-01-07 17:10:17 +09:00
parent 02bdb2a4fc
commit 3393ba6466
7 changed files with 41 additions and 23 deletions

1
.idea/.name generated
View File

@@ -1 +0,0 @@
Terrarum_renewed

View File

@@ -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

View File

@@ -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"));

View File

@@ -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

View File

@@ -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.

View File

@@ -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)

View File

@@ -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 {