Skip to content

feat(gui): Add Random button to LAN and Online game lobbies#421

Open
bill-rich wants to merge 1 commit intoGeneralsOnlineDevelopmentTeam:mainfrom
bill-rich:go_random_button
Open

feat(gui): Add Random button to LAN and Online game lobbies#421
bill-rich wants to merge 1 commit intoGeneralsOnlineDevelopmentTeam:mainfrom
bill-rich:go_random_button

Conversation

@bill-rich
Copy link
Copy Markdown

@bill-rich bill-rich commented Mar 26, 2026

Adds a host-only "Random" button to the LAN and Online game setup screens that assigns random factions, colors, and start positions for all players currently set to "Random" or unset values.

A common way to get random factions and start positions is the "in-and-out" method: everyone sets their faction and location to random, the host starts the game so the engine assigns them, then everyone quits, creates a new lobby, and manually sets the assigned factions and positions. This is tedious and, in online lobbies, risky since getting the same group of players back together is not guaranteed. This button lets the host resolve all random assignments directly in the lobby, removing the need for the in-and-out workaround entirely and saving considerable time since the game start, quit, and rejoin cycle is eliminated.

The randomization logic mirrors the existing populateRandomSideAndColor and populateRandomStartPosition algorithms from GameLogic.cpp:

  • Assigns factions only to slots set to PLAYERTEMPLATE_RANDOM
  • Respects locked generals and the "old factions only" setting
  • Assigns colors only to slots without a color selected
  • Places opponents far apart and teammates close together using the map's start position waypoints
  • Resets the accepted state so players can review before starting

The button is disabled for non-host players. Manually chosen factions, colors, and positions are not overwritten. Team assignments are not changed.

New files:

  • RandomAssign.h / RandomAssign.cpp: Shared randomization module used by both LAN and Online menus

Changed files:

  • LanGameOptionsMenu.cpp: Hooks up the Random button for LAN lobbies
  • WOLGameSetupMenu.cpp: Hooks up the Random button for Online lobbies
  • Window/Menus/GameSpyGameOptionsMenu.wnd: Randomize button added
  • Window/Menus/LanGameOptionsMenu.wnd: Randomize button added
  • Data/English/generals.csf: GUI:Randomize -> RANDOMIZE
Screenshot From 2026-03-26 10-47-16 Screenshot From 2026-03-26 10-47-47

wnd and csf files:
https://drive.google.com/file/d/1sKVIkG2xaKD4z6PKnbosr9BV1IYMOniT/view?usp=sharing

Depends on: GeneralsOnlineDevelopmentTeam/Services#13

@tintinhamans
Copy link
Copy Markdown

Should probably be presented differently imo, maybe as a tournament mode or something.

As is it's not ideal for casual play due to host being able to re-room until they get their desired army.

@bill-rich
Copy link
Copy Markdown
Author

bill-rich commented Mar 28, 2026

What are you thinking for how else it could be done? The main goal is to just skip the in-and-out.

The idea was that since it just does what the game does once the match starts, you'd wait until everyone was in, hit the button, and then just play as though everyone got their factions and locations and then quit and rejoined. The host would have to either fully quit out and create a new room or set themselves to random and run again. At that point, I would think they would have just set themselves to whatever they want anyway.

Happy to adjust as needed.

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