mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-07-13 10:13:42 +00:00
Compare commits
39 Commits
develop
...
bump-version
| Author | SHA1 | Date | |
|---|---|---|---|
| 5dd4c97ed1 | |||
| 13390c5388 | |||
| 2f995a71ae | |||
| 3b5c6491a3 | |||
| db8719b5cd | |||
| a3c4b82a5d | |||
| 3b0e49fb06 | |||
| cf8f10b949 | |||
| 6f50cad76b | |||
| 03d91b1f4d | |||
| e407d246e2 | |||
| 234bdf5877 | |||
| c3b4528c89 | |||
| 5cf6d1d228 | |||
| 65017d0834 | |||
| 1237e7e533 | |||
| e2d7721438 | |||
| 0146a1cbe8 | |||
| 352a3aa536 | |||
| ac8c386c61 | |||
| d1fb15fc9a | |||
| f376d9f7be | |||
| 2f3dcfeb5a | |||
| 913ba1c793 | |||
| 9a0c9d3ce4 | |||
| a0d9be18b7 | |||
| 87d2e3355a | |||
| afb3763eab | |||
| 9de5a08b0c | |||
| bef623a281 | |||
| e852245bae | |||
| 5f5af9b0a7 | |||
| 64f2e08ed2 | |||
| 707682f4a8 | |||
| 913674740d | |||
| 1c575ff1bc | |||
| e72c217e63 | |||
| 75bae8ee5a | |||
| acc2dd29e9 |
@@ -0,0 +1 @@
|
||||
patreon: BeamMP
|
||||
@@ -1,7 +1,11 @@
|
||||
name: Linux
|
||||
|
||||
on: [push]
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'develop'
|
||||
- 'minor'
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
name: Windows
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'develop'
|
||||
- 'minor'
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
VCPKG_DEFAULT_TRIPLET: x64-windows-static
|
||||
|
||||
@@ -141,6 +141,7 @@ endif(UNIX)
|
||||
|
||||
if (WIN32)
|
||||
add_compile_options("-D_WIN32_WINNT=0x0601")
|
||||
add_compile_options("/bigobj")
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
@@ -194,6 +195,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE ${PRJ_DEFINITIONS} ${PRJ_WARN
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC "/bigobj")
|
||||
target_link_options(${PROJECT_NAME} PRIVATE "/SUBSYSTEM:CONSOLE")
|
||||
endif(MSVC)
|
||||
|
||||
|
||||
+20
-3
@@ -53,11 +53,28 @@ Do **NOT** pull with merge. This is the default git behavior for `git pull`, but
|
||||
|
||||
The only acceptable merge commits are those which actually merge functionally different branches into each other, for example for merging one feature branch into another.
|
||||
|
||||
## Workflow
|
||||
|
||||
### Making an issue and fixing it
|
||||
|
||||
1. Create an issue detailing the feature or bug.
|
||||
2. Assign a milestone to the issue, or wait for a maintainer to add a milestone to your issue.
|
||||
3. Fork the repository and base your work on the branch mentioned in the milestone attached to your issue (e.g. `v3.0.0 (develop)` -> `develop`).
|
||||
4. Program your feature or bug fix.
|
||||
5. Open a PR that references the issue by number in the format: `#12345`.
|
||||
6. Someone will review your PR and merge it, or ask for changes.
|
||||
|
||||
### Fixing an existing issue
|
||||
|
||||
1. Fork the repository and base your work on the branch mentioned in the milestone attached to your issue (e.g. `v3.0.0 (develop)` -> `develop`).
|
||||
2. Program your feature or bug fix.
|
||||
3. Open a PR that references the issue by number in the format: `#12345`.
|
||||
4. Someone will review your PR and merge it, or ask for changes.
|
||||
|
||||
## Branches
|
||||
|
||||
### Which branch should I base my work on?
|
||||
|
||||
Each *feature* or *bug-fix* is implemented on a new Git branch, branched off of the branch it should be based on. The `master` branch is usually stable, so we don't do development on it. It is always a safe bet to branch off of `master`, but it may be more work to merge later. Branches to base your work on are usually branches like `rc-v3.3.0`, when the latest public version is `3.2.0`, for example. These can often be found in Pull-Requests on GitHub which are tagged `Release Candidate`.
|
||||
- `minor`: Minor releases, like `v1.2.3` -> `v1.3.0` or `v1.2.3` -> `v1.2.4`.
|
||||
- `develop`: Major releases, like `v1.2.3` -> `v2.0.0`, and larger feature/minor releases.
|
||||
|
||||
## Unit tests & CI/CD
|
||||
|
||||
|
||||
Vendored
+1
-1
Submodule deps/commandline updated: b2a29733f9...04952e4811
+6
-3
@@ -106,8 +106,6 @@ public:
|
||||
static std::vector<std::string> GetBackendUrlsInOrder() {
|
||||
return {
|
||||
"backend.beammp.com",
|
||||
"backup1.beammp.com",
|
||||
"backup2.beammp.com"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -152,7 +150,7 @@ private:
|
||||
static inline std::mutex mShutdownHandlersMutex {};
|
||||
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
||||
|
||||
static inline Version mVersion { 3, 2, 2 };
|
||||
static inline Version mVersion { 3, 3, 0 };
|
||||
};
|
||||
|
||||
void SplitString(std::string const& str, const char delim, std::vector<std::string>& out);
|
||||
@@ -214,6 +212,10 @@ void RegisterThread(const std::string& str);
|
||||
do { \
|
||||
Application::Console().Write(_this_location + std::string("[LUA ERROR] ") + (x)); \
|
||||
} while (false)
|
||||
#define beammp_lua_log(level, plugin, x) \
|
||||
do { \
|
||||
Application::Console().Write(_this_location + fmt::format("[{}] [{}] ", plugin, level) + (x)); \
|
||||
} while (false)
|
||||
#define beammp_lua_warn(x) \
|
||||
do { \
|
||||
Application::Console().Write(_this_location + std::string("[LUA WARN] ") + (x)); \
|
||||
@@ -269,6 +271,7 @@ void RegisterThread(const std::string& str);
|
||||
#define beammp_tracef(...) beammp_trace(fmt::format(__VA_ARGS__))
|
||||
#define beammp_lua_errorf(...) beammp_lua_error(fmt::format(__VA_ARGS__))
|
||||
#define beammp_lua_warnf(...) beammp_lua_warn(fmt::format(__VA_ARGS__))
|
||||
#define beammp_lua_log(level, plugin, x) /* x */
|
||||
|
||||
#endif // DOCTEST_CONFIG_DISABLE
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace Env {
|
||||
enum class Key {
|
||||
// provider settings
|
||||
PROVIDER_UPDATE_MESSAGE,
|
||||
PROVIDER_DISABLE_CONFIG,
|
||||
PROVIDER_PORT_ENV,
|
||||
};
|
||||
|
||||
std::optional<std::string> Get(Key key);
|
||||
|
||||
+2
-1
@@ -35,11 +35,11 @@ public:
|
||||
[[nodiscard]] bool Failed() const { return mFailed; }
|
||||
|
||||
void FlushToFile();
|
||||
void PrintDebug();
|
||||
|
||||
private:
|
||||
void CreateConfigFile();
|
||||
void ParseFromFile(std::string_view name);
|
||||
void PrintDebug();
|
||||
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, std::string& OutValue);
|
||||
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, bool& OutValue);
|
||||
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, int& OutValue);
|
||||
@@ -48,5 +48,6 @@ private:
|
||||
std::string TagsAsPrettyArray() const;
|
||||
bool IsDefault();
|
||||
bool mFailed { false };
|
||||
bool mDisableConfig { false };
|
||||
std::string mConfigFileName;
|
||||
};
|
||||
|
||||
@@ -58,6 +58,7 @@ private:
|
||||
void Command_Status(const std::string& cmd, const std::vector<std::string>& args);
|
||||
void Command_Settings(const std::string& cmd, const std::vector<std::string>& args);
|
||||
void Command_Clear(const std::string&, const std::vector<std::string>& args);
|
||||
void Command_Version(const std::string& cmd, const std::vector<std::string>& args);
|
||||
|
||||
void Command_Say(const std::string& FullCommand);
|
||||
bool EnsureArgsCount(const std::vector<std::string>& args, size_t n);
|
||||
@@ -75,6 +76,7 @@ private:
|
||||
{ "settings", [this](const auto& a, const auto& b) { Command_Settings(a, b); } },
|
||||
{ "clear", [this](const auto& a, const auto& b) { Command_Clear(a, b); } },
|
||||
{ "say", [this](const auto&, const auto&) { Command_Say(""); } }, // shouldn't actually be called
|
||||
{ "version", [this](const auto& a, const auto& b) { Command_Version(a, b); } },
|
||||
};
|
||||
|
||||
std::unique_ptr<Commandline> mCommandline { nullptr };
|
||||
|
||||
@@ -55,6 +55,7 @@ private:
|
||||
TResourceManager& mResourceManager;
|
||||
std::thread mUDPThread;
|
||||
std::thread mTCPThread;
|
||||
std::mutex mOpenIDMutex;
|
||||
|
||||
std::vector<uint8_t> UDPRcvFromClient(ip::udp::endpoint& ClientEndpoint);
|
||||
void HandleDownload(TConnection&& TCPSock);
|
||||
|
||||
@@ -121,6 +121,14 @@ void TClient::SetCarData(int Ident, const std::string& Data) {
|
||||
}
|
||||
|
||||
int TClient::GetCarCount() const {
|
||||
// mVechileData holds both unicycle and cars which both count towards the maximum car count
|
||||
// spawning a unicycle meant reaching the max, hence being unable to spawn car. this dirty fixes the problem for now.
|
||||
std::unique_lock lock(mVehicleDataMutex);
|
||||
for (auto& v : mVehicleData) {
|
||||
if (v.ID() == mUnicycleID) {
|
||||
return int(mVehicleData.size() - 1);
|
||||
}
|
||||
}
|
||||
return int(mVehicleData.size());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ void Application::CheckForUpdates() {
|
||||
auto RemoteVersion = Version(VersionStrToInts(Response));
|
||||
if (IsOutdated(MyVersion, RemoteVersion)) {
|
||||
std::string RealVersionString = std::string("v") + RemoteVersion.AsString();
|
||||
const std::string DefaultUpdateMsg = "NEW VERSION IS OUT! Please update to the new version ({}) of the BeamMP-Server! Download it here: https://beammp.com/! For a guide on how to update, visit: https://wiki.beammp.com/en/home/server-maintenance#updating-the-server";
|
||||
const std::string DefaultUpdateMsg = "NEW VERSION IS OUT! Please update to the new version ({}) of the BeamMP-Server! Download it here: https://beammp.com/! For a guide on how to update, visit: https://docs.beammp.com/server/server-maintenance/#updating-the-server";
|
||||
auto UpdateMsg = Env::Get(Env::Key::PROVIDER_UPDATE_MESSAGE).value_or(DefaultUpdateMsg);
|
||||
UpdateMsg = fmt::vformat(std::string_view(UpdateMsg), fmt::make_format_args(RealVersionString));
|
||||
beammp_warnf("{}{}{}", ANSI_YELLOW_BOLD, UpdateMsg, ANSI_RESET);
|
||||
|
||||
@@ -33,6 +33,12 @@ std::string_view Env::ToString(Env::Key key) {
|
||||
case Key::PROVIDER_UPDATE_MESSAGE:
|
||||
return "BEAMMP_PROVIDER_UPDATE_MESSAGE";
|
||||
break;
|
||||
case Key::PROVIDER_DISABLE_CONFIG:
|
||||
return "BEAMMP_PROVIDER_DISABLE_CONFIG";
|
||||
break;
|
||||
case Key::PROVIDER_PORT_ENV:
|
||||
return "BEAMMP_PROVIDER_PORT_ENV";
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
+37
-8
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include "Env.h"
|
||||
#include "TConfig.h"
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
@@ -87,7 +88,9 @@ TEST_CASE("TConfig::TConfig") {
|
||||
TConfig::TConfig(const std::string& ConfigFileName)
|
||||
: mConfigFileName(ConfigFileName) {
|
||||
Application::SetSubsystemStatus("Config", Application::Status::Starting);
|
||||
if (!fs::exists(mConfigFileName) || !fs::is_regular_file(mConfigFileName)) {
|
||||
auto DisableConfig = Env::Get(Env::Key::PROVIDER_DISABLE_CONFIG).value_or("false");
|
||||
mDisableConfig = DisableConfig == "true" || DisableConfig == "1";
|
||||
if (!mDisableConfig && (!fs::exists(mConfigFileName) || !fs::is_regular_file(mConfigFileName))) {
|
||||
beammp_info("No config file found! Generating one...");
|
||||
CreateConfigFile();
|
||||
}
|
||||
@@ -143,7 +146,7 @@ void TConfig::FlushToFile() {
|
||||
SetComment(data["Misc"][StrSendErrorsMessageEnabled.data()].comments(), " You can turn on/off the SendErrors message you get on startup here");
|
||||
std::stringstream Ss;
|
||||
Ss << "# This is the BeamMP-Server config file.\n"
|
||||
"# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n"
|
||||
"# Help & Documentation: `https://docs.beammp.com/server/server-maintenance/`\n"
|
||||
"# IMPORTANT: Fill in the AuthKey with the key you got from `https://keymaster.beammp.com/` on the left under \"Keys\"\n"
|
||||
<< data;
|
||||
auto File = std::fopen(mConfigFileName.c_str(), "w+");
|
||||
@@ -161,7 +164,9 @@ void TConfig::FlushToFile() {
|
||||
|
||||
void TConfig::CreateConfigFile() {
|
||||
// build from old config Server.cfg
|
||||
|
||||
if (mDisableConfig) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (fs::exists("Server.cfg")) {
|
||||
// parse it (this is weird and bad and should be removed in some future version)
|
||||
@@ -181,6 +186,9 @@ void TConfig::TryReadValue(toml::value& Table, const std::string& Category, cons
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mDisableConfig) {
|
||||
return;
|
||||
}
|
||||
if (Table[Category.c_str()][Key.data()].is_string()) {
|
||||
OutValue = Table[Category.c_str()][Key.data()].as_string();
|
||||
}
|
||||
@@ -194,6 +202,9 @@ void TConfig::TryReadValue(toml::value& Table, const std::string& Category, cons
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mDisableConfig) {
|
||||
return;
|
||||
}
|
||||
if (Table[Category.c_str()][Key.data()].is_boolean()) {
|
||||
OutValue = Table[Category.c_str()][Key.data()].as_boolean();
|
||||
}
|
||||
@@ -206,6 +217,9 @@ void TConfig::TryReadValue(toml::value& Table, const std::string& Category, cons
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mDisableConfig) {
|
||||
return;
|
||||
}
|
||||
if (Table[Category.c_str()][Key.data()].is_integer()) {
|
||||
OutValue = int(Table[Category.c_str()][Key.data()].as_integer());
|
||||
}
|
||||
@@ -213,11 +227,18 @@ void TConfig::TryReadValue(toml::value& Table, const std::string& Category, cons
|
||||
|
||||
void TConfig::ParseFromFile(std::string_view name) {
|
||||
try {
|
||||
toml::value data = toml::parse<toml::preserve_comments>(name.data());
|
||||
toml::value data {};
|
||||
if (!mDisableConfig) {
|
||||
data = toml::parse<toml::preserve_comments>(name.data());
|
||||
}
|
||||
// GENERAL
|
||||
TryReadValue(data, "General", StrDebug, EnvStrDebug, Application::Settings.DebugModeEnabled);
|
||||
TryReadValue(data, "General", StrPrivate, EnvStrPrivate, Application::Settings.Private);
|
||||
TryReadValue(data, "General", StrPort, EnvStrPort, Application::Settings.Port);
|
||||
if (Env::Get(Env::Key::PROVIDER_PORT_ENV).has_value()) {
|
||||
TryReadValue(data, "General", StrPort, Env::Get(Env::Key::PROVIDER_PORT_ENV).value(), Application::Settings.Port);
|
||||
} else {
|
||||
TryReadValue(data, "General", StrPort, EnvStrPort, Application::Settings.Port);
|
||||
}
|
||||
TryReadValue(data, "General", StrMaxCars, EnvStrMaxCars, Application::Settings.MaxCars);
|
||||
TryReadValue(data, "General", StrMaxPlayers, EnvStrMaxPlayers, Application::Settings.MaxPlayers);
|
||||
TryReadValue(data, "General", StrMap, EnvStrMap, Application::Settings.MapName);
|
||||
@@ -238,13 +259,18 @@ void TConfig::ParseFromFile(std::string_view name) {
|
||||
Application::SetSubsystemStatus("Config", Application::Status::Bad);
|
||||
return;
|
||||
}
|
||||
PrintDebug();
|
||||
|
||||
// Update in any case
|
||||
FlushToFile();
|
||||
if (!mDisableConfig) {
|
||||
FlushToFile();
|
||||
}
|
||||
// all good so far, let's check if there's a key
|
||||
if (Application::Settings.Key.empty()) {
|
||||
beammp_error("No AuthKey specified in the \"" + std::string(mConfigFileName) + "\" file. Please get an AuthKey, enter it into the config file, and restart this server.");
|
||||
if (mDisableConfig) {
|
||||
beammp_error("No AuthKey specified in the environment.");
|
||||
} else {
|
||||
beammp_error("No AuthKey specified in the \"" + std::string(mConfigFileName) + "\" file. Please get an AuthKey, enter it into the config file, and restart this server.");
|
||||
}
|
||||
Application::SetSubsystemStatus("Config", Application::Status::Bad);
|
||||
mFailed = true;
|
||||
return;
|
||||
@@ -256,6 +282,9 @@ void TConfig::ParseFromFile(std::string_view name) {
|
||||
}
|
||||
|
||||
void TConfig::PrintDebug() {
|
||||
if (mDisableConfig) {
|
||||
beammp_debug("Provider turned off the generation and parsing of the ServerConfig.toml");
|
||||
}
|
||||
beammp_debug(std::string(StrDebug) + ": " + std::string(Application::Settings.DebugModeEnabled ? "true" : "false"));
|
||||
beammp_debug(std::string(StrPrivate) + ": " + std::string(Application::Settings.Private ? "true" : "false"));
|
||||
beammp_debug(std::string(StrPort) + ": " + std::to_string(Application::Settings.Port));
|
||||
|
||||
+10
-1
@@ -247,7 +247,8 @@ void TConsole::Command_Help(const std::string&, const std::vector<std::string>&
|
||||
lua [state id] switches to lua, optionally into a specific state id's lua
|
||||
settings [command] sets or gets settings for the server, run `settings help` for more info
|
||||
status how the server is doing and what it's up to
|
||||
clear clears the console window)";
|
||||
clear clears the console window
|
||||
version displays the server version)";
|
||||
Application::Console().WriteRaw("BeamMP-Server Console: " + std::string(sHelpString));
|
||||
}
|
||||
|
||||
@@ -267,6 +268,14 @@ void TConsole::Command_Clear(const std::string&, const std::vector<std::string>&
|
||||
mCommandline->write("\x1b[;H\x1b[2J");
|
||||
}
|
||||
|
||||
void TConsole::Command_Version(const std::string& cmd, const std::vector<std::string>& args) {
|
||||
if (!EnsureArgsCount(args, 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Application::Console().WriteRaw("Current version: v" + Application::ServerVersionString());
|
||||
}
|
||||
|
||||
void TConsole::Command_Kick(const std::string&, const std::vector<std::string>& args) {
|
||||
if (!EnsureArgsCount(args, 1, size_t(-1))) {
|
||||
return;
|
||||
|
||||
+36
-1
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "TLuaEngine.h"
|
||||
#include "Client.h"
|
||||
#include "Common.h"
|
||||
#include "CustomAssert.h"
|
||||
#include "Http.h"
|
||||
#include "LuaAPI.h"
|
||||
@@ -829,6 +830,40 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, TLuaStateI
|
||||
MPTable.set_function("Set", &LuaAPI::MP::Set);
|
||||
|
||||
auto UtilTable = StateView.create_named_table("Util");
|
||||
UtilTable.set_function("LogDebug", [this](sol::variadic_args args) {
|
||||
std::string ToPrint = "";
|
||||
for (const auto& arg : args) {
|
||||
ToPrint += LuaAPI::LuaToString(static_cast<const sol::object>(arg));
|
||||
ToPrint += "\t";
|
||||
}
|
||||
if (Application::Settings.DebugModeEnabled) {
|
||||
beammp_lua_log("DEBUG", mStateId, ToPrint);
|
||||
}
|
||||
});
|
||||
UtilTable.set_function("LogInfo", [this](sol::variadic_args args) {
|
||||
std::string ToPrint = "";
|
||||
for (const auto& arg : args) {
|
||||
ToPrint += LuaAPI::LuaToString(static_cast<const sol::object>(arg));
|
||||
ToPrint += "\t";
|
||||
}
|
||||
beammp_lua_log("INFO", mStateId, ToPrint);
|
||||
});
|
||||
UtilTable.set_function("LogWarn", [this](sol::variadic_args args) {
|
||||
std::string ToPrint = "";
|
||||
for (const auto& arg : args) {
|
||||
ToPrint += LuaAPI::LuaToString(static_cast<const sol::object>(arg));
|
||||
ToPrint += "\t";
|
||||
}
|
||||
beammp_lua_log("WARN", mStateId, ToPrint);
|
||||
});
|
||||
UtilTable.set_function("LogError", [this](sol::variadic_args args) {
|
||||
std::string ToPrint = "";
|
||||
for (const auto& arg : args) {
|
||||
ToPrint += LuaAPI::LuaToString(static_cast<const sol::object>(arg));
|
||||
ToPrint += "\t";
|
||||
}
|
||||
beammp_lua_log("ERROR", mStateId, ToPrint);
|
||||
});
|
||||
UtilTable.set_function("JsonEncode", &LuaAPI::MP::JsonEncode);
|
||||
UtilTable.set_function("JsonDecode", [this](const std::string& str) {
|
||||
return Lua_JsonDecode(str);
|
||||
@@ -1101,7 +1136,7 @@ void TLuaResult::MarkAsReady() {
|
||||
void TLuaResult::WaitUntilReady() {
|
||||
std::unique_lock readyLock(*this->ReadyMutex);
|
||||
// wait if not ready yet
|
||||
if(!this->Ready)
|
||||
if (!this->Ready)
|
||||
this->ReadyCondition->wait(readyLock);
|
||||
}
|
||||
|
||||
|
||||
@@ -630,6 +630,7 @@ void TNetwork::OnDisconnect(const std::weak_ptr<TClient>& ClientPtr) {
|
||||
}
|
||||
|
||||
int TNetwork::OpenID() {
|
||||
std::unique_lock OpenIDLock(mOpenIDMutex);
|
||||
int ID = 0;
|
||||
bool found;
|
||||
do {
|
||||
|
||||
+6
-3
@@ -65,10 +65,13 @@ void TPPSMonitor::operator()() {
|
||||
V += c->GetCarCount();
|
||||
}
|
||||
// kick on "no ping"
|
||||
if (c->SecondsSinceLastPing() > (20 * 60)) {
|
||||
beammp_debug("client " + std::string("(") + std::to_string(c->GetID()) + ")" + c->GetName() + " timing out: " + std::to_string(c->SecondsSinceLastPing()) + ", pps: " + Application::PPS());
|
||||
if (c->SecondsSinceLastPing() > (20 * 60) ){
|
||||
beammp_debugf("client {} ({}) timing out: {}", c->GetID(), c->GetName(), c->SecondsSinceLastPing());
|
||||
TimedOutClients.push_back(c);
|
||||
}
|
||||
} else if (c->IsSynced() && c->SecondsSinceLastPing() > (1 * 60)) {
|
||||
beammp_debugf("client {} ({}) timing out: {}", c->GetName(), c->GetID(), c->SecondsSinceLastPing());
|
||||
TimedOutClients.push_back(c);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
+24
-1
@@ -30,6 +30,7 @@
|
||||
#include "TResourceManager.h"
|
||||
#include "TServer.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
@@ -40,6 +41,9 @@ USAGE:
|
||||
ARGUMENTS:
|
||||
--help
|
||||
Displays this help and exits.
|
||||
--port=1234
|
||||
Sets the server's listening TCP and
|
||||
UDP port. Overrides ENV and ServerConfig.
|
||||
--config=/path/to/ServerConfig.toml
|
||||
Absolute or relative path to the
|
||||
Server Config file, including the
|
||||
@@ -91,6 +95,7 @@ int BeamMPServerMain(MainArguments Arguments) {
|
||||
Parser.RegisterArgument({ "help" }, ArgsParser::NONE);
|
||||
Parser.RegisterArgument({ "version" }, ArgsParser::NONE);
|
||||
Parser.RegisterArgument({ "config" }, ArgsParser::HAS_VALUE);
|
||||
Parser.RegisterArgument({ "port" }, ArgsParser::HAS_VALUE);
|
||||
Parser.RegisterArgument({ "working-directory" }, ArgsParser::HAS_VALUE);
|
||||
Parser.Parse(Arguments.List);
|
||||
if (!Parser.Verify()) {
|
||||
@@ -124,7 +129,7 @@ int BeamMPServerMain(MainArguments Arguments) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TConfig Config(ConfigPath);
|
||||
|
||||
if (Config.Failed()) {
|
||||
@@ -135,6 +140,24 @@ int BeamMPServerMain(MainArguments Arguments) {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// override port if provided via arguments
|
||||
if (Parser.FoundArgument({ "port" })) {
|
||||
auto Port = Parser.GetValueOfArgument({ "port" });
|
||||
if (Port.has_value()) {
|
||||
auto P = int(std::strtoul(Port.value().c_str(), nullptr, 10));
|
||||
if (P == 0 || P < 0 || P > UINT16_MAX) {
|
||||
beammp_errorf("Custom port requested via --port is invalid: '{}'", Port.value());
|
||||
return 1;
|
||||
} else {
|
||||
Application::Settings.Port = P;
|
||||
beammp_info("Custom port requested via commandline arguments: " + Port.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Config.PrintDebug();
|
||||
|
||||
Application::InitializeConsole();
|
||||
Application::Console().StartLoggingToFile();
|
||||
|
||||
|
||||
+1
-1
Submodule vcpkg updated: 8397227251...326d8b43e3
Reference in New Issue
Block a user