Merge pull request #86 from BeamMP/rc-v3.0.1

Release Candidate v3.0.1
This commit is contained in:
Lion 2022-02-11 11:07:39 +01:00 committed by GitHub
commit a4f07c9a4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 9 deletions

3
.gitmodules vendored
View File

@ -22,3 +22,6 @@
[submodule "deps/cpp-httplib"] [submodule "deps/cpp-httplib"]
path = deps/cpp-httplib path = deps/cpp-httplib
url = https://github.com/yhirose/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/commandline")
include_directories("${PROJECT_SOURCE_DIR}/deps/sol2/include") include_directories("${PROJECT_SOURCE_DIR}/deps/sol2/include")
include_directories("${PROJECT_SOURCE_DIR}/deps/cpp-httplib") include_directories("${PROJECT_SOURCE_DIR}/deps/cpp-httplib")
include_directories("${PROJECT_SOURCE_DIR}/deps/json/single_include")
include_directories("${PROJECT_SOURCE_DIR}/deps") include_directories("${PROJECT_SOURCE_DIR}/deps")
add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT) add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT)

View File

@ -3,6 +3,8 @@
- ADDED Backup URLs to UpdateCheck (will fail less often now) - 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 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 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 # v3.0.0

1
deps/json vendored Submodule

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

View File

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

View File

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