Skip to content

Commit

Permalink
Do not unload groups asked for by quests (#2212)
Browse files Browse the repository at this point in the history
  • Loading branch information
scooterboo authored Jun 16, 2023
1 parent 89376d5 commit 6da5343
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public boolean execute(GameQuest quest, QuestData.QuestExecParam condition, Stri
if (!scriptManager.refreshGroupSuite(groupId, suiteId, quest)) {
result = false;
}
scriptManager.getGroupById(groupId).dontUnload = true;
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emu/grasscutter/game/world/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ public void checkGroups() {
.collect(Collectors.toSet());

for (var group : this.loadedGroups) {
if (!visible.contains(group.id) && !group.dynamic_load)
if (!visible.contains(group.id) && !group.dynamic_load && !group.dontUnload)
unloadGroup(scriptManager.getBlocks().get(group.block_id), group.id);
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/emu/grasscutter/scripts/SceneScriptManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ public boolean refreshGroupSuite(int groupId, int suiteId) {
suiteId,
groupId,
getScene().getId());
} else {
Grasscutter.getLogger().debug("Refreshing group {} suite {}", groupId, suiteId);
suiteId =
refreshGroup(
targetGroupInstance,
suiteId,
false); // If suiteId is zero, the value of suiteId changes
scene.broadcastPacket(new PacketGroupSuiteNotify(groupId, suiteId));
if (targetGroupInstance == null) return false;
}
Grasscutter.getLogger().debug("Refreshing group {} suite {}", groupId, suiteId);
suiteId =
refreshGroup(
targetGroupInstance,
suiteId,
false); // If suiteId is zero, the value of suiteId changes
scene.broadcastPacket(new PacketGroupSuiteNotify(groupId, suiteId));

return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/emu/grasscutter/scripts/data/SceneGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public final class SceneGroup {
public SceneGarbage garbages;
public SceneInitConfig init_config;
@Getter public boolean dynamic_load = false;
public boolean dontUnload = false;

public SceneReplaceable is_replaceable;

Expand Down

0 comments on commit 6da5343

Please sign in to comment.