Skip to content

Added multiplayer voting, lobby improvements, and clipboard paste support#87

Open
xcomcoopdev wants to merge 2 commits into
mainfrom
feature/multiplayer-voting-and-ui-improvements
Open

Added multiplayer voting, lobby improvements, and clipboard paste support#87
xcomcoopdev wants to merge 2 commits into
mainfrom
feature/multiplayer-voting-and-ui-improvements

Conversation

@xcomcoopdev

@xcomcoopdev xcomcoopdev commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Fixes #24

Added vote timeout, cooldown, and custom battle craft locking (v2.0)

Summary

This pull request improves the multiplayer voting system and the Custom Battle craft equipment flow.

Voting system

  • Increased the vote timeout from 15 to 30 seconds.
  • Votes are automatically rejected if no result is reached before the timeout.
  • Added a visible countdown to the VoteMenu.
  • Added a 60-second cooldown before the same player can start another vote.
  • The cooldown is tracked per player seat and enforced by the host.
  • Other players can still start a vote while the previous initiator is on cooldown.
  • Added a CoopState notification showing how long the player must wait.
  • Open VoteMenus are cancelled safely if the connection is lost.
  • A cancelled VoteMenu displays:
    • CONNECTION LOST - VOTE CANCELLED
    • A working CLOSE button.
image1 image2 image3

Custom Battle craft locking

  • The client does not see the EQUIP CRAFT button immediately.
  • When the host selects EQUIP CRAFT in the Mission Generator, a confirmation screen is shown.
  • Confirming the action locks the selected craft for the multiplayer session.
  • The host can no longer change or randomize the craft after it has been locked.
  • The client receives the locked craft information from the host.
  • The client can only open EQUIP CRAFT after the host has confirmed and entered the equipment screen.
  • The craft lock is cleared when the multiplayer connection or session ends.
  • After disconnecting, the host can change and randomize the craft normally again.
image4 image5

Regression tests

Expanded test_vote_system.py to verify:

  • 30-second vote timeout configuration.
  • Automatic vote rejection after timeout.
  • Matching timeout results on the host and client.
  • VoteMenu countdown state.
  • 60-second per-player vote cooldown.
  • Cooldown notification behavior.
  • Other players being allowed to start votes during another player's cooldown.
  • VoteMenu cancellation after connection loss.
  • Existing strict-majority rules.
  • Duplicate vote prevention.
  • Real player names in VoteMenu.
  • Host-authoritative vote synchronization.

The test can be run from the project root with:

python tools\coop_test\test_vote_system.py

Test result:

ALL VOTE SYSTEM TESTS PASSED

Added multiplayer voting, lobby improvements, and clipboard paste support (v1.0)

Summary

This pull request adds a multiplayer voting system, improves the Custom Battle lobby, adds clipboard paste support to multiplayer connection fields, removes obsolete pause helper functions, and introduces regression tests for the voting implementation.

Multiplayer Vote System

  • Added a new VoteMenu for multiplayer decisions.
  • Added YES and NO voting.
  • Added strict-majority voting rules:
    • 2 players require 2 YES votes.
    • 3 players require 2 YES votes.
    • 4 players require 3 YES votes.
    • A tied vote does not pass.
  • The player who starts a vote automatically votes YES.
  • Prevented players from voting more than once.
  • Added player-specific vote states:
    • WAITING
    • YES
    • NO
  • Replaced generic PLAYER 1, PLAYER 2, etc. labels with the actual multiplayer player names.
  • Player names are captured when the vote starts and sent to all clients with the vote state.
  • Added support for the following network messages:
    • vote_request
    • vote_start
    • vote_cast
    • vote_update
    • vote_result
  • The host is authoritative for validating votes and deciding the final result.
  • Added comments explaining the complete voting flow and network responsibilities.
  • Added an initial vote action for abandoning the current Battlescape mission.
  • Multiplayer mission abort now requires a successful vote.
  • Single-player mission abort behavior remains unchanged.
image1 image2 image5

Vote Result Synchronization Fix

  • Fixed a client-side infinite loop that could occur after accepting an abandon-mission vote.
  • Clients no longer execute the vote action directly after receiving vote_result.
  • The host executes the action and clients wait for the normal synchronized battle-ending message.
  • Added safety checks to EndCoopBattle() to prevent repeatedly calling popState() when the referenced BattlescapeState has already been removed.

Test Harness and Regression Tests

  • Added voting commands to TestServer.cpp.
  • Added a Python regression test using the existing OpenXcom test harness.
  • Added getter-based test access instead of using friend class TestServer.
  • Tests verify:
    • 3-player strict-majority behavior.
    • 4-player strict-majority behavior.
    • Rejection of a 2-2 tie.
    • Prevention of duplicate votes.
    • Correct player names on both host and client VoteMenus.
    • Removal of fallback PLAYER 1 and PLAYER 2 labels.
    • Host-authoritative vote result synchronization.
    • Matching final vote state on host and client.

The test can be run from the project root with:

python tools\coop_test\test_vote_system.py

Expected final output:

ALL VOTE SYSTEM TESTS PASSED

Custom Battle Lobby

  • Improved the locked Custom Battle lobby buttons.
  • The host continues to see BATTLE SETTINGS.
  • Clients now see EQUIP CRAFT in the same location.
  • The client button opens the existing craft equipment screen directly.
  • Returning from the equipment screen takes the client back to the lobby.
  • The button is hidden safely when the required save, base, craft, or New Battle state is unavailable.
image3

Clipboard Paste Support

  • Added a new clipboard implementation under:
CoopMod/clipboard/
  • Added separate SDL 1.2 platform backends:
    • Win32 clipboard support for Windows and Windows XP.
    • X11 clipboard support for Linux.
    • NSPasteboard support for macOS.
  • Added clipboard paste support to TextEdit.
  • Added keyboard shortcuts:
    • Windows and Linux: Ctrl+V
    • macOS: Command+V
  • Pasted text replaces the existing field contents.
  • Added paste support to:
    • Direct Connect IP address.
    • Direct Connect port.
    • Host Menu port.
    • Add Server IP address.
    • Add Server port.
  • Port fields filter pasted content and accept only numeric characters.
  • IP fields continue to support IPv4 addresses, IPv6 addresses, and hostnames.
  • Newline and tab characters are removed from pasted values.

Pause Cleanup

  • Removed the obsolete functions:
void setPauseOn();
void setPauseOff();
  • Removed their declarations, definitions, and remaining call sites.
  • Removed empty condition blocks left behind after the pause calls were removed.
  • Existing multiplayer turn and synchronization state variables were left unchanged.

Build System

  • Added the new VoteMenu and clipboard source files to CMake.
  • Updated OpenXcom.2010.vcxproj.
  • Updated OpenXcom.2010.vcxproj.filters.
  • Added missing CoopMod source and header entries to the Visual Studio project.
  • Removed duplicate project entries.
  • Kept the original project directory structure.

@NonPolynomialTim

Copy link
Copy Markdown
Collaborator

Overall this looks pretty good! We'd just need to figure out the CI test failures and the cause of the client crash during CI testing

@xcomcoopdev

Copy link
Copy Markdown
Collaborator Author

I am not going to add anything else to this pull request, so it is ready from my side. @NonPolynomialTim, could you check, when you have time, that the tests pass and then merge it into main? :)

@NonPolynomialTim

Copy link
Copy Markdown
Collaborator

@xcomcoopdev would you like me to fix the test failures and add some more test to get this merged, or are you planning on coming back to it?

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.

[Bug] Player 2 cannot abandon mission

2 participants