Commit 273f31b2 authored by fallenstardust's avatar fallenstardust

sync ocgcore

parent 305f65ec
This diff is collapsed.
...@@ -23,58 +23,61 @@ class group; ...@@ -23,58 +23,61 @@ class group;
struct chain; struct chain;
struct card_data { struct card_data {
uint32 code; uint32 code{ 0 };
uint32 alias; uint32 alias{ 0 };
uint64 setcode; uint64 setcode{ 0 };
uint32 type; uint32 type{ 0 };
uint32 level; uint32 level{ 0 };
uint32 attribute; uint32 attribute{ 0 };
uint32 race; uint32 race{ 0 };
int32 attack; int32 attack{ 0 };
int32 defense; int32 defense{ 0 };
uint32 lscale; uint32 lscale{ 0 };
uint32 rscale; uint32 rscale{ 0 };
uint32 link_marker; uint32 link_marker{ 0 };
void clear(); void clear();
}; };
struct card_state { struct card_state {
card_state() uint32 code{ 0 };
: code(0), code2(0), type(0), level(0), rank(0), link(0), lscale(0), rscale(0), attribute(0), race(0), attack(0), defense(0), base_attack(0), base_defense(0), uint32 code2{ 0 };
controler(PLAYER_NONE), location(0), sequence(0), position(0), reason(0), pzone(false), reason_card(nullptr), reason_player(PLAYER_NONE), reason_effect(nullptr) {}
uint32 code;
uint32 code2;
std::vector<uint32> setcode; std::vector<uint32> setcode;
uint32 type; uint32 type{ 0 };
uint32 level; uint32 level{ 0 };
uint32 rank; uint32 rank{ 0 };
uint32 link; uint32 link{ 0 };
uint32 lscale; uint32 lscale{ 0 };
uint32 rscale; uint32 rscale{ 0 };
uint32 attribute; uint32 attribute{ 0 };
uint32 race; uint32 race{ 0 };
int32 attack; int32 attack{ 0 };
int32 defense; int32 defense{ 0 };
int32 base_attack; int32 base_attack{ 0 };
int32 base_defense; int32 base_defense{ 0 };
uint8 controler; uint8 controler{ PLAYER_NONE };
uint8 location; uint8 location{ 0 };
uint8 sequence; uint8 sequence{ 0 };
uint8 position; uint8 position{ 0 };
uint32 reason; uint32 reason{ 0 };
bool pzone; bool pzone{ false };
card* reason_card; card* reason_card{ nullptr };
uint8 reason_player; uint8 reason_player{ PLAYER_NONE };
effect* reason_effect; effect* reason_effect{ nullptr };
bool is_location(int32 loc) const; bool is_location(int32 loc) const;
bool is_main_mzone() const {
return location == LOCATION_MZONE && sequence >= 0 && sequence <= 4;
}
bool is_stzone() const {
return location == LOCATION_SZONE && sequence >= 0 && sequence <= 4;
}
void init_state(); void init_state();
}; };
struct query_cache { struct query_cache {
uint32 code; uint32 info_location;
uint32 alias; uint32 current_code;
uint32 type; uint32 type;
uint32 level; uint32 level;
uint32 rank; uint32 rank;
...@@ -94,23 +97,19 @@ struct query_cache { ...@@ -94,23 +97,19 @@ struct query_cache {
struct material_info { struct material_info {
// Synchron // Synchron
card* limit_tuner; card* limit_tuner{ nullptr };
group* limit_syn; group* limit_syn{ nullptr };
int32 limit_syn_minc; int32 limit_syn_minc{ 0 };
int32 limit_syn_maxc; int32 limit_syn_maxc{ 0 };
// Xyz // Xyz
group* limit_xyz; group* limit_xyz{ nullptr };
int32 limit_xyz_minc; int32 limit_xyz_minc{ 0 };
int32 limit_xyz_maxc; int32 limit_xyz_maxc{ 0 };
// Link // Link
group* limit_link; group* limit_link{ nullptr };
card* limit_link_card; card* limit_link_card{ nullptr };
int32 limit_link_minc; int32 limit_link_minc{ 0 };
int32 limit_link_maxc; int32 limit_link_maxc{ 0 };
material_info()
: limit_tuner(nullptr), limit_syn(nullptr), limit_syn_minc(0), limit_syn_maxc(0), limit_xyz(nullptr), limit_xyz_minc(0), limit_xyz_maxc(0),
limit_link(nullptr), limit_link_card(nullptr), limit_link_minc(0), limit_link_maxc(0) {}
}; };
const material_info null_info; const material_info null_info;
...@@ -218,7 +217,7 @@ public: ...@@ -218,7 +217,7 @@ public:
static bool card_operation_sort(card* c1, card* c2); static bool card_operation_sort(card* c1, card* c2);
const bool is_extra_deck_monster() { return !!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)); } const bool is_extra_deck_monster() { return !!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)); }
uint32 get_infos(byte* buf, int32 query_flag, int32 use_cache = TRUE); int32 get_infos(byte* buf, uint32 query_flag, int32 use_cache = TRUE);
uint32 get_info_location(); uint32 get_info_location();
uint32 second_code(uint32 code); uint32 second_code(uint32 code);
uint32 get_code(); uint32 get_code();
......
...@@ -37,6 +37,8 @@ struct card_sort { ...@@ -37,6 +37,8 @@ struct card_sort {
bool operator()(void* const & c1, void* const & c2) const; bool operator()(void* const & c1, void* const & c2) const;
}; };
#define CURRENT_RULE 5
//Locations //Locations
#define LOCATION_DECK 0x01 // #define LOCATION_DECK 0x01 //
#define LOCATION_HAND 0x02 // #define LOCATION_HAND 0x02 //
...@@ -166,6 +168,8 @@ struct card_sort { ...@@ -166,6 +168,8 @@ struct card_sort {
#define REASON_LINK 0x10000000 // #define REASON_LINK 0x10000000 //
#define REASON_LOST_OVERLAY 0x20000000 // #define REASON_LOST_OVERLAY 0x20000000 //
#define REASONS_PROCEDURE (REASON_SYNCHRO | REASON_XYZ | REASON_LINK)
//Status //Status
#define STATUS_DISABLED 0x0001 // #define STATUS_DISABLED 0x0001 //
#define STATUS_TO_ENABLE 0x0002 // #define STATUS_TO_ENABLE 0x0002 //
......
...@@ -136,7 +136,9 @@ int32 effect::is_available(int32 neglect_disabled) { ...@@ -136,7 +136,9 @@ int32 effect::is_available(int32 neglect_disabled) {
return FALSE; return FALSE;
if(!phandler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY)) if(!phandler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))
return FALSE; return FALSE;
if((phandler->current.location & LOCATION_ONFIELD) && !phandler->is_position(POS_FACEUP)) if (phandler->current.is_location(LOCATION_ONFIELD) && !phandler->is_position(POS_FACEUP))
return FALSE;
if (phandler->current.is_stzone() && (phandler->data.type & (TYPE_SPELL | TYPE_TRAP)) && phandler->is_affected_by_effect(EFFECT_CHANGE_TYPE))
return FALSE; return FALSE;
if(is_flag(EFFECT_FLAG_OWNER_RELATE) && is_can_be_forbidden() && powner->is_status(STATUS_FORBIDDEN)) if(is_flag(EFFECT_FLAG_OWNER_RELATE) && is_can_be_forbidden() && powner->is_status(STATUS_FORBIDDEN))
return FALSE; return FALSE;
...@@ -302,8 +304,6 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -302,8 +304,6 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
card* phandler = get_handler(); card* phandler = get_handler();
if(!(phandler->get_type() & TYPE_MONSTER) && (get_active_type() & TYPE_MONSTER)) if(!(phandler->get_type() & TYPE_MONSTER) && (get_active_type() & TYPE_MONSTER))
return FALSE; return FALSE;
if((phandler->get_type() & TYPE_CONTINUOUS) && (phandler->get_type() & TYPE_EQUIP))
return FALSE;
if((type & EFFECT_TYPE_QUICK_O) && is_flag(EFFECT_FLAG_DELAY) && !in_range(phandler)) if((type & EFFECT_TYPE_QUICK_O) && is_flag(EFFECT_FLAG_DELAY) && !in_range(phandler))
return FALSE; return FALSE;
if(!neglect_faceup && (phandler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))) { if(!neglect_faceup && (phandler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))) {
...@@ -327,6 +327,8 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -327,6 +327,8 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
if((type & EFFECT_TYPE_FIELD) && !(range & (LOCATION_DECK | LOCATION_EXTRA))) if((type & EFFECT_TYPE_FIELD) && !(range & (LOCATION_DECK | LOCATION_EXTRA)))
return FALSE; return FALSE;
} }
if (phandler->current.is_stzone() && (phandler->data.type & (TYPE_SPELL|TYPE_TRAP)) && phandler->is_affected_by_effect(EFFECT_CHANGE_TYPE))
return FALSE;
if((type & EFFECT_TYPE_FIELD) && (phandler->current.controler != playerid) && !is_flag(EFFECT_FLAG_BOTH_SIDE | EFFECT_FLAG_EVENT_PLAYER)) if((type & EFFECT_TYPE_FIELD) && (phandler->current.controler != playerid) && !is_flag(EFFECT_FLAG_BOTH_SIDE | EFFECT_FLAG_EVENT_PLAYER))
return FALSE; return FALSE;
if(phandler->is_status(STATUS_FORBIDDEN)) if(phandler->is_status(STATUS_FORBIDDEN))
...@@ -337,7 +339,8 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -337,7 +339,8 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
card* phandler = get_handler(); card* phandler = get_handler();
if((type & EFFECT_TYPE_FIELD) && phandler->is_status(STATUS_BATTLE_DESTROYED)) if((type & EFFECT_TYPE_FIELD) && phandler->is_status(STATUS_BATTLE_DESTROYED))
return FALSE; return FALSE;
if(((type & EFFECT_TYPE_FIELD) || ((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE))) && (phandler->current.location & LOCATION_ONFIELD) if(((type & EFFECT_TYPE_FIELD) || ((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE)))
&& (phandler->current.location & LOCATION_ONFIELD)
&& (!phandler->is_position(POS_FACEUP) || !phandler->is_status(STATUS_EFFECT_ENABLED))) && (!phandler->is_position(POS_FACEUP) || !phandler->is_status(STATUS_EFFECT_ENABLED)))
return FALSE; return FALSE;
if((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE) && !in_range(phandler)) if((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE) && !in_range(phandler))
...@@ -640,7 +643,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) { ...@@ -640,7 +643,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
uint8 tp = handler->pduel->game_field->infos.turn_player; uint8 tp = handler->pduel->game_field->infos.turn_player;
if((((reset_flag & RESET_SELF_TURN) && pid == tp) || ((reset_flag & RESET_OPPO_TURN) && pid != tp)) if((((reset_flag & RESET_SELF_TURN) && pid == tp) || ((reset_flag & RESET_OPPO_TURN) && pid != tp))
&& (reset_level & 0x3ff & reset_flag)) && (reset_level & 0x3ff & reset_flag))
reset_count--; --reset_count;
if(reset_count == 0) if(reset_count == 0)
return TRUE; return TRUE;
return FALSE; return FALSE;
......
...@@ -28,12 +28,12 @@ struct effect_set { ...@@ -28,12 +28,12 @@ struct effect_set {
if(index >= count) if(index >= count)
return; return;
if(index == count - 1) { if(index == count - 1) {
count--; --count;
return; return;
} }
for(int i = index; i < count - 1; ++i) for(int i = index; i < count - 1; ++i)
container[i] = container[i + 1]; container[i] = container[i + 1];
count--; --count;
} }
void clear() { void clear() {
count = 0; count = 0;
......
This diff is collapsed.
This diff is collapsed.
...@@ -10,21 +10,15 @@ ...@@ -10,21 +10,15 @@
#include "duel.h" #include "duel.h"
group::group(duel* pd) { group::group(duel* pd) {
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
group::group(duel* pd, card* pcard) { group::group(duel* pd, card* pcard) {
container.insert(pcard); container.insert(pcard);
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
group::group(duel* pd, const card_set& cset): container(cset) { group::group(duel* pd, const card_set& cset): container(cset) {
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
...@@ -18,13 +18,14 @@ class duel; ...@@ -18,13 +18,14 @@ class duel;
class group { class group {
public: public:
using card_set = std::set<card*, card_sort>; using card_set = std::set<card*, card_sort>;
int32 ref_handle;
duel* pduel; duel* pduel;
card_set container; card_set container;
card_set::iterator it; card_set::iterator it;
uint32 is_readonly; int32 ref_handle{ 0 };
uint32 is_readonly{ 0 };
bool is_iterator_dirty{ true };
inline bool has_card(card* c) { bool has_card(card* c) {
return container.find(c) != container.end(); return container.find(c) != container.end();
} }
......
...@@ -127,16 +127,16 @@ int32 interpreter::load_script(const char* script_name) { ...@@ -127,16 +127,16 @@ int32 interpreter::load_script(const char* script_name) {
byte* buffer = read_script(script_name, &len); byte* buffer = read_script(script_name, &len);
if (!buffer) if (!buffer)
return OPERATION_FAIL; return OPERATION_FAIL;
no_action++; ++no_action;
int32 error = luaL_loadbuffer(current_state, (char*)buffer, len, script_name) || lua_pcall(current_state, 0, 0, 0); int32 error = luaL_loadbuffer(current_state, (char*)buffer, len, script_name) || lua_pcall(current_state, 0, 0, 0);
if (error) { if (error) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action--; --no_action;
return OPERATION_SUCCESS; return OPERATION_SUCCESS;
} }
int32 interpreter::load_card_script(uint32 code) { int32 interpreter::load_card_script(uint32 code) {
...@@ -243,7 +243,7 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) { ...@@ -243,7 +243,7 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) {
break; break;
} }
} }
pushed++; ++pushed;
} }
params.clear(); params.clear();
} }
...@@ -268,23 +268,23 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) { ...@@ -268,23 +268,23 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) {
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action++; ++no_action;
call_depth++; ++call_depth;
push_param(current_state); push_param(current_state);
if (lua_pcall(current_state, param_count, ret_count, 0)) { if (lua_pcall(current_state, param_count, ret_count, 0)) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -308,24 +308,24 @@ int32 interpreter::call_card_function(card* pcard, const char* f, uint32 param_c ...@@ -308,24 +308,24 @@ int32 interpreter::call_card_function(card* pcard, const char* f, uint32 param_c
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action++; ++no_action;
call_depth++; ++call_depth;
lua_remove(current_state, -2); lua_remove(current_state, -2);
push_param(current_state); push_param(current_state);
if (lua_pcall(current_state, param_count, ret_count, 0)) { if (lua_pcall(current_state, param_count, ret_count, 0)) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -350,23 +350,23 @@ int32 interpreter::call_code_function(uint32 code, const char* f, uint32 param_c ...@@ -350,23 +350,23 @@ int32 interpreter::call_code_function(uint32 code, const char* f, uint32 param_c
return OPERATION_FAIL; return OPERATION_FAIL;
} }
lua_remove(current_state, -2); lua_remove(current_state, -2);
no_action++; ++no_action;
call_depth++; ++call_depth;
push_param(current_state); push_param(current_state);
if (lua_pcall(current_state, param_count, ret_count, 0)) { if (lua_pcall(current_state, param_count, ret_count, 0)) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return OPERATION_FAIL; return OPERATION_FAIL;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -378,21 +378,21 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) { ...@@ -378,21 +378,21 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
params.clear(); params.clear();
return TRUE; return TRUE;
} }
no_action++; ++no_action;
call_depth++; ++call_depth;
if (call_function(f, param_count, 1)) { if (call_function(f, param_count, 1)) {
int32 result = lua_toboolean(current_state, -1); int32 result = lua_toboolean(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return result; return result;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -402,8 +402,8 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) { ...@@ -402,8 +402,8 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
if(!findex || lua_isnil(current_state, findex)) if(!findex || lua_isnil(current_state, findex))
return TRUE; return TRUE;
no_action++; ++no_action;
call_depth++; ++call_depth;
luaL_checkstack(current_state, 1 + extraargs, NULL); luaL_checkstack(current_state, 1 + extraargs, NULL);
lua_pushvalue(current_state, findex); lua_pushvalue(current_state, findex);
interpreter::card2value(current_state, pcard); interpreter::card2value(current_state, pcard);
...@@ -413,8 +413,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { ...@@ -413,8 +413,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -423,8 +423,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { ...@@ -423,8 +423,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
} }
int32 result = lua_toboolean(current_state, -1); int32 result = lua_toboolean(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -434,8 +434,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) { ...@@ -434,8 +434,8 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraargs) { int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraargs) {
if(!findex || lua_isnil(current_state, findex)) if(!findex || lua_isnil(current_state, findex))
return 0; return 0;
no_action++; ++no_action;
call_depth++; ++call_depth;
luaL_checkstack(current_state, 1 + extraargs, NULL); luaL_checkstack(current_state, 1 + extraargs, NULL);
lua_pushvalue(current_state, findex); lua_pushvalue(current_state, findex);
interpreter::card2value(current_state, pcard); interpreter::card2value(current_state, pcard);
...@@ -445,8 +445,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg ...@@ -445,8 +445,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1)); sprintf(pduel->strbuffer, "%s", lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -455,8 +455,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg ...@@ -455,8 +455,8 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
} }
int32 result = lua_isinteger(current_state, -1) ? (int32)lua_tointeger(current_state, -1) : (int32)lua_tonumber(current_state, -1); int32 result = lua_isinteger(current_state, -1) ? (int32)lua_tointeger(current_state, -1) : (int32)lua_tonumber(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -468,8 +468,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) { ...@@ -468,8 +468,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
params.clear(); params.clear();
return 0; return 0;
} }
no_action++; ++no_action;
call_depth++; ++call_depth;
if (call_function(f, param_count, 1)) { if (call_function(f, param_count, 1)) {
int32 result = 0; int32 result = 0;
if(lua_isboolean(current_state, -1)) if(lua_isboolean(current_state, -1))
...@@ -479,16 +479,16 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) { ...@@ -479,16 +479,16 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
else else
result = (int32)lua_tonumber(current_state, -1); result = (int32)lua_tonumber(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
} }
return result; return result;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -502,8 +502,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i ...@@ -502,8 +502,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
return is_success; return is_success;
} }
int32 stack_top = lua_gettop(current_state); int32 stack_top = lua_gettop(current_state);
no_action++; ++no_action;
call_depth++; ++call_depth;
if (call_function(f, param_count, LUA_MULTRET)) { if (call_function(f, param_count, LUA_MULTRET)) {
int32 stack_newtop = lua_gettop(current_state); int32 stack_newtop = lua_gettop(current_state);
for (int32 index = stack_top + 1; index <= stack_newtop; ++index) { for (int32 index = stack_top + 1; index <= stack_newtop; ++index) {
...@@ -519,8 +519,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i ...@@ -519,8 +519,8 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
lua_settop(current_state, stack_top); lua_settop(current_state, stack_top);
is_success = OPERATION_SUCCESS; is_success = OPERATION_SUCCESS;
} }
no_action--; --no_action;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -552,7 +552,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -552,7 +552,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
params.clear(); params.clear();
return OPERATION_FAIL; return OPERATION_FAIL;
} }
call_depth++; ++call_depth;
coroutines.emplace(f, rthread); coroutines.emplace(f, rthread);
} else { } else {
rthread = it->second; rthread = it->second;
...@@ -560,7 +560,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -560,7 +560,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
sprintf(pduel->strbuffer, "recursive event trigger detected."); sprintf(pduel->strbuffer, "recursive event trigger detected.");
handle_message(pduel, 1); handle_message(pduel, 1);
params.clear(); params.clear();
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -589,7 +589,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -589,7 +589,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
*yield_value = (uint32)lua_tointeger(rthread, -1); *yield_value = (uint32)lua_tointeger(rthread, -1);
} }
current_state = lua_state; current_state = lua_state;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
...@@ -603,7 +603,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -603,7 +603,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
handle_message(pduel, 1); handle_message(pduel, 1);
lua_pop(rthread, 1); lua_pop(rthread, 1);
current_state = lua_state; current_state = lua_state;
call_depth--; --call_depth;
if(call_depth == 0) { if(call_depth == 0) {
pduel->release_script_group(); pduel->release_script_group();
pduel->restore_assumes(); pduel->restore_assumes();
......
...@@ -68,7 +68,7 @@ int32 scriptlib::card_get_fusion_code(lua_State *L) { ...@@ -68,7 +68,7 @@ int32 scriptlib::card_get_fusion_code(lua_State *L) {
uint32 otcode = pcard->get_another_code(); uint32 otcode = pcard->get_another_code();
if(otcode) { if(otcode) {
lua_pushinteger(L, otcode); lua_pushinteger(L, otcode);
count++; ++count;
} }
if(pcard->pduel->game_field->core.not_material) if(pcard->pduel->game_field->core.not_material)
return count; return count;
...@@ -87,7 +87,7 @@ int32 scriptlib::card_get_link_code(lua_State *L) { ...@@ -87,7 +87,7 @@ int32 scriptlib::card_get_link_code(lua_State *L) {
uint32 otcode = pcard->get_another_code(); uint32 otcode = pcard->get_another_code();
if(otcode) { if(otcode) {
lua_pushinteger(L, otcode); lua_pushinteger(L, otcode);
count++; ++count;
} }
effect_set eset; effect_set eset;
pcard->filter_effect(EFFECT_ADD_LINK_CODE, &eset); pcard->filter_effect(EFFECT_ADD_LINK_CODE, &eset);
...@@ -1629,7 +1629,7 @@ int32 scriptlib::card_get_activate_effect(lua_State *L) { ...@@ -1629,7 +1629,7 @@ int32 scriptlib::card_get_activate_effect(lua_State *L) {
for(auto& eit : pcard->field_effect) { for(auto& eit : pcard->field_effect) {
if(eit.second->type & EFFECT_TYPE_ACTIVATE) { if(eit.second->type & EFFECT_TYPE_ACTIVATE) {
interpreter::effect2value(L, eit.second); interpreter::effect2value(L, eit.second);
count++; ++count;
} }
} }
return count; return count;
...@@ -1783,7 +1783,7 @@ int32 scriptlib::card_is_has_effect(lua_State *L) { ...@@ -1783,7 +1783,7 @@ int32 scriptlib::card_is_has_effect(lua_State *L) {
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
if(check_player == PLAYER_NONE || eset[i]->check_count_limit(check_player)) { if(check_player == PLAYER_NONE || eset[i]->check_count_limit(check_player)) {
interpreter::effect2value(L, eset[i]); interpreter::effect2value(L, eset[i]);
size++; ++size;
} }
} }
if(!size) { if(!size) {
...@@ -2409,7 +2409,6 @@ int32 scriptlib::card_is_releasable(lua_State *L) { ...@@ -2409,7 +2409,6 @@ int32 scriptlib::card_is_releasable(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
pcard->current.reason |= REASON_COST;
uint32 p = pcard->pduel->game_field->core.reason_player; uint32 p = pcard->pduel->game_field->core.reason_player;
if(pcard->is_releasable_by_nonsummon(p)) if(pcard->is_releasable_by_nonsummon(p))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
...@@ -2421,7 +2420,6 @@ int32 scriptlib::card_is_releasable_by_effect(lua_State *L) { ...@@ -2421,7 +2420,6 @@ int32 scriptlib::card_is_releasable_by_effect(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
pcard->current.reason |= REASON_EFFECT; pcard->current.reason &= ~REASON_COST;
uint32 p = pcard->pduel->game_field->core.reason_player; uint32 p = pcard->pduel->game_field->core.reason_player;
effect* re = pcard->pduel->game_field->core.reason_effect; effect* re = pcard->pduel->game_field->core.reason_effect;
if(pcard->is_releasable_by_nonsummon(p) && pcard->is_releasable_by_effect(p, re)) if(pcard->is_releasable_by_nonsummon(p) && pcard->is_releasable_by_effect(p, re))
......
...@@ -152,7 +152,7 @@ int32 scriptlib::debug_reload_field_begin(lua_State *L) { ...@@ -152,7 +152,7 @@ int32 scriptlib::debug_reload_field_begin(lua_State *L) {
else if (flag & DUEL_OBSOLETE_RULING) else if (flag & DUEL_OBSOLETE_RULING)
pduel->game_field->core.duel_rule = 1; pduel->game_field->core.duel_rule = 1;
else else
pduel->game_field->core.duel_rule = 5; pduel->game_field->core.duel_rule = CURRENT_RULE;
return 0; return 0;
} }
int32 scriptlib::debug_reload_field_end(lua_State *L) { int32 scriptlib::debug_reload_field_end(lua_State *L) {
......
This diff is collapsed.
...@@ -574,7 +574,7 @@ int32 scriptlib::effect_use_count_limit(lua_State *L) { ...@@ -574,7 +574,7 @@ int32 scriptlib::effect_use_count_limit(lua_State *L) {
if (!oath_only || code & EFFECT_COUNT_CODE_OATH) if (!oath_only || code & EFFECT_COUNT_CODE_OATH)
while(count) { while(count) {
peffect->dec_count(p); peffect->dec_count(p);
count--; --count;
} }
return 0; return 0;
} }
......
...@@ -46,6 +46,7 @@ int32 scriptlib::group_delete(lua_State *L) { ...@@ -46,6 +46,7 @@ int32 scriptlib::group_delete(lua_State *L) {
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
if(pgroup->is_readonly != 2) if(pgroup->is_readonly != 2)
return 0; return 0;
pgroup->is_iterator_dirty = true;
pgroup->is_readonly = 0; pgroup->is_readonly = 0;
pduel->sgroups.insert(pgroup); pduel->sgroups.insert(pgroup);
return 0; return 0;
...@@ -66,6 +67,7 @@ int32 scriptlib::group_clear(lua_State *L) { ...@@ -66,6 +67,7 @@ int32 scriptlib::group_clear(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
if (pgroup->is_readonly != 1) { if (pgroup->is_readonly != 1) {
pgroup->is_iterator_dirty = true;
pgroup->container.clear(); pgroup->container.clear();
} }
return 0; return 0;
...@@ -77,6 +79,7 @@ int32 scriptlib::group_add_card(lua_State *L) { ...@@ -77,6 +79,7 @@ int32 scriptlib::group_add_card(lua_State *L) {
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
card* pcard = *(card**) lua_touserdata(L, 2); card* pcard = *(card**) lua_touserdata(L, 2);
if (pgroup->is_readonly != 1) { if (pgroup->is_readonly != 1) {
pgroup->is_iterator_dirty = true;
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
return 0; return 0;
...@@ -88,6 +91,7 @@ int32 scriptlib::group_remove_card(lua_State *L) { ...@@ -88,6 +91,7 @@ int32 scriptlib::group_remove_card(lua_State *L) {
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
card* pcard = *(card**) lua_touserdata(L, 2); card* pcard = *(card**) lua_touserdata(L, 2);
if (pgroup->is_readonly != 1) { if (pgroup->is_readonly != 1) {
pgroup->is_iterator_dirty = true;
pgroup->container.erase(pcard); pgroup->container.erase(pcard);
} }
return 0; return 0;
...@@ -96,6 +100,9 @@ int32 scriptlib::group_get_next(lua_State *L) { ...@@ -96,6 +100,9 @@ int32 scriptlib::group_get_next(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
if (pgroup->is_iterator_dirty) {
return luaL_error(L, "Called Group.GetNext without calling Group.GetFirst first.");
}
if(pgroup->it == pgroup->container.end()) if(pgroup->it == pgroup->container.end())
lua_pushnil(L); lua_pushnil(L);
else { else {
...@@ -111,6 +118,7 @@ int32 scriptlib::group_get_first(lua_State *L) { ...@@ -111,6 +118,7 @@ int32 scriptlib::group_get_first(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
pgroup->is_iterator_dirty = false;
if (pgroup->container.size()) { if (pgroup->container.size()) {
pgroup->it = pgroup->container.begin(); pgroup->it = pgroup->container.begin();
interpreter::card2value(L, (*(pgroup->it))); interpreter::card2value(L, (*(pgroup->it)));
...@@ -185,7 +193,7 @@ int32 scriptlib::group_filter_count(lua_State *L) { ...@@ -185,7 +193,7 @@ int32 scriptlib::group_filter_count(lua_State *L) {
uint32 count = 0; uint32 count = 0;
for (auto& pcard : cset) { for (auto& pcard : cset) {
if(pduel->lua->check_matching(pcard, 2, extraargs)) if(pduel->lua->check_matching(pcard, 2, extraargs))
count++; ++count;
} }
lua_pushinteger(L, count); lua_pushinteger(L, count);
return 1; return 1;
...@@ -387,7 +395,7 @@ int32 scriptlib::group_is_exists(lua_State *L) { ...@@ -387,7 +395,7 @@ int32 scriptlib::group_is_exists(lua_State *L) {
uint32 result = FALSE; uint32 result = FALSE;
for (auto& pcard : cset) { for (auto& pcard : cset) {
if(pduel->lua->check_matching(pcard, 2, extraargs)) { if(pduel->lua->check_matching(pcard, 2, extraargs)) {
fcount++; ++fcount;
if(fcount >= count) { if(fcount >= count) {
result = TRUE; result = TRUE;
break; break;
...@@ -637,11 +645,13 @@ int32 scriptlib::group_remove(lua_State *L) { ...@@ -637,11 +645,13 @@ int32 scriptlib::group_remove(lua_State *L) {
uint32 extraargs = lua_gettop(L) - 3; uint32 extraargs = lua_gettop(L) - 3;
if(pgroup->is_readonly == 1) if(pgroup->is_readonly == 1)
return 0; return 0;
pgroup->is_iterator_dirty = true;
for (auto cit = pgroup->container.begin(); cit != pgroup->container.end();) { for (auto cit = pgroup->container.begin(); cit != pgroup->container.end();) {
auto rm = cit++; if((*cit) != pexception && pduel->lua->check_matching(*cit, 2, extraargs)) {
if((*rm) != pexception && pduel->lua->check_matching(*rm, 2, extraargs)) { cit = pgroup->container.erase(cit);
pgroup->container.erase(rm);
} }
else
++cit;
} }
return 0; return 0;
} }
...@@ -653,6 +663,7 @@ int32 scriptlib::group_merge(lua_State *L) { ...@@ -653,6 +663,7 @@ int32 scriptlib::group_merge(lua_State *L) {
group* mgroup = *(group**) lua_touserdata(L, 2); group* mgroup = *(group**) lua_touserdata(L, 2);
if(pgroup->is_readonly == 1) if(pgroup->is_readonly == 1)
return 0; return 0;
pgroup->is_iterator_dirty = true;
pgroup->container.insert(mgroup->container.begin(), mgroup->container.end()); pgroup->container.insert(mgroup->container.begin(), mgroup->container.end());
return 0; return 0;
} }
...@@ -664,6 +675,7 @@ int32 scriptlib::group_sub(lua_State *L) { ...@@ -664,6 +675,7 @@ int32 scriptlib::group_sub(lua_State *L) {
group* sgroup = *(group**) lua_touserdata(L, 2); group* sgroup = *(group**) lua_touserdata(L, 2);
if(pgroup->is_readonly == 1) if(pgroup->is_readonly == 1)
return 0; return 0;
pgroup->is_iterator_dirty = true;
for (auto& pcard : sgroup->container) { for (auto& pcard : sgroup->container) {
pgroup->container.erase(pcard); pgroup->container.erase(pcard);
} }
...@@ -730,7 +742,7 @@ int32 scriptlib::group_get_bin_class_count(lua_State *L) { ...@@ -730,7 +742,7 @@ int32 scriptlib::group_get_bin_class_count(lua_State *L) {
int32 ans = 0; int32 ans = 0;
while(er) { while(er) {
er &= er - 1; er &= er - 1;
ans++; ++ans;
} }
lua_pushinteger(L, ans); lua_pushinteger(L, ans);
return 1; return 1;
......
...@@ -72,7 +72,7 @@ extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, int32 options) { ...@@ -72,7 +72,7 @@ extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, int32 options) {
else if(options & DUEL_OBSOLETE_RULING) //provide backward compatibility with replay else if(options & DUEL_OBSOLETE_RULING) //provide backward compatibility with replay
pd->game_field->core.duel_rule = 1; pd->game_field->core.duel_rule = 1;
else if(!pd->game_field->core.duel_rule) else if(!pd->game_field->core.duel_rule)
pd->game_field->core.duel_rule = 5; pd->game_field->core.duel_rule = CURRENT_RULE;
pd->game_field->core.shuffle_hand_check[0] = FALSE; pd->game_field->core.shuffle_hand_check[0] = FALSE;
pd->game_field->core.shuffle_hand_check[1] = FALSE; pd->game_field->core.shuffle_hand_check[1] = FALSE;
pd->game_field->core.shuffle_deck_check[0] = FALSE; pd->game_field->core.shuffle_deck_check[0] = FALSE;
...@@ -223,20 +223,22 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid ...@@ -223,20 +223,22 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid
if(location == LOCATION_DECK) if(location == LOCATION_DECK)
return (int32)player.list_main.size(); return (int32)player.list_main.size();
if(location == LOCATION_MZONE) { if(location == LOCATION_MZONE) {
uint32 count = 0; int32 count = 0;
for(auto& pcard : player.list_mzone) for(auto& pcard : player.list_mzone)
if(pcard) count++; if(pcard)
++count;
return count; return count;
} }
if(location == LOCATION_SZONE) { if(location == LOCATION_SZONE) {
uint32 count = 0; int32 count = 0;
for(auto& pcard : player.list_szone) for(auto& pcard : player.list_szone)
if(pcard) count++; if(pcard)
++count;
return count; return count;
} }
return 0; return 0;
} }
extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache) { extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, uint32 query_flag, byte* buf, int32 use_cache) {
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
duel* ptduel = (duel*)pduel; duel* ptduel = (duel*)pduel;
...@@ -245,7 +247,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, ...@@ -245,7 +247,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
if(location == LOCATION_MZONE) { if(location == LOCATION_MZONE) {
for(auto& pcard : player.list_mzone) { for(auto& pcard : player.list_mzone) {
if(pcard) { if(pcard) {
uint32 clen = pcard->get_infos(p, query_flag, use_cache); int32 clen = pcard->get_infos(p, query_flag, use_cache);
p += clen; p += clen;
} else { } else {
*((int32*)p) = 4; *((int32*)p) = 4;
...@@ -256,7 +258,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, ...@@ -256,7 +258,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
else if(location == LOCATION_SZONE) { else if(location == LOCATION_SZONE) {
for(auto& pcard : player.list_szone) { for(auto& pcard : player.list_szone) {
if(pcard) { if(pcard) {
uint32 clen = pcard->get_infos(p, query_flag, use_cache); int32 clen = pcard->get_infos(p, query_flag, use_cache);
p += clen; p += clen;
} else { } else {
*((int32*)p) = 4; *((int32*)p) = 4;
...@@ -279,7 +281,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, ...@@ -279,7 +281,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
else else
return 0; return 0;
for(auto& pcard : *lst) { for(auto& pcard : *lst) {
uint32 clen = pcard->get_infos(p, query_flag, use_cache); int32 clen = pcard->get_infos(p, query_flag, use_cache);
p += clen; p += clen;
} }
} }
......
...@@ -46,7 +46,7 @@ extern "C" DECL_DLLEXPORT void new_card(intptr_t pduel, uint32 code, uint8 owner ...@@ -46,7 +46,7 @@ extern "C" DECL_DLLEXPORT void new_card(intptr_t pduel, uint32 code, uint8 owner
extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32 code, uint8 owner, uint8 location); extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32 code, uint8 owner, uint8 location);
extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache); extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location); extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location);
extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache); extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, uint32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf); extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT void set_responsei(intptr_t pduel, int32 value); extern "C" DECL_DLLEXPORT void set_responsei(intptr_t pduel, int32 value);
extern "C" DECL_DLLEXPORT void set_responseb(intptr_t pduel, byte* buf); extern "C" DECL_DLLEXPORT void set_responseb(intptr_t pduel, byte* buf);
......
This diff is collapsed.
...@@ -755,7 +755,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa ...@@ -755,7 +755,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa
int32 scount = 0; int32 scount = 0;
for(int32 ft = 0x1; ft < (1 << RACES_COUNT); ft <<= 1) { for(int32 ft = 0x1; ft < (1 << RACES_COUNT); ft <<= 1) {
if(ft & available) if(ft & available)
scount++; ++scount;
} }
if(scount <= count) { if(scount <= count) {
count = scount; count = scount;
...@@ -775,7 +775,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa ...@@ -775,7 +775,7 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
sel++; ++sel;
} }
if(sel != count) { if(sel != count) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
...@@ -794,7 +794,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a ...@@ -794,7 +794,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a
int32 scount = 0; int32 scount = 0;
for(int32 ft = 0x1; ft != 0x80; ft <<= 1) { for(int32 ft = 0x1; ft != 0x80; ft <<= 1) {
if(ft & available) if(ft & available)
scount++; ++scount;
} }
if(scount <= count) { if(scount <= count) {
count = scount; count = scount;
...@@ -814,7 +814,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a ...@@ -814,7 +814,7 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
sel++; ++sel;
} }
if(sel != count) { if(sel != count) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
......
This diff is collapsed.
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class scriptlib { class scriptlib {
public: public:
static int32 check_param(lua_State* L, int32 param_type, int32 index, BOOL retfalse = FALSE); static int32 check_param(lua_State* L, int32 param_type, int32 index, int32 retfalse = FALSE);
static int32 check_param_count(lua_State* L, int32 count); static int32 check_param_count(lua_State* L, int32 count);
static int32 check_action_permission(lua_State* L); static int32 check_action_permission(lua_State* L);
......
--[[message
更新:2023-03-26
卡数:12
规则:新大师
简介:不容小觑的似羊动物~~~
]]
--By OURYGO-YGO EZ manager
Debug.SetAIName("顽雨沉风")
Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN+DUEL_PSEUDO_SHUFFLE+DUEL_SIMPLE_AI,5)
Debug.SetPlayerInfo(0,500,0,0)
Debug.SetPlayerInfo(1,30000,0,0)
local c=Debug.AddCard(55948544,1,1,LOCATION_EXTRA,0,POS_FACEUP_ATTACK)
local n=0
function print_hand(e,tp,eg,ep,ev,re,r,rp)
local ac=Duel.AnnounceCard(tp)
local c=Duel.CreateToken(tp,ac)
if n<2 then
Duel.SendtoHand(c,nil,REASON_RULE)
Duel.ShuffleHand(tp)
n=n+1
else
if n==10 then
Debug.ShowHint("印卡过多,审判降临!")
Duel.SetLP(0,0)
else
n=n+1
Duel.Remove(c,POS_FACEUP,REASON_RULE)
Duel.SendtoDeck(c,tp,0,REASON_RULE)
end
end
end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_BOTH_SIDE)
e1:SetRange(LOCATION_EXTRA)
e1:SetOperation(print_hand)
c:RegisterEffect(e1)
Debug.AddCard(14558127,1,1,LOCATION_HAND,0,POS_FACEDOWN)
local
m1=Debug.AddCard(65403020,0,0,LOCATION_MZONE,2,POS_FACEUP_ATTACK)
Debug.AddCard(67441435,0,0,LOCATION_GRAVE,0,POS_FACEUP_ATTACK)
Debug.AddCard(81035362,0,0,LOCATION_MZONE,1,POS_FACEUP_ATTACK)
Debug.AddCard(86099788,1,1,LOCATION_MZONE,4,POS_FACEUP_ATTACK)
Debug.AddCard(11366199,1,1,LOCATION_MZONE,3,POS_FACEUP_ATTACK)
Debug.AddCard(41147577,1,1,LOCATION_MZONE,2,POS_FACEUP_ATTACK)
Debug.AddCard(26268488,1,1,LOCATION_MZONE,1,POS_FACEUP_ATTACK)
Debug.AddCard(17016362,1,1,LOCATION_MZONE,0,POS_FACEUP_ATTACK)
local
s1=Debug.AddCard(19508728,0,0,LOCATION_SZONE,2,POS_FACEUP)
Debug.PreEquip(s1,m1)
Debug.AddCard(68462976,1,1,LOCATION_SZONE,5,POS_FACEUP)
Debug.ReloadFieldEnd()
Debug.ShowHint("这是一个印卡残局,点击对方额外卡组可以发动《法老的审判》打印任意卡")
Debug.ShowHint("只能打印2张卡到手卡,其他8张卡片将被添加到主卡组或额外卡组。")
aux.BeginPuzzle()
--[[message
更新:2023-03-26
卡数:17
规则:新大师
]]
--created by puzzle editor
Debug.SetAIName("蛋总")
Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN+DUEL_SIMPLE_AI,5)
Debug.SetPlayerInfo(0,100,0,0)
Debug.SetPlayerInfo(1,16150,0,0)
--自己的怪兽区
Debug.AddCard(14878871,0,0,LOCATION_MZONE,2,POS_FACEUP_ATTACK) --救援猫
--对方的怪兽区
Debug.AddCard(23995346,1,1,LOCATION_MZONE,1,POS_FACEUP_ATTACK) --究极龙骑士
Debug.AddCard(23995346,1,1,LOCATION_MZONE,2,POS_FACEUP_ATTACK) --究极龙骑士
Debug.AddCard(23995346,1,1,LOCATION_MZONE,3,POS_FACEUP_ATTACK) --究极龙骑士
--自己的魔陷区
--对方的魔陷区
Debug.AddCard(77859858,1,1,LOCATION_SZONE,1,POS_FACEDOWN_ATTACK) --步向破灭的速攻抽卡
--自己的手卡
--对方的手卡
--自己的墓地
Debug.AddCard(96930127,0,0,LOCATION_GRAVE,0,POS_FACEUP_ATTACK) --链犬
Debug.AddCard(96930127,0,0,LOCATION_GRAVE,0,POS_FACEUP_ATTACK) --链犬
Debug.AddCard(96930127,0,0,LOCATION_GRAVE,0,POS_FACEUP_ATTACK) --链犬
--对方的墓地
--自己除外的卡
--对方除外的卡
--自己的卡组
Debug.AddCard(49374988,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK) --魔偶甜点·枫糖浆绵羊
Debug.AddCard(34680482,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK) --魔偶甜点·果冻天使
Debug.AddCard(91350799,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK) --魔偶甜点·热香饼猫头鹰
--自己的额外
Debug.AddCard(95169481,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --恐牙狼 钻石恐狼
Debug.AddCard(95169481,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --恐牙狼 钻石恐狼
Debug.AddCard(80764541,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --No.44 白天马
Debug.AddCard(82633039,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --鸟铳士 卡斯泰尔
Debug.AddCard(80796456,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --No.70 大罪蛛
Debug.AddCard(16195942,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --暗叛逆超量龙
Debug.AddCard(67598234,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --电影之骑士 盖亚剑士
Debug.AddCard(3987233,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --金毛妇
Debug.AddCard(3987233,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --金毛妇
Debug.AddCard(79016563,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --二进制女巫
Debug.ReloadFieldEnd()
aux.BeginPuzzle()
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE_START+PHASE_END)
e1:SetCondition(function(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==0 end)
e1:SetOperation(function(e,tp,eg,ep,ev,re,r,rp)
Debug.ShowHint("提示:金毛妇") end)
Duel.RegisterEffect(e1,0)
--[[message
更新:2023-03-27
卡数:17
规则:新大师
]]
Debug.SetAIName("QB20180206音响电子界")
Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN+DUEL_PSEUDO_SHUFFLE+DUEL_SIMPLE_AI,5)
Debug.SetPlayerInfo(0,100,0,0)
Debug.SetPlayerInfo(1,8500,0,0)
--自己的怪兽区
Debug.AddCard(11801343,0,0,LOCATION_MZONE,1,POS_FACEUP_ATTACK) --垃圾收集员
Debug.AddCard(50366775,0,0,LOCATION_MZONE,2,POS_FACEUP_ATTACK) --格式弹涂鱼
Debug.AddCard(15341821,0,0,LOCATION_MZONE,3,POS_FACEUP_ATTACK) --蒲公英狮
--对方的怪兽区
Debug.AddCard(30532390,1,1,LOCATION_MZONE,0,POS_FACEUP_DEFENSE) --隆隆隆石人
Debug.AddCard(8508055,1,1,LOCATION_MZONE,1,POS_FACEUP_DEFENSE) --时钟共鸣者
Debug.AddCard(65623423,1,1,LOCATION_MZONE,2,POS_FACEUP_DEFENSE) --暗黑共鸣者
--自己的魔陷区
--对方的魔陷区
--自己的手卡
Debug.AddCard(12525049,0,0,LOCATION_HAND,4,POS_FACEUP_ATTACK) --音响战士 吉他手
Debug.AddCard(31826057,0,0,LOCATION_HAND,2,POS_FACEUP_ATTACK) --音响战士 钢琴
Debug.AddCard(68933343,0,0,LOCATION_HAND,3,POS_FACEUP_ATTACK) --音响战士 贝司手
Debug.AddCard(43583400,0,0,LOCATION_HAND,1,POS_FACEUP_ATTACK) --抗锯齿星人
Debug.AddCard(49919798,0,0,LOCATION_HAND,5,POS_FACEUP_ATTACK) --音响战士 合成器
--对方的手卡
--自己的墓地
--对方的墓地
--自己除外的卡
--对方除外的卡
--自己的卡组
Debug.AddCard(94331452,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK) --音响战士 架子鼓
Debug.AddCard(5399521,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK) --音响战士 麦克风
Debug.AddCard(34492631,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK) --废品巨人
Debug.AddCard(7445307,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK) --双汇编亚龙
Debug.AddCard(15066114,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK) --分段龙
--对方的卡组
--自己的额外
Debug.AddCard(22423493,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --机壳守护神 路径灵
Debug.AddCard(61665245,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --召唤女巫
Debug.AddCard(70902743,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --红莲魔龙
Debug.AddCard(64880894,0,0,LOCATION_EXTRA,0,POS_FACEDOWN_ATTACK) --星尘充能战士
Debug.ReloadFieldEnd()
aux.BeginPuzzle()
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE_START+PHASE_END)
e1:SetCondition(function(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==0 end)
e1:SetOperation(function(e,tp,eg,ep,ev,re,r,rp)
Debug.ShowHint("提示:蒲公英狮") end)
Duel.RegisterEffect(e1,0)
--[[message
更新:2023-03-26
卡数:14
规则:大师2020
]]
--By OURYGO-Office
Debug.SetAIName("顽雨沉风")
Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN+DUEL_SIMPLE_AI+DUEL_PSEUDO_SHUFFLE,5)
Debug.SetPlayerInfo(0,8000,0,0)
Debug.SetPlayerInfo(1,11600,0,0)
Debug.AddCard(35659410,0,0,LOCATION_HAND,0,POS_FACEUP_ATTACK)
Debug.AddCard(38517737,0,0,LOCATION_HAND,0,POS_FACEUP_ATTACK)
Debug.AddCard(66961194,0,0,LOCATION_HAND,0,POS_FACEUP_ATTACK)
Debug.AddCard(08240199,0,0,LOCATION_HAND,0,POS_FACEUP_ATTACK)
Debug.AddCard(53318263,1,1,LOCATION_HAND,0,POS_FACEUP_ATTACK)
local g13=Debug.AddCard(6740720,1,1,LOCATION_MZONE,3,POS_FACEUP_ATTACK)
local g11=Debug.AddCard(6740720,1,1,LOCATION_MZONE,1,POS_FACEUP_ATTACK)
local m02=Debug.AddCard(41620959,0,0,LOCATION_SZONE,2,POS_FACEDOWN)
Debug.AddCard(17751597,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK)
Debug.AddCard(25451383,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK)
Debug.AddCard(71039903,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK)
Debug.AddCard(30576089,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK)
Debug.AddCard(89631139,0,0,LOCATION_DECK,0,POS_FACEUP_ATTACK)
Debug.AddCard(72378329,0,0,LOCATION_EXTRA,0,POS_FACEDOWN)Debug.AddCard(70534340,0,0,LOCATION_EXTRA,0,POS_FACEDOWN)Debug.AddCard(03322931,0,0,LOCATION_EXTRA,0,POS_FACEDOWN)Debug.AddCard(34995106,0,0,LOCATION_GRAVE,0,POS_FACEUP)Debug.ReloadFieldEnd()
Debug.ShowHint("在这个回合取得胜利!")
aux.BeginPuzzle()
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