Skip to content

Commit

Permalink
Fix headless check in Exporting for dedicated servers (godotengine#8362)
Browse files Browse the repository at this point in the history
The example didn't work as `--headless` isn't part of `OS.get_cmdline_args()`' return value.

This new approach also works if the binary automatically uses headless mode
because it's the only display server built in the binary (which can be the case
for custom builds).

Co-authored-by: Hugo Locurcio <[email protected]>
  • Loading branch information
mweibel and Calinou authored Nov 1, 2023
1 parent 0f46393 commit 56d0a58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tutorials/export/exporting_for_dedicated_servers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ main scene (or an autoload)'s ``_ready()`` method:
.. tabs::
.. code-tab:: gdscript

if "--headless" in OS.get_cmdline_args():
if DisplayServer.get_name() == "headless":
# Run your server startup code here...
#
# Using this check, you can start a dedicated server by running
Expand All @@ -229,7 +229,7 @@ main scene (or an autoload)'s ``_ready()`` method:

using System.Linq;

if (OS.GetCmdlineArgs().Contains("--headless"))
if (DisplayServer.GetName() == "headless")
{
// Run your server startup code here...
//
Expand Down

0 comments on commit 56d0a58

Please sign in to comment.