From 715e0cfd1c3aecbcabe7e4c60d04828e97a906fc Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Tue, 28 Oct 2025 07:15:21 -0700 Subject: [PATCH] Fix records not displaying main character correctly --- .../emu/nebula/game/tower/StarTowerBuild.java | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/emu/nebula/game/tower/StarTowerBuild.java b/src/main/java/emu/nebula/game/tower/StarTowerBuild.java index e01302f..8b06cb5 100644 --- a/src/main/java/emu/nebula/game/tower/StarTowerBuild.java +++ b/src/main/java/emu/nebula/game/tower/StarTowerBuild.java @@ -5,6 +5,7 @@ import dev.morphia.annotations.Id; import dev.morphia.annotations.Indexed; import emu.nebula.data.GameData; import emu.nebula.database.GameDatabaseObject; +import emu.nebula.proto.Public.ItemTpl; import emu.nebula.proto.PublicStarTower.BuildPotential; import emu.nebula.proto.PublicStarTower.StarTowerBuildBrief; import emu.nebula.proto.PublicStarTower.StarTowerBuildDetail; @@ -28,9 +29,10 @@ public class StarTowerBuild implements GameDatabaseObject { private boolean preference; private int score; - private Int2IntMap chars; + private int[] charIds; private int[] discIds; + private Int2IntMap charPots; private Int2IntMap potentials; private Int2IntMap subNoteSkills; @@ -43,21 +45,22 @@ public class StarTowerBuild implements GameDatabaseObject { this.uid = Snowflake.newUid(); this.playerUid = instance.getPlayer().getUid(); this.name = ""; + this.charPots = new Int2IntOpenHashMap(); this.potentials = new Int2IntOpenHashMap(); this.subNoteSkills = new Int2IntOpenHashMap(); + // Characters + this.charIds = instance.getDiscs().stream() + .filter(d -> d.getId() > 0) + .mapToInt(d -> d.getId()) + .toArray(); + // Discs this.discIds = instance.getDiscs().stream() .filter(d -> d.getId() > 0) .mapToInt(d -> d.getId()) .toArray(); - // Characters - this.chars = new Int2IntOpenHashMap(); - - instance.getChars().stream() - .forEach(c -> this.getChars().put(c.getId(), 0)); - // Add potentials for (int id : instance.getPotentials()) { // Add to potential map @@ -67,7 +70,7 @@ public class StarTowerBuild implements GameDatabaseObject { var potentialData = GameData.getPotentialDataTable().get(id); if (potentialData != null) { int charId = potentialData.getCharId(); - this.getChars().put(charId, this.getChars().get(charId) + 1); + this.getCharPots().put(charId, this.getCharPots().get(charId) + 1); } } } @@ -92,10 +95,10 @@ public class StarTowerBuild implements GameDatabaseObject { .addAllDiscIds(this.getDiscIds()); // Add characters - for (var character : this.getChars().int2IntEntrySet()) { + for (int charId : this.getCharIds()) { var charProto = TowerBuildChar.newInstance() - .setCharId(character.getIntKey()) - .setPotentialCnt(character.getIntValue()); + .setCharId(charId) + .setPotentialCnt(this.getCharPots().get(charId)); proto.addChars(charProto); } @@ -106,6 +109,7 @@ public class StarTowerBuild implements GameDatabaseObject { public StarTowerBuildDetail toDetailProto() { var proto = StarTowerBuildDetail.newInstance(); + // Potentials for (var entry : this.getPotentials().int2IntEntrySet()) { var potential = BuildPotential.newInstance() .setPotentialId(entry.getIntKey()) @@ -114,6 +118,15 @@ public class StarTowerBuild implements GameDatabaseObject { proto.getMutablePotentials().add(potential); } + // Sub note skills + for (var entry : this.getSubNoteSkills().int2IntEntrySet()) { + var skill = ItemTpl.newInstance() + .setTid(entry.getIntKey()) + .setQty(entry.getIntValue()); + + proto.addSubNoteSkills(skill); + } + return proto; } }