From f0ec7a76938b63f58cac2c9b3a29deb7bfa11fdf Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 24 Jan 2024 23:17:23 +0000 Subject: [PATCH] Add function for whether OpenTTD is running headlessly Always returns true for dedicated builds Returns _network_dedicated otherwise --- src/stdafx.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/stdafx.h b/src/stdafx.h index 30935ddb9b..8a76b61b17 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -546,4 +546,14 @@ inline void free(const void *ptr) #define SINGLE_ARG(...) __VA_ARGS__ +#if defined(DEDICATED) +inline constexpr bool IsHeadless() { return true; } +#else +inline bool IsHeadless() +{ + extern bool _network_dedicated; + return _network_dedicated; +} +#endif + #endif /* STDAFX_H */