mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
call onInit on hot-reload, cleanup, remove warnings
onInit is now called on hot-reload, for the whole plugin. Arguably, this is not expected behavior, since only one file is being reloaded, but this is the easiest way to do it, and the entire hot-reload process is only for development purposes. Open an issue if this breaks your stuff :^)
This commit is contained in:
parent
0a8e7d8e50
commit
ad414ec5c9
@ -19,7 +19,7 @@ public:
|
|||||||
void FlushToFile();
|
void FlushToFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateConfigFile(std::string_view name);
|
void CreateConfigFile();
|
||||||
void ParseFromFile(std::string_view name);
|
void ParseFromFile(std::string_view name);
|
||||||
void PrintDebug();
|
void PrintDebug();
|
||||||
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, std::string& OutValue);
|
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, std::string& OutValue);
|
||||||
|
@ -62,7 +62,7 @@ TConfig::TConfig(const std::string& ConfigFileName)
|
|||||||
Application::SetSubsystemStatus("Config", Application::Status::Starting);
|
Application::SetSubsystemStatus("Config", Application::Status::Starting);
|
||||||
if (!fs::exists(mConfigFileName) || !fs::is_regular_file(mConfigFileName)) {
|
if (!fs::exists(mConfigFileName) || !fs::is_regular_file(mConfigFileName)) {
|
||||||
beammp_info("No config file found! Generating one...");
|
beammp_info("No config file found! Generating one...");
|
||||||
CreateConfigFile(mConfigFileName);
|
CreateConfigFile();
|
||||||
}
|
}
|
||||||
if (!mFailed) {
|
if (!mFailed) {
|
||||||
if (fs::exists("Server.cfg")) {
|
if (fs::exists("Server.cfg")) {
|
||||||
@ -138,7 +138,7 @@ void TConfig::FlushToFile() {
|
|||||||
std::fclose(File);
|
std::fclose(File);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConfig::CreateConfigFile(std::string_view name) {
|
void TConfig::CreateConfigFile() {
|
||||||
// build from old config Server.cfg
|
// build from old config Server.cfg
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -47,8 +47,8 @@ void TPluginMonitor::operator()() {
|
|||||||
TLuaChunk Chunk(Contents, Pair.first, fs::path(Pair.first).parent_path().string());
|
TLuaChunk Chunk(Contents, Pair.first, fs::path(Pair.first).parent_path().string());
|
||||||
auto StateID = mEngine->GetStateIDForPlugin(fs::path(Pair.first).parent_path());
|
auto StateID = mEngine->GetStateIDForPlugin(fs::path(Pair.first).parent_path());
|
||||||
auto Res = mEngine->EnqueueScript(StateID, Chunk);
|
auto Res = mEngine->EnqueueScript(StateID, Chunk);
|
||||||
// TODO: call onInit
|
|
||||||
mEngine->AddResultToCheck(Res);
|
mEngine->AddResultToCheck(Res);
|
||||||
|
mEngine->ReportErrors(mEngine->TriggerLocalEvent(StateID, "onInit"));
|
||||||
} else {
|
} else {
|
||||||
// TODO: trigger onFileChanged event
|
// TODO: trigger onFileChanged event
|
||||||
beammp_trace("Change detected in file \"" + Pair.first + "\", event trigger not implemented yet");
|
beammp_trace("Change detected in file \"" + Pair.first + "\", event trigger not implemented yet");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user