mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
Merge branch 'rc-v3.0.1' into rc-v3.1.0
This commit is contained in:
commit
01268821dc
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -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
|
||||||
|
@ -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)
|
||||||
|
@ -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
1
deps/json
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit eb2182414749825be086c825edb5229e5c28503d
|
@ -424,10 +424,6 @@ TConsole::TConsole() {
|
|||||||
mCommandline.set_history_limit(20);
|
mCommandline.set_history_limit(20);
|
||||||
mCommandline.set_prompt("> ");
|
mCommandline.set_prompt("> ");
|
||||||
BackupOldLog();
|
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) {
|
mCommandline.on_command = [this](Commandline& c) {
|
||||||
try {
|
try {
|
||||||
auto cmd = c.get_command();
|
auto cmd = c.get_command();
|
||||||
|
@ -121,6 +121,9 @@ void THeartbeatThread::operator()() {
|
|||||||
beammp_error("Backend REFUSED the auth key. " + Message);
|
beammp_error("Backend REFUSED the auth key. " + Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isAuth) {
|
||||||
|
Application::SetSubsystemStatus("Heartbeat", Application::Status::Good);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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) {
|
||||||
|
@ -77,6 +77,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
int BeamMPServerMain(MainArguments Arguments) {
|
int BeamMPServerMain(MainArguments Arguments) {
|
||||||
setlocale(LC_ALL, "C");
|
setlocale(LC_ALL, "C");
|
||||||
|
Application::InitializeConsole();
|
||||||
ArgsParser Parser;
|
ArgsParser Parser;
|
||||||
Parser.RegisterArgument({ "help" }, ArgsParser::NONE);
|
Parser.RegisterArgument({ "help" }, ArgsParser::NONE);
|
||||||
Parser.RegisterArgument({ "version" }, ArgsParser::NONE);
|
Parser.RegisterArgument({ "version" }, ArgsParser::NONE);
|
||||||
@ -117,8 +118,11 @@ int BeamMPServerMain(MainArguments Arguments) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::InitializeConsole();
|
|
||||||
Application::SetSubsystemStatus("Main", Application::Status::Starting);
|
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();
|
SetupSignalHandlers();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user