diff --git a/data/minigame/tzhaar_fight_pits/tzhaar_fight_pit.npcs.toml b/data/minigame/tzhaar_fight_pits/tzhaar_fight_pit.npcs.toml index f59d54a61a..ab0b2f4988 100644 --- a/data/minigame/tzhaar_fight_pits/tzhaar_fight_pit.npcs.toml +++ b/data/minigame/tzhaar_fight_pits/tzhaar_fight_pit.npcs.toml @@ -14,7 +14,7 @@ categories = ["tz_haar"] examine = "Some kind of bat..." [tz_kih_fight_pits_2] -clone = "tz_kih" +clone = "tz_kih_fight_pits" id = 2628 [tz_kek_fight_pits] diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt index 1219eae853..4fec113429 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/NPCDefinitions.kt @@ -37,8 +37,10 @@ object NPCDefinitions : DefinitionsDecoder { ) { timedLoad("npc extra") { val ids = Object2IntOpenHashMap() + val refs = Object2IntOpenHashMap() ids.defaultReturnValue(-1) for (path in paths) { + refs.clear() Config.fileReader(path, 150) { while (nextSection()) { val stringId = section() @@ -48,8 +50,8 @@ object NPCDefinitions : DefinitionsDecoder { when (val key = key()) { "clone" -> { val name = string() - val npc = ids.getInt(name) - require(npc >= 0) { "Cannot find npc id to clone '$name'" } + val npc = refs.getInt(name) + require(npc >= 0) { "Cannot find npc to clone with id '$name' in ${path}. Make sure it's in the same file." } val definition = definitions[npc] extras.putAll(definition.extras ?: continue) } @@ -80,6 +82,7 @@ object NPCDefinitions : DefinitionsDecoder { } } require(!ids.containsKey(stringId)) { "Duplicate npc id found '$stringId' at $path." } + refs[stringId] = id ids[stringId] = id definitions[id].stringId = stringId if (extras.isNotEmpty()) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt index 3c39e6588a..c9bbf295d6 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/data/definition/ObjectDefinitions.kt @@ -35,8 +35,10 @@ object ObjectDefinitions : DefinitionsDecoder { fun load(paths: List): ObjectDefinitions { timedLoad("object extra") { val ids = Object2IntOpenHashMap() + val refs = Object2IntOpenHashMap() ids.defaultReturnValue(-1) for (path in paths) { + refs.clear() Config.fileReader(path) { while (nextSection()) { val stringId = section() @@ -50,8 +52,8 @@ object ObjectDefinitions : DefinitionsDecoder { "mining" -> extras[key] = Rock(this) "clone" -> { val name = string() - val obj = ids.getInt(name) - require(obj >= 0) { "Cannot find object id to clone '$name'" } + val obj = refs.getInt(name) + require(obj >= 0) { "Cannot find object to clone with id '$name' in ${path}. Make sure it's in the same file." } val definition = definitions[obj] extras.putAll(definition.extras ?: continue) } @@ -67,6 +69,7 @@ object ObjectDefinitions : DefinitionsDecoder { } require(!ids.containsKey(stringId)) { "Duplicate object id found '$stringId' at $path." } ids[stringId] = id + refs[stringId] = id definitions[id].stringId = stringId if (extras.isNotEmpty()) { definitions[id].extras = extras