Skip to content

Enable BARONY_SUPER_MULTIPLAYER and remove remaining 4-player assumptions#940

Closed
sayhiben wants to merge 101 commits intoTurningWheel:masterfrom
sayhiben:8p-mod
Closed

Enable BARONY_SUPER_MULTIPLAYER and remove remaining 4-player assumptions#940
sayhiben wants to merge 101 commits intoTurningWheel:masterfrom
sayhiben:8p-mod

Conversation

@sayhiben
Copy link
Copy Markdown

@sayhiben sayhiben commented Feb 8, 2026

Summary

This PR re-enables BARONY_SUPER_MULTIPLAYER and removes remaining hardcoded 4-player assumptions in multiplayer-facing systems, while preserving existing 1–4 player behavior where possible.

Goal: make 4+ player lobbies practical and upstream-reviewable without changing core gameplay intent for current 4-player flows.

Prior work and borrowed approaches

  • Source: Make BARONY_SUPER_MULTIPLAYER functional #824 (Make BARONY_SUPER_MULTIPLAYER functional)
    • Borrowed the packet-size direction to prevent larger lobby/save payload pressure, then extended this PR to a larger packet budget for current MAXPLAYERS HELO payloads.
    • Borrowed the lobbyPlayerJoinRequest(... lockedSlots[MAXPLAYERS]) direction for join-slot handling.
    • Borrowed the core approach of reusing existing player-themed assets for overflow players when unique variants do not exist.
  • Source: CrabNicholson-Ba/Barony-8-Player compare against upstream master (24 commits / 8 files in the compare snapshot)
    • Borrowed the direction to re-enable and propagate BARONY_SUPER_MULTIPLAYER through build/config wiring (CMake + platform project defines).
    • Borrowed the direction to systematically replace hardcoded 4-player assumptions with MAXPLAYERS logic in touched networking/UI/save-load paths.
    • Borrowed the direction to extend extra-player loot/theme behavior beyond 4 players.
  • This PR adapts those directions to upstream standards by consolidating repeated mappings into shared lookup/helpers, tightening player-slot validation, and documenting overflow behavior explicitly.

What Changed

Build and config

  • Added BARONY_SUPER_MULTIPLAYER option/define wiring across build configs.
  • Updated the CMake option label to reflect 16-player super-multiplayer builds.
  • Increased NET_PACKET_SIZE to 2048.
  • Added compile-time HELO payload guards for both HELO layouts:
    • loadingsavegame HELO (chunk_size = 6 + 32 + 6 * 10): static_assert(8 + MAXPLAYERS * chunk_size <= NET_PACKET_SIZE).
    • normal HELO (chunk_size = 6 + 32): static_assert(8 + MAXPLAYERS * chunk_size <= NET_PACKET_SIZE).
  • Cleaned up macOS PNG linking to use find_package(PNG REQUIRED) instead of a repo-staged dylib.
  • Minor include/config cleanup for Apple/Windows project paths.

Shared player-slot mapping

  • Introduced a shared player-slot lookup utility to replace repeated switch-based mapping.
  • Applied it to ghost models, world/lobby icon themes, XP bar themes, and loot bag mapping.
  • Centralized loot bag helpers for:
    • player -> variation
    • variation -> player
    • player/variation -> light palette

Networking and slot safety

  • Replaced remaining fixed-size multiplayer assumptions with MAXPLAYERS in touched networking paths.
  • Added stronger player-slot validation and bounds checks in packet/combat/UI paths.
  • Updated lobby join request handling to use lockedSlots[MAXPLAYERS].
  • Hardened packet handlers against invalid player indices.

Lobby/UI updates for >4 players

  • Added paged lobby layout helpers (4 slots/page) and page focus for joining player index.
  • Reworked lobby settings controls to use dropdown UX for larger player counts:
    • player-count selection via dropdown.
    • kick-target selection via dropdown + explicit Kick confirmation button.
  • Updated settings label text to # Players to avoid overflow in the lobby settings card.
  • Added explicit confirmation warning when selecting 5+ players.
  • Added host-side ready-state snapshot sync for new joiners who miss historical REDY packets.
  • Added ready-up status text that remains visible while paging:
    • Page X/Y
    • Joined: I/Total Players
  • Updated lobby browser player-count rendering to show text (X/MAXPLAYERS) when icon variants run out.
  • Continue-game card still uses 2x2 thumbnails and now shows +N when additional players are connected.

Overflow-player gameplay scaling (>4 players)

  • Added overflow-aware scaling in map generation and loot/monster balancing while keeping <=4 behavior intact.
  • Increased practical caps/maximums for high-player lobbies (within bounded rules) in overflow scaling paths.
  • Updated appraisal overflow scaling to preserve 3p/4p behavior while continuing to scale in larger overflow lobbies.

