Commit aa9d7d5c authored by VanillaSalt's avatar VanillaSalt

fix

parent cf202a65
...@@ -291,6 +291,7 @@ public: ...@@ -291,6 +291,7 @@ public:
#define EFFECT_CHANGE_RSCALE 137 // #define EFFECT_CHANGE_RSCALE 137 //
#define EFFECT_SET_POSITION 140 // #define EFFECT_SET_POSITION 140 //
#define EFFECT_SELF_DESTROY 141 // #define EFFECT_SELF_DESTROY 141 //
#define EFFECT_SELF_TOGRAVE 142
#define EFFECT_DOUBLE_TRIBUTE 150 #define EFFECT_DOUBLE_TRIBUTE 150
#define EFFECT_DECREASE_TRIBUTE 151 #define EFFECT_DECREASE_TRIBUTE 151
#define EFFECT_DECREASE_TRIBUTE_SET 152 #define EFFECT_DECREASE_TRIBUTE_SET 152
...@@ -368,6 +369,7 @@ public: ...@@ -368,6 +369,7 @@ public:
#define EFFECT_SYNCHRO_CHECK 310 #define EFFECT_SYNCHRO_CHECK 310
#define EFFECT_QP_ACT_IN_NTPHAND 311 #define EFFECT_QP_ACT_IN_NTPHAND 311
#define EFFECT_MUST_BE_SMATERIAL 312 #define EFFECT_MUST_BE_SMATERIAL 312
#define EFFECT_TO_GRAVE_REDIRECT_CB 313
#define EFFECT_SPSUMMON_PROC_G 320 #define EFFECT_SPSUMMON_PROC_G 320
#define EFFECT_SUMMON_COUNT_LIMIT 330 #define EFFECT_SUMMON_COUNT_LIMIT 330
#define EFFECT_SPSUMMON_COUNT_LIMIT 331 #define EFFECT_SPSUMMON_COUNT_LIMIT 331
......
...@@ -2774,6 +2774,14 @@ int32 field::send_to(uint16 step, group * targets, card * target) { ...@@ -2774,6 +2774,14 @@ int32 field::send_to(uint16 step, group * targets, card * target) {
return TRUE; return TRUE;
} }
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 {
group* targets;
card_set leave, discard, detach;
bool show_decktop[2];
card_vector cv;
card_vector::iterator cvit;
effect* predirect;
} ;
switch(step) { switch(step) {
case 0: { case 0: {
uint8 dest; uint8 dest;
...@@ -2860,7 +2868,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2860,7 +2868,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
return FALSE; return FALSE;
} }
case 3: { case 3: {
uint32 redirect, dest, redirect_seq; uint32 dest, redirect, redirect_seq, check_cb;
for(auto cit = targets->container.begin(); cit != targets->container.end(); ++cit) for(auto cit = targets->container.begin(); cit != targets->container.end(); ++cit)
(*cit)->enable_field_effect(FALSE); (*cit)->enable_field_effect(FALSE);
adjust_instant(); adjust_instant();
...@@ -2869,6 +2877,9 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2869,6 +2877,9 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
dest = (pcard->operation_param >> 8) & 0xff; dest = (pcard->operation_param >> 8) & 0xff;
redirect = 0; redirect = 0;
redirect_seq = 0; redirect_seq = 0;
check_cb = 0;
if((dest & LOCATION_GRAVE) && pcard->is_affected_by_effect(EFFECT_TO_GRAVE_REDIRECT_CB))
check_cb = 1;
if((pcard->current.location & LOCATION_ONFIELD) && !pcard->is_status(STATUS_SUMMON_DISABLED)) { if((pcard->current.location & LOCATION_ONFIELD) && !pcard->is_status(STATUS_SUMMON_DISABLED)) {
redirect = pcard->leave_field_redirect(pcard->current.reason); redirect = pcard->leave_field_redirect(pcard->current.reason);
redirect_seq = redirect >> 16; redirect_seq = redirect >> 16;
...@@ -2889,21 +2900,25 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2889,21 +2900,25 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pcard->current.reason |= REASON_REDIRECT; pcard->current.reason |= REASON_REDIRECT;
pcard->operation_param = (pcard->operation_param & 0xffff0000) | (redirect << 8) | redirect_seq; pcard->operation_param = (pcard->operation_param & 0xffff0000) | (redirect << 8) | redirect_seq;
} }
if(check_cb)
pcard->operation_param = (pcard->operation_param & 0xff0fffff) | (1 << 20);
} }
return FALSE; return FALSE;
} }
case 4: { case 4: {
card_set leave, discard, detach; exargs *param = new exargs;
uint8 oloc, playerid, dest, seq; core.units.begin()->ptarget = (group*)param;
bool show_decktop[2] = {false, false}; param->targets = targets;
card_vector cv(targets->container.begin(), targets->container.end()); param->show_decktop[0] = false;
if(cv.size() > 1) param->show_decktop[1] = false;
std::sort(cv.begin(), cv.end(), card::card_operation_sort); param->cv.assign(targets->container.begin(), targets->container.end());
if(param->cv.size() > 1)
std::sort(param->cv.begin(), param->cv.end(), card::card_operation_sort);
if(core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) { if(core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) {
int32 d0 = player[0].list_main.size() - 1, s0 = d0; int32 d0 = player[0].list_main.size() - 1, s0 = d0;
int32 d1 = player[1].list_main.size() - 1, s1 = d1; int32 d1 = player[1].list_main.size() - 1, s1 = d1;
for(uint32 i = 0; i < cv.size(); ++i) { for(uint32 i = 0; i < param->cv.size(); ++i) {
card* pcard = cv[i]; card* pcard = param->cv[i];
if(pcard->current.location != LOCATION_DECK) if(pcard->current.location != LOCATION_DECK)
continue; continue;
if((pcard->current.controler == 0) && (pcard->current.sequence == s0)) if((pcard->current.controler == 0) && (pcard->current.sequence == s0))
...@@ -2936,79 +2951,156 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2936,79 +2951,156 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
} }
} }
} }
for (auto cvit = cv.begin(); cvit != cv.end(); ++cvit) { param->cvit = param->cv.begin();
card* pcard = *cvit; return FALSE;
oloc = pcard->current.location; }
playerid = (pcard->operation_param >> 16) & 0xff; case 5: {
dest = (pcard->operation_param >> 8) & 0xff; exargs *param = (exargs*)targets;
seq = (pcard->operation_param) & 0xff; if(param->cvit == param->cv.end()) {
pcard->enable_field_effect(FALSE); core.units.begin()->step = 8;
if(pcard->data.type & TYPE_TOKEN) { return FALSE;
pduel->write_buffer8(MSG_MOVE); }
pduel->write_buffer32(pcard->data.code); card* pcard = *param->cvit;
pduel->write_buffer8(pcard->current.controler); param->predirect = 0;
pduel->write_buffer8(pcard->current.location); uint32 check_cb = (pcard->operation_param >> 20) & 0xf;
pduel->write_buffer8(pcard->current.sequence); if(check_cb)
pduel->write_buffer8(pcard->current.position); param->predirect = pcard->is_affected_by_effect(EFFECT_TO_GRAVE_REDIRECT_CB);
pduel->write_buffer8(0); pcard->enable_field_effect(FALSE);
pduel->write_buffer8(0); if(pcard->data.type & TYPE_TOKEN) {
pduel->write_buffer8(0); pduel->write_buffer8(MSG_MOVE);
pduel->write_buffer8(0); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer32(pcard->current.reason); pduel->write_buffer8(pcard->current.controler);
pcard->previous.controler = pcard->current.controler; pduel->write_buffer8(pcard->current.location);
pcard->previous.location = pcard->current.location; pduel->write_buffer8(pcard->current.sequence);
pcard->previous.sequence = pcard->current.sequence; pduel->write_buffer8(pcard->current.position);
pcard->previous.position = pcard->current.position; pduel->write_buffer8(0);
pcard->current.reason &= ~REASON_TEMPORARY; pduel->write_buffer8(0);
pcard->fieldid = infos.field_id++; pduel->write_buffer8(0);
pcard->reset(RESET_LEAVE, RESET_EVENT); pduel->write_buffer8(0);
pcard->relate_effect.clear(); pduel->write_buffer32(pcard->current.reason);
remove_card(pcard); pcard->previous.controler = pcard->current.controler;
leave.insert(pcard); pcard->previous.location = pcard->current.location;
continue; pcard->previous.sequence = pcard->current.sequence;
} pcard->previous.position = pcard->current.position;
if(dest == LOCATION_GRAVE) { pcard->current.reason &= ~REASON_TEMPORARY;
core.hint_timing[pcard->current.controler] |= TIMING_TOGRAVE; pcard->fieldid = infos.field_id++;
} else if(dest == LOCATION_HAND) { pcard->reset(RESET_LEAVE, RESET_EVENT);
pcard->set_status(STATUS_PROC_COMPLETE, FALSE); pcard->relate_effect.clear();
core.hint_timing[pcard->current.controler] |= TIMING_TOHAND; remove_card(pcard);
} else if(dest == LOCATION_DECK) { param->leave.insert(pcard);
pcard->set_status(STATUS_PROC_COMPLETE, FALSE); ++param->cvit;
core.hint_timing[pcard->current.controler] |= TIMING_TODECK; core.units.begin()->step = 4;
} else if(dest == LOCATION_REMOVED) { return FALSE;
core.hint_timing[pcard->current.controler] |= TIMING_REMOVE; }
} if(param->predirect && get_useable_count(pcard->current.controler, LOCATION_SZONE, pcard->current.controler, LOCATION_REASON_TOFIELD) > 0)
if(pcard->current.controler != playerid || pcard->current.location != dest) { add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)pcard, pcard->current.controler, 0);
pduel->write_buffer8(MSG_MOVE); else
pduel->write_buffer32(pcard->data.code); returns.ivalue[0] = 0;
pduel->write_buffer32(pcard->get_info_location()); return FALSE;
if(pcard->overlay_target) { }
detach.insert(pcard->overlay_target); case 6: {
pcard->overlay_target->xyz_remove(pcard); if(returns.ivalue[0])
} return FALSE;
move_card(playerid, pcard, dest, seq); exargs *param = (exargs*)targets;
pcard->current.position = (pcard->operation_param >> 24); card* pcard = *param->cvit;
pduel->write_buffer32(pcard->get_info_location()); uint8 oloc = pcard->current.location;
pduel->write_buffer32(pcard->current.reason); uint8 playerid = (pcard->operation_param >> 16) & 0xf;
} uint8 dest = (pcard->operation_param >> 8) & 0xff;
if((core.deck_reversed && pcard->current.location == LOCATION_DECK) || (pcard->current.position == POS_FACEUP_DEFENCE)) uint8 seq = (pcard->operation_param) & 0xff;
show_decktop[pcard->current.controler] = true; if(dest == LOCATION_GRAVE) {
pcard->set_status(STATUS_LEAVE_CONFIRMED, FALSE); core.hint_timing[pcard->current.controler] |= TIMING_TOGRAVE;
if(pcard->status & (STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED)) { } else if(dest == LOCATION_HAND) {
pcard->set_status(STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED, FALSE); pcard->set_status(STATUS_PROC_COMPLETE, FALSE);
pcard->previous.location = 0; core.hint_timing[pcard->current.controler] |= TIMING_TOHAND;
} else if(oloc & LOCATION_ONFIELD) { } else if(dest == LOCATION_DECK) {
pcard->reset(RESET_LEAVE, RESET_EVENT); pcard->set_status(STATUS_PROC_COMPLETE, FALSE);
raise_single_event(pcard, 0, EVENT_LEAVE_FIELD, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); core.hint_timing[pcard->current.controler] |= TIMING_TODECK;
leave.insert(pcard); } else if(dest == LOCATION_REMOVED) {
} core.hint_timing[pcard->current.controler] |= TIMING_REMOVE;
if(pcard->current.reason & REASON_DISCARD) { }
raise_single_event(pcard, 0, EVENT_DISCARD, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); if(pcard->current.controler != playerid || pcard->current.location != dest) {
discard.insert(pcard); pduel->write_buffer8(MSG_MOVE);
pduel->write_buffer32(pcard->data.code);
pduel->write_buffer32(pcard->get_info_location());
if(pcard->overlay_target) {
param->detach.insert(pcard->overlay_target);
pcard->overlay_target->xyz_remove(pcard);
} }
move_card(playerid, pcard, dest, seq);
pcard->current.position = (pcard->operation_param >> 24);
pduel->write_buffer32(pcard->get_info_location());
pduel->write_buffer32(pcard->current.reason);
} }
if((core.deck_reversed && pcard->current.location == LOCATION_DECK) || (pcard->current.position == POS_FACEUP_DEFENCE))
param->show_decktop[pcard->current.controler] = true;
pcard->set_status(STATUS_LEAVE_CONFIRMED, FALSE);
if(pcard->status & (STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED)) {
pcard->set_status(STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED, FALSE);
pcard->previous.location = 0;
} else if(oloc & LOCATION_ONFIELD) {
pcard->reset(RESET_LEAVE, RESET_EVENT);
param->leave.insert(pcard);
}
if(pcard->current.reason & REASON_DISCARD)
param->discard.insert(pcard);
++param->cvit;
core.units.begin()->step = 4;
return FALSE;
}
case 7: {
exargs *param = (exargs*)targets;
card* pcard = *param->cvit;
uint32 flag;
get_useable_count(pcard->current.controler, LOCATION_SZONE, pcard->current.controler, LOCATION_REASON_TOFIELD, &flag);
flag = ((flag << 8) & 0xff00) | 0xffffe0ff;
add_process(PROCESSOR_SELECT_PLACE, 0, 0, 0, 0x10000 + pcard->current.controler, flag);
return FALSE;
}
case 8: {
exargs *param = (exargs*)targets;
card* pcard = *param->cvit;
uint8 oloc = pcard->current.location;
uint8 seq = returns.bvalue[2];
pduel->write_buffer8(MSG_MOVE);
pduel->write_buffer32(pcard->data.code);
pduel->write_buffer32(pcard->get_info_location());
if(pcard->overlay_target) {
param->detach.insert(pcard->overlay_target);
pcard->overlay_target->xyz_remove(pcard);
}
move_card(pcard->current.controler, pcard, LOCATION_SZONE, seq);
pcard->current.position = POS_FACEUP;
pduel->write_buffer32(pcard->get_info_location());
pduel->write_buffer32(pcard->current.reason);
pcard->set_status(STATUS_LEAVE_CONFIRMED, FALSE);
if(pcard->status & (STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED)) {
pcard->set_status(STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED, FALSE);
pcard->previous.location = 0;
} else if(oloc & LOCATION_ONFIELD) {
pcard->reset(RESET_LEAVE, RESET_EVENT);
param->leave.insert(pcard);
}
if(pcard->current.reason & REASON_DISCARD)
param->discard.insert(pcard);
if(param->predirect->operation) {
tevent e;
e.event_cards = targets;
e.event_player = pcard->current.controler;
e.event_value = 0;
e.reason = pcard->current.reason;
e.reason_effect = reason_effect;
e.reason_player = pcard->current.controler;
core.sub_solving_event.push_back(e);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, param->predirect, 0, pcard->current.controler, 0);
}
++param->cvit;
core.units.begin()->step = 4;
return FALSE;
}
case 9: {
exargs *param = (exargs*)targets;
if(core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) { if(core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) {
if(show_decktop[0]) { if(param->show_decktop[0]) {
card* ptop = *player[0].list_main.rbegin(); card* ptop = *player[0].list_main.rbegin();
pduel->write_buffer8(MSG_DECK_TOP); pduel->write_buffer8(MSG_DECK_TOP);
pduel->write_buffer8(0); pduel->write_buffer8(0);
...@@ -3018,7 +3110,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3018,7 +3110,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
else else
pduel->write_buffer32(ptop->data.code | 0x80000000); pduel->write_buffer32(ptop->data.code | 0x80000000);
} }
if(show_decktop[1]) { if(param->show_decktop[1]) {
card* ptop = *player[1].list_main.rbegin(); card* ptop = *player[1].list_main.rbegin();
pduel->write_buffer8(MSG_DECK_TOP); pduel->write_buffer8(MSG_DECK_TOP);
pduel->write_buffer8(1); pduel->write_buffer8(1);
...@@ -3029,24 +3121,32 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3029,24 +3121,32 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pduel->write_buffer32(ptop->data.code | 0x80000000); pduel->write_buffer32(ptop->data.code | 0x80000000);
} }
} }
if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && detach.size()) { for(auto iter = param->leave.begin(); iter != param->leave.end(); ++iter)
for(auto iter = detach.begin(); iter != detach.end(); ++iter) { raise_single_event(*iter, 0, EVENT_LEAVE_FIELD, (*iter)->current.reason_effect, (*iter)->current.reason, (*iter)->current.reason_player, 0, 0);
for(auto iter = param->discard.begin(); iter != param->discard.end(); ++iter)
raise_single_event(*iter, 0, EVENT_DISCARD, (*iter)->current.reason_effect, (*iter)->current.reason, (*iter)->current.reason_player, 0, 0);
if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size()) {
for(auto iter = param->detach.begin(); iter != param->detach.end(); ++iter) {
if((*iter)->current.location & LOCATION_MZONE) if((*iter)->current.location & LOCATION_MZONE)
raise_single_event(*iter, 0, EVENT_DETACH_MATERIAL, reason_effect, reason, reason_player, 0, 0); raise_single_event(*iter, 0, EVENT_DETACH_MATERIAL, reason_effect, reason, reason_player, 0, 0);
} }
} }
adjust_instant(); adjust_instant();
process_single_event(); process_single_event();
if(leave.size()) if(param->leave.size())
raise_event(&leave, EVENT_LEAVE_FIELD, reason_effect, reason, reason_player, 0, 0); raise_event(&param->leave, EVENT_LEAVE_FIELD, reason_effect, reason, reason_player, 0, 0);
if(discard.size()) if(param->discard.size())
raise_event(&discard, EVENT_DISCARD, reason_effect, reason, reason_player, 0, 0); raise_event(&param->discard, EVENT_DISCARD, reason_effect, reason, reason_player, 0, 0);
if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && detach.size()) if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size())
raise_event(&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();
return FALSE; return FALSE;
} }
case 5: { case 10: {
exargs *param = (exargs*)targets;
core.units.begin()->ptarget = param->targets;
targets = param->targets;
delete param;
uint8 nloc; uint8 nloc;
card_set tohand, todeck, tograve, remove, released, destroyed; card_set tohand, todeck, tograve, remove, released, destroyed;
card_set equipings, overlays; card_set equipings, overlays;
...@@ -3068,15 +3168,15 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3068,15 +3168,15 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
if(nloc == LOCATION_HAND) { if(nloc == LOCATION_HAND) {
tohand.insert(pcard); tohand.insert(pcard);
pcard->reset(RESET_TOHAND, RESET_EVENT); pcard->reset(RESET_TOHAND, RESET_EVENT);
raise_single_event(*cit, 0, EVENT_TO_HAND, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_TO_HAND, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} else if(nloc == LOCATION_DECK || nloc == LOCATION_EXTRA) { } else if(nloc == LOCATION_DECK || nloc == LOCATION_EXTRA) {
todeck.insert(pcard); todeck.insert(pcard);
pcard->reset(RESET_TODECK, RESET_EVENT); pcard->reset(RESET_TODECK, RESET_EVENT);
raise_single_event(*cit, 0, EVENT_TO_DECK, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_TO_DECK, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} else if(nloc == LOCATION_GRAVE) { } else if(nloc == LOCATION_GRAVE) {
tograve.insert(pcard); tograve.insert(pcard);
pcard->reset(RESET_TOGRAVE, RESET_EVENT); pcard->reset(RESET_TOGRAVE, RESET_EVENT);
raise_single_event(*cit, 0, EVENT_TO_GRAVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_TO_GRAVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} }
} }
if(nloc == LOCATION_REMOVED || ((pcard->data.type & TYPE_TOKEN) && ((pcard->operation_param >> 8) & 0xff) == LOCATION_REMOVED)) { if(nloc == LOCATION_REMOVED || ((pcard->data.type & TYPE_TOKEN) && ((pcard->operation_param >> 8) & 0xff) == LOCATION_REMOVED)) {
...@@ -3121,7 +3221,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3121,7 +3221,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
adjust_instant(); adjust_instant();
return FALSE; return FALSE;
} }
case 6: { case 11: {
core.operated_set.clear(); core.operated_set.clear();
core.operated_set = targets->container; core.operated_set = targets->container;
returns.ivalue[0] = targets->container.size(); returns.ivalue[0] = targets->container.size();
......
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