From f58ba82f17bf6eef4eddcf41d65aa048f2d20618 Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Tue, 6 Oct 2026 22:04:24 -0700 Subject: [PATCH] Real fix for main story chapter 9 --- .../nebula/game/story/StoryChoiceInfo.java | 14 ++--- .../emu/nebula/game/story/StoryManager.java | 12 ---- .../emu/nebula/game/story/StoryOptionLog.java | 62 +++++++++++++------ 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/main/java/emu/nebula/game/story/StoryChoiceInfo.java b/src/main/java/emu/nebula/game/story/StoryChoiceInfo.java index 86082ad..2e5c7f2 100644 --- a/src/main/java/emu/nebula/game/story/StoryChoiceInfo.java +++ b/src/main/java/emu/nebula/game/story/StoryChoiceInfo.java @@ -1,7 +1,6 @@ package emu.nebula.game.story; import dev.morphia.annotations.Entity; -import emu.nebula.proto.Public.StoryChoice; import lombok.Getter; @Getter @@ -19,14 +18,9 @@ public class StoryChoiceInfo { this.group = group; this.value = value; } - - // Proto - - public StoryChoice toProto() { - var proto = StoryChoice.newInstance() - .setGroup(this.getGroup()) - .setValue(this.getValue()); - - return proto; + + public StoryChoiceInfo setValue(int value) { + this.value = value; + return this; } } diff --git a/src/main/java/emu/nebula/game/story/StoryManager.java b/src/main/java/emu/nebula/game/story/StoryManager.java index 58f24b7..a99a7ce 100644 --- a/src/main/java/emu/nebula/game/story/StoryManager.java +++ b/src/main/java/emu/nebula/game/story/StoryManager.java @@ -270,18 +270,6 @@ public class StoryManager extends PlayerManager implements GameDatabaseObject { save = true; } - // Hardcoded fix if the player is missing the last option in main story chapter 9 - if (this.getCompletedStories().contains(1025)) { - if (!this.getEvidences().contains(1004)) { - this.getEvidences().add(1004); - save = true; - } - if (!this.getEvidences().contains(1007)) { - this.getEvidences().add(1007); - save = true; - } - } - // Save to database if (save) { this.save(); diff --git a/src/main/java/emu/nebula/game/story/StoryOptionLog.java b/src/main/java/emu/nebula/game/story/StoryOptionLog.java index 7cc71db..9b477c7 100644 --- a/src/main/java/emu/nebula/game/story/StoryOptionLog.java +++ b/src/main/java/emu/nebula/game/story/StoryOptionLog.java @@ -6,8 +6,9 @@ import java.util.List; import dev.morphia.annotations.Entity; import emu.nebula.proto.Public.Story; +import emu.nebula.proto.Public.StoryChoice; import emu.nebula.proto.StorySett.StoryOptions; - +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import lombok.Getter; import us.hebi.quickbuf.RepeatedMessage; @@ -81,23 +82,23 @@ public class StoryOptionLog { return this.personality.size(); } - public boolean hasPersonalityOption(int group, int choice) { - if (this.personality == null) { - return false; - } - - return this.personality.stream() - .filter(c -> c.getGroup() == group && c.getValue() == choice) - .findFirst() - .isPresent(); - } - - public boolean addPersonalityOption(int group, int choice) { + public void addPersonalityOption(int group, int choice) { if (this.personality == null) { this.personality = new ArrayList<>(); } - return this.personality.add(new StoryChoiceInfo(group, choice)); + // Try and get existing group option + var option = this.personality.stream() + .filter(c -> c.getGroup() == group) + .findFirst() + .orElseGet(null); + + // Set value for choice option + if (option == null) { + this.personality.add(new StoryChoiceInfo(group, choice)); + } else { + option.setValue(choice); + } } public boolean settlePersonality(RepeatedMessage options) { @@ -109,10 +110,7 @@ public class StoryOptionLog { break; } - // Skip if we already have this choice - if (this.hasPersonalityOption(option.getGroup(), option.getChoice())) { - continue; - } + // TODO fix old accounts with multiple of the same personality groups // Add this.addPersonalityOption(option.getGroup(), option.getChoice()); @@ -128,14 +126,38 @@ public class StoryOptionLog { public void encodeStoryProto(Story proto) { if (this.major != null) { + var chosen = new Int2IntOpenHashMap(); + for (var choice : this.major) { - proto.addMajor(choice.toProto()); + var value = chosen.get(choice.getGroup()) | choice.getValue(); + chosen.put(choice.getGroup(), value); + } + + for (var entry : chosen.int2IntEntrySet()) { + var choice = StoryChoice.newInstance() + .setGroup(entry.getIntKey()) + .setValue(entry.getIntValue()); + + proto.addMajor(choice); } } if (this.personality != null) { + var chosen = new Int2IntOpenHashMap(); + for (var choice : this.personality) { - proto.addMajor(choice.toProto()); + chosen.put(choice.getGroup(), choice.getValue()); + } + + for (var entry : chosen.int2IntEntrySet()) { + int factor = 5; // Guessed value + int value = (entry.getIntValue() << 4) + (factor << 8); + + var choice = StoryChoice.newInstance() + .setGroup(entry.getIntKey()) + .setValue(value); + + proto.addPersonality(choice); } } }