Skip to content

Refresh world list to show newly created worlds #176#373

Draft
ModMaker101 wants to merge 5 commits intosmartcmd:mainfrom
ModMaker101:fix/world-list-not-refreshing-176
Draft

Refresh world list to show newly created worlds #176#373
ModMaker101 wants to merge 5 commits intosmartcmd:mainfrom
ModMaker101:fix/world-list-not-refreshing-176

Conversation

@ModMaker101
Copy link
Contributor

Description

Ensure newly created or saved worlds appear immediately in the world section UIs without requiring a full game restart. This PR forces a refresh of save metadata and level lists in the affected menus and modernizes LeveStorageSource list APIs to use smart pointers and value returned std::vectores.

Changes

Previous Behavior

  • After creating a world, returning to Load/Join, in Game Save management, or Select World screens would not show the newly created worlds.
    -The lists were populated from cached data and only refreshed on first use or after a game restart.
    SelectWorldScreen held a vector<LevelSummary*>* and dereferenced entries via ->at(i) making refresh logic awkward.
  • McRegionLevelStorageSource::getLevelList() returned an empty vector or didn't enumerate filesystem entries for levels, so the in-session refresh had nothing new to display.

Root Cause

  • Stake cache ussage, the UI relied on previously fetched save/level metadata and skipped requerying the storage unless the cached ptr was null.
  • No explicit refresh on screen init, SelectWorldScreen::postInit() did not refetch the level list when returning from a play session.
  • Non-robust API ownership, returning a raw ptr to a vector of raw LevelSummary* made ownership unclear and discouraged repopulation. The lack of a consistent value returned container led to stale data persisting across screen lifecycles.
  • Incomplete level enumeration, MCRegionLevelStorageSource::getLevelLis() previously contained disabled directory logic, as a result of this it didn't rebuild the list during a refresh.

New Behavior

  • Immediate world visibility, newly create worlds appear in the world lists immediately after saving and returning to the menus.
  • Consistent refresh on entry.
  • Safter Smart ptrs used.
  • Actual enumeration.

Fix Implementation

  • Force refresh in save menus to prevent a stale cache.
  • Refresh the world list on screen init
  • And like above it goes into more details which I basically fixed it, aka I'm getting tired of writing.

Related Issues

#176
#201

2026-03-03.22-22-06.mp4

if the video doesn't make sense there were 4 worlds before then I made a new one then it created the new one then I scrolled back down and there were 5 because it refreshed.

@ModMaker101 ModMaker101 requested a review from void2012 March 4, 2026 05:46
@dtentiion
Copy link
Contributor

My PR adds logic to rread the LevelName from the level.dat NBT inside the saveData.ms. Perhaps we could merge the architectural improvements (using smart pointers and std::vector for LevelStorageSource) from your PR with the Windows pathng/NBT logic from mine? Since they address some of the same issues

@void2012 void2012 marked this pull request as draft March 4, 2026 07:08
@codeHusky
Copy link
Collaborator

codeHusky commented Mar 4, 2026

#201 partially resolved this but it would be useful to still have this as it seems like a general improvement over the current way the world list works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants