Skip to content

VirtualRoomSet Rework#869

Merged
ConnorForan merged 4 commits into
mainfrom
virtual_room_set_rework
Jun 2, 2026
Merged

VirtualRoomSet Rework#869
ConnorForan merged 4 commits into
mainfrom
virtual_room_set_rework

Conversation

@Guantol-Lemat

Copy link
Copy Markdown
Contributor
  • Simplify adding rooms by introducing a single "RoomHolder" that guarantees pointer stability for all added rooms. VirtualRoomSets are now simple vectors of room pointers.
  • Fix issues caused by room ID collisions when restoring a GameState on continue.
  • Prepare the manager for support of CustomRoomSets.

- Simplified room holder
- Prepared support for custom room sets.
- Fixed restore issues caused by ID collisions.
- Add a separate set of RestoreRoomDB for remote and local game states.
- Fix StageID and Mode not being properly applied to newly added rooms.
- Fix DbGameStateRoom being marked as VirtualGameStateRoom.
- Fix InitDB not reusing repeated room indexes.
- Fix Lua/C++ index handling in AddLuaRooms.

namespace {
static constexpr size_t CHUNK_SIZE = 64 * 1024 / sizeof(RoomConfig_Room); // 64 KB
using RoomChunk = std::array<RoomConfig_Room, CHUNK_SIZE>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we splitting up the rooms into chunks? Is this just for memory allocation optimization? (ie, vector resizing)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is primarily a memory locality optimization, with the added benefit of reducing reallocations in the main vector. The goal is to have fast room iteration while filtering, while also keeping the implementation of add_room relatively simple.

OutAddStbRooms out;

LogUtility::LogContext logContext;
//logContext.emplace_back(REPENTOGON::StringFormat("[LUA] Add Rooms from `.../content/rooms/%s` to set (%u, %i): ", filename.c_str(), stageId, mode));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these commented-out lines intended to be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to add them back in.

int numRooms = 0;
file->Read(&numRooms, 4, 1);

//logContext.emplace_back(REPENTOGON::StringFormat("Reading %d Rooms from `%s`...", numRooms, filepath.c_str()));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was keeping this comment intended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also forgot to add this one back in.

@ConnorForan ConnorForan merged commit 914dae3 into main Jun 2, 2026
1 check passed
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.

2 participants