mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-02 07:45:26 +00:00
this gets rid of a bunch of unclear cases which I mistakenly created while refactoring for this rewrite. One example is having to call into TTCPServer to do UDP sending in some cases.
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "Common.h"
|
|
#include "IThreaded.h"
|
|
#include "TLuaFile.h"
|
|
#include "TServer.h"
|
|
#include <lua.hpp>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <set>
|
|
|
|
class TLuaEngine : public IThreaded {
|
|
public:
|
|
explicit TLuaEngine(TServer& Server, TNetwork& Network);
|
|
|
|
using TSetOfLuaFile = std::set<std::unique_ptr<TLuaFile>>;
|
|
|
|
void operator()() override;
|
|
|
|
[[nodiscard]] const TSetOfLuaFile& LuaFiles() const { return mLuaFiles; }
|
|
[[nodiscard]] TServer& Server() { return mServer; }
|
|
[[nodiscard]] const TServer& Server() const { return mServer; }
|
|
[[nodiscard]] TNetwork& Network() { return mNetwork; }
|
|
[[nodiscard]] const TNetwork& Network() const { return mNetwork; }
|
|
|
|
std::optional<std::reference_wrapper<TLuaFile>> GetScript(lua_State* L);
|
|
|
|
private:
|
|
void FolderList(const std::string& Path, bool HotSwap);
|
|
void RegisterFiles(const std::string& Path, bool HotSwap);
|
|
bool NewFile(const std::string& Path);
|
|
|
|
TNetwork& mNetwork;
|
|
TServer& mServer;
|
|
std::string mPath;
|
|
bool mShutdown { false };
|
|
TSetOfLuaFile mLuaFiles;
|
|
};
|