mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-02-16 02:30:54 +00:00
Fix various issues and crashes
This commit is contained in:
@@ -82,9 +82,32 @@ public:
|
||||
static std::array<uint8_t, 3> VersionStrToInts(const std::string& str);
|
||||
static bool IsOutdated(const Version& Current, const Version& Newest);
|
||||
|
||||
static void InitializeConsole() {
|
||||
if (!mConsole) {
|
||||
mConsole = std::make_unique<TConsole>();
|
||||
}
|
||||
}
|
||||
|
||||
enum class Status {
|
||||
Starting,
|
||||
Good,
|
||||
Bad,
|
||||
};
|
||||
|
||||
using SystemStatusMap = std::unordered_map<std::string /* system name */, Status /* status */>;
|
||||
|
||||
static const SystemStatusMap& GetSubsystemStatuses() {
|
||||
return mSystemStatusMap;
|
||||
}
|
||||
|
||||
static void SetSubsystemStatus(const std::string& Subsystem, Status status) {
|
||||
mSystemStatusMap[Subsystem] = status;
|
||||
}
|
||||
|
||||
private:
|
||||
static inline SystemStatusMap mSystemStatusMap {};
|
||||
static inline std::string mPPS;
|
||||
static std::unique_ptr<TConsole> mConsole;
|
||||
static inline std::unique_ptr<TConsole> mConsole;
|
||||
static inline std::mutex mShutdownHandlersMutex {};
|
||||
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
||||
|
||||
|
||||
@@ -91,14 +91,14 @@ static auto w_printf_s = [](const char* fmt, ...) {
|
||||
va_end(args);
|
||||
};
|
||||
|
||||
static auto w_sprintf_s = [](char* buf, size_t buf_size, const char* fmt, ...) {
|
||||
static auto w_sprintf_s = [](char* buf, size_t, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(buf, fmt, args);
|
||||
va_end(args);
|
||||
};
|
||||
|
||||
static auto w_sprintf_s_ret = [](char* buf, size_t buf_size, const char* fmt, ...) {
|
||||
static auto w_sprintf_s_ret = [](char* buf, size_t, const char* fmt, ...) {
|
||||
int ret;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
@@ -3,12 +3,16 @@
|
||||
#include <Common.h>
|
||||
#include <IThreaded.h>
|
||||
#include <filesystem>
|
||||
#include <httplib.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#include <httplib.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Crypto {
|
||||
@@ -36,12 +40,6 @@ namespace Server {
|
||||
void operator()();
|
||||
|
||||
private:
|
||||
/**
|
||||
* the shared pointer is necessary because httplib is a blocking library and due lacking thread-safety
|
||||
* will "forget" about its environment, when configured across multiple threads.
|
||||
* So we need to able to start the server (make it "listen()") in a single Thread.
|
||||
*/
|
||||
std::shared_ptr<httplib::SSLServer> mHttpLibServerInstancePtr;
|
||||
std::thread mThread;
|
||||
};
|
||||
// todo: all of these functions are likely unsafe,
|
||||
|
||||
@@ -16,19 +16,19 @@ public:
|
||||
void InitializeLuaConsole(TLuaEngine& Engine);
|
||||
void BackupOldLog();
|
||||
Commandline& Internal() { return mCommandline; }
|
||||
|
||||
|
||||
private:
|
||||
void RunAsCommand(const std::string& cmd, bool IgnoreNotACommand = false);
|
||||
void ChangeToLuaConsole(const std::string& LuaStateId);
|
||||
void ChangeToRegularConsole();
|
||||
|
||||
|
||||
void Command_Lua(const std::string& cmd);
|
||||
void Command_Help(const std::string& cmd);
|
||||
void Command_Kick(const std::string& cmd);
|
||||
void Command_Say(const std::string& cmd);
|
||||
void Command_List(const std::string& cmd);
|
||||
void Command_Status(const std::string& cmd);
|
||||
|
||||
|
||||
Commandline mCommandline;
|
||||
std::vector<std::string> mCachedLuaHistory;
|
||||
std::vector<std::string> mCachedRegularHistory;
|
||||
|
||||
Reference in New Issue
Block a user