Save/load and local constraints

  • Added compatibility handling for legacy saves with missing/mismatched players_connected.
  • Kept local splitscreen capped to MAX_SPLITSCREEN (4) while keeping MAXPLAYERS array handling safe.

GameUI status-effect queue initialization

  • Replaced hardcoded StatusEffectQueue array initialization with dynamic initialization based on MAXPLAYERS.
  • Added default constructor support and startup player-index assignment for all queue entries.

Validation

I made these changes on a Macbook, so apply whatever build process you usually use. Mine's:

  • cmake -S . -B build-mac
  • cmake --build build-mac -j8

Then, try manual smoke checks on touched lobby/ready/state-sync/player-index mapping flows.

Helpful testing script

./scripts/launch-multi-instance-mac.sh --instances 16 --stagger 1 --size 1280x720

Things to test manually with 5p+

  • Create LAN/Online lobbies at 5, 6, 8, 12, and 16 players; confirm the 5+ warning prompt appears and selection still applies correctly.
  • Verify # Players settings label + dropdown layout does not overflow the settings card.
  • Verify default slot-lock behavior when hosting LAN/Online (extra slots locked by default) and ensure local/joined flows still behave as expected.
  • Reduce player count while extra slots are occupied; verify kick confirmation text is correct for 1-player, 2-player, and multi-player kick scenarios.
  • Verify kick dropdown + confirm behavior targets the intended player across higher slot indices/pages.
  • Join players in mixed order (including late joiners after others are already ready) and verify ready cards/countdown state stays in sync.
  • Confirm late joiners receive host ready-state snapshots (no stale/unready cards after join).
  • Confirm joining as player index >= 4 focuses to the correct lobby page automatically.
  • Verify Page X/Y and Joined: I/Total Players remain visible and correct regardless of current page.
  • Navigate lobby pages with keyboard/controller for players beyond slot 4; verify focus, card placement, paperdolls, ping frames, warnings, and countdown alignment while scrolling.
  • Verify lobby browser player-count rendering uses icons for 0-4 players and X/MAXPLAYERS text for >4 players.
  • Verify direct-connect account labels show sensible names for players 5+ (Player 5, Player 6, etc.).
  • Start runs with 5+ players and smoke test first-floor gameplay + floor transitions for join/drop stability.
  • In normal and colorblind modes, verify player-slot visual mapping for ghost sprites, world icons/callouts, and XP bar themes across players 1+.
  • Drop and inspect loot bags for multiple player slots in normal and colorblind modes; verify world sprite, inventory icon, minimap skull color, and light palette consistency.
  • Verify dropped loot bags use variation-based bounds correctly (not fixed sprite constants) for on-ground behavior and lighting.
  • Save and reload a 5+ run; verify connected-player metadata remains consistent and continue-card display shows extra players (+N) as expected.
  • Load legacy saves with missing/mismatched players_connected data and verify continue-card rendering stays sane.
  • Compare 4-player baseline vs 5+ for map generation scaling (spawn density, loot-vs-monster rerolls, breakable monster/gold behavior, food/gold bag scaling).
  • Smoke test hunger/appraisal pacing at 3p, 4p, 5p, 8p, 12p, and 16p to confirm legacy behavior is preserved and overflow scaling is reasonable.
  • In local mode, run /splitscreen with values above 4 and verify it caps to MAX_SPLITSCREEN without affecting MAXPLAYERS safety.
  • Smoke test pause/unpause, enemy HP bars, and combat interactions with remote players to catch invalid-slot regressions.

Checked items above are backed by smoke artifacts captured on February 10, 2026 and tracked in docs/multiplayer-expansion-verification-plan.md (notably: tests/smoke/artifacts/churn-ready-sync-20260209-212709-p8-c3x2-r2, tests/smoke/artifacts/churn-ready-sync-20260209-213532-p16-c3x4, tests/smoke/artifacts/account-label-coverage-20260209-223536-p8-r5, tests/smoke/artifacts/account-label-coverage-20260209-223827-p16-r1, tests/smoke/artifacts/mapgen-full-v2-complete, tests/smoke/artifacts/churn-20260209-174003-p8-c5x2).

Known limitations

5+ player mode remains experimental and may desync (though, perhaps less so with this PR); lobby flow now warns before enabling it.

Added a section about the mod's purpose and status.
This change cleans up the 8-player branch for upstream review by removing hardcoded
8-slot switch blocks, documenting/standardizing player theme reuse behavior, and
consolidating repeated player-slot validity checks.

Player mapping and list cleanup
- Replace repeated switch statements with MAXPLAYERS-driven mapping tables in:
  - src/actplayer.cpp (ghost model selection)
  - src/interface/interface.cpp (world icon palette)
  - src/interface/playerinventory.cpp (loot bag image selection)
  - src/ui/GameUI.cpp (XP bar theme selection)
- Preserve legacy ordering for early players while making overflow behavior explicit
  and consistent for higher indices.
