mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +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
|
||||
|
||||
import net.torvald.terrarum.serialise.toLittle
|
||||
import net.torvald.terrarum.serialise.toLittleLong
|
||||
import org.apache.commons.codec.digest.DigestUtils
|
||||
import java.util.Random
|
||||
@@ -12,6 +13,11 @@ class HQRNG @JvmOverloads constructor(seed: Long = System.nanoTime()) : Random()
|
||||
private var s0: Long
|
||||
private var s1: Long
|
||||
|
||||
constructor(s0: Long, s1: Long) : this() {
|
||||
this.s0 = s0
|
||||
this.s1 = s1
|
||||
}
|
||||
|
||||
init {
|
||||
if (seed == 0L)
|
||||
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)
|
||||
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);
|
||||
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
|
||||
|
||||
@@ -121,9 +121,9 @@ object Lang {
|
||||
return ret2.replace('>', Terrarum.joypadLabelStart).capitalize()
|
||||
|
||||
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"))
|
||||
"${AppLoader.fontGame.charsetOverrideSerbian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideNormal}"
|
||||
"${AppLoader.fontGame.charsetOverrideSerbian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideDefault}"
|
||||
else
|
||||
ret2.capitalize()
|
||||
}
|
||||
|
||||
@@ -176,10 +176,10 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
val world: GameWorldExtension,
|
||||
val historicalFigureIDBucket: ArrayList<Int>,
|
||||
val realGamePlayer: IngamePlayer,
|
||||
val rogueseed: Long,
|
||||
val rogueiter: Int,
|
||||
val weatherseed: Long,
|
||||
val weatheriter: Int
|
||||
val rogueS0: Long,
|
||||
val rogueS1: Long,
|
||||
val weatherS0: Long,
|
||||
val weatherS1: Long
|
||||
)
|
||||
|
||||
data class NewWorldParameters(
|
||||
@@ -209,8 +209,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
// set the randomisers right
|
||||
RoguelikeRandomiser.loadFromSave(gameSaveData.rogueseed, gameSaveData.rogueiter)
|
||||
WeatherMixer.loadFromSave(gameSaveData.weatherseed, gameSaveData.weatheriter)
|
||||
RoguelikeRandomiser.loadFromSave(gameSaveData.rogueS0, gameSaveData.rogueS1)
|
||||
WeatherMixer.loadFromSave(gameSaveData.weatherS0, gameSaveData.weatherS1)
|
||||
|
||||
|
||||
//initGame()
|
||||
@@ -242,8 +242,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
historicalFigureIDBucket = ArrayList<Int>()
|
||||
|
||||
|
||||
RoguelikeRandomiser.seed = HQRNG().nextLong()
|
||||
|
||||
|
||||
// add new player and put it to actorContainer
|
||||
//playableActorDelegate = PlayableActorDelegate(PlayerBuilderSigrid())
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
package net.torvald.terrarum.modulebasegame
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import java.util.*
|
||||
|
||||
internal interface RNGConsumer {
|
||||
|
||||
val RNG: Random
|
||||
var seed: Long
|
||||
var iterations: Int
|
||||
val RNG: HQRNG
|
||||
|
||||
fun loadFromSave(seed: Long, iterations: Int) {
|
||||
this.seed = seed
|
||||
this.iterations = iterations
|
||||
|
||||
repeat(iterations, { RNG.nextInt() })
|
||||
}
|
||||
|
||||
private fun incIterations() {
|
||||
iterations++
|
||||
|
||||
if (iterations < 0) iterations = 0
|
||||
}
|
||||
|
||||
fun getRandomLong(): Long {
|
||||
iterations++
|
||||
return RNG.nextLong()
|
||||
fun loadFromSave(s0: Long, s1: Long) {
|
||||
RNG.reseed(s0, s1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import java.util.*
|
||||
|
||||
|
||||
@@ -33,10 +34,14 @@ object UITitleRemoConYaml {
|
||||
|
||||
val debugTools = """
|
||||
- Development Tools $
|
||||
- Building Maker
|
||||
- Building Maker
|
||||
- Start New Random Game
|
||||
""".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> {
|
||||
var currentIndentLevel = -1
|
||||
|
||||
@@ -35,8 +35,6 @@ import java.util.*
|
||||
internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
override val RNG = HQRNG()
|
||||
override var seed = 0L
|
||||
override var iterations = 0
|
||||
|
||||
|
||||
var weatherList: HashMap<String, ArrayList<BaseModularWeather>>
|
||||
|
||||
@@ -20,7 +20,6 @@ object RoguelikeRandomiser : RNGConsumer {
|
||||
val coloursTaken: ArrayList<Col4096> = ArrayList()
|
||||
|
||||
override val RNG = HQRNG()
|
||||
override var seed = 0L
|
||||
|
||||
private val POTION_HEAL_TIER1 = 0x00
|
||||
private val POTION_HEAL_TIRE2 = 0x01
|
||||
@@ -29,7 +28,6 @@ object RoguelikeRandomiser : RNGConsumer {
|
||||
|
||||
private val POTION_BERSERK_TIER1 = 0x20
|
||||
|
||||
override var iterations = 0
|
||||
|
||||
fun setupColours() {
|
||||
|
||||
@@ -55,13 +53,11 @@ object RoguelikeRandomiser : RNGConsumer {
|
||||
|
||||
fun shuffleArrayInt(ar: IntArray, rnd: Random) {
|
||||
for (i in ar.size - 1 downTo 0) {
|
||||
val index = rnd.nextInt(i + 1);
|
||||
val index = rnd.nextInt(i + 1)
|
||||
// Simple swap
|
||||
val a = ar[index];
|
||||
ar[index] = ar[i];
|
||||
ar[i] = a;
|
||||
|
||||
iterations++
|
||||
val a = ar[index]
|
||||
ar[index] = ar[i]
|
||||
ar[i] = a
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.torvald.terrarum.modulecomputers.virtualcomputer.terminal
|
||||
|
||||
import net.torvald.terrarumsansbitmap.slick2d.GameFontBase
|
||||
import net.torvald.terrarum.blendMul
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import java.util.*
|
||||
|
||||
@@ -19,10 +19,7 @@ internal object WriteMeta {
|
||||
val BYTE_NULL: Byte = 0
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
... Terrain seed (8 bytes)
|
||||
... Randomiser seed (8 bytes)
|
||||
... Randomiser iterations (4 bytes)
|
||||
... Weather seed (8 bytes)
|
||||
... Weather iterations (4 bytes)
|
||||
... Randomiser s0 (8 bytes)
|
||||
... Randomiser s1 (4 bytes)
|
||||
... Weather s0 (8 bytes)
|
||||
... Weather s1 (4 bytes)
|
||||
|
||||
... SHA-256 hash of worldinfo1 when not compressed (32 bytes)
|
||||
... SHA-256 hash of worldinfo2 when not compressed (32 bytes)
|
||||
|
||||
Reference in New Issue
Block a user