Skip to content

refactor!: Table rewrite and DependentExtensions/Samples/Tests on std:: (5/6) - #105

Open
Segfaultd wants to merge 10 commits into
refactor/modern-memory-4-pluginsfrom
refactor/modern-memory-5-table-extensions
Open

Segfaultd wants to merge 10 commits into
refactor/modern-memory-4-pluginsfrom
refactor/modern-memory-5-table-extensions

Conversation

@Segfaultd

Copy link
Copy Markdown
Member

Summary

  • Table (table.h/table.cpp) rewritten on std::map<unsigned, std::unique_ptr<Row>> with GetRows()
  • TableSerializer gets six robustness fixes for peer input, plus a new table_serializer fuzz harness and corpus
  • DependentExtensions, Samples and Tests converted: Lobby2, Autopatcher, RakVoice, the database interfaces, Rooms, the Steam glue
  • Steam room merge iterates over a snapshot, so a callback that leaves the room no longer invalidates the iterator

Notes

Not built locally: Samples/Rooms, the Steam glue, MSVC-only samples and the database samples (several include headers that don't exist, on master too). Windows CI is the first real check for those.

Test plan

  • Debug -Werror build; unit tests plus the Reliability/Simulated/RakPeer/Encrypt/Mtu/Split integration tests

Commits

  • refactor!: Table on std::map and unique_ptr
  • refactor!: Lobby2 on std:: containers
  • refactor!: RPC3, SQLite3Plugin and Autopatcher on std:: containers
  • refactor!: samples on std:: containers
  • refactor!: tests on std:: containers
  • style: clang-format table.cpp
  • fix: Steam room merge survives callbacks that leave the room

Stack, merge in order: 1/6 safety net, 2/6 allocator, 3/6 core transport, 4/6 plugins, 5/6 Table + extensions, 6/6 delete DataStructures. Each PR targets the branch of the one before it. Breaking change for the next major version; no version bump yet.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review: 2

  • main
  • master

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d62d4125-86fd-4481-a24d-e309c3928448

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Segfaultd
Segfaultd force-pushed the refactor/modern-memory-4-plugins branch from 50e293d to f887476 Compare November 16, 2026 11:43
@Segfaultd
Segfaultd force-pushed the refactor/modern-memory-5-table-extensions branch from 64f2cb0 to b4a5c4e Compare November 16, 2026 11:43
DataStructures::Table becomes MafiaNet::Table in mafianet/table.h. Rows
live in a std::map<unsigned, std::unique_ptr<Row>> (ascending row id,
as the B+ tree iterated) exposed through GetRows(); GetListHead() and
the Page iteration are gone. Row::cells is std::vector<std::unique_ptr<
Cell>>, List parameters are std::vector, and Row's copy is deleted
explicitly (it is exported). Table keeps a deep copy, now also as a
copy constructor. ds_table.h, ds_table.cpp and ds_bplus_tree.h are
deleted.

Behaviour fixes made while rewriting:
- SortTable sorts stably: rows tied on every sort column keep row id
  order. The OrderedList version dropped them (RakAssert in Debug) and
  left the tail of the output array unwritten.
- RemoveRows frees the rows it removes; AddRow returns nullptr for an
  existing id in every overload; GetRowByIndex reaches every row.
- A cell buffer carries one trailing zero byte, so a binary value
  compared as a string cannot read past it; Set() copes with its own
  buffer as input.

TableSerializer rejects malformed peer input instead of asserting or
reading out of bounds: a truncated row count, unchecked row/cell reads,
an out-of-range cell index, a duplicate row id, an unknown column type
or filter operation, a failed ReadAlignedBytesSafeAlloc and too many
filter queries now all return false. A zero-length BINARY cell is
written as a length-0 blob instead of tripping RakAssert. FilterQuery
value-initializes its fields. The serialized bytes of existing tables
are unchanged (TableSerializerGolden).

New table_serializer fuzz harness and corpus; Lobby2 and the samples
are updated to the new API.
Lobby2 messages, Lobby2Server/Client, the Rooms plugin, the PostgreSQL
and Steam back ends and PostgreSQLInterface no longer use DataStructures.

- List -> std::vector, Queue -> std::deque, Map -> std::map, Multilist
  -> std::vector.
- Lobby2Server::users stays a sorted std::vector (index lookups);
  GetUsers() returns const std::vector<User *>&. Admin and ranking
  address sets are std::set<SystemAddress>.
- RoomsPlugin participants are a std::map keyed by handle that owns
  them through std::unique_ptr; RoomsPlugin is non-copyable.
- The room and quick-join sort lists are sorted vectors filled through
  InsertSortedUnique(), which keeps the old OrderedList binary search:
  RoomsSortByTimeThenTotalSlots and the QuickJoinUser comparators are
  not strict weak orders.
- AllGamesRoomsContainer::SearchByFilter and the PerGameRoomsContainer
  sort helpers take std::vector<Room *>&.
- Lobby2Client_Steam::GetRoomMembers fills a std::set<uint64_t>; Steam
  room members are std::maps keyed by address and by Steam ID.
- Every length that goes on the wire keeps its explicit 16/32-bit cast.
- RPC3: local functions and slots are std::unordered_maps owning their
  entries through std::unique_ptr. HashIndex handles become pointers:
  GetLocalSlot()/GetLocalFunction() return nullptr when unregistered, and
  InvokeSignal() takes a LocalSlot*. Slot objects are a vector sorted by
  LocalSlotObjectComp. Keys are built without RakString's printf-style
  constructor, since identifiers come from the network. RPC3 is
  non-copyable.
- SQLite3Plugin: SQLite3Table rows are std::vector<std::unique_ptr<SQLite3Row>>;
  dbHandles is a vector sorted by dbIdentifier, looked up through the new
  protected GetDBHandleIndex(). The row and column counts on the wire stay
  32-bit.
- Autopatcher: the connection pool and waiting queue are std::deques,
  patchingUsers a std::vector.
ComprehensivePCGame, MasterServer, PHPDirectoryServer2, TestDLL and the
self-scaling Autopatcher samples no longer use DataStructures.
PHPDirectoryServer2 keeps its fields in a std::map, so GetField() and the
uploaded form keep their column-name order.
The integration fixtures' destroy lists and TestHelpers' Standard*Prep
take std::vector; the last ds_list.h includes in Tests are gone.
CallRoomCallbacks kept an iterator into roomMembersById while
NotifyNewMember/NotifyDroppedMember ran user callbacks synchronously.
A callback that leaves the room (Console_LeaveRoom_Steam -> NotifyLeaveRoom
-> ClearRoom) cleared the map and left the iterator dangling. The old
index loop re-checked the size and stopped. Merge over a local copy of the
member map instead.
ProfanityFilter and RoomTypes call strcpy, strpbrk, strspn and friends but got <cstring> only through ds_list.h and ds_table.h, which ProfanityFilter.h and RoomTypes.h no longer include. GCC on Linux then failed to build Lobby2.
@Segfaultd
Segfaultd force-pushed the refactor/modern-memory-5-table-extensions branch from b4a5c4e to d44d4d3 Compare November 16, 2026 13:58
@Segfaultd
Segfaultd force-pushed the refactor/modern-memory-4-plugins branch from f887476 to 81ee9cd Compare November 16, 2026 13:58

This branch has not been deployed

No deployments
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.

1 participant