Skip to content

Stabilize multiplayer, reconnects, and synchronized gameplay - #64

Draft
skywo1f wants to merge 216 commits into
afwbkbc:mainfrom
skywo1f:agent/ci-and-gameplay-audit
Draft

skywo1f wants to merge 216 commits into
afwbkbc:mainfrom
skywo1f:agent/ci-and-gameplay-audit

Conversation

@skywo1f

@skywo1f skywo1f commented Jul 17, 2026 •

Copy link
Copy Markdown

Summary

This draft PR moves GLSMAC from a fragile multiplayer prototype toward a testable gameplay foundation. It combines transport and reconnect stabilization with synchronized movement, combat, base conquest, production, colony founding, the first playable Former terraforming loop, the first synchronized research milestone, and terminal conquest victory.

Multiplayer and reconnects

  • Add a validated per-instance network port and forward it through the multiplayer test tools.
  • Make framed reads/writes, packet sizes, disconnects, slot replacement, and running-game reconnects deterministic.
  • Preserve queued events while a reconnecting player downloads a synchronized snapshot.
  • Flush applied outbound events before snapshotting so state cannot appear once in the snapshot and again in deferred replay.
  • Restore turn, player, faction, map, terrain, unit, base, resource, animation, facility, production, expansion, terraforming, research, and terminal victory state transactionally.
  • Validate dimensions, IDs, references, enum and flag domains, nested lengths, render geometry, unit metadata, research state, victory state, and trailing payload data before committing restored state.
  • Replace Release-only assertion assumptions with runtime validation where restored or network state can violate ownership and identity contracts.
  • Fix buffer ownership, allocation arithmetic, mesh and texture replacement leaks, unit-definition ownership, and deferred animation lifetime races.

Synchronized gameplay

  • Resolve combat ties as one hit, advance surviving attackers after the final defender, and capture enemy bases during post-combat advance.
  • Preserve founding-faction architecture independently from current base ownership across capture and reconnect.
  • Add conventional unit metadata and morale, Scout Patrol, Colony Pod, and Former definitions while retaining native-life behavior.
  • Add an authoritative found_base event with owner, turn, movement, terrain, spacing, occupancy, and lock validation plus exact rollback.
  • Add typed eight-slot production queues for repeatable units and unique facilities, including synchronized completion, overflow, and rollback.
  • Add Recycling Tanks as the first facility: 40 minerals and +1 nutrient, mineral, and energy per base.
  • Replace placeholder base production UI with real queue state, costs, stored minerals, output, turn estimates, controls, and built facilities.

Former terraforming

  • Add authoritative start and cancel events for land Farm, Mine, and Solar Collector orders.
  • Serialize active unit order type and remaining turns, validate malformed or unsupported orders, and preserve exact rollback state.
  • Consume the Former's turn while working, advance jobs once per synchronized turn, and prevent movement, attacks, and skip orders until cancellation.
  • Apply Farm, Mine, and Solar yield changes, including Mine and Solar mutual exclusion.
  • Regenerate affected terrain atlas data and sprite instances without reloading the map.
  • Add a selected-Former action menu, current-order status, cancel command, and keyboard actions.
  • Persist an active client-owned Farm job across running disconnect/reconnect.

Centauri Ecology research

  • Add deterministic per-player known technologies, current target, and lab progress to native state, wrappers, snapshots, and reconnect restore.
  • Define the v0.4 Centauri Ecology milestone with a fixed 20-lab cost.
  • Give the appropriate factions their original Centauri Ecology starting technology; other factions begin researching it.
  • Convert each base's energy allocation and lab bonus into authoritative per-turn research output.
  • Add master-only initialization and progress events with exact rollback and malformed-input validation.
  • Add serialized unit technology prerequisites and gate Former production on Centauri Ecology.
  • Replace the bottom-bar placeholder with live target, progress, and discovered state.
  • Verify free and non-free starts, completion, Former unlock, two-peer synchronization, and restart persistence.

