Skip to content

Commit

Permalink
Merge pull request #737 from openmultiplayer/amir/changes
Browse files Browse the repository at this point in the history
Add boundary to TD font setter, fix spectating when spectated disconnects, add webserver binding
  • Loading branch information
AmyrAhmady authored Oct 12, 2023
2 parents 441a63a + 6c0c459 commit e2fdba7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
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

0 comments on commit e2fdba7

Please sign in to comment.