Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boundary to TD font setter, fix spectating when spectated disconnects, add webserver binding #737

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Server/Components/CustomModels/models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand All @@ -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);
}
}
}

Expand All @@ -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);
Expand Down Expand Up @@ -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())
{
Expand Down
5 changes: 5 additions & 0 deletions Server/Components/TextDraws/textdraw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions Server/Source/player_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down