Conquest victory

  • Declare host-authored conquest victory when only one active faction retains a base or a living colony-capable unit.
  • Persist winner, victory type, and terminal turn in synchronized world snapshots.
  • Reject postgame state-changing events while retaining multiplayer chat.
  • Announce the winning faction and final mission year in the in-game message log.
  • Guard single-player starts from immediate victory and verify identical terminal state on both peers.

Notable fixes

  • Replacing the final base owner exposed a corrupt frontend owner-index tree in optimized multiplayer builds. Base navigation now derives ordering from the authoritative base map instead of maintaining a fragile duplicate index.
  • Combat used two inclusive comparisons, so exact ties damaged both units; resolution now chooses one hit.
  • Host animation completion could race slower peers, and cancellation re-entered a locked sequence map; sequence IDs are synchronized and aborts run outside the lock.
  • Reconnect snapshots conflated current base ownership with founding faction and could replay already-snapshotted events.
  • Base minerals were calculated for display but never accumulated or converted into production.
  • The base screen's lab figures were display-only placeholders; one shared calculation now drives UI and synchronized research.
  • The frontend took sole ownership of generated terrain texture data; frontend and backend ownership are now separated safely.
  • Runtime turn advancement now waits for asynchronous founding lifecycle checks.

Validation

  • Optimized Windows Release build passed.
  • Release gse, runtime_smoke, research_runtime_smoke, multiplayer_runtime_smoke, and running_reconnect_smoke all passed.
  • The conquest multiplayer scenario passed five consecutive Release runs, with both peers synchronized and postgame mutation rejected.
  • Final AddressSanitizer multiplayer passed in 200.5 seconds with host and client exiting 0, conquest and reconnect probes passing, malformed-packet probes passing, and no sanitizer report.
  • Graphical integration tests loaded the installed SMAC Planetary Pack assets.
  • git diff --cached --check passed before commit.

Cold AddressSanitizer asset loading is much slower than normal execution. Instrumented runs use longer internal allowances while every outer command retains a hard 15-minute cap.

Remaining limitations

This remains a draft, not a finished Alpha Centauri replacement. Terraforming currently covers only land Farm, Mine, and Solar Collector orders. Research currently covers only Centauri Ecology with a fixed milestone cost. Full unit design and CVR composition, additional facilities and secret projects, hurry production, surrender and cooperative victory, other victory types, diplomacy, strategic AI, complete rules and balance, durable versioned user saves, packaging, and broad UI/playtest polish remain incomplete. Original SMAC data assets are still required locally. The snapshot and network format changed, so all peers must run the same build.

@afwbkbc

afwbkbc commented Aug 27, 2026 •

Copy link
Copy Markdown
Owner

did a quick test.

  1. faction choose UI looks wrong and doesn't select faction correctly
  2. tab key not working, clicking on base does not open base screen
  3. starting 'Scout Patrol' units spawn with 0.0 moves and can't move
  4. clicking '+' in build causes crash
  5. turn stays at 'WAITING FOR PLAYERS', upon clicking changes to 'PLEASE WAIT'
  6. AIs move during player's turn, feels slow and laggy
  7. clicking any side menu causes crash

so wasn't able to test 99% of changes here because it's impossible to do anything.
please fix to make it playable, good luck 😆

@afwbkbc afwbkbc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

run the actual game and fix it

@afwbkbc afwbkbc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

problems:

  1. faction choose UI looks wrong and doesn't select faction correctly
  2. tab key not working, clicking on base does not open base screen
  3. starting 'Scout Patrol' units spawn with 0.0 moves and can't move
  4. clicking '+' in build causes crash
  5. turn stays at 'WAITING FOR PLAYERS', upon clicking changes to 'PLEASE WAIT'
  6. clicking any side menu causes crash
  7. AIs start during player's turn, everything feels slow and laggy

unable to progress further to test other changes, fix those first

@afwbkbc

afwbkbc commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Just noticed it's in Draft status, nvm then 🙂

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.

3 participants