Start rewrite of lua, rename all print functions

This commit is contained in:
Lion Kortlepel
2021-09-16 01:04:01 +02:00
parent d082620525
commit dd4e4c4467
20 changed files with 215 additions and 136 deletions

View File

@@ -122,11 +122,11 @@ void RegisterThread(const std::string str);
#endif // defined(DEBUG)
#define warn(x) Application::Console().Write(_this_location + std::string("[WARN] ") + (x))
#define info(x) Application::Console().Write(_this_location + std::string("[INFO] ") + (x))
#define error(x) Application::Console().Write(_this_location + std::string("[ERROR] ") + (x))
#define beammp_warn(x) Application::Console().Write(_this_location + std::string("[WARN] ") + (x))
#define beammp_info(x) Application::Console().Write(_this_location + std::string("[INFO] ") + (x))
#define beammp_error(x) Application::Console().Write(_this_location + std::string("[ERROR] ") + (x))
#define luaprint(x) Application::Console().Write(_this_location + std::string("[LUA] ") + (x))
#define debug(x) \
#define beammp_debug(x) \
do { \
if (Application::Settings.DebugModeEnabled) { \
Application::Console().Write(_this_location + std::string("[DEBUG] ") + (x)); \

View File

@@ -1,6 +1,5 @@
#pragma once
#include "TLuaFile.h"
#include <atomic>
#include <fstream>
#include "commandline.h"
@@ -11,9 +10,9 @@ public:
void Write(const std::string& str);
void WriteRaw(const std::string& str);
void InitializeLuaConsole(TLuaEngine& Engine);
// BROKEN void InitializeLuaConsole(TLuaEngine& Engine);
private:
std::unique_ptr<TLuaFile> mLuaConsole { nullptr };
// BROKEN std::unique_ptr<TLuaFile> mLuaConsole { nullptr };
Commandline mCommandline;
};

View File

@@ -0,0 +1,32 @@
#pragma once
#include "TNetwork.h"
#include "TServer.h"
#include <filesystem>
#include <sol/sol.hpp>
#include <toml11/toml.hpp>
#include <unordered_map>
#include <vector>
namespace fs = std::filesystem;
class TLuaPlugin;
class TLuaEngine : IThreaded {
public:
TLuaEngine(TServer& Server, TNetwork& Network);
void operator()() override;
private:
void CollectPlugins();
void InitializePlugin(const fs::path& folder);
TNetwork& mNetwork;
TServer& mServer;
sol::state mL;
std::atomic_bool mShutdown { false };
fs::path mResourceServerPath;
std::vector<TLuaPlugin> mLuaPlugins;
std::unordered_map<std::string, sol::state> mLuaStates;
};