diff --git a/Server/Components/CustomModels/models.cpp b/Server/Components/CustomModels/models.cpp index 87b78d072..925410f54 100644 --- a/Server/Components/CustomModels/models.cpp +++ b/Server/Components/CustomModels/models.cpp @@ -296,6 +296,7 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player bool enabled = true; uint16_t modelsPort = 7777; String modelsPath = "models"; + String webServerBindAddress = ""; String cdn = ""; bool usingCdn = false; uint16_t httpThreads = 50; // default max_players is 50 @@ -414,6 +415,7 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player config.setString("artwork.models_path", modelsPath); config.setInt("network.http_threads", httpThreads); config.setInt("artwork.port", modelsPort); + config.setString("artwork.web_server_bind", webServerBindAddress); } else { @@ -440,6 +442,13 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player { config.setInt("artwork.port", modelsPort); } + // We provide a way for users to set webserver bind address, sometimes they want it + // To be different rather than 127.0.0.1 or server's public IP. For example, in some + // Situations you want to bind it to 0.0.0.0, like in a docker container. + if (config.getType("artwork.web_server_bind") == ConfigOptionType_None) + { + config.setString("artwork.web_server_bind", webServerBindAddress); + } } } @@ -453,6 +462,7 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player modelsPath = String(core->getConfig().getString("artwork.models_path")); cdn = String(core->getConfig().getString("artwork.cdn")); httpThreads = *core->getConfig().getInt("network.http_threads"); + webServerBindAddress = String(core->getConfig().getString("artwork.web_server_bind")); NetCode::RPC::RequestTXD::addEventHandler(*core, &requestDownloadLinkHandler); NetCode::RPC::RequestDFF::addEventHandler(*core, &requestDownloadLinkHandler); @@ -521,7 +531,21 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player return; } - webServer = new WebServer(core, modelsPath, core->getConfig().getString("network.bind"), *core->getConfig().getInt("artwork.port"), core->getConfig().getString("network.public_addr"), httpThreads); + StringView bindAddress; + StringView networkBindAddress = core->getConfig().getString("network.bind"); + if (webServerBindAddress.size()) + { + bindAddress = StringView(webServerBindAddress.c_str(), webServerBindAddress.size()); + } + else + { + if (!networkBindAddress.empty()) + { + bindAddress = networkBindAddress; + } + } + + webServer = new WebServer(core, modelsPath, bindAddress, *core->getConfig().getInt("artwork.port"), core->getConfig().getString("network.public_addr"), httpThreads); if (webServer->is_running()) { diff --git a/Server/Components/TextDraws/textdraw.hpp b/Server/Components/TextDraws/textdraw.hpp index 03f984340..2f952a6c8 100644 --- a/Server/Components/TextDraws/textdraw.hpp +++ b/Server/Components/TextDraws/textdraw.hpp @@ -174,6 +174,11 @@ class TextDrawBase : public T, public PoolIDProvider, public NoCopy T& setStyle(TextDrawStyle s) override { + if (static_cast<int>(s) >= 16 || static_cast<int>(s) < 0) + { + style = TextDrawStyle_FontBeckettRegular; + return *this; + } style = s; return *this; } diff --git a/Server/Source/player_impl.hpp b/Server/Source/player_impl.hpp index 1da939ec1..01e85ad82 100644 --- a/Server/Source/player_impl.hpp +++ b/Server/Source/player_impl.hpp @@ -606,6 +606,15 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy void setSpectating(bool spectating) override { + // Reset internal player spectating data if ID is already set to a player + // Related issue: https://github.com/openmultiplayer/open.mp/issues/735 + if (!spectating && spectateData_.spectateID != INVALID_PLAYER_ID) + { + spectateData_.type = PlayerSpectateData::ESpectateType::None; + spectateData_.spectateID = INVALID_PLAYER_ID; + spectateData_.spectating = false; + } + if (spectating == spectateData_.spectating) { return;