Opened 5 years ago

Last modified 5 months ago

#3556 new enhancement

[PATCH] Dedicated server

Reported by: elexis Owned by:
Priority: Nice to Have Milestone: Backlog
Component: Network Keywords: patch, beta
Cc: andy011973@…, Victor ADASCALITEI Patch:

Description (last modified by Victor ADASCALITEI)


  • A dedicated host is a gameserver running from command-line
  • It has almost no performance requirements
    • no graphics are displayed
    • no local player/observer joins the game
  • could allow Wildfire Games to host multiple games on a single machine
    • can be patched independently from the release cycle (f.e. in case of bugs or abuse)
    • might satisfy the demand for servers (as only a minority of users can host/configure their router currently)
    • useful for rated games as we could make sure to not quit the server prematurely
    • ideally ensure not to kill all games when restarting the lobbybot

Notice that the source code is freely available, which means everyone will be able to use dedicated hosts. It will be the job of the programmers and lobby moderators to prevent and stop abuse.


1. Implement & commit basic functions * Only one host per instance * Use chat commands instead of gui (similar to scythewirlers autohost implementation #3419) * No client-side changes required (bugs can't affect regular hosting/joining)

(Skipped to avoid adding code which would have to be removed later)

  1. Implement gamesetup UI changes
    • Allow either the first or everyone to control the gamesettings (#3806)
    • If there are serious bugs, we could revert to 1
  1. Implement hosting on different ports (done in #3575)
    • Requirement for Wildfire Games being able to host multiple games simultaneously on a single machine
    • To prevent abuse (in case of attacks on users IP-addresses), hosting games by unauthorized users could be prohibited.
    • Optional: Trusted hosts (authorized lobby accounts) could be able to advertize more than one game at a time.
  1. Lobby changes
    • New button "Wildfire-Games Host"
      • XPartaMupp will spawn (at most) 1 gameserver per user
      • The user will join this game and become a moderator of it

Attachments (3)

t3556_dedicated_server_WIP_v0.1.patch (20.1 KB) - added by elexis 5 years ago.
Proof of concept. Server running and chat working. Still opens an unused window and has no features besides chat yet.
t3556_dedicated_server_WIP_v0.2.patch (23.1 KB) - added by elexis 5 years ago.
No more useless windows, only command line. Takes a fraction of a second to start. Changed to class structure.
t3556_dedicated_server_WIP_v0.3.patch (54.1 KB) - added by elexis 5 years ago.

Download all attachments as: .zip

Change History (21)

Changed 5 years ago by elexis

Proof of concept. Server running and chat working. Still opens an unused window and has no features besides chat yet.

Changed 5 years ago by elexis

No more useless windows, only command line. Takes a fraction of a second to start. Changed to class structure.

Changed 5 years ago by elexis

comment:1 Changed 4 years ago by elexis

Description: modified (diff)

comment:2 Changed 4 years ago by elexis

Description: modified (diff)

comment:3 in reply to:  2 Changed 4 years ago by Vladislav Belov

Current patch still creates the graphic context, so app could be crashed when runs on the server w/o a graphic card. The rest of the patch looks good.

comment:4 Changed 4 years ago by elexis

Description: modified (diff)

comment:5 Changed 4 years ago by elexis

Component: Multiplayer lobbyNetwork

(set component to network)

comment:6 Changed 4 years ago by elexis

In 18322:

Major network cleanup. Patch by Imarok.

Access the server from the client only, not from the GUI (except for autostarted games).
Thereby lay the foundation for clients to setup the game (refs #3806) and dedicated hosting (refs #3556).
Doesn't transfer nor remove the SetTurnLength? showcase from r7936.

comment:7 Changed 4 years ago by Andy A.

Cc: andy011973@… added

comment:8 Changed 4 years ago by Imarok

Description: modified (diff)

comment:9 Changed 4 years ago by elexis

Keywords: patch added
Summary: Dedicated server[PATCH] Dedicated server


Besides the new controller authorization mechanism #3806, removing DedicatedServer_Gamesetup.cpp implies:

Problem: lobby stanzas

  • The server should send the stanza (so that it doesn't depend on some client registering the game which might disconnect and thus unregister the game)
  • but only the client has access to the simulation data (defeated state #3476) and the server should avoid any gameattribute-parsing logic ideally
  • Edge cases empty host: If the server doesn't construct the packets on its own, but relays a copy sent by a client: which packets should be sent if no client connected yet? what stanza to send if the game is running and all clients disconnected (the "player X is offline" state would be outdated with the last disconnect)

Proposed solution:

  • So the server has to construct an empty packet from scratch when starting a lobbied game. If the last client disconnected from a lobbied game, the server has to correct the playerlist entry. Therefore it would make sense if the server can produce the entire logic on its own.
  • Instead of requesting a lobby stanza from a client, the server could just request the player-defeated-state. But introducing a packet for either of these things seems very undesirable. It is probably better to just not send the defeated state if the game is hosted by a dedicated server. (There might be a dedicated server that also simulates the game optionally, for example to determine the winner of rated games. If that were enabled, it could also report the defeated state without asking a client).
  • The NetServerknows the current player assignments, game attributes and has a list of connected GUIDs / clients, thus could send these 3 arguments to a JS function that does the complex stanza construction in r18534. The affected functions would have to be moved to source/lobby/ if we want to distribute the dedicated server without requiring public/.

comment:10 Changed 4 years ago by scythetwirler

Keywords: beta added

comment:11 Changed 4 years ago by scythetwirler

Milestone: BacklogAlpha 22

comment:12 Changed 3 years ago by Andy A.

Owner: set to Andy A.
Status: newassigned

comment:13 Changed 3 years ago by Andy A.

Status: assignednew

comment:14 Changed 3 years ago by Andy A.

Owner: Andy A. deleted

comment:15 Changed 3 years ago by Imarok

refs #4364 a comment from scythetwirler at this ticket, that is probably better suited here: "If you could set the XMPP resource on the JID of the default dedicated server to something different (0ad is the default for the main client) for easy recognition, that'd be great. :)"

Last edited 3 years ago by Imarok (previous) (diff)

comment:16 Changed 3 years ago by elexis

Milestone: Alpha 22Backlog

Backlogging due to lack of progress

comment:17 Changed 2 years ago by Victor ADASCALITEI

Cc: Victor ADASCALITEI added
Description: modified (diff)

I'm interested in this.

comment:18 Changed 5 months ago by elexis

In 23374:

Gamesetup class rewrite, fixes #5322, refs #5387.

  • Decouples settings logically which in turn allows fixing many problems arising from previous coupling.
  • Fixes the persist-match-settings feature, refs #2963, refs #3049.
  • Improves performance of the matchsetup by rebuilding GUI objects only when necessary.

Provides groundwork for:


Enable maps to restrict setting values:

  • If a map specifies an AI or Civs for a playerslot, the controller can't assign a player/other AI or Civ to that slot, refs #3049, #3013.

Fix per player StartingResources?, PopulationCap?, StartingTechnologies?, DisabledTechnologies?, DisabledTemplates? following rP12756, refs #812, fixes #4504. Use this for DisabledTechnologies? on Polar Sea.

Persist user settings for Skirmish maps:

  • All user chosen settings are persisted when changing the selected map or maptype, except where the selected map overwrites the setting value and except for Scenario maps which still use the default value where the map doesn't specify the setting value.
  • Tickets relating to that Skirmish mapchange user setting persistance:
    • Selecting a map doesn't change the selected civilizations, fixes #3120 (together with r23279 removing map specified Civs).
    • Selecting a map type doesn't reset the selected settings, fixes #5372.
    • Selecting a map doesn't change the selected victory conditions, unless the map specifies those, refs #4661, #3209. (Atlas still writes VictoryConditions? to every map.)
    • Consume the player color palette from Skirmish maps, refs rP17040 / #1580. Preserve the selected playercolors when switching the Skirmish/Random? map by chosing the most similar colors if the map comes with a different palette.

Rated games:

  • Hide and disable Rated game setting unless there are exactly two players, fixes #3950, supersedes D2117.
  • Display conspicuous warning if the game is rated, so players are perfectly aware.

Autostarted games:

  • Allow using the gamesetup page to autostart matches with arbitrary maps, not only this one tutorial, as reported in D194 and rP19599, refs D11.


  • Keep gamesetup page open after disconnect, allowing players to read chat messages indicating why the host stopped the server, fixes #4114.
  • The message subscription system allows new and mod settings to run custom logic on arbitrary setting changes (most importantly on map change). This removes hardcoded logic restrictions from the gamesetup option unification rewrite in rP19504/D322, refs #3994, such as the hardcoding of setting references in selectMap to biomes from rP20115/D852 and the difficulty from rP20760/D1189, RelicDuration?, WonderDuration?, LastManStanding?, RegicideGarrison?, TriggerScripts?, CircularMap?, Garrison, DisabledTemplates?.


  • Display values of disabled checkboxes with Yes/No? labels, fixes D2349, reviewed by nani.

Clean g_GameAttributes of invalid values and gamesetup GUI temporaries, refs #3049, #3883:


  • Refactor to MapCache? class, store maps of all types and use it in the replaymenu, lobby and session as well.


  • Remove hardcodings and coupling of the SettingTabsPanel? with biomes/difficulties/chat UI from D1027/rP20945.


  • Restructure the page to use hierarchical object organization (topPanel, centerPanel, centerLeftPanel, bottomPanel, centerCenterPanel, centerRightPanel, bottomLeftPanel, bottomRightPanel), allowing to deduplicate object position margins and size math and ease navigation.

New defaults:

  • Check LockedTeams? default in multiplayer (not only rated games).
  • Persist the rated game setting instead of defaulting to true when restarting a match, which often lead to unintentional rated games when rehosting.
  • 60 FPS in menus since they are animated

Autocomplete sorting fixed (playernames should be completed first).
Refactoring encompasses the one proposed in Polakrity and bb D1651.

Differential Revision:
Tested by: nani
Discussed with:

Emojis by: asterix, Imarok, fpre, nani, Krinkle, Stan, Angen, Freagarach

Note: See TracTickets for help on using tickets.