mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
still tryin to fix shits
This commit is contained in:
@@ -283,7 +283,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
// Terrarum.itemCodex.loadFromSave(codices.item)
|
||||
// Terrarum.apocryphas = HashMap(codices.apocryphas)
|
||||
|
||||
savegameNickname = codices.disk.getDiskName(Common.CHARSET)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,9 +309,17 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
// overwrite player's props with world's for multiplayer
|
||||
// see comments on IngamePlayer.unauthorisedPlayerProps to know why this is necessary.
|
||||
codices.player.backupPlayerProps(isMultiplayer) // backup first!
|
||||
printdbg(this, "postInitForLoadFromSave")
|
||||
printdbg(this, "Player UUID: ${codices.player.uuid}")
|
||||
printdbg(this, world.playersLastStatus.keys)
|
||||
printdbg(this, world.playersLastStatus[codices.player.uuid])
|
||||
world.playersLastStatus[codices.player.uuid].let { // regardless of the null-ness, we still keep the backup, which WriteActor looks for it
|
||||
// if the world has some saved values, use them
|
||||
if (it != null) {
|
||||
|
||||
printdbg(this, "Found LastStatus mapping for Player ${codices.player.uuid}")
|
||||
printdbg(this, "Changing XY Position (${codices.player.hitbox.canonicalX}, ${codices.player.hitbox.canonicalY}) -> ${it.physics.position}")
|
||||
|
||||
codices.player.setPosition(it.physics.position)
|
||||
if (isMultiplayer) {
|
||||
codices.player.actorValue = it.actorValue!!
|
||||
@@ -321,6 +328,9 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
// if not, move player to the spawn point
|
||||
else {
|
||||
printdbg(this, "No mapping found")
|
||||
printdbg(this, "Changing XY Position (${codices.player.hitbox.canonicalX},${codices.player.hitbox.canonicalY}) -> (${world.spawnX * TILE_SIZED}, ${world.spawnY * TILE_SIZED})")
|
||||
|
||||
codices.player.setPosition(world.spawnX * TILE_SIZED, world.spawnY * TILE_SIZED)
|
||||
}
|
||||
}
|
||||
@@ -337,8 +347,11 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
// go to spawn position
|
||||
printdbg(this, "World Spawn position: (${world.spawnX}, ${world.spawnY})")
|
||||
|
||||
worldSavefileName = "$savegameNickname-${world.worldIndex}"
|
||||
playerSavefileName = (actorGamer.actorValue.getAsString(AVKey.NAME) ?: "Player") + "-${actorGamer.uuid}"
|
||||
// worldSavefileName = "$savegameNickname-${world.worldIndex}"
|
||||
// playerSavefileName = (actorGamer.actorValue.getAsString(AVKey.NAME) ?: "Player") + "-${actorGamer.uuid}"
|
||||
|
||||
worldSavefileName = LoadSavegame.getWorldSavefileName(savegameNickname, world)
|
||||
playerSavefileName = LoadSavegame.getPlayerSavefileName(actorGamer)
|
||||
|
||||
worldDisk = VDUtil.createNewDisk(
|
||||
1L shl 60,
|
||||
|
||||
@@ -4,7 +4,9 @@ import com.badlogic.gdx.graphics.Pixmap
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameworld.BlockLayer
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.ChunkLoadingLoadScreen
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
@@ -122,6 +124,10 @@ object WriteSavegame {
|
||||
*/
|
||||
object LoadSavegame {
|
||||
|
||||
fun getSavegameNickname(worldDisk: SimpleFileSystem) = worldDisk.getDiskName(Common.CHARSET)
|
||||
fun getWorldSavefileName(nick: String, world: GameWorld) = "$nick-${world.worldIndex}"
|
||||
fun getPlayerSavefileName(player: IngamePlayer) = (player.actorValue.getAsString(AVKey.NAME) ?: "Player") + "-${player.uuid}"
|
||||
|
||||
fun getFileBytes(disk: SimpleFileSystem, id: Long): ByteArray64 = disk.getFile(id)!!.bytes
|
||||
fun getFileReader(disk: SimpleFileSystem, id: Long): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET)
|
||||
|
||||
@@ -142,7 +148,11 @@ object LoadSavegame {
|
||||
world.layerWall = BlockLayer(world.width, world.height)
|
||||
|
||||
newIngame.world = world // must be set before the loadscreen, otherwise the loadscreen will try to read from the NullWorld which is already destroyed
|
||||
|
||||
newIngame.worldDisk = worldDisk.sync()
|
||||
newIngame.playerDisk = playerDisk.sync()
|
||||
newIngame.savegameNickname = getSavegameNickname(worldDisk)
|
||||
newIngame.worldSavefileName = getWorldSavefileName(newIngame.savegameNickname, world)
|
||||
newIngame.playerSavefileName = getPlayerSavefileName(player)
|
||||
|
||||
|
||||
val loadJob = { it: LoadScreenBase ->
|
||||
|
||||
@@ -426,7 +426,11 @@ removefile:
|
||||
*/
|
||||
fun sync(): VirtualDisk {
|
||||
// rebuild VirtualDisk out of this and use it to write out
|
||||
return VDUtil.readDiskArchive(diskFile, Level.INFO)
|
||||
val disk = VDUtil.readDiskArchive(diskFile, Level.INFO)
|
||||
VDUtil.dumpToRealMachine(disk, diskFile)
|
||||
entryToOffsetTable.clear()
|
||||
rebuild()
|
||||
return disk
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,10 @@ class HashedFluidType: HashMap<BlockAddress, FluidType>()
|
||||
class HashedWirings: HashMap<BlockAddress, GameWorld.WiringNode>()
|
||||
class HashedWiringGraph: HashMap<BlockAddress, WiringGraphMap>()
|
||||
class MetaModuleCSVPair: HashMap<String, ZipCodedStr>()
|
||||
class PlayersLastStatus: HashMap<UUID, PlayerLastStatus>()
|
||||
class PlayersLastStatus: HashMap<String, PlayerLastStatus>() {
|
||||
operator fun get(uuid: UUID) = this[uuid.toString()]
|
||||
operator fun set(uuid: UUID, value: PlayerLastStatus) = this.set(uuid.toString(), value)
|
||||
}
|
||||
class PlayerLastStatus() {
|
||||
var physics = PhysicalStatus(); private set // mandatory
|
||||
var inventory: ActorInventory? = null; private set // optional (multiplayer only)
|
||||
|
||||
Reference in New Issue
Block a user