mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 14:04:05 +09:00
trying to make savegame collecting faster
This commit is contained in:
@@ -1581,17 +1581,18 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
public static void printdbg(Object obj, Object message) {
|
public static void printdbg(Object obj, Object message) {
|
||||||
if (IS_DEVELOPMENT_BUILD) {
|
if (IS_DEVELOPMENT_BUILD) {
|
||||||
var timeNow = getTIME_T();
|
var timeNow = System.currentTimeMillis();
|
||||||
var ss = timeNow % 60;
|
var ss = (timeNow / 1000) % 60;
|
||||||
var mm = (timeNow / 60) % 60;
|
var mm = (timeNow / 60000) % 60;
|
||||||
var hh = (timeNow / 3600) % 24;
|
var hh = (timeNow / 3600000) % 24;
|
||||||
|
var ms = timeNow % 1000;
|
||||||
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
||||||
String prompt = csiG+String.format("%02d:%02d:%02d%s [%s] ",hh,mm,ss,csi0,out);
|
String prompt = csiG+String.format("%02d:%02d:%02d.%03d%s [%s] ",hh,mm,ss,ms,csi0,out);
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
System.out.println(prompt+"null");
|
System.out.println(prompt+"null");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String indentation = " ".repeat(out.length() + 11);
|
String indentation = " ".repeat(out.length() + 15);
|
||||||
String[] msgLines = message.toString().split("\\n");
|
String[] msgLines = message.toString().split("\\n");
|
||||||
for (int i = 0; i < msgLines.length; i++) {
|
for (int i = 0; i < msgLines.length; i++) {
|
||||||
System.out.println((i == 0 ? prompt : indentation) + msgLines[i]);
|
System.out.println((i == 0 ? prompt : indentation) + msgLines[i]);
|
||||||
@@ -1602,12 +1603,13 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
public static void printdbgerr(Object obj, Object message) {
|
public static void printdbgerr(Object obj, Object message) {
|
||||||
if (IS_DEVELOPMENT_BUILD) {
|
if (IS_DEVELOPMENT_BUILD) {
|
||||||
var timeNow = getTIME_T();
|
var timeNow = System.currentTimeMillis();
|
||||||
var ss = timeNow % 60;
|
var ss = (timeNow / 1000) % 60;
|
||||||
var mm = (timeNow / 60) % 60;
|
var mm = (timeNow / 60000) % 60;
|
||||||
var hh = (timeNow / 3600) % 24;
|
var hh = (timeNow / 3600000) % 24;
|
||||||
|
var ms = timeNow % 1000;
|
||||||
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
||||||
String prompt = csiB+String.format("%02d:%02d:%02d%s [%s] ",hh,mm,ss,csiR,out);
|
String prompt = csiB+String.format("%02d:%02d:%02d.%03d%s [%s] ",hh,mm,ss,ms,csiR,out);
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
System.out.println(prompt+"null"+csi0);
|
System.out.println(prompt+"null"+csi0);
|
||||||
}
|
}
|
||||||
@@ -1622,12 +1624,13 @@ public class App implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void printmsg(Object obj, Object message) {
|
public static void printmsg(Object obj, Object message) {
|
||||||
var timeNow = getTIME_T();
|
var timeNow = System.currentTimeMillis();
|
||||||
var ss = timeNow % 60;
|
var ss = (timeNow / 1000) % 60;
|
||||||
var mm = (timeNow / 60) % 60;
|
var mm = (timeNow / 60000) % 60;
|
||||||
var hh = (timeNow / 3600) % 24;
|
var hh = (timeNow / 3600000) % 24;
|
||||||
|
var ms = timeNow % 1000;
|
||||||
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
||||||
String prompt = csiG+String.format("%02d:%02d:%02d%s [%s] ",hh,mm,ss,csi0,out);
|
String prompt = csiG+String.format("%02d:%02d:%02d.%03d%s [%s] ",hh,mm,ss,ms,csi0,out);
|
||||||
if (message == null)
|
if (message == null)
|
||||||
System.out.println(prompt+"null");
|
System.out.println(prompt+"null");
|
||||||
else
|
else
|
||||||
@@ -1635,12 +1638,13 @@ public class App implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void printmsgerr(Object obj, Object message) {
|
public static void printmsgerr(Object obj, Object message) {
|
||||||
var timeNow = getTIME_T();
|
var timeNow = System.currentTimeMillis();
|
||||||
var ss = timeNow % 60;
|
var ss = (timeNow / 1000) % 60;
|
||||||
var mm = (timeNow / 60) % 60;
|
var mm = (timeNow / 60000) % 60;
|
||||||
var hh = (timeNow / 3600) % 24;
|
var hh = (timeNow / 3600000) % 24;
|
||||||
|
var ms = timeNow % 1000;
|
||||||
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
||||||
String prompt = csiB+String.format("%02d:%02d:%02d%s [%s] ",hh,mm,ss,csiR,out);
|
String prompt = csiB+String.format("%02d:%02d:%02d.%03d%s [%s] ",hh,mm,ss,ms,csiR,out);
|
||||||
if (message == null)
|
if (message == null)
|
||||||
System.out.println(prompt+"null"+csi0);
|
System.out.println(prompt+"null"+csi0);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -44,8 +44,13 @@ class SavegameCollection(files0: List<DiskSkimmer>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun collectFromBaseFilename(basedir: File, name: String): SavegameCollection {
|
fun collectFromBaseFilename(skimmers: List<DiskSkimmer>, name: String): SavegameCollection {
|
||||||
val files = basedir.listFiles().filter { it.name.startsWith(name) }
|
return SavegameCollection(skimmers)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun collectFromBaseFilename(dir: File, name: String): SavegameCollection {
|
||||||
|
val files = dir.listFiles().filter { it.name.startsWith(name) }
|
||||||
.mapNotNull { try { DiskSkimmer(it, true) } catch (e: Throwable) { null } }
|
.mapNotNull { try { DiskSkimmer(it, true) } catch (e: Throwable) { null } }
|
||||||
return SavegameCollection(files)
|
return SavegameCollection(files)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ object Terrarum : Disposable {
|
|||||||
fun setCurrentIngameInstance(ingame: IngameInstance) {
|
fun setCurrentIngameInstance(ingame: IngameInstance) {
|
||||||
this.ingame = ingame
|
this.ingame = ingame
|
||||||
|
|
||||||
printdbg(this, "Accepting new ingame instance '${ingame.javaClass.canonicalName}', called by:")
|
printdbg("ListSavegames", "Accepting new ingame instance '${ingame.javaClass.canonicalName}', called by:")
|
||||||
printStackTrace(this)
|
printStackTrace(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ object Terrarum : Disposable {
|
|||||||
/*fun resize(width: Int, height: Int) {
|
/*fun resize(width: Int, height: Int) {
|
||||||
ingame?.resize(width, height)
|
ingame?.resize(width, height)
|
||||||
|
|
||||||
printdbg(this, "newsize: ${Gdx.graphics.width}x${Gdx.graphics.height} | internal: ${width}x$height")
|
printdbg("ListSavegames", "newsize: ${Gdx.graphics.width}x${Gdx.graphics.height} | internal: ${width}x$height")
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
@@ -786,11 +786,10 @@ fun AppUpdateListOfSavegames() {
|
|||||||
App.savegamePlayers.clear()
|
App.savegamePlayers.clear()
|
||||||
App.savegamePlayersName.clear()
|
App.savegamePlayersName.clear()
|
||||||
|
|
||||||
println("Listing saved worlds...")
|
|
||||||
|
|
||||||
|
|
||||||
// create list of worlds
|
// create list of worlds
|
||||||
File(worldsDir).listFiles().filter { !it.isDirectory && !it.name.contains('.') }.mapNotNull { file ->
|
printdbg("ListSavegames", "Listing saved worlds...")
|
||||||
|
val worldsDirLs = File(worldsDir).listFiles().filter { !it.isDirectory && !it.name.contains('.') }.mapNotNull { file ->
|
||||||
try {
|
try {
|
||||||
DiskSkimmer(file, true)
|
DiskSkimmer(file, true)
|
||||||
}
|
}
|
||||||
@@ -799,19 +798,30 @@ fun AppUpdateListOfSavegames() {
|
|||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}.sortedByDescending { it.getLastModifiedTime() }.forEachIndexed { index, it ->
|
}.sortedByDescending { it.getLastModifiedTime() }
|
||||||
println("${index+1}.\t${it.diskFile.absolutePath}")
|
val filteringResults = arrayListOf<List<DiskSkimmer>>()
|
||||||
// it.rebuild()
|
worldsDirLs.forEach {
|
||||||
|
val li = arrayListOf(it)
|
||||||
|
listOf(".1",".2",".3",".a",".b",".c").forEach { suffix ->
|
||||||
|
val file = File(it.diskFile.absolutePath + suffix)
|
||||||
|
try {
|
||||||
|
val d = DiskSkimmer(file, true)
|
||||||
|
li.add(d)
|
||||||
|
}
|
||||||
|
catch (e: Throwable) {}
|
||||||
|
}
|
||||||
|
filteringResults.add(li)
|
||||||
|
}
|
||||||
|
filteringResults.forEachIndexed { index, list ->
|
||||||
|
val it = list.first()
|
||||||
|
printdbg("ListSavegames", " ${index+1}.\t${it.diskFile.absolutePath}")
|
||||||
|
|
||||||
// val jsonFile = it.getFile(SAVEGAMEINFO)!!
|
printdbg("ListSavegames", " collecting...")
|
||||||
// var worldUUID: UUID? = null
|
val collection = SavegameCollection.collectFromBaseFilename(list, it.diskFile.name)
|
||||||
// JsonFetcher.readFromJsonString(ByteArray64Reader(jsonFile.bytes, Common.CHARSET)).forEachSiblings { name, value ->
|
printdbg("ListSavegames", " get UUID...")
|
||||||
// if (name == "worldIndex") worldUUID = UUID.fromString(value.asString())
|
|
||||||
// }
|
|
||||||
|
|
||||||
val collection = SavegameCollection.collectFromBaseFilename(File(worldsDir), it.diskFile.name)
|
|
||||||
val worldUUID = collection.getUUID()
|
val worldUUID = collection.getUUID()
|
||||||
|
|
||||||
|
printdbg("ListSavegames", " registration...")
|
||||||
// if multiple valid savegames with same UUID exist, only the most recent one is retained
|
// if multiple valid savegames with same UUID exist, only the most recent one is retained
|
||||||
if (!App.savegameWorlds.contains(worldUUID)) {
|
if (!App.savegameWorlds.contains(worldUUID)) {
|
||||||
App.savegameWorlds[worldUUID] = collection
|
App.savegameWorlds[worldUUID] = collection
|
||||||
@@ -821,32 +831,41 @@ fun AppUpdateListOfSavegames() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
println("Listing saved players...")
|
|
||||||
|
|
||||||
// create list of players
|
// create list of players
|
||||||
File(playersDir).listFiles().filter { !it.isDirectory && !it.name.contains('.') }.mapNotNull { file ->
|
printdbg("ListSavegames", "Listing saved players...")
|
||||||
|
val playersDirLs = File(playersDir).listFiles().filter { !it.isDirectory && !it.name.contains('.') }.mapNotNull { file ->
|
||||||
try {
|
try {
|
||||||
DiskSkimmer(file, true)
|
DiskSkimmer(file, true)
|
||||||
}
|
}
|
||||||
catch (e: Throwable) {
|
catch (e: Throwable) {
|
||||||
System.err.println("Unable to load a player file ${file.absolutePath}")
|
System.err.println("Unable to load a world file ${file.absolutePath}")
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}.sortedByDescending { it.getLastModifiedTime() }.forEachIndexed { index, it ->
|
}.sortedByDescending { it.getLastModifiedTime() }
|
||||||
println("${index+1}.\t${it.diskFile.absolutePath}")
|
val filteringResults2 = arrayListOf<List<DiskSkimmer>>()
|
||||||
// it.rebuild()
|
playersDirLs.forEach {
|
||||||
|
val li = arrayListOf(it)
|
||||||
|
listOf(".1",".2",".3",".a",".b",".c").forEach { suffix ->
|
||||||
|
val file = File(it.diskFile.absolutePath + suffix)
|
||||||
|
try {
|
||||||
|
val d = DiskSkimmer(file, true)
|
||||||
|
li.add(d)
|
||||||
|
}
|
||||||
|
catch (e: Throwable) {}
|
||||||
|
}
|
||||||
|
filteringResults2.add(li)
|
||||||
|
}
|
||||||
|
filteringResults2.forEachIndexed { index, list ->
|
||||||
|
val it = list.first()
|
||||||
|
printdbg("ListSavegames", " ${index+1}.\t${it.diskFile.absolutePath}")
|
||||||
|
|
||||||
// val jsonFile = it.getFile(SAVEGAMEINFO)!!
|
printdbg("ListSavegames", " collecting...")
|
||||||
// var playerUUID: UUID? = null
|
val collection = SavegameCollection.collectFromBaseFilename(list, it.diskFile.name)
|
||||||
// JsonFetcher.readFromJsonString(ByteArray64Reader(jsonFile.bytes, Common.CHARSET)).forEachSiblings { name, value ->
|
printdbg("ListSavegames", " get UUID...")
|
||||||
// if (name == "uuid") playerUUID = UUID.fromString(value.asString())
|
|
||||||
// }
|
|
||||||
|
|
||||||
val collection = SavegameCollection.collectFromBaseFilename(File(playersDir), it.diskFile.name)
|
|
||||||
val playerUUID = collection.getUUID()
|
val playerUUID = collection.getUUID()
|
||||||
|
|
||||||
|
printdbg("ListSavegames", " registration...")
|
||||||
// if multiple valid savegames with same UUID exist, only the most recent one is retained
|
// if multiple valid savegames with same UUID exist, only the most recent one is retained
|
||||||
if (!App.savegamePlayers.contains(playerUUID)) {
|
if (!App.savegamePlayers.contains(playerUUID)) {
|
||||||
App.savegamePlayers[playerUUID] = collection
|
App.savegamePlayers[playerUUID] = collection
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ fun main() {
|
|||||||
|
|
||||||
// write pixels
|
// write pixels
|
||||||
for (gammaPair in 0..1) {
|
for (gammaPair in 0..1) {
|
||||||
|
val gamma = if (gammaPair == 0) HALF_PI else 3* HALF_PI
|
||||||
|
|
||||||
for (albedo0 in 0 until Skybox.albedoCnt) {
|
for (albedo0 in 0 until Skybox.albedoCnt) {
|
||||||
val albedo = Skybox.albedos[albedo0]
|
val albedo = Skybox.albedos[albedo0]
|
||||||
println("Albedo=$albedo")
|
println("Albedo=$albedo")
|
||||||
@@ -74,9 +76,9 @@ fun main() {
|
|||||||
// println("$yp\t$theta")
|
// println("$yp\t$theta")
|
||||||
|
|
||||||
val xyz = CIEXYZ(
|
val xyz = CIEXYZ(
|
||||||
ArHosekSkyModel.arhosek_tristim_skymodel_radiance(state, theta, HALF_PI, 0).toFloat(),
|
ArHosekSkyModel.arhosek_tristim_skymodel_radiance(state, theta, gamma, 0).toFloat(),
|
||||||
ArHosekSkyModel.arhosek_tristim_skymodel_radiance(state, theta, HALF_PI, 1).toFloat(),
|
ArHosekSkyModel.arhosek_tristim_skymodel_radiance(state, theta, gamma, 1).toFloat(),
|
||||||
ArHosekSkyModel.arhosek_tristim_skymodel_radiance(state, theta, HALF_PI, 2).toFloat()
|
ArHosekSkyModel.arhosek_tristim_skymodel_radiance(state, theta, gamma, 2).toFloat()
|
||||||
)
|
)
|
||||||
val xyz2 = xyz.scaleToFit(elevationDeg)
|
val xyz2 = xyz.scaleToFit(elevationDeg)
|
||||||
val rgb = xyz2.toRGB().toColor()
|
val rgb = xyz2.toRGB().toColor()
|
||||||
|
|||||||
@@ -520,7 +520,10 @@ class UIItemPlayerCells(
|
|||||||
private val isImported: Boolean
|
private val isImported: Boolean
|
||||||
|
|
||||||
init {
|
init {
|
||||||
App.savegamePlayers[playerUUID]!!.loadable().getFile(SAVEGAMEINFO)?.bytes?.let {
|
val loadable = App.savegamePlayers[playerUUID]!!.loadable()
|
||||||
|
printdbg(this, "UUID: ${playerUUID}")
|
||||||
|
printdbg(this, "File: ${loadable.diskFile.absolutePath}")
|
||||||
|
loadable.getFile(SAVEGAMEINFO)?.bytes?.let {
|
||||||
var lastPlayTime0 = 0L
|
var lastPlayTime0 = 0L
|
||||||
|
|
||||||
JsonFetcher.readFromJsonString(ByteArray64Reader(it, Common.CHARSET)).forEachSiblings { name, value ->
|
JsonFetcher.readFromJsonString(ByteArray64Reader(it, Common.CHARSET)).forEachSiblings { name, value ->
|
||||||
@@ -536,7 +539,7 @@ class UIItemPlayerCells(
|
|||||||
.atZone(TimeZone.getDefault().toZoneId())
|
.atZone(TimeZone.getDefault().toZoneId())
|
||||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||||
|
|
||||||
}
|
} ?: throw Error("SAVEGAMEINFO not found on Skimmer:${loadable.diskFile}")
|
||||||
|
|
||||||
val savegamePair = SavegameCollectionPair(App.savegamePlayers[playerUUID], App.savegameWorlds[worldUUID])
|
val savegamePair = SavegameCollectionPair(App.savegamePlayers[playerUUID], App.savegameWorlds[worldUUID])
|
||||||
savegameStatus = savegamePair.status
|
savegameStatus = savegamePair.status
|
||||||
|
|||||||
Reference in New Issue
Block a user