mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-04 14:56:04 +00:00
Lua: Pass plugin path and filename to queue for later
This commit is contained in:
@@ -61,7 +61,7 @@ TConsole::TConsole() {
|
||||
if (!mLuaEngine) {
|
||||
beammp_info("Lua not started yet, please try again in a second");
|
||||
} else {
|
||||
auto Future = mLuaEngine->EnqueueScript(mStateId, std::make_shared<std::string>(cmd));
|
||||
auto Future = mLuaEngine->EnqueueScript(mStateId, { std::make_shared<std::string>(cmd), "", "" });
|
||||
while (!Future->Ready) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ void TLuaEngine::WaitForAll(std::vector<std::shared_ptr<TLuaResult>>& Results) {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<TLuaResult> TLuaEngine::EnqueueScript(TLuaStateId StateID, const std::shared_ptr<std::string>& Script) {
|
||||
std::shared_ptr<TLuaResult> TLuaEngine::EnqueueScript(TLuaStateId StateID, const TLuaChunk& Script) {
|
||||
std::unique_lock Lock(mLuaStatesMutex);
|
||||
beammp_debug("enqueuing script into \"" + StateID + "\"");
|
||||
return mLuaStates.at(StateID)->EnqueueScript(Script);
|
||||
@@ -349,7 +349,7 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, std::atomi
|
||||
Start();
|
||||
}
|
||||
|
||||
std::shared_ptr<TLuaResult> TLuaEngine::StateThreadData::EnqueueScript(const std::shared_ptr<std::string>& Script) {
|
||||
std::shared_ptr<TLuaResult> TLuaEngine::StateThreadData::EnqueueScript(const TLuaChunk& Script) {
|
||||
beammp_debug("enqueuing script into \"" + mStateId + "\"");
|
||||
std::unique_lock Lock(mStateExecuteQueueMutex);
|
||||
auto Result = std::make_shared<TLuaResult>();
|
||||
@@ -409,7 +409,7 @@ void TLuaEngine::StateThreadData::operator()() {
|
||||
|
||||
beammp_debug("Running script");
|
||||
sol::state_view StateView(mState);
|
||||
auto Res = StateView.safe_script(*S.first, sol::script_pass_on_error);
|
||||
auto Res = StateView.safe_script(*S.first.Content, sol::script_pass_on_error, S.first.FileName);
|
||||
S.second->Ready = true;
|
||||
if (Res.valid()) {
|
||||
S.second->Error = false;
|
||||
|
||||
@@ -40,7 +40,7 @@ TLuaPlugin::TLuaPlugin(TLuaEngine& Engine, const TLuaPluginConfig& Config, const
|
||||
beammp_debug("Successfully read \"" + Entry.string() + "\" (" + std::to_string(NRead) + " Bytes)");
|
||||
mFileContents[fs::relative(Entry).string()] = Contents;
|
||||
// Execute first time
|
||||
auto Result = mEngine.EnqueueScript(mConfig.StateId, Contents);
|
||||
auto Result = mEngine.EnqueueScript(mConfig.StateId, { Contents, Entry, MainFolder });
|
||||
ResultsToCheck.emplace_back(Entry.string(), std::move(Result));
|
||||
} else {
|
||||
beammp_error("Error while reading script file \"" + Entry.string() + "\". Did the file change while reading?");
|
||||
|
||||
Reference in New Issue
Block a user