fix(codegen): put the region in the dialog id instead of always hoenn (#100)

This commit is contained in:
Fiereu authored and GitHub committed 2026-08-07 15:12:10 +02:00
1 parent 67e3b14a1d
commit 085407ccf1
2 files changed
+16 -5

No files matched your search

@@ -10,8 +10,9 @@ package ${pkg}
import de.fiereu.openmmo.common.dialog.DialogLine import de.fiereu.openmmo.common.dialog.DialogLine
/** /**
* Overworld dialog lines for this location, generated from the decomp text. Each [textId] is * Overworld dialog lines for this location, generated from the decomp text. Each [textId] is the
* 0x10000000 or the string's retail ROM offset, ready to send in a DialogAction packet. * region id shifted into the top nibble or the string's retail ROM offset, ready to send in a
* DialogAction packet.
*/ */
enum class ${enumName}(override val textId: Int) : DialogLine { enum class ${enumName}(override val textId: Int) : DialogLine {
@for(DialogEntry e : entries) @for(DialogEntry e : entries)
@@ -2,10 +2,19 @@
package de.fiereu.openmmo.codegen.dialog package de.fiereu.openmmo.codegen.dialog
import de.fiereu.openmmo.common.enums.Region
import java.io.File import java.io.File
// GBA dialog ids carry the retail ROM file offset in the low bits with the mode-1 resolver on top. // A GBA dialog id is the retail ROM file offset with the region on top, which is how the client
private const val GBA_MODE = 0x10000000 // knows the ROM to resolve it in. Captured Kanto ids carry 0 there and Hoenn ids carry 1.
private const val REGION_SHIFT = 28
private fun regionMode(region: String): Int {
val known =
Region.entries.find { it.name.equals(region, ignoreCase = true) }
?: error("unknown region '$region', its dialog ids cannot be built")
return known.wireValue.toInt() shl REGION_SHIFT
}
fun main(args: Array<String>) { fun main(args: Array<String>) {
require(args.size >= 5) { require(args.size >= 5) {
@@ -48,6 +57,7 @@ private fun generateRegion(
} }
val charmap = Charmap.load(File(decompDir, "charmap.txt")) val charmap = Charmap.load(File(decompDir, "charmap.txt"))
val mode = regionMode(region)
var unencodable = 0 var unencodable = 0
var notFound = 0 var notFound = 0
@@ -63,7 +73,7 @@ private fun generateRegion(
notFound++ notFound++
return@mapNotNull null return@mapNotNull null
} }
DialogLine(t.label, GBA_MODE or offset, RenderUtil.preview(t.content)) DialogLine(t.label, mode or offset, RenderUtil.preview(t.content))
} }
println( println(