- Add comments that explain why repeats begin at the first overflow slot and how the
  fallback/cycle works when art/theme variants are limited.

Network and player-slot validation cleanup
- Introduce small local helpers to centralize player-slot validation where we had
  repeated ad-hoc checks:
  - src/interface/drawstatus.cpp
  - src/entity.cpp
  - src/net.cpp
- Remove redundant conditional checks in net message paths after introducing shared
  validation helpers.
- Keep behavioral guards intact while making intent clearer (local-only UI state vs
  remote packet forwarding, connected/usable slot checks, etc.).

UI and readability fixes
- src/ui/MainMenu.cpp
  - Normalize indentation in touched lobby helper blocks.
  - Shorten the experimental >4 players warning prompt lines to avoid dialog
    formatting issues.
  - Auto-focus the ready-up page based on joining player index so players >= 4 land
    on the correct page.
  - Adjust paperdoll paging bounds to avoid left-edge clipping during page animation.
  - Improve lobby browser player-count rendering: keep icon variants for 0-4 players
    and switch to "X/MAXPLAYERS" text when the lobby exceeds 4 players.
  - Add clarifying comment for fixed 2x2 save thumbnail layout break condition.
- src/player.cpp
  - Clean up indentation/formatting in getAccountName() and extract direct-connect
    name selection into a clearer helper.

Build system cleanup (macOS)
- src/CMakeLists.txt
  - Use find_package(PNG REQUIRED) on macOS as well.
  - Remove direct inclusion/linking of a repo-staged libpng16.16.dylib for barony
    and editor targets.
  - Link PNG via ${PNG_LIBRARY} and include ${PNG_INCLUDE_DIR} consistently across
    platforms.

Validation
- cmake -S . -B build-mac
- cmake --build build-mac -j8
Refactor 8p player mapping logic and clean macOS PNG linking
Replace TOOL_PLAYER_LOOT_BAG switch-based player mapping in src/items.cpp with MAXPLAYERS-driven lookup tables that preserve the legacy ordering and overflow cycling behavior.\n\nSimplify serverUpdatePlayerSummonStrength() in src/net.cpp by removing a redundant explicit MAXPLAYERS guard now covered by hasUsablePlayerSlot().\n\nRestore README.md to upstream content so the 8-player branch header is not included in the upstream PR diff.
@sayhiben sayhiben changed the title Enable Super Multiplayer Mode Re-enable BARONY_SUPER_MULTIPLAYER and generalize multiplayer paths to MAXPLAYERS Feb 9, 2026
@sayhiben sayhiben changed the title Re-enable BARONY_SUPER_MULTIPLAYER and generalize multiplayer paths to MAXPLAYERS Enable BARONY_SUPER_MULTIPLAYER and remove remaining 4-player assumptions Feb 9, 2026
@sayhiben sayhiben marked this pull request as ready for review February 9, 2026 07:26
@sayhiben
Copy link
Copy Markdown
Author

sayhiben commented Feb 9, 2026

@WALLOFJUSTICE @SheridanR - Hey, so I bought this game for a group of friends, but we usually end up having 5p for game night lately. I found the linked attempts to expand to 8p and ran with them. I tried to find everything with lists of players or max player assumptions and then adapt without changing 1-4p.

It's not a small change, but it feels fairly cohesive to me, and I think it would be cool to see more 5+ player groups get to play Barony. Happy to change whatever. This is hard for me to test, but maybe y'all have some suggestions. Thanks!

@sayhiben
Copy link
Copy Markdown
Author

sayhiben commented Feb 9, 2026

I messaged the Barony community discord about this and immediately got an ask for 12p support, so I'm bumping the max to 16p and making some adjustments. Will add some more commits today, but the general approach won't change, so feel free to review whenever you get the itch

@sayhiben sayhiben marked this pull request as draft February 11, 2026 01:05
@sayhiben
Copy link
Copy Markdown
Author

Just a quick update here - I'm going through and doing a balancing/tuning pass, then I'll wrap around and do some code cleanup. There are a large number of added lines at the moment due mostly to automated testing harnesses that I'll remove or pull into a separate PR in case anyone finds them useful. I'll also aim to split this into bite-sized PRs in the long run to remove 4p-max assumptions from the main build and slowly move closer to this full support implementation

In the meantime, I plan to use this branch to update CrabNicholson-Ba/Barony-8-Player and the associated Steam Workshop "mod" so that we can get extended multiplayer back into the hands of players who are willing to install the alternate binaries

WALL OF JUSTICE and others added 29 commits March 22, 2026 12:46
* offhand items with no AC dont add to AC effectiveness
* debug doors check key locks
* map hash update
* remove double sfx deface spell
* ensemble channels configure at end of game files loading
Signed-off-by: SheridanR <sheridan.rathbun@gmail.com>
@sayhiben sayhiben closed this Mar 23, 2026
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