130 lines
4.0 KiB
Kotlin
130 lines
4.0 KiB
Kotlin
package ru.dbotthepony.kstarbound
|
|
|
|
import kotlinx.coroutines.future.future
|
|
import org.apache.logging.log4j.LogManager
|
|
import org.lwjgl.Version
|
|
import ru.dbotthepony.kommons.io.ByteKey
|
|
import ru.dbotthepony.kommons.util.AABBi
|
|
import ru.dbotthepony.kommons.vector.Vector2d
|
|
import ru.dbotthepony.kommons.vector.Vector2i
|
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
|
import ru.dbotthepony.kstarbound.io.BTreeDB5
|
|
import ru.dbotthepony.kstarbound.server.IntegratedStarboundServer
|
|
import ru.dbotthepony.kstarbound.server.world.LegacyWorldStorage
|
|
import ru.dbotthepony.kstarbound.server.world.ServerUniverse
|
|
import ru.dbotthepony.kstarbound.server.world.ServerWorld
|
|
import ru.dbotthepony.kstarbound.util.random.staticRandomDouble
|
|
import ru.dbotthepony.kstarbound.world.WorldGeometry
|
|
import java.io.BufferedInputStream
|
|
import java.io.ByteArrayInputStream
|
|
import java.io.DataInputStream
|
|
import java.io.File
|
|
import java.net.InetSocketAddress
|
|
import java.util.zip.Inflater
|
|
import java.util.zip.InflaterInputStream
|
|
|
|
private val LOGGER = LogManager.getLogger()
|
|
|
|
fun main() {
|
|
Starbound.addPakPath(File("J:\\Steam\\steamapps\\common\\Starbound\\assets\\packed.pak"))
|
|
Starbound.doBootstrap()
|
|
|
|
if (false) {
|
|
val data = ServerUniverse()
|
|
|
|
val t = System.nanoTime()
|
|
val result = Starbound.COROUTINES.future {
|
|
val systems = data.scanSystems(AABBi(Vector2i(-50, -50), Vector2i(50, 50)), setOf("whitestar"))
|
|
|
|
for (system in systems) {
|
|
for (children in data.children(system)) {
|
|
if (children.isPlanet) {
|
|
val params = data.parameters(children)!!
|
|
|
|
if (params.visitableParameters != null) {
|
|
//val write = params.visitableParameters!!.toJson(false)
|
|
//println(write)
|
|
//println(Starbound.gson.fromJson(write, VisitableWorldParameters::class.java))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
systems
|
|
}.get()
|
|
|
|
println(System.nanoTime() - t)
|
|
|
|
data.close()
|
|
|
|
return
|
|
}
|
|
|
|
/*val db0 = BTreeDB5(File("F:\\SteamLibrary\\steamapps\\common\\Starbound - Unstable\\storage\\universe\\389760395_938904237_-238610574_5.world"))
|
|
val db2 = BTreeDB6.create(File("testdb.bdb"), sync = false)
|
|
|
|
for (key in db0.findAllKeys()) {
|
|
db2.write(key, db0.read(key).get())
|
|
}
|
|
|
|
db2.close()*/
|
|
|
|
LOGGER.info("Running LWJGL ${Version.getVersion()}")
|
|
|
|
//Thread.sleep(6_000L)
|
|
|
|
//val db = BTreeDB6(File("testdb.bdb"))
|
|
val db = BTreeDB5(File("F:\\SteamLibrary\\steamapps\\common\\Starbound - Unstable\\storage\\universe\\389760395_938904237_-238610574_5.world"))
|
|
//val db = BTreeDB(File("world.world"))
|
|
|
|
val meta = DataInputStream(BufferedInputStream(InflaterInputStream(ByteArrayInputStream(db.read(ByteKey(0, 0, 0, 0, 0)).get()), Inflater())))
|
|
|
|
println(meta.readInt())
|
|
println(meta.readInt())
|
|
|
|
// println(VersionedJson(meta))
|
|
|
|
val client = StarboundClient.create().get()
|
|
//val client2 = StarboundClient.create().get()
|
|
//val world = ServerWorld.load(server, LegacyWorldStorage.file(db)).get()
|
|
|
|
//Starbound.addFilePath(File("./unpacked_assets/"))
|
|
|
|
/*for (folder in File("J:\\Steam\\steamapps\\workshop\\content\\211820").list()!!) {
|
|
val f = File("J:\\Steam\\steamapps\\workshop\\content\\211820\\$folder\\contents.pak")
|
|
|
|
if (f.exists()) {
|
|
Starbound.addPakPath(f)
|
|
}
|
|
}*/
|
|
|
|
//Starbound.addPakPath(File("packed.pak"))
|
|
|
|
Starbound.initializeGame()
|
|
|
|
Starbound.mailboxInitialized.submit {
|
|
val server = IntegratedStarboundServer(File("./"))
|
|
val world = ServerWorld.load(server, LegacyWorldStorage.file(db)).get()
|
|
//world.thread.start()
|
|
|
|
//ply = PlayerEntity(client.world!!)
|
|
|
|
//ply!!.position = Vector2d(225.0, 680.0)
|
|
//ply!!.spawn()
|
|
|
|
//client.world!!.parallax = Starbound.parallaxAccess["garden"]
|
|
|
|
//client.connectToLocalServer(server.channels.createLocalChannel())
|
|
//client.connectToRemoteServer(InetSocketAddress("127.0.0.1", 21025))
|
|
//client2.connectToLocalServer(server.channels.createLocalChannel(), UUID.randomUUID())
|
|
server.channels.createChannel(InetSocketAddress(21060))
|
|
}
|
|
|
|
//ent.position += Vector2d(y = 14.0, x = -10.0)
|
|
client.camera.pos = Vector2d(238.0, 685.0)
|
|
//client2.camera.pos = Vector2d(238.0, 685.0)
|
|
//client.camera.pos = Vector2f(0f, 0f)
|
|
|
|
//ent.spawn()
|
|
}
|