Commit d15a0b1c authored by fallenstardust's avatar fallenstardust

sync ocgcore

parent 50f20805
......@@ -15,6 +15,7 @@ namespace irr {
}
namespace ygo {
constexpr int MAX_STRING_ID = 0x7ff;
constexpr uint32_t MIN_CARD_ID = (uint32_t)(MAX_STRING_ID + 1) >> 4;
constexpr uint32_t MAX_CARD_ID = 0x0fffffffU;
......
......@@ -8,20 +8,21 @@
#include "config.h"
namespace ygo {
constexpr int DECK_MAX_SIZE = 60;
constexpr int DECK_MIN_SIZE = 40;
constexpr int EXTRA_MAX_SIZE = 15;
constexpr int SIDE_MAX_SIZE = 15;
constexpr int PACK_MAX_SIZE = 1000;
constexpr int MAINC_MAX = 250; // the limit of card_state
constexpr int SIDEC_MAX = MAINC_MAX;
constexpr int DECK_MAX_SIZE = 60;
constexpr int DECK_MIN_SIZE = 40;
constexpr int EXTRA_MAX_SIZE = 15;
constexpr int SIDE_MAX_SIZE = 15;
constexpr int PACK_MAX_SIZE = 1000;
constexpr int DECK_CATEGORY_PACK = 0;
constexpr int DECK_CATEGORY_BOT = 1;
constexpr int DECK_CATEGORY_NONE = 2;
constexpr int DECK_CATEGORY_SEPARATOR = 3;
constexpr int DECK_CATEGORY_CUSTOM = 4;
constexpr int MAINC_MAX = 250; // the limit of card_state
constexpr int SIDEC_MAX = MAINC_MAX;
constexpr int DECK_CATEGORY_PACK = 0;
constexpr int DECK_CATEGORY_BOT = 1;
constexpr int DECK_CATEGORY_NONE = 2;
constexpr int DECK_CATEGORY_SEPARATOR = 3;
constexpr int DECK_CATEGORY_CUSTOM = 4;
struct LFList {
unsigned int hash{};
......
......@@ -14,8 +14,9 @@
#define check_trivially_copyable(T) static_assert(std::is_trivially_copyable<T>::value == true && std::is_standard_layout<T>::value == true, "not trivially copyable")
namespace ygo {
constexpr int SIZE_NETWORK_BUFFER = 0x20000;
constexpr int MAX_DATA_SIZE = UINT16_MAX - 1;
constexpr int SIZE_NETWORK_BUFFER = 0x20000;
constexpr int MAX_DATA_SIZE = UINT16_MAX - 1;
struct HostInfo {
uint32_t lflist{};
......
......@@ -2624,6 +2624,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,7 +14,8 @@
#include "ocgapi.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) {
lua_state = luaL_newstate();
current_state = lua_state;
std::memcpy(lua_getextraspace(lua_state), &pd, LUA_EXTRASPACE); //set_duel_info
......@@ -139,7 +140,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)
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);
......
......@@ -50,6 +50,7 @@ public:
coroutine_map coroutines;
int32_t no_action{};
int32_t call_depth{};
bool enable_unsafe_feature{};
explicit interpreter(duel* pd, bool enable_unsafe_libraries);
~interpreter();
......
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