Skip to content

Releases: MafiaHub/MafiaNet

v0.9.0

08 Jun 10:36

Choose a tag to compare

Core

  • Strong-typed PeerGuid (#25). A new enum class PeerGuid : uint64_t names a peer's RakNetGUID value distinctly from NetworkID (an object id), so the two can no longer be passed interchangeably in a uint64_t-typed signature — removing a class of silent "passed the wrong id" bugs in ReplicaManager3 glue and void(uint64_t) callbacks.
    • Convert with MafiaNet::ToPeerGuid() / MafiaNet::ToGuid(); compare against the UNASSIGNED_PEER_GUID sentinel.
    • As a trivially-copyable 8-byte scoped enum it serializes byte-identically through BitStream (and therefore VariableDeltaSerializer) to the raw uint64_t it replaces — fully wire-compatible, no netcode/protocol bump.
    • Purely additive; no behavioural change.

Full Changelog: v0.8.0...v0.9.0

v0.8.0

03 Jun 18:47

Choose a tag to compare

Core

  • Optional disconnect reason on graceful disconnects. CloseConnection gains a final optional const BitStream *reasonData argument whose bytes are appended right after the ID_DISCONNECTION_NOTIFICATION message ID, so the remote peer can learn why it was dropped (e.g. a kick/ban enum plus a custom string). The receiver reads it like any other message body — packet->data + 1 for packet->length - 1 bytes. Only graceful disconnects carry a reason; locally-synthesized notifications (ID_CONNECTION_LOST and the timeout/dead-connection path) stay payload-less, so consumers must tolerate a zero-length body. Wire-backward-compatible: peers that only inspect data[0] are unaffected.

Bug fix

  • RakPeer::CloseConnection no longer coerces an unresolved target index (-1 from GetIndexFromSystemAddress) to 0 and then reads remoteSystemList[0] — which targeted an unrelated peer's slot or crashed when the list was unallocated. The close socket is now resolved without assuming a valid slot index.

Testing

  • Added DisconnectReasonTest covering reason round-trip, the nullptr default, and the empty-but-non-null BitStream guard.

Full Changelog: v0.7.0...v0.8.0

v0.7.0

03 Jun 09:35

Choose a tag to compare

Virtual Worlds (Dimensions) for ReplicaManager3

This release adds runtime per-player dimension scoping on top of ReplicaManager3 — the SA-MP `SetPlayerVirtualWorld` / FiveM routing-bucket model for instanced interiors such as apartments.

Highlights

  • New lightweight per-entity / per-observer `VirtualWorldId` tag (distinct from the heavyweight RM3 `WorldId`). Players only see entities sharing their virtual world (or the `VIRTUAL_WORLD_GLOBAL` sentinel), switchable on the fly with no reconnect, while staying on the same connection and RM3 world.
  • Derive entities from the new `VirtualWorldReplica3` base (`mafianet/VirtualWorldReplica3.h`) — no per-object filtering code.
  • `Connection_RM3`: `Get/SetVirtualWorld` (the observer's dimension).
  • `ReplicaManager3`: `GetConnectionsInVirtualWorld` / `GetGuidsInVirtualWorld` (recipient-filter helpers for scoping chat/RPC/raw sends) and `SetPlayerVirtualWorld`.
  • The filter is applied only by the authority for an (entity, connection) pair, so a downloaded copy never despawns the entity at its owner.

Docs & tests

  • New "Virtual Worlds (Dimensions)" plugin guide; expanded contributing guide (how to test networked features end-to-end, the RM3 authority model, multi-peer gotchas).
  • New `VirtualWorldTest` (deterministic) and a self-contained `Samples/VirtualWorld` demo/smoke test.

See `mafianet/VirtualWorld.h` and `Samples/VirtualWorld` to get started.

Full changelog: v0.6.1...v0.7.0

v0.6.1

02 Jun 18:48

Choose a tag to compare

ReplicaManager3: const-qualify GetReplicaAtIndex

GetReplicaAtIndex was the only one of the four ReplicaManager3 read accessors that was non-const, even though its sibling GetConnectionAtIndex (same pattern, returns an internal pointer by index) is const. This forced const methods on derived managers to const_cast away constness just to iterate replicas.

Replica3 *GetReplicaAtIndex(unsigned index, WorldId worldId=0) const;

The method only reads the world's replica list and returns an existing pointer — no mutation — so the const qualifier is accurate. The returned Replica3* stays non-const, consistent with GetConnectionAtIndex returning a non-const Connection_RM3* from a const method.

Compatibility: Source-compatible — adding const to a read accessor doesn't break existing non-const call sites, and lets const iterators drop their const_cast. No ABI-sensitive layout change.

Closes #8 (via #9).

Full Changelog: v0.6.0...v0.6.1

v0.6.0

02 Jun 17:44

Choose a tag to compare

RPC4 handlers now carry user context

RegisterFunction, RegisterSlot, RegisterBlockingFunction and the RPC4GlobalRegistration handler constructors now take an opaque void *context that is passed back to the handler on every invocation. This removes the need for file-static global pointers to route an RPC back to an object instance — each registration carries its own context, so the same handler can serve multiple object instances under one identifier. The void* approach keeps RPC4 free of external dependencies. (#4, #5)

Bug fixes

  • RakPeer::CloseConnection no longer dereferences a null rakNetSocket during connection teardown (a pre-existing crash in release builds, where the assertion is compiled out); it now falls back to the primary socket.

Testing

  • Added RPC4ContextTest covering slot, nonblocking, and blocking handler context.
  • Quarantined the flaky ManyClientsOneServerDeallocateBlockingTest under CI pending a pre-existing teardown-race fix (#7).

⚠️ Breaking changes

  • RPC4 handler signatures gained a trailing void *context parameter, and the registration / global-registration functions take a context argument. There are no compatibility overloads — update your handlers and registration calls (pass nullptr when no context is needed).

Full changelog: v0.5.1...v0.6.0

v0.5.1

31 May 20:22

Choose a tag to compare

Plugins

  • Added DirectoryDeltaTransfer::AddFile(const char *filePath, const char *fileName) to queue a single file for upload, complementing the recursive AddUploadsFromSubdirectory. It forwards to the existing FileList::AddFile overload, making the fork self-sufficient for downstream consumers (MafiaHub Framework) that depend on this helper.

Full Changelog: v0.5.0...v0.5.1

v0.5.0

31 May 19:25

Choose a tag to compare

MafiaNet v0.5.0 — namespace & header cleanup, plus a BitStream serialization safety fix.

API & Namespace Cleanup

  • Standardized on the MafiaNet namespace throughout the library.
  • Removed the legacy SLNet compatibility macro, replaced with an MNet short-hand alias that expands to MafiaNet.
  • Dropped stale RakNet namespace-alias references (the alias no longer existed in code) and migrated remaining sample code to MafiaNet::.
  • Collapsed the three header layers inherited from the RakNet/SLikeNet lineage into the single canonical Source/include/mafianet/ set. The redirect-only Source/*.h and Source/mafianet/*.h stubs were removed; all includes now use the mafianet/... form.

Bug Fixes

  • Guarded BitStream's catch-all Write/Read templates with a std::is_trivially_copyable static_assert, preventing silent pointer-aliasing and double-frees when serializing types that own heap memory (e.g. std::string).
  • Added binary-safe, length-prefixed std::string BitStream specializations (wire-compatible with RakString).
  • Fixed Ranking_GetMatches serializing SubmittedMatch through the unsafe catch-all instead of its own Serialize().

Testing

  • Added the BitStreamStringTest regression test.

⚠️ Breaking Changes

  • Includes: legacy include spellings are gone — include public headers via the mafianet/... path (e.g. mafianet/string.h instead of RakString.h).
  • Namespace: the SLNet namespace macro has been removed — use MafiaNet (or the new MNet shorthand).
  • Serialization: serializing a non-trivially-copyable type through the generic BitStream::Write/Read now fails to compile by design; provide an explicit Serialize() or a type specialization.

Full changelog: v0.4.0...v0.5.0

v0.4.0 — Cross-Platform & Stability

26 May 12:28

Choose a tag to compare

MafiaNet v0.4.0 focuses on cross-platform support, dependency modernization, and stability.

Cross-Platform Support

  • Full macOS and Linux compatibility, including merged Socket2 definitions
  • Removed deprecated platform back-ends to simplify the socket layer
  • Fixed IPv6 connectivity and initialization issues
  • Guarded the <sys/io.h> include to x86/x86_64 only (fixes ARM builds)

Dependencies

  • Build pipeline upgraded to OpenSSL 3.6.0 (3.0+ still required)
  • Updated miniupnpc 2.2.8 → 2.3.3
  • Updated Opus 1.5.2 → 1.6.1
  • Dependencies are now fetched on demand via CMake FetchContent instead of being bundled in-tree

Bug Fixes

  • Fixed undefined behaviour from a negative doubleunsigned cast in congestion control
  • Guard against a null socket in BCS_CLOSE_CONNECTION handling
  • Fixed DLL exports on Windows
  • Fixed sample compilation across all platforms

Testing & CI

  • CI now builds and runs the full test suite on Linux, macOS and Windows (stress tests included)
  • Added a Dockerfile for running the test suite in a container
  • Numerous test-stability improvements: mesh-convergence waits, race-condition fixes, and a thread-safe plugin lifecycle for PacketChangerPlugin

Full Changelog: ...v0.4.0