Commit 80c420d2 authored by nanahira's avatar nanahira

Merge branch 'master' into szonedl

parents 3779e8d9 9efa33ab
......@@ -33,8 +33,8 @@ duel::~duel() {
delete pgroup;
for(auto& peffect : effects)
delete peffect;
delete lua;
delete game_field;
delete lua;
}
void duel::clear() {
for(auto& pcard : cards)
......
......@@ -2668,6 +2668,16 @@ int32_t field::check_tuner_material(lua_State* L, card* pcard, card* tuner, int3
return FALSE;
}
}
effect* extra_synchro_material_effect = tuner->is_affected_by_effect(EFFECT_EXTRA_SYNCHRO_MATERIAL);
if (extra_synchro_material_effect) {
if (!extra_synchro_material_effect->check_count_limit(playerid)) {
return FALSE;
}
int32_t value = extra_synchro_material_effect->get_value(pcard);
if (value <= 0) {
return FALSE;
}
}
int32_t mzone_limit = get_mzone_limit(playerid, playerid, LOCATION_REASON_TOFIELD);
if(mzone_limit < 0) {
if(location == LOCATION_HAND) {
......
......@@ -14,15 +14,12 @@
#include "ocgapi.h"
#include "interpreter.h"
interpreter::interpreter(duel* pd, bool enable_unsafe_libraries): coroutines(256) {
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);
lua_state = lua_newstate(LuaMemTracker::AllocThunk, mem_tracker);
current_state = lua_state;
pduel = pd;
std::memcpy(lua_getextraspace(lua_state), &pd, LUA_EXTRASPACE); //set_duel_info
no_action = 0;
call_depth = 0;
disable_action_check = 0;
//Initial
#ifdef YGOPRO_NO_LUA_SAFE
luaL_openlibs(lua_state);
......@@ -260,7 +257,11 @@ int32_t interpreter::load_script(const char* script_name) {
return OPERATION_FAIL;
++no_action;
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 && true)
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) {
interpreter::sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1);
......
......@@ -34,17 +34,18 @@ public:
using param_list = std::list<std::pair<lua_param, LuaParamType>>;
duel* pduel;
char msgbuf[64];
char msgbuf[64]{};
lua_State* lua_state;
lua_State* current_state;
LuaMemTracker* mem_tracker;
param_list params;
param_list resumes;
coroutine_map coroutines;
int32_t no_action;
int32_t call_depth;
int32_t disable_action_check;
int32_t preloaded;
int32_t no_action{};
int32_t call_depth{};
bool enable_unsafe_feature{};
int32_t disable_action_check{};
int32_t preloaded{};
explicit interpreter(duel* pd, bool enable_unsafe_libraries);
~interpreter();
......
......@@ -372,7 +372,7 @@ int32_t scriptlib::duel_clear_registry(lua_State *L) {
int32_t scriptlib::duel_enable_global_flag(lua_State *L) {
check_param_count(L, 1);
int32_t flag = (int32_t)lua_tointeger(L, 1);
uint32_t flag = (uint32_t)lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->core.global_flag |= flag;
return 0;
......
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