Merge branch 'rc-v3.0.1' into rc-v3.1.0

This commit is contained in:
Lion Kortlepel 2022-02-15 15:15:51 +01:00
commit 01268821dc
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
9 changed files with 36 additions and 15 deletions

3
.gitmodules vendored
View File

@ -22,3 +22,6 @@
[submodule "deps/cpp-httplib"]
path = deps/cpp-httplib
url = https://github.com/yhirose/cpp-httplib
[submodule "deps/json"]
path = deps/json
url = https://github.com/nlohmann/json

View File

@ -16,6 +16,7 @@ include_directories("${PROJECT_SOURCE_DIR}/deps/websocketpp")
include_directories("${PROJECT_SOURCE_DIR}/deps/commandline")
include_directories("${PROJECT_SOURCE_DIR}/deps/sol2/include")
include_directories("${PROJECT_SOURCE_DIR}/deps/cpp-httplib")
include_directories("${PROJECT_SOURCE_DIR}/deps/json/single_include")
include_directories("${PROJECT_SOURCE_DIR}/deps")
add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT)

View File

@ -3,6 +3,8 @@
- ADDED Backup URLs to UpdateCheck (will fail less often now)
- FIXED a bug where, when run with --working-directory, the Server.log would still be in the original directory
- FIXED a bug which could cause the plugin reload thread to spin at 100% if the reloaded plugin's didn't terminate
- FIXED an issue which would cause servers to crash on mod download via SIGPIPE on POSIX
- FIXED an issue which would cause servers to crash when checking if a vehicle is a unicycle
# v3.0.0

1
deps/json vendored Submodule

@ -0,0 +1 @@
Subproject commit eb2182414749825be086c825edb5229e5c28503d

View File

@ -424,10 +424,6 @@ TConsole::TConsole() {
mCommandline.set_history_limit(20);
mCommandline.set_prompt("> ");
BackupOldLog();
bool success = mCommandline.enable_write_to_file("Server.log");
if (!success) {
beammp_error("unable to open file for writing: \"Server.log\"");
}
mCommandline.on_command = [this](Commandline& c) {
try {
auto cmd = c.get_command();

View File

@ -121,6 +121,9 @@ void THeartbeatThread::operator()() {
beammp_error("Backend REFUSED the auth key. " + Message);
}
}
if (isAuth) {
Application::SetSubsystemStatus("Heartbeat", Application::Status::Good);
}
}
}

View File

@ -187,7 +187,11 @@ void TNetwork::Identify(const TConnection& client) {
} else if (Code == 'D') {
HandleDownload(client.Socket);
} else if (Code == 'P') {
#if defined(BEAMMP_LINUX) || defined(BEAMMP_APPLE)
send(client.Socket, "P", 1, MSG_NOSIGNAL);
#else
send(client.Socket, "P", 1, 0);
#endif
CloseSocketProper(client.Socket);
return;
} else {
@ -778,7 +782,11 @@ void TNetwork::SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std
bool TNetwork::TCPSendRaw(TClient& C, SOCKET socket, char* Data, int32_t Size) {
intmax_t Sent = 0;
do {
#if defined(BEAMMP_LINUX) || defined(BEAMMP_APPLE)
intmax_t Temp = send(socket, &Data[Sent], int(Size - Sent), MSG_NOSIGNAL);
#else
intmax_t Temp = send(socket, &Data[Sent], int(Size - Sent), 0);
#endif
if (Temp < 1) {
beammp_info("Socket Closed! " + std::to_string(socket));
CloseSocketProper(socket);

View File

@ -7,14 +7,14 @@
#include <any>
#include <sstream>
#include <nlohmann/json.hpp>
#include "LuaAPI.h"
#undef GetObject // Fixes Windows
#include "Json.h"
namespace json = rapidjson;
TServer::TServer(const std::vector<std::string_view>& Arguments) {
beammp_info("BeamMP Server v" + Application::ServerVersionString());
Application::SetSubsystemStatus("Server", Application::Status::Starting);
@ -171,15 +171,18 @@ void TServer::HandleEvent(TClient& c, const std::string& Data) {
}
}
bool TServer::IsUnicycle(TClient& c, const std::string& CarJson) {
rapidjson::Document Car;
Car.Parse(CarJson.c_str(), CarJson.size());
if (Car.HasParseError()) {
beammp_error("Failed to parse vehicle data -> " + CarJson);
} else if (Car["jbm"].IsString() && std::string(Car["jbm"].GetString()) == "unicycle") {
return true;
try {
auto Car = nlohmann::json::parse(CarJson);
const std::string jbm = "jbm";
if (Car.contains(jbm) && Car["jbm"].is_string() && Car["jbm"] == "unicycle") {
return true;
}
} catch (const std::exception& e) {
beammp_error("Failed to parse vehicle data as json for client " + std::to_string(c.GetID()) + ": '" + CarJson + "'");
}
return false;
}
bool TServer::ShouldSpawn(TClient& c, const std::string& CarJson, int ID) {
if (c.GetUnicycleID() > -1 && (c.GetCarCount() - 1) < Application::Settings.MaxCars) {

View File

@ -77,6 +77,7 @@ int main(int argc, char** argv) {
int BeamMPServerMain(MainArguments Arguments) {
setlocale(LC_ALL, "C");
Application::InitializeConsole();
ArgsParser Parser;
Parser.RegisterArgument({ "help" }, ArgsParser::NONE);
Parser.RegisterArgument({ "version" }, ArgsParser::NONE);
@ -117,8 +118,11 @@ int BeamMPServerMain(MainArguments Arguments) {
}
}
Application::InitializeConsole();
Application::SetSubsystemStatus("Main", Application::Status::Starting);
bool Success = Application::Console().Internal().enable_write_to_file("Server.log");
if (!Success) {
beammp_error("unable to open file for writing: \"Server.log\"");
}
SetupSignalHandlers();