Skip to content

Commit

Permalink
Replace Main.name with server.name setting
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed Jan 10, 2025
1 parent 84585c5 commit cb73da6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
13 changes: 5 additions & 8 deletions game/src/main/kotlin/world/gregs/voidps/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import world.gregs.voidps.network.GameServer
import world.gregs.voidps.network.LoginServer
import world.gregs.voidps.network.login.protocol.decoders
import world.gregs.voidps.script.loadScripts
import java.io.File
import java.util.*
import kotlin.coroutines.CoroutineContext

Expand All @@ -34,19 +33,17 @@ import kotlin.coroutines.CoroutineContext
object Main : CoroutineScope {

override val coroutineContext: CoroutineContext = Contexts.Game
lateinit var name: String
private val logger = InlineLogger()

@OptIn(ExperimentalUnsignedTypes::class)
@JvmStatic
fun main(args: Array<String>) {
val startTime = System.currentTimeMillis()
val properties = settings()
name = Settings["server.name"]
val settings = settings()

// File server
val cache = timed("cache") { Cache.load(properties) }
val server = GameServer.load(cache, properties)
val cache = timed("cache") { Cache.load(settings) }
val server = GameServer.load(cache, settings)
val job = server.start(Settings["network.port"].toInt())

// Content
Expand All @@ -60,15 +57,15 @@ object Main : CoroutineScope {
// Login server
val decoders = decoders(get<Huffman>())
val accountLoader: PlayerAccountLoader = get()
val loginServer = LoginServer.load(properties, decoders, accountLoader)
val loginServer = LoginServer.load(settings, decoders, accountLoader)

// Game world
val stages = getTickStages()
World.start()
val scope = CoroutineScope(Contexts.Game)
val engine = GameLoop(stages).start(scope)
server.loginServer = loginServer
logger.info { "$name loaded in ${System.currentTimeMillis() - startTime}ms" }
logger.info { "${Settings["server.name"]} loaded in ${System.currentTimeMillis() - startTime}ms" }
runBlocking {
try {
job.join()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package world.gregs.voidps.world.activity.achievement
import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.client.sendScript
import world.gregs.voidps.engine.client.variable.BitwiseValues
import world.gregs.voidps.engine.data.Settings
import world.gregs.voidps.engine.data.definition.VariableDefinitions
import world.gregs.voidps.Main.name
import world.gregs.voidps.engine.entity.character.npc.NPCOption
import world.gregs.voidps.engine.entity.character.npc.npcOperate
import world.gregs.voidps.engine.entity.character.player.Player
Expand All @@ -25,7 +25,7 @@ import world.gregs.voidps.world.interact.dialogue.type.player

npcOperate("Talk-to", "explorer_jack") {
if (player["introducing_explorer_jack_task", "uncompleted"] == "uncompleted") {
npc<Talk>("Ah! Welcome to ${name}, lad. My name's Explorer jack. I'm an explorer by trade, and I'm one of the Taskmasters around these parts")
npc<Talk>("Ah! Welcome to ${Settings["server.name"]}, lad. My name's Explorer jack. I'm an explorer by trade, and I'm one of the Taskmasters around these parts")
player<Quiz>("Taskmaster? What Tasks are you Master of?")
whatIsTaskSystem()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package world.gregs.voidps.world.interact.entity.npc

import world.gregs.voidps.Main.name
import world.gregs.voidps.engine.client.ui.dialogue.talkWith
import world.gregs.voidps.engine.client.ui.open
import world.gregs.voidps.engine.data.Settings
import world.gregs.voidps.engine.entity.character.CharacterContext
import world.gregs.voidps.engine.entity.character.npc.NPCs
import world.gregs.voidps.engine.entity.character.npc.npcApproach
Expand Down Expand Up @@ -46,7 +46,7 @@ suspend fun CharacterContext.menu() {
option("I'd like to see my collection box.", block = { player.open("collection_box") })
option("I'd like to see my Returned Items box.", block = { player.open("returned_items") })
option("What is this place?") {
npc<Talk>("This is a branch of the Bank of $name. We have branches in many towns.")
npc<Talk>("This is a branch of the Bank of ${Settings["server.name"]}. We have branches in many towns.")
choice {
option("And what do you do?") {
npc<Talk>("We will look after your items and money for you. Leave your valuables with us if you want to keep them safe.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.varrock
import world.gregs.voidps.Main

Check warning on line 3 in game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.client.ui.interact.itemOnNPCApproach
import world.gregs.voidps.engine.data.Settings
import world.gregs.voidps.engine.entity.character.forceChat
import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext
import world.gregs.voidps.engine.entity.character.npc.npcApproach
Expand Down Expand Up @@ -38,7 +39,7 @@ npcApproach("Talk-to", "bartender_blue_moon_inn") {
choice {
option<Talk>("Oh ah well...")
option<Quiz>("Game? What are you talking about?") {
npc<Angry>("This world around us... is an online game... called ${Main.name}.")
npc<Angry>("This world around us... is an online game... called ${Settings["server.name"]}.")
player<Quiz>("Nope, still don't understand what you are talking about. What does 'online' mean?")
npc<Angry>("It's a sort of connection between magic boxes across the world, big boxes on people's desktops and little ones people can carry. They can talk to each other to play games.")
player<Angry>("I give up. You're obviously completely mad!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ abstract class WorldTest : KoinTest {

@BeforeAll
fun beforeAll() {
Main.name = "test"
properties = Properties()
properties.load(WorldTest::class.java.getResourceAsStream("/test.properties")!!)
settings = Settings.load(properties)
Expand Down

0 comments on commit cb73da6

Please sign in to comment.