mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
serialised RNG; font update
This commit is contained in:
Binary file not shown.
Binary file not shown.
BIN
assets/graphics/fonts/terrarum-sans-bitmap/LatinExtC_variable.tga
LFS
Normal file
BIN
assets/graphics/fonts/terrarum-sans-bitmap/LatinExtC_variable.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/graphics/fonts/terrarum-sans-bitmap/devanagari_bengali_variable.tga
LFS
Normal file
BIN
assets/graphics/fonts/terrarum-sans-bitmap/devanagari_bengali_variable.tga
LFS
Normal file
Binary file not shown.
BIN
assets/graphics/fonts/terrarum-sans-bitmap/diacritical_marks_variable.tga
LFS
Normal file
BIN
assets/graphics/fonts/terrarum-sans-bitmap/diacritical_marks_variable.tga
LFS
Normal file
Binary file not shown.
BIN
assets/graphics/fonts/terrarum-sans-bitmap/greek_polytonic_xyswap_variable.tga
LFS
Normal file
BIN
assets/graphics/fonts/terrarum-sans-bitmap/greek_polytonic_xyswap_variable.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/graphics/fonts/terrarum-sans-bitmap/kartuli_allcaps_variable.tga
LFS
Normal file
BIN
assets/graphics/fonts/terrarum-sans-bitmap/kartuli_allcaps_variable.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
BIN
assets/graphics/fonts/terrarum-sans-bitmap/richtext_furigana.tga
LFS
Normal file
BIN
assets/graphics/fonts/terrarum-sans-bitmap/richtext_furigana.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
package net.torvald.random
|
package net.torvald.random
|
||||||
|
|
||||||
|
import net.torvald.terrarum.serialise.toLittle
|
||||||
import net.torvald.terrarum.serialise.toLittleLong
|
import net.torvald.terrarum.serialise.toLittleLong
|
||||||
import org.apache.commons.codec.digest.DigestUtils
|
import org.apache.commons.codec.digest.DigestUtils
|
||||||
import java.util.Random
|
import java.util.Random
|
||||||
@@ -12,6 +13,11 @@ class HQRNG @JvmOverloads constructor(seed: Long = System.nanoTime()) : Random()
|
|||||||
private var s0: Long
|
private var s0: Long
|
||||||
private var s1: Long
|
private var s1: Long
|
||||||
|
|
||||||
|
constructor(s0: Long, s1: Long) : this() {
|
||||||
|
this.s0 = s0
|
||||||
|
this.s1 = s1
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (seed == 0L)
|
if (seed == 0L)
|
||||||
throw IllegalArgumentException("Invalid seed: cannot be zero")
|
throw IllegalArgumentException("Invalid seed: cannot be zero")
|
||||||
@@ -30,4 +36,11 @@ class HQRNG @JvmOverloads constructor(seed: Long = System.nanoTime()) : Random()
|
|||||||
s1 = x xor y xor (x ushr 17) xor (y ushr 26)
|
s1 = x xor y xor (x ushr 17) xor (y ushr 26)
|
||||||
return s1 + y
|
return s1 + y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun serialize() = s0.toLittle() + s1.toLittle()
|
||||||
|
|
||||||
|
fun reseed(s0: Long, s1: Long) {
|
||||||
|
this.s0 = s0
|
||||||
|
this.s1 = s1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
|
|
||||||
|
|
||||||
TextureRegionPack.Companion.setGlobalFlipY(true);
|
TextureRegionPack.Companion.setGlobalFlipY(true);
|
||||||
fontGame = new GameFontBase("assets/graphics/fonts/terrarum-sans-bitmap", false, true, Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
fontGame = new GameFontBase("assets/graphics/fonts/terrarum-sans-bitmap", false, true, Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ object Lang {
|
|||||||
return ret2.replace('>', Terrarum.joypadLabelStart).capitalize()
|
return ret2.replace('>', Terrarum.joypadLabelStart).capitalize()
|
||||||
|
|
||||||
return if (key.getEndTag().contains("bg"))
|
return if (key.getEndTag().contains("bg"))
|
||||||
"${AppLoader.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideNormal}"
|
"${AppLoader.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideDefault}"
|
||||||
else if (key.getEndTag().contains("sr"))
|
else if (key.getEndTag().contains("sr"))
|
||||||
"${AppLoader.fontGame.charsetOverrideSerbian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideNormal}"
|
"${AppLoader.fontGame.charsetOverrideSerbian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideDefault}"
|
||||||
else
|
else
|
||||||
ret2.capitalize()
|
ret2.capitalize()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,10 +176,10 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
val world: GameWorldExtension,
|
val world: GameWorldExtension,
|
||||||
val historicalFigureIDBucket: ArrayList<Int>,
|
val historicalFigureIDBucket: ArrayList<Int>,
|
||||||
val realGamePlayer: IngamePlayer,
|
val realGamePlayer: IngamePlayer,
|
||||||
val rogueseed: Long,
|
val rogueS0: Long,
|
||||||
val rogueiter: Int,
|
val rogueS1: Long,
|
||||||
val weatherseed: Long,
|
val weatherS0: Long,
|
||||||
val weatheriter: Int
|
val weatherS1: Long
|
||||||
)
|
)
|
||||||
|
|
||||||
data class NewWorldParameters(
|
data class NewWorldParameters(
|
||||||
@@ -209,8 +209,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
|
|
||||||
// set the randomisers right
|
// set the randomisers right
|
||||||
RoguelikeRandomiser.loadFromSave(gameSaveData.rogueseed, gameSaveData.rogueiter)
|
RoguelikeRandomiser.loadFromSave(gameSaveData.rogueS0, gameSaveData.rogueS1)
|
||||||
WeatherMixer.loadFromSave(gameSaveData.weatherseed, gameSaveData.weatheriter)
|
WeatherMixer.loadFromSave(gameSaveData.weatherS0, gameSaveData.weatherS1)
|
||||||
|
|
||||||
|
|
||||||
//initGame()
|
//initGame()
|
||||||
@@ -242,8 +242,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
historicalFigureIDBucket = ArrayList<Int>()
|
historicalFigureIDBucket = ArrayList<Int>()
|
||||||
|
|
||||||
|
|
||||||
RoguelikeRandomiser.seed = HQRNG().nextLong()
|
|
||||||
|
|
||||||
|
|
||||||
// add new player and put it to actorContainer
|
// add new player and put it to actorContainer
|
||||||
//playableActorDelegate = PlayableActorDelegate(PlayerBuilderSigrid())
|
//playableActorDelegate = PlayableActorDelegate(PlayerBuilderSigrid())
|
||||||
|
|||||||
@@ -1,29 +1,14 @@
|
|||||||
package net.torvald.terrarum.modulebasegame
|
package net.torvald.terrarum.modulebasegame
|
||||||
|
|
||||||
|
import net.torvald.random.HQRNG
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
internal interface RNGConsumer {
|
internal interface RNGConsumer {
|
||||||
|
|
||||||
val RNG: Random
|
val RNG: HQRNG
|
||||||
var seed: Long
|
|
||||||
var iterations: Int
|
|
||||||
|
|
||||||
fun loadFromSave(seed: Long, iterations: Int) {
|
fun loadFromSave(s0: Long, s1: Long) {
|
||||||
this.seed = seed
|
RNG.reseed(s0, s1)
|
||||||
this.iterations = iterations
|
|
||||||
|
|
||||||
repeat(iterations, { RNG.nextInt() })
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun incIterations() {
|
|
||||||
iterations++
|
|
||||||
|
|
||||||
if (iterations < 0) iterations = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getRandomLong(): Long {
|
|
||||||
iterations++
|
|
||||||
return RNG.nextLong()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
import net.torvald.terrarum.ui.UIItem
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param savefile TEVd file
|
||||||
|
*
|
||||||
|
* Created by minjaesong on 2018-09-15.
|
||||||
|
*/
|
||||||
|
class UIItemSavegameInfoCell(
|
||||||
|
parent: UICanvas,
|
||||||
|
savefile: File,
|
||||||
|
override val width: Int,
|
||||||
|
override var posX: Int,
|
||||||
|
override var posY: Int
|
||||||
|
) : UIItem(parent) {
|
||||||
|
|
||||||
|
override val height: Int = Terrarum.fontGame.lineHeight.toInt() * 2
|
||||||
|
|
||||||
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.Second
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.blendNormal
|
||||||
|
import net.torvald.terrarum.serialise.SavegameLedger
|
||||||
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
import net.torvald.terrarum.ui.UIItemList
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2018-09-15.
|
||||||
|
*/
|
||||||
|
class UITitleCharactersList : UICanvas() {
|
||||||
|
|
||||||
|
override var openCloseTime: Second = 0f
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private val moduleAreaHMargin = 48
|
||||||
|
|
||||||
|
private val moduleAreaBorder = 8
|
||||||
|
|
||||||
|
override var width = (Terrarum.WIDTH * 0.75).toInt() - moduleAreaHMargin
|
||||||
|
override var height = Terrarum.HEIGHT - moduleAreaHMargin * 2
|
||||||
|
|
||||||
|
private val moduleInfoCells = ArrayList<UIItemSavegameInfoCell>()
|
||||||
|
// build module list
|
||||||
|
init {
|
||||||
|
SavegameLedger.getSavefileList()?.forEachIndexed { index, file ->
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val mouduleArea = UIItemList<UIItemSavegameInfoCell>(
|
||||||
|
this,
|
||||||
|
moduleInfoCells,
|
||||||
|
(Terrarum.WIDTH * 0.25f).toInt(), moduleAreaHMargin,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
inactiveCol = Color.WHITE,
|
||||||
|
border = moduleAreaBorder
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
uiItems.add(mouduleArea)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateUI(delta: Float) {
|
||||||
|
mouduleArea.update(delta)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
blendNormal()
|
||||||
|
mouduleArea.render(batch, camera)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doOpening(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doClosing(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endOpening(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endClosing(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import net.torvald.terrarum.AppLoader
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
@@ -33,10 +34,14 @@ object UITitleRemoConYaml {
|
|||||||
|
|
||||||
val debugTools = """
|
val debugTools = """
|
||||||
- Development Tools $
|
- Development Tools $
|
||||||
- Building Maker
|
- Building Maker
|
||||||
|
- Start New Random Game
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
operator fun invoke() = parseYamlList(menus)
|
operator fun invoke() = if (AppLoader.IS_DEVELOPMENT_BUILD)
|
||||||
|
parseYamlList(menus + "\n" + debugTools)
|
||||||
|
else
|
||||||
|
parseYamlList(menus)
|
||||||
|
|
||||||
fun parseYamlList(yaml: String): QNDTreeNode<String> {
|
fun parseYamlList(yaml: String): QNDTreeNode<String> {
|
||||||
var currentIndentLevel = -1
|
var currentIndentLevel = -1
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ import java.util.*
|
|||||||
internal object WeatherMixer : RNGConsumer {
|
internal object WeatherMixer : RNGConsumer {
|
||||||
|
|
||||||
override val RNG = HQRNG()
|
override val RNG = HQRNG()
|
||||||
override var seed = 0L
|
|
||||||
override var iterations = 0
|
|
||||||
|
|
||||||
|
|
||||||
var weatherList: HashMap<String, ArrayList<BaseModularWeather>>
|
var weatherList: HashMap<String, ArrayList<BaseModularWeather>>
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ object RoguelikeRandomiser : RNGConsumer {
|
|||||||
val coloursTaken: ArrayList<Col4096> = ArrayList()
|
val coloursTaken: ArrayList<Col4096> = ArrayList()
|
||||||
|
|
||||||
override val RNG = HQRNG()
|
override val RNG = HQRNG()
|
||||||
override var seed = 0L
|
|
||||||
|
|
||||||
private val POTION_HEAL_TIER1 = 0x00
|
private val POTION_HEAL_TIER1 = 0x00
|
||||||
private val POTION_HEAL_TIRE2 = 0x01
|
private val POTION_HEAL_TIRE2 = 0x01
|
||||||
@@ -29,7 +28,6 @@ object RoguelikeRandomiser : RNGConsumer {
|
|||||||
|
|
||||||
private val POTION_BERSERK_TIER1 = 0x20
|
private val POTION_BERSERK_TIER1 = 0x20
|
||||||
|
|
||||||
override var iterations = 0
|
|
||||||
|
|
||||||
fun setupColours() {
|
fun setupColours() {
|
||||||
|
|
||||||
@@ -55,13 +53,11 @@ object RoguelikeRandomiser : RNGConsumer {
|
|||||||
|
|
||||||
fun shuffleArrayInt(ar: IntArray, rnd: Random) {
|
fun shuffleArrayInt(ar: IntArray, rnd: Random) {
|
||||||
for (i in ar.size - 1 downTo 0) {
|
for (i in ar.size - 1 downTo 0) {
|
||||||
val index = rnd.nextInt(i + 1);
|
val index = rnd.nextInt(i + 1)
|
||||||
// Simple swap
|
// Simple swap
|
||||||
val a = ar[index];
|
val a = ar[index]
|
||||||
ar[index] = ar[i];
|
ar[index] = ar[i]
|
||||||
ar[i] = a;
|
ar[i] = a
|
||||||
|
|
||||||
iterations++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.torvald.terrarum.modulecomputers.virtualcomputer.terminal
|
package net.torvald.terrarum.modulecomputers.virtualcomputer.terminal
|
||||||
|
|
||||||
import net.torvald.terrarumsansbitmap.slick2d.GameFontBase
|
|
||||||
import net.torvald.terrarum.blendMul
|
import net.torvald.terrarum.blendMul
|
||||||
import net.torvald.terrarum.blendNormal
|
import net.torvald.terrarum.blendNormal
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
@@ -19,10 +19,7 @@ internal object WriteMeta {
|
|||||||
val BYTE_NULL: Byte = 0
|
val BYTE_NULL: Byte = 0
|
||||||
|
|
||||||
val terraseed: Long = WorldGenerator.SEED
|
val terraseed: Long = WorldGenerator.SEED
|
||||||
val rogueseed: Long = RoguelikeRandomiser.seed
|
|
||||||
val rogueiter: Int = RoguelikeRandomiser.iterations
|
|
||||||
val weatherseed: Long = WeatherMixer.seed
|
|
||||||
val weatheriter: Int = WeatherMixer.iterations
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write save meta to specified directory. Returns false if something went wrong.
|
* Write save meta to specified directory. Returns false if something went wrong.
|
||||||
|
|||||||
BIN
tmp_wenquanyi.tga
LFS
Normal file
BIN
tmp_wenquanyi.tga
LFS
Normal file
Binary file not shown.
@@ -14,10 +14,10 @@ Ord Hex Description
|
|||||||
... 00 String terminator
|
... 00 String terminator
|
||||||
|
|
||||||
... Terrain seed (8 bytes)
|
... Terrain seed (8 bytes)
|
||||||
... Randomiser seed (8 bytes)
|
... Randomiser s0 (8 bytes)
|
||||||
... Randomiser iterations (4 bytes)
|
... Randomiser s1 (4 bytes)
|
||||||
... Weather seed (8 bytes)
|
... Weather s0 (8 bytes)
|
||||||
... Weather iterations (4 bytes)
|
... Weather s1 (4 bytes)
|
||||||
|
|
||||||
... SHA-256 hash of worldinfo1 when not compressed (32 bytes)
|
... SHA-256 hash of worldinfo1 when not compressed (32 bytes)
|
||||||
... SHA-256 hash of worldinfo2 when not compressed (32 bytes)
|
... SHA-256 hash of worldinfo2 when not compressed (32 bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user