Commit 4ce12893 authored by nanahira's avatar nanahira

Merge branch 'fix-lua' of github.com:Fluorohydride/ygopro-core

parents 0b244e29 49459757
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
#include "ocgapi.h" #include "ocgapi.h"
#include "interpreter.h" #include "interpreter.h"
interpreter::interpreter(duel* pd, bool enable_unsafe_libraries) : coroutines(256), pduel(pd) { interpreter::interpreter(duel* pd, bool enable_unsafe_libraries)
: coroutines(256), pduel(pd), enable_unsafe_feature(enable_unsafe_libraries) {
mem_tracker = new LuaMemTracker(YGOPRO_LUA_MEMORY_SIZE); mem_tracker = new LuaMemTracker(YGOPRO_LUA_MEMORY_SIZE);
lua_state = lua_newstate(LuaMemTracker::AllocThunk, mem_tracker); lua_state = lua_newstate(LuaMemTracker::AllocThunk, mem_tracker);
current_state = lua_state; current_state = lua_state;
...@@ -256,7 +257,11 @@ int32_t interpreter::load_script(const char* script_name) { ...@@ -256,7 +257,11 @@ int32_t interpreter::load_script(const char* script_name) {
return OPERATION_FAIL; return OPERATION_FAIL;
++no_action; ++no_action;
luaL_checkstack(current_state, 2, nullptr); luaL_checkstack(current_state, 2, nullptr);
int32_t error = luaL_loadbuffer(current_state, (const char*)buffer, len, script_name) || lua_pcall(current_state, 0, 0, 0); int32_t error = 0;
if (enable_unsafe_feature)
error = luaL_loadbuffer(current_state, (const char*)buffer, len, script_name) || lua_pcall(current_state, 0, 0, 0);
else
error = luaL_loadbufferx(current_state, (const char*)buffer, len, script_name, "t") || lua_pcall(current_state, 0, 0, 0);
if (error) { if (error) {
interpreter::sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); interpreter::sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
......
...@@ -43,6 +43,7 @@ public: ...@@ -43,6 +43,7 @@ public:
coroutine_map coroutines; coroutine_map coroutines;
int32_t no_action{}; int32_t no_action{};
int32_t call_depth{}; int32_t call_depth{};
bool enable_unsafe_feature{};
int32_t disable_action_check{}; int32_t disable_action_check{};
int32_t preloaded{}; int32_t preloaded{};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment