Commit b1cc5c18 authored by nanahira's avatar nanahira Committed by GitHub

Merge branch 'master' into x64

parents 03b59cd0 5dec848b
...@@ -1461,7 +1461,7 @@ int32 card::get_old_union_count() { ...@@ -1461,7 +1461,7 @@ int32 card::get_old_union_count() {
void card::xyz_overlay(card_set* materials) { void card::xyz_overlay(card_set* materials) {
if(materials->size() == 0) if(materials->size() == 0)
return; return;
card_set des; card_set des, leave_grave;
field::card_vector cv; field::card_vector cv;
for(auto& pcard : *materials) for(auto& pcard : *materials)
cv.push_back(pcard); cv.push_back(pcard);
...@@ -1528,9 +1528,18 @@ void card::xyz_overlay(card_set* materials) { ...@@ -1528,9 +1528,18 @@ void card::xyz_overlay(card_set* materials) {
pduel->game_field->add_to_disable_check_list(pcard); pduel->game_field->add_to_disable_check_list(pcard);
} }
xyz_add(pcard); xyz_add(pcard);
if(pcard->previous.location == LOCATION_GRAVE) {
leave_grave.insert(pcard);
pduel->game_field->raise_single_event(pcard, 0, EVENT_LEAVE_GRAVE, pduel->game_field->core.reason_effect, pcard->current.reason, pduel->game_field->core.reason_player, 0, 0);
}
pduel->write_buffer32(pcard->get_info_location()); pduel->write_buffer32(pcard->get_info_location());
pduel->write_buffer32(pcard->current.reason); pduel->write_buffer32(pcard->current.reason);
} }
if(leave_grave.size()) {
pduel->game_field->raise_event(&leave_grave, EVENT_LEAVE_GRAVE, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0);
pduel->game_field->process_single_event();
pduel->game_field->process_instant_event();
}
if(des.size()) if(des.size())
pduel->game_field->destroy(&des, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE); pduel->game_field->destroy(&des, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE);
else else
......
...@@ -481,6 +481,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -481,6 +481,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EVENT_BECOME_TARGET 1028 #define EVENT_BECOME_TARGET 1028
#define EVENT_DESTROYED 1029 #define EVENT_DESTROYED 1029
#define EVENT_MOVE 1030 #define EVENT_MOVE 1030
#define EVENT_LEAVE_GRAVE 1031
#define EVENT_ADJUST 1040 #define EVENT_ADJUST 1040
#define EVENT_BREAK_EFFECT 1050 #define EVENT_BREAK_EFFECT 1050
#define EVENT_SUMMON_SUCCESS 1100 #define EVENT_SUMMON_SUCCESS 1100
......
...@@ -522,7 +522,7 @@ public: ...@@ -522,7 +522,7 @@ public:
int32 check_spself_from_hand_trigger(const chain& ch) const; int32 check_spself_from_hand_trigger(const chain& ch) const;
int32 is_able_to_enter_bp(); int32 is_able_to_enter_bp();
void add_process(uint16 type, uint16 step, effect* peffect, group* target, int32 arg1, int32 arg2, int32 arg3 = 0, int32 arg4 = 0, void* ptr1 = NULL, void* ptr2 = NULL); void add_process(uint16 type, uint16 step, effect* peffect, group* target, int32 arg1, int32 arg2, int32 arg3 = 0, int32 arg4 = 0, void* ptr1 = nullptr, void* ptr2 = nullptr);
int32 process(); int32 process();
int32 execute_cost(uint16 step, effect* peffect, uint8 triggering_player); int32 execute_cost(uint16 step, effect* peffect, uint8 triggering_player);
int32 execute_operation(uint16 step, effect* peffect, uint8 triggering_player); int32 execute_operation(uint16 step, effect* peffect, uint8 triggering_player);
......
...@@ -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 = 3; pduel->game_field->core.duel_rule = 5;
return 0; return 0;
} }
int32 scriptlib::debug_reload_field_end(lua_State *L) { int32 scriptlib::debug_reload_field_end(lua_State *L) {
......
...@@ -1161,14 +1161,14 @@ int32 scriptlib::duel_is_environment(lua_State *L) { ...@@ -1161,14 +1161,14 @@ int32 scriptlib::duel_is_environment(lua_State *L) {
uint32 playerid = PLAYER_ALL; uint32 playerid = PLAYER_ALL;
if(lua_gettop(L) >= 2) if(lua_gettop(L) >= 2)
playerid = (uint32)lua_tointeger(L, 2); playerid = (uint32)lua_tointeger(L, 2);
uint32 loc = LOCATION_FZONE + LOCATION_ONFIELD; uint32 loc = LOCATION_ONFIELD;
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3)
loc = (uint32)lua_tointeger(L, 3); loc = (uint32)lua_tointeger(L, 3);
if(playerid != 0 && playerid != 1 && playerid != PLAYER_ALL) if(playerid != 0 && playerid != 1 && playerid != PLAYER_ALL)
return 0; return 0;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
int32 ret = 0, fc = 0; int32 ret = 0, fc = 0;
if(loc & LOCATION_FZONE) { if(loc & (LOCATION_FZONE + LOCATION_SZONE)) {
card* pcard = pduel->game_field->player[0].list_szone[5]; card* pcard = pduel->game_field->player[0].list_szone[5];
if(pcard && pcard->is_position(POS_FACEUP) && pcard->get_status(STATUS_EFFECT_ENABLED)) { if(pcard && pcard->is_position(POS_FACEUP) && pcard->get_status(STATUS_EFFECT_ENABLED)) {
fc = 1; fc = 1;
...@@ -1210,6 +1210,20 @@ int32 scriptlib::duel_is_environment(lua_State *L) { ...@@ -1210,6 +1210,20 @@ int32 scriptlib::duel_is_environment(lua_State *L) {
} }
} }
} }
if(!ret && (loc & LOCATION_GRAVE)) {
if(playerid == 0 || playerid == PLAYER_ALL) {
for(auto& pcard : pduel->game_field->player[0].list_grave) {
if(code == pcard->get_code())
ret = 1;
}
}
if(playerid == 1 || playerid == PLAYER_ALL) {
for(auto& pcard : pduel->game_field->player[1].list_grave) {
if(code == pcard->get_code())
ret = 1;
}
}
}
if(!fc) { if(!fc) {
effect_set eset; effect_set eset;
pduel->game_field->filter_field_effect(EFFECT_CHANGE_ENVIRONMENT, &eset); pduel->game_field->filter_field_effect(EFFECT_CHANGE_ENVIRONMENT, &eset);
......
...@@ -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 = 3; pd->game_field->core.duel_rule = 5;
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;
......
...@@ -3760,7 +3760,7 @@ int32 field::send_replace(uint16 step, group * targets, card * target) { ...@@ -3760,7 +3760,7 @@ int32 field::send_replace(uint16 step, group * targets, card * target) {
int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint32 reason, uint8 reason_player) { int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint32 reason, uint8 reason_player) {
struct exargs { struct exargs {
group* targets; group* targets;
card_set leave, detach; card_set leave_field, leave_grave, detach;
bool show_decktop[2]; bool show_decktop[2];
card_vector cv; card_vector cv;
card_vector::iterator cvit; card_vector::iterator cvit;
...@@ -3988,7 +3988,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3988,7 +3988,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pcard->reset(RESET_LEAVE, RESET_EVENT); pcard->reset(RESET_LEAVE, RESET_EVENT);
pcard->clear_relate_effect(); pcard->clear_relate_effect();
remove_card(pcard); remove_card(pcard);
param->leave.insert(pcard); param->leave_field.insert(pcard);
++param->cvit; ++param->cvit;
core.units.begin()->step = 4; core.units.begin()->step = 4;
return FALSE; return FALSE;
...@@ -4041,7 +4041,9 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -4041,7 +4041,9 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pcard->previous.location = 0; pcard->previous.location = 0;
} else if(oloc & LOCATION_ONFIELD) { } else if(oloc & LOCATION_ONFIELD) {
pcard->reset(RESET_LEAVE, RESET_EVENT); pcard->reset(RESET_LEAVE, RESET_EVENT);
param->leave.insert(pcard); param->leave_field.insert(pcard);
} else if(oloc == LOCATION_GRAVE) {
param->leave_grave.insert(pcard);
} }
if(pcard->previous.location == LOCATION_OVERLAY) if(pcard->previous.location == LOCATION_OVERLAY)
pcard->previous.controler = control_player; pcard->previous.controler = control_player;
...@@ -4086,7 +4088,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -4086,7 +4088,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
} else if(oloc & LOCATION_ONFIELD) { } else if(oloc & LOCATION_ONFIELD) {
pcard->reset(RESET_LEAVE + RESET_MSCHANGE, RESET_EVENT); pcard->reset(RESET_LEAVE + RESET_MSCHANGE, RESET_EVENT);
pcard->clear_card_target(); pcard->clear_card_target();
param->leave.insert(pcard); param->leave_field.insert(pcard);
} }
if(param->predirect->operation) { if(param->predirect->operation) {
tevent e; tevent e;
...@@ -4145,8 +4147,10 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -4145,8 +4147,10 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
} }
pcard->refresh_disable_status(); pcard->refresh_disable_status();
} }
for(auto& pcard : param->leave) for(auto& pcard : param->leave_field)
raise_single_event(pcard, 0, EVENT_LEAVE_FIELD, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_LEAVE_FIELD, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
for(auto& pcard : param->leave_grave)
raise_single_event(pcard, 0, EVENT_LEAVE_GRAVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size()) { if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size()) {
for(auto& pcard : param->detach) { for(auto& pcard : param->detach) {
if(pcard->current.location & LOCATION_MZONE) if(pcard->current.location & LOCATION_MZONE)
...@@ -4154,8 +4158,10 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -4154,8 +4158,10 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
} }
} }
process_single_event(); process_single_event();
if(param->leave.size()) if(param->leave_field.size())
raise_event(&param->leave, EVENT_LEAVE_FIELD, reason_effect, reason, reason_player, 0, 0); raise_event(&param->leave_field, EVENT_LEAVE_FIELD, reason_effect, reason, reason_player, 0, 0);
if(param->leave_grave.size())
raise_event(&param->leave_grave, EVENT_LEAVE_GRAVE, reason_effect, reason, reason_player, 0, 0);
if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size()) if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size())
raise_event(&param->detach, EVENT_DETACH_MATERIAL, reason_effect, reason, reason_player, 0, 0); raise_event(&param->detach, EVENT_DETACH_MATERIAL, reason_effect, reason, reason_player, 0, 0);
process_instant_event(); process_instant_event();
...@@ -4618,6 +4624,10 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4618,6 +4624,10 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
if(ret == 1 && target->current.location == LOCATION_MZONE && !(target->data.type & TYPE_MONSTER)) if(ret == 1 && target->current.location == LOCATION_MZONE && !(target->data.type & TYPE_MONSTER))
send_to(target, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, 0); send_to(target, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, 0);
else { else {
if(target->previous.location == LOCATION_GRAVE) {
raise_single_event(target, 0, EVENT_LEAVE_GRAVE, target->current.reason_effect, target->current.reason, move_player, 0, 0);
raise_event(target, EVENT_LEAVE_GRAVE, target->current.reason_effect, target->current.reason, move_player, 0, 0);
}
raise_single_event(target, 0, EVENT_MOVE, target->current.reason_effect, target->current.reason, target->current.reason_player, 0, 0); raise_single_event(target, 0, EVENT_MOVE, target->current.reason_effect, target->current.reason, target->current.reason_player, 0, 0);
raise_event(target, EVENT_MOVE, target->current.reason_effect, target->current.reason, target->current.reason_player, 0, 0); raise_event(target, EVENT_MOVE, target->current.reason_effect, target->current.reason, target->current.reason_player, 0, 0);
process_single_event(); process_single_event();
......
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