Skip to content

AoE2:DE 1v1 automatch2 (ranked/unranked) simple implementation - #1

Closed
Chichimokers wants to merge 80 commits into
mainfrom
feat/automatch2-matchmaking
Closed

Chichimokers wants to merge 80 commits into
mainfrom
feat/automatch2-matchmaking

Conversation

@Chichimokers

Copy link
Copy Markdown
Owner

AoE2:DE 1v1 Automatch2 (simple implementation)

What was implemented

  • Added Automatch2 (queue/pair/host/join/cleanup) for AoE2:DE 1v1 only.
  • New routes: /game/automatch2/polling, /game/automatch2/stoppolling, /game/automatch2/updateStatus.
  • Matched responses include host, map, peers, battle server/relay ports; host driven via matched polling (not WSS host message).
  • Host flow creates/reserves advertisement via update path (AoE2 never calls /advertisement/host for automatch).
  • Automatch advertisements marked with automatch flag; joins/updates bypass normal custom-game password/flow and preserve matchmaking fields.
  • Platform session ID stored pending and applied to advertisement when created/updated.
  • Relay IP resolved per-joiner from the local server IP the client used to reach us (LAN VPN aware). Peer URLs use real addresses. GameMessage built with object form and correct member schema.
  • Matched response peer IPs use request-local address. Automatch advertisement uses 27-field AoE2 layout (client-accepted). Preserve existing custom games, advertisements, sessions, WSS, BattleServer behavior.

What was achieved (how)

  1. Built queueing by compatible 1v1 matchTypes (accepted aliases 20,6,1 -> canonical queue/leaderboard 6, 2 players, team size 1, Arabia). Paired earliest host, reserved match/ad id, selected BattleServer.
  2. Host gets pre-advertisement matched polling response; creates advertisement on /advertisement/update with reserved id. Joiner stays unmatched until ad exists, gets matched response with host/peers.
  3. Applied platform session from host before ad creation. Fixed per-client relay resolution and GameMessage/member layout via runtime inspection of client memory/logs.
  4. Reverted AoE2 advertisement encoding to 27 fields (insert GoG/xbox/empty fields in correct positions) after testing showed 24-field layout caused WorldwideUpdateAdvertisementAsync / AdvertisementByIDCache "response was not formatted correctly". Kept platformSessionId/automatch behavior.

Tested

  • Local two-client LAN tests against the local server with battle-server-manager started manually.
  • Tested in Ranked/Scored Multiplayer (1v1 Automatch) path as exercised by the client; verified queue/pair/host reservation, advertisement creation, GameMessage, and peer/relay IP resolution. Logs confirmed per-client relay IP and platformSessionId on ad in later tests.
  • Testing showed the 27-field advertisement layout is required by this AoE2:DE client; 24-field caused parse failures. Corrected to 27 fields and rebuilt/deployed.

Guidelines left for matchmaking (current state)

  • Scope: 1v1 only for this implementation.
  • Simplicity: minimal pairing (earliest host), fixed map Arabia for 1v1 queue, no requeue on host failure in current code path (cleanup/expire handled), host timeout ~45s.
  • Protocol: matched polling drives flow; Automatch2GameMessage is JSON object (named fields); teams come from polling; random ad password bypassed for automatch joins.
  • Networking: resolve relay per client from request local IP, not synthetic ad IP. Host/joiner addresses must be request-local.
  • Compatibility: must preserve 27-field AoE2 advertisement layout; any future ad changes need client validation (avoid breaking ordinary custom games).

Room for improvement (documented)

  • Full cross-region/multi-battle-server selection polish, skill/rating-based matching (MMR/leaderboards), queue timeouts/retries, better cancellation, host migration, NAT/relay fallbacks, more robust GameMessage compatibility, and expansion beyond 1v1. The simple pairing is intentional for this first working pass; evidence from logs/reverse-engineering shows the protocol is more flexible than the minimal path used here.

Files

See diff for full changes (models/automatch2.go, routes/game/automatch2/*, advertisement routes/models, battleServer/host/guest/wss/http/router updates).

luskaner and others added 30 commits May 1, 2026 22:38
* Fix: cache missing debug tasks
Enhancement: Added config-helper module as means to interop for getting profile/game info on Linux systems via Wine.
Enhancement: Added support for Client.Executable as 'steam_crossover' and 'steam_wine' on Linux systems.
Update: Moved Client.IsolateMetadata and Client.IsolateProfiles parameters to own Client.Isolation section and renamed as Client.Isolation.Metadata and Client.Isolation.Profiles respectively
Enhancement: Added Client.Isolation.Path so the user can specify the path to the game user data, enabling custom path and isolation at the same time on Linux.

* Fixes to previous commit

* Fixes to previous commit (again)

* Fixes to previous commit (re-again)
…y-win7 to XTLS/go-win due to delays releasing new versions
…r#508)

* Added support in battle-server-manager and launcher to macOS

* Fix: macos interpretting hosts with unseparated comment as not part of the host itself

* Updated dependencies

* Added battle-server, launcher and game mocks to test for macOS (but can work on all). Correctly revert when using host (or cert) file paths. Refactor flags of programs being called internally. Fixed PID unlock not deleting the file

* Updated dependencies. Removed cobra dependency left-over from launch

* Fixes after Github review

* Fixes mock fixes

* Made compatible Battle-server mock for Wine

* Change Battle-server init wait from 10s to 30s for slower PC's and Wine

* Print error when failed to add or remove local certificate

* More fixes. Certificate setting in launcher can be 'auto' now

* Fixed typo. Show window when security add/remove cert in mac. Do not setSid if process is just waited on unix-like systems

* Properly quote arguments in Unix-like systems.

* Require alacritty for shell commands

* Removed unix outdated terminal apps and reused for macos

* Improved terminal selection for linux and macOS and its detection

* Mock launcher now chdir to own dir to avoid issues. macOS now kills cert cache service to avoid cache issues

* Flush dns and certs at the beginning while starting admin agent. Other minor fixes

* Simplified code

* Update dependencies and golang to 1.26.4

* return error when checking connection

* revert go-toml library to 2.3.X due to bug reading files

* wine fixes for game battleserver start and minor other changes

* Only build battleserver.go for windows to avoid ide errors

* Isolation fixes: checking path even when disabled and and not exiting returning error when failed auto retrival

* further fixes and now macos certificates are read manually due to system cache interfering

* use find-certificate in macos instead of export that requires a dialog

* fix previous commit

* fix previous commit

* fix ProcessedByNames and GetProcessStartTime for mac

* optimized linux ProcessedByNames and macos now looks at cmdline similar to linux

* fix some commands not returning exit code and made exit code and pidlock coherent

* fix launcher not stopping config admin agent if there is no reverting to be done yet

* fix for terminalArgs function

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: David Fernández Aldana <luskaner@users.noreply.github.com>

* Mock launcher print correctly

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: David Fernández Aldana <luskaner@users.noreply.github.com>

* Fix Development.MD

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: David Fernández Aldana <luskaner@users.noreply.github.com>

* typos fixed

---------

Signed-off-by: David Fernández Aldana <luskaner@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Initial AoE 2: DE for macOS native implementation

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: David Fernández Aldana <luskaner@users.noreply.github.com>
…com (luskaner#551)

* Linux: restart service instead of resolved if available
…om, implement ipv4 auto in battleserver returning wan IP as necessary (luskaner#556)
…k (as old as it was supported at the start of the project, ~2024Q2) (luskaner#559)
…le-server-manager. Added ignoreIfExisting to genCert. Battle-server-manager SSL.* simplified to CertsPath. Fixed not loading env after loading conf file (luskaner#560)
luskaner and others added 25 commits July 29, 2026 19:37
Signed-off-by: David Fernández Aldana <luskaner@users.noreply.github.com>
@Chichimokers
Chichimokers force-pushed the feat/automatch2-matchmaking branch from 24947e5 to 0405402 Compare October 23, 2026 18:23
@Chichimokers

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR luskaner#669. Kept the branch in the fork.

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