Skip to content

Reduce core surface: dead platforms, extras library, DS_* deprecations, snake_case files (#50) - #58

Merged
Segfaultd merged 7 commits into
masterfrom
chore/drop-dead-platforms
Oct 8, 2026
Merged

Segfaultd merged 7 commits into
masterfrom
chore/drop-dead-platforms

Conversation

@Segfaultd

@Segfaultd Segfaultd commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Closes #50. All four stages, plus a header-naming cleanup.

Stage 1: dead platforms removed

Xbox 360, PS3, PS4, PS Vita and Google Native Client. Their *Includes.h headers were already empty stubs; what remained was #ifdef islands and commented-out console code.

  • Deleted XBox360Includes.h, PS3Includes.h, PS4Includes.h, VitaIncludes.h, PS4Includes.cpp, VitaIncludes.cpp, and Samples/nacl_sdk/.
  • Deleted socket.h / RakNetSocket.cpp: the pre-RakNetSocket2 socket class. The .cpp was one big comment and the header had zero includers.
  • Stripped every __native_client__, _PS3 / __PS3__ / SN_TARGET_PS3, _PS4 and SN_TARGET_PSP2 branch (via unifdef), plus the commented-out blocks that referenced them.
  • Merged RakNetSocket2_Windows_Linux_360.cpp into RakNetSocket2_Windows_Linux.cpp; RNS2_Windows_Linux_360 → RNS2_Windows_Linux.
  • Removed SocketDescriptor::remotePortRakNetWasStartedOn_PS3_PSP2, SocketDescriptor::chromeInstance, RNS2_BerkleyBindParameters::remotePortRakNetWasStartedOn_PS3_PS4_PSP2 and the _PP_Instance_ macro. ABI note: SocketDescriptor shrinks, so consumers must rebuild.
  • ID_XBOX_360_* / ID_XBOX_LOBBY are kept as reserved enum values so wire values do not shift.

Stage 2: extras library

EmailSender, HTTPConnection, HTTPConnection2, TelnetTransport, RakNetTransport2, ConsoleServer, CommandParserInterface, RakNetCommandParser, LogCommandParser and PacketConsoleLogger move out of the core into MafiaNetExtras (MafiaNet::MafiaNetExtras), a static library built with -DMAFIANET_BUILD_EXTRAS=ON (off by default, forced on by MAFIANET_BUILD_SAMPLES since nine samples use them). Headers stay under include/mafianet/, so include paths are unchanged; only the link line changes. The target links the core PUBLIC, so linking it alone is enough. Nothing in the core referenced these classes. Installed and exported alongside the core targets.

Stage 3: DS_* audit

Consumer counts over Source/, Tests/, Samples/, DependentExtensions/: ds_binary_search_tree.h, ds_huffman_encoding_tree_factory.h, ds_ordered_channel_heap.h and ds_byte_pool.h have zero consumers; ds_queue_linked_list.h is used only by ds_binary_search_tree.h. All five now emit a #pragma message on inclusion (silenced by MAFIANET_SILENCE_DEPRECATED_INCLUDES) and are scheduled for removal in the next minor. Everything else has at least one real consumer (ds_range_list/ds_bplus_tree in the reliability layer, ds_weighted_graph/ds_tree in ConnectionGraph2, etc.) and stays.

Stage 4: minimal build configuration

  • -DMAFIANET_DISABLED_FEATURES="ReplicaManager3;RPC4Plugin" compiles out named plugins; -DMAFIANET_MINIMAL=ON compiles out all 37 optional plugins. Names are validated against MAFIANET_OPTIONAL_FEATURES in Source/CMakeLists.txt. Defines are PUBLIC so consumers see the same header configuration.
  • Documented in docs/getting-started/building.rst ("Minimal builds", "The extras library"), changelog "Unreleased" section, CLAUDE.md.
  • New linux-minimal CI job builds static + shared with MAFIANET_MINIMAL=ON; linux-native now also builds the extras target.

File naming: snake_case

The include directory mixed PascalCase (ReliabilityLayer.h) with lowercase names inherited from SLikeNet (peer.h, string.h), and .cpp files did not match their headers (peer.h ↔ RakPeer.cpp). Every file under Source/ is now lowercase snake_case with no RakNet prefix, and each .cpp matches its header:

old new
BitStream.h bit_stream.h
ReliabilityLayer.h / .cpp reliability_layer.h / .cpp
peerinterface.h / RakPeer.cpp peer_interface.h / peer.cpp
DS_List.h, DS_BPlusTree.h ds_list.h, ds_bplus_tree.h
HTTPConnection2.h, UDPForwarder.h, RPC4Plugin.h http_connection2.h, udp_forwarder.h, rpc4_plugin.h
RakVoice.h, CCRakNetUDT.h, RakNetSocket2_Berkley.cpp voice.h, cc_udt.h, socket2_berkley.cpp
_FindFirst.h find_first.h

270 files renamed, 520 files had references rewritten (library, tests, samples, extensions, docs, README, CLAUDE.md). Class names are unchanged. mafianet/mafianet.h and the already-lowercase crypto/ headers stay as they are.

No forwarding shims. Almost every rename differs from the old name only by case, so shims cannot coexist on Windows or macOS. On those platforms the old spellings still resolve; on Linux consumers update their includes once. The changelog says so.

Include style, enforced. Several library headers now share a name with a C header (string.h, time.h, assert.h, alloca.h). A bare #include "string.h" inside include/mafianet/ would pick the library's file. All sibling includes inside the library were therefore normalized to "mafianet/<name>.h", and a new CI step fails on any uppercase file name under Source/ or any bare quoted include of a library header. The only bare includes left are inside comments, the optional user-supplied CustomPacketIdentifiers.h, and the external cat/ headers.

Measurements (macOS arm64, Release, clean build of MafiaNetStatic, 3 runs each)

Configuration user CPU (s) libMafiaNetStatic.a public headers
master 31.1 – 32.7 2,142,072 B 174
this PR, stage 1 only 30.5 – 32.9 2,140,336 B 165
this PR, MAFIANET_MINIMAL=ON 20.9 – 21.4 832,240 B 165

Stage 1 removes ~1,900 lines but changes neither compile time nor size: that code was already preprocessed out on every supported platform. The minimal configuration cuts CPU time by ~34% and static size by 61%. Stage 2 moves ten translation units out of the default core build on top of that (not re-measured separately; the extras .a is produced alongside when enabled).

Bug fix found along the way: Linux directory walks never terminated

DirectoryDeltaTransferStreaming.LargeFilesAreWrittenChunkByChunk hit the 600 s timeout on every Linux CI run, on master as well. Reproducing in Docker with RSS sampling and gdb showed it was not a hang but the OOM killer: FileList::AddFilesFromDirectory recursed into output//////.. forever at ~70 MB/s. Cause: _findnext copied entry names with strncpy_s(name, d_name, 512), a count equal to the destination size; the shim then read d_name[512], far past the 256-byte dirent field, to decide whether the copy fit, saw garbage on Linux and returned an empty name, which defeated the "."/".." filter. macOS happened to read a zero there. The shim also wrote its terminator at dest[size] when count == size. Both fixed (_TRUNCATE in _findnext; the shim now reads at most count bytes and rejects a copy that would not fit, as MSVC does), with unit tests for the shim bounds and the walk's termination.

CI changes

Build & Test runs on pull requests only (plus workflow_dispatch), with a new push to a PR cancelling its in-flight run. Pushes to master trigger nothing; a v* tag triggers the release packaging workflow and the docs deploy, neither of which runs tests. A new step fails on uppercase file names under Source/ or bare quoted includes of library headers.

Verification

  • Linux, Docker (ubuntu 24.04), Debug and Release, with MAFIANET_BUILD_EXTRAS=ON: 211/211 unit and 65/65 integration pass in both.
  • macOS: 211/211 unit, 65/65 integration, all samples build against MafiaNetExtras.
  • MAFIANET_MINIMAL=ON builds both library targets; an unknown name in MAFIANET_DISABLED_FEATURES fails at configure.
  • Zero deprecation pragma messages from the in-tree build.
  • SessionConfigLive.StaticExchangeDeliversBothPayloads fails intermittently on master too (2/10 runs with master's own binary); CI's --repeat until-pass:3 absorbs it and it deserves its own issue.

Follow-ups

  • Remove the five deprecated ds_* headers in the next minor.
  • File the SessionConfigLive.StaticExchangeDeliversBothPayloads flake.

…stages 1 and 4)

Remove the Xbox 360, PS3, PS4, Vita and Native Client remnants: the empty
*Includes.h/.cpp stubs, Samples/nacl_sdk, the pre-RakNetSocket2 socket.h /
RakNetSocket.cpp (no consumers, only commented-out console code), and every
__native_client__ / _PS3 / _PS4 / SN_TARGET_* preprocessor island. The
PS3/Native Client fields on SocketDescriptor and RNS2_BerkleyBindParameters
go with them; RNS2_Windows_Linux_360 becomes RNS2_Windows_Linux. ID_XBOX_*
message identifiers stay as reserved values so wire values do not shift.

Add MAFIANET_DISABLED_FEATURES and MAFIANET_MINIMAL so the
_RAKNET_SUPPORT_<Name> flags from NativeFeatureIncludes.h can be set from
CMake (PUBLIC on the library targets, unknown names rejected), document them
in building.rst, and add a linux-minimal CI job that builds the all-plugins-off
configuration.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55d4711b-4126-41a7-bf6d-2ab13af17679
📥 Commits

Reviewing files that changed from the base of the PR and between 29b35a1 and 2dacc7b.

⛔ Files ignored due to path filters (3)
  • Samples/nacl_sdk/RakNet_NativeClient/icon_128.png is excluded by !**/*.png
  • Samples/nacl_sdk/RakNet_NativeClient/icon_16.png is excluded by !**/*.png
  • Samples/nacl_sdk/RakNet_NativeClient/icon_32.png is excluded by !**/*.png
📒 Files selected for processing (56)
  • .github/workflows/build.yml
  • CLAUDE.md
  • CMakeLists.txt
  • DependentExtensions/MySQLInterface/MySQLInterface.cpp
  • Samples/CMakeLists.txt
  • Samples/Encryption/Encryption.cpp
  • Samples/RakVoiceFMOD/main.cpp
  • Samples/iOS/ChatClient/ChatClient.xcodeproj/project.pbxproj
  • Samples/nacl_sdk/RakNet_NativeClient/HowToSetup.txt
  • Samples/nacl_sdk/RakNet_NativeClient/blob.nmf
  • Samples/nacl_sdk/RakNet_NativeClient/httpd.py
  • Samples/nacl_sdk/RakNet_NativeClient/index.htm
  • Samples/nacl_sdk/RakNet_NativeClient/js1.js
  • Samples/nacl_sdk/RakNet_NativeClient/js2.js
  • Samples/nacl_sdk/RakNet_NativeClient/main_ppapi.cpp
  • Samples/nacl_sdk/RakNet_NativeClient/manifest.json
  • Source/CMakeLists.txt
  • Source/include/mafianet/LinuxStrings.h
  • Source/include/mafianet/MessageIdentifiers.h
  • Source/include/mafianet/NatTypeDetectionCommon.h
  • Source/include/mafianet/NatTypeDetectionServer.h
  • Source/include/mafianet/PS3Includes.h
  • Source/include/mafianet/PS4Includes.h
  • Source/include/mafianet/ReliabilityLayer.h
  • Source/include/mafianet/SendToThread.h
  • Source/include/mafianet/SocketDefines.h
  • Source/include/mafianet/SocketIncludes.h
  • Source/include/mafianet/SocketLayer.h
  • Source/include/mafianet/ThreadPool.h
  • Source/include/mafianet/VitaIncludes.h
  • Source/include/mafianet/XBox360Includes.h
  • Source/include/mafianet/defines.h
  • Source/include/mafianet/peer.h
  • Source/include/mafianet/peerinterface.h
  • Source/include/mafianet/socket.h
  • Source/include/mafianet/socket2.h
  • Source/include/mafianet/types.h
  • Source/src/NatTypeDetectionClient.cpp
  • Source/src/NatTypeDetectionCommon.cpp
  • Source/src/NatTypeDetectionServer.cpp
  • Source/src/PS4Includes.cpp
  • Source/src/PacketOutputWindowLogger.cpp
  • Source/src/RakNetSocket.cpp
  • Source/src/RakNetSocket2.cpp
  • Source/src/RakNetSocket2_Berkley.cpp
  • Source/src/RakNetSocket2_Windows_Linux.cpp
  • Source/src/RakNetSocket2_Windows_Linux_360.cpp
  • Source/src/RakNetTypes.cpp
  • Source/src/RakPeer.cpp
  • Source/src/ReliabilityLayer.cpp
  • Source/src/SocketLayer.cpp
  • Source/src/TCPInterface.cpp
  • Source/src/UDPForwarder.cpp
  • Source/src/VitaIncludes.cpp
  • docs/changelog.rst
  • docs/getting-started/building.rst
💤 Files with no reviewable changes (36)
  • Samples/nacl_sdk/RakNet_NativeClient/manifest.json
  • Source/include/mafianet/VitaIncludes.h
  • Source/include/mafianet/PS3Includes.h
  • Samples/nacl_sdk/RakNet_NativeClient/HowToSetup.txt
  • Samples/CMakeLists.txt
  • Source/src/PS4Includes.cpp
  • Samples/nacl_sdk/RakNet_NativeClient/js2.js
  • Source/include/mafianet/XBox360Includes.h
  • Source/include/mafianet/PS4Includes.h
  • Samples/nacl_sdk/RakNet_NativeClient/blob.nmf
  • Source/src/RakNetTypes.cpp
  • Source/src/UDPForwarder.cpp
  • Samples/nacl_sdk/RakNet_NativeClient/index.htm
  • Samples/nacl_sdk/RakNet_NativeClient/js1.js
  • Source/include/mafianet/socket.h
  • Source/src/RakNetSocket.cpp
  • Samples/nacl_sdk/RakNet_NativeClient/httpd.py
  • Source/include/mafianet/SocketLayer.h
  • Source/src/VitaIncludes.cpp
  • Source/src/RakNetSocket2_Windows_Linux_360.cpp
  • Source/include/mafianet/ThreadPool.h
  • Samples/RakVoiceFMOD/main.cpp
  • DependentExtensions/MySQLInterface/MySQLInterface.cpp
  • Source/src/PacketOutputWindowLogger.cpp
  • Source/include/mafianet/SocketDefines.h
  • Samples/nacl_sdk/RakNet_NativeClient/main_ppapi.cpp
  • Source/src/NatTypeDetectionClient.cpp
  • Source/include/mafianet/SendToThread.h
  • Source/include/mafianet/NatTypeDetectionServer.h
  • Samples/iOS/ChatClient/ChatClient.xcodeproj/project.pbxproj
  • Source/src/NatTypeDetectionServer.cpp
  • Source/include/mafianet/LinuxStrings.h
  • Source/include/mafianet/SocketIncludes.h
  • Source/src/NatTypeDetectionCommon.cpp
  • Source/include/mafianet/ReliabilityLayer.h
  • Source/include/mafianet/NatTypeDetectionCommon.h

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The PR adds CMake options to disable selected or all optional plugins and adds a Linux minimal-build job. It also removes legacy platform code and socket interfaces, updates shared networking paths, and documents the changes.

Changes

Build Configuration and Platform Cleanup

Layer / File(s) Summary
Configure and document minimal builds
.github/workflows/build.yml, CMakeLists.txt, Source/CMakeLists.txt, docs/*, CLAUDE.md
CMake can disable named optional plugins or all listed optional plugins. Invalid names cause a configure error, and feature definitions are public on configured library targets. The Linux workflow builds a minimal Release configuration without running tests. Documentation describes the options and their effects.
Remove retired platform interfaces and samples
Source/include/mafianet/*, Source/src/*, Source/CMakeLists.txt, Samples/*, DependentExtensions/*, docs/changelog.rst
The changes remove platform-specific declarations, obsolete socket code, and Native Client sample files and build references. Xbox message identifiers remain reserved at their existing values.
Update shared socket and network paths
Source/src/*, Source/include/mafianet/*, Samples/Encryption/Encryption.cpp
Native Client-specific guards and socket parameters are removed from shared networking paths. Windows and Linux use the renamed RNS2_Windows_Linux::Send_Windows_Linux implementation. Debug authentication checks in the encryption sample are no longer excluded on Native Client.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 2dacc

This PR removes obsolete platform code and adds options for minimal builds. No concrete merge-blocking risk was found; consumers must rebuild because SocketDescriptor changed.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 14 files. (6 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title correctly mentions dead platform removal, but it also claims changes for an extras library, DS_* deprecations, and snake_case files that are not present in this pull request. Use a title that matches the actual scope, such as: "Remove dead platform code and add minimal-build plugin selection".
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Docstring Coverage

Explanation

Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 14 files. (6 skipped: 6 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

A rabbit checks the build at dawn,
And hops through flags as plugins yawn.
Old sockets rest, their branches neat,
New paths keep Linux on its feet.
The reserved IDs stay in line,
Then carrots mark a green build sign.

Comment @coderabbitai help to get the list of available commands.

…#50 stages 2 and 3)

Stage 2: move EmailSender, HTTPConnection/HTTPConnection2, TelnetTransport,
RakNetTransport2, ConsoleServer, CommandParserInterface, RakNetCommandParser,
LogCommandParser and PacketConsoleLogger out of the core into a MafiaNetExtras
static library (MAFIANET_BUILD_EXTRAS, forced on by MAFIANET_BUILD_SAMPLES).
Headers and include paths are unchanged; samples link the extras target.

Stage 3: DS_BinarySearchTree, DS_QueueLinkedList, DS_HuffmanEncodingTreeFactory,
DS_OrderedChannelHeap and DS_BytePool have no in-tree consumer; they now emit
a deprecation #pragma message and are scheduled for removal.

Header naming: every public header now carries the PascalCase name of what it
declares, matching its .cpp (peerinterface.h -> RakPeerInterface.h, string.h ->
RakString.h, types.h -> RakNetTypes.h, ...). The umbrella mafianet/mafianet.h
stays. Old names remain as forwarding headers with a #pragma message for one
release cycle, except aliases.h, version.h and gettimeofday.h, whose new names
differ only by case. The lowercase .cpp files were renamed to match.
@Segfaultd Segfaultd changed the title Reduce core surface: drop dead platforms, add CMake plugin selection (#50, stages 1 + 4) Reduce core surface: dead platforms, extras library, DS_* deprecations, header naming (#50) Oct 8, 2026
Follow-up to the header rename: MafiaNet dropped the Rak/RakNet prefix on
purpose, so the renamed headers use the bare PascalCase name (PeerInterface.h,
String.h, Types.h, ...). The lowercase shims whose new name differs only by
case are removed since they cannot coexist on case-insensitive file systems.
@Segfaultd
Segfaultd force-pushed the chore/drop-dead-platforms branch from b3055fd to d3cc2ae Compare October 8, 2026 09:00
Every header and source is now lowercase snake_case with no RakNet prefix
(bit_stream.h, peer_interface.h, voice.h, cc_udt.h), and each .cpp matches
its header. Class names are unchanged. Library headers include siblings only
as "mafianet/<name>.h" so string.h, time.h and assert.h cannot shadow the C
headers; a CI step enforces both rules. The remaining lowercase forwarding
shims are removed since the real files now carry those names.
@Segfaultd Segfaultd changed the title Reduce core surface: dead platforms, extras library, DS_* deprecations, header naming (#50) Reduce core surface: dead platforms, extras library, DS_* deprecations, snake_case files (#50) Oct 8, 2026
The snake_case pass rewrote the sample's SOURCES line too, although that file
belongs to the sample, not the library, and was not renamed.
Pushes to master no longer rebuild or retest, since master only changes
through a PR that already ran Build & Test. A release tag triggers the
packaging workflow and the documentation deploy, neither of which runs
tests. A new push to a PR cancels that PR's in-flight run.
_findnext copied each entry name with a count equal to the destination size.
The strncpy_s shim then read one byte past dirent::d_name to decide whether
the copy fit, saw garbage on Linux, returned ERANGE and an empty name. The
empty name slipped past the "."/".." filter and AddFilesFromDirectory
recursed into "dir//" forever, allocating until the OOM killer stopped it;
that is the 600 s timeout of DirectoryDeltaTransferStreaming on Linux CI.

_findnext now copies with _TRUNCATE, and the shim reads at most count bytes
of the source and rejects a copy that would not fit, as MSVC does, instead of
writing the terminator one byte past the destination. Unit tests pin both.
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.

Reduce core surface: drop dead platforms, split non networking utilities

1 participant