Commit 567b9ad6 authored by salix5's avatar salix5

fix operation_param

Now operation_param is only used in move_card(), discard_deck().
parent 7f4e9653
...@@ -57,6 +57,12 @@ card::card(duel* pd) { ...@@ -57,6 +57,12 @@ card::card(duel* pd) {
pduel = pd; pduel = pd;
owner = PLAYER_NONE; owner = PLAYER_NONE;
operation_param = 0; operation_param = 0;
release_param = 0;
sum_param = 0;
position_param = 0;
spsummon_param = 0;
to_field_param = 0;
direct_attackable = 0;
summon_info = 0; summon_info = 0;
status = 0; status = 0;
memset(&q_cache, 0xff, sizeof(query_cache)); memset(&q_cache, 0xff, sizeof(query_cache));
...@@ -1698,7 +1704,8 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) { ...@@ -1698,7 +1704,8 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) {
filter_effect(EFFECT_TO_GRAVE_REDIRECT, &es); filter_effect(EFFECT_TO_GRAVE_REDIRECT, &es);
else if(destination == LOCATION_REMOVED) else if(destination == LOCATION_REMOVED)
filter_effect(EFFECT_REMOVE_REDIRECT, &es); filter_effect(EFFECT_REMOVE_REDIRECT, &es);
else return 0; else
return 0;
for(int32 i = 0; i < es.size(); ++i) { for(int32 i = 0; i < es.size(); ++i) {
redirect = es[i]->get_value(this, 0); redirect = es[i]->get_value(this, 0);
if((redirect & LOCATION_HAND) && !is_affected_by_effect(EFFECT_CANNOT_TO_HAND) && pduel->game_field->is_player_can_send_to_hand(current.controler, this)) if((redirect & LOCATION_HAND) && !is_affected_by_effect(EFFECT_CANNOT_TO_HAND) && pduel->game_field->is_player_can_send_to_hand(current.controler, this))
......
...@@ -114,6 +114,8 @@ public: ...@@ -114,6 +114,8 @@ public:
uint32 release_param; uint32 release_param;
uint32 sum_param; uint32 sum_param;
uint32 position_param; uint32 position_param;
uint32 spsummon_param;
uint32 to_field_param;
uint8 direct_attackable; uint8 direct_attackable;
uint8 announce_count; uint8 announce_count;
uint8 attacked_count; uint8 attacked_count;
......
...@@ -145,7 +145,7 @@ void field::reload_field_info() { ...@@ -145,7 +145,7 @@ void field::reload_field_info() {
pduel->write_buffer32(peffect->description); pduel->write_buffer32(peffect->description);
} }
} }
// Debug.AddCard() will call this function directly // The core of moving cards, and Debug.AddCard() will call this function directly.
// check Fusion/S/X monster redirection by the rule, set fieldid_r // check Fusion/S/X monster redirection by the rule, set fieldid_r
void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence) { void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence) {
if (pcard->current.location != 0) if (pcard->current.location != 0)
...@@ -270,8 +270,13 @@ void field::remove_card(card* pcard) { ...@@ -270,8 +270,13 @@ void field::remove_card(card* pcard) {
pcard->current.location = 0; pcard->current.location = 0;
pcard->current.sequence = 0; pcard->current.sequence = 0;
} }
// moving cards:
// 1. draw()
// 2. discard_deck()
// 3. swap_control()
// 4. control_adjust()
// 5. move_card()
// check Fusion/S/X monster redirection by the rule // check Fusion/S/X monster redirection by the rule
// it will call remove_card(), add_card()
void field::move_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence) { void field::move_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence) {
if (!is_location_useable(playerid, location, sequence)) if (!is_location_useable(playerid, location, sequence))
return; return;
......
...@@ -153,7 +153,7 @@ void field::special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, u ...@@ -153,7 +153,7 @@ void field::special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, u
pcard->current.reason = REASON_SPSUMMON; pcard->current.reason = REASON_SPSUMMON;
pcard->current.reason_effect = core.reason_effect; pcard->current.reason_effect = core.reason_effect;
pcard->current.reason_player = core.reason_player; pcard->current.reason_player = core.reason_player;
pcard->operation_param = (playerid << 24) + (nocheck << 16) + (nolimit << 8) + positions; pcard->spsummon_param = (playerid << 24) + (nocheck << 16) + (nolimit << 8) + positions;
} }
group* pgroup = pduel->new_group(*target); group* pgroup = pduel->new_group(*target);
pgroup->is_readonly = TRUE; pgroup->is_readonly = TRUE;
...@@ -170,7 +170,7 @@ void field::special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, ...@@ -170,7 +170,7 @@ void field::special_summon_step(card* target, uint32 sumtype, uint32 sumplayer,
target->current.reason = REASON_SPSUMMON; target->current.reason = REASON_SPSUMMON;
target->current.reason_effect = core.reason_effect; target->current.reason_effect = core.reason_effect;
target->current.reason_player = core.reason_player; target->current.reason_player = core.reason_player;
target->operation_param = (playerid << 24) + (nocheck << 16) + (nolimit << 8) + positions; target->spsummon_param = (playerid << 24) + (nocheck << 16) + (nolimit << 8) + positions;
add_process(PROCESSOR_SPSUMMON_STEP, 0, core.reason_effect, NULL, 0, 0, 0, 0, target); add_process(PROCESSOR_SPSUMMON_STEP, 0, core.reason_effect, NULL, 0, 0, 0, 0, target);
} }
void field::special_summon_complete(effect* reason_effect, uint8 reason_player) { void field::special_summon_complete(effect* reason_effect, uint8 reason_player) {
...@@ -242,7 +242,7 @@ void field::release(card* target, effect* reason_effect, uint32 reason, uint32 r ...@@ -242,7 +242,7 @@ void field::release(card* target, effect* reason_effect, uint32 reason, uint32 r
tset.insert(target); tset.insert(target);
release(&tset, reason_effect, reason, reason_player); release(&tset, reason_effect, reason, reason_player);
} }
// set current.reason and send to locations other than LOCATION_ONFIELD // set current.reason, operation_param
// send-to in scripts: here->PROCESSOR_SENDTO, step 0 // send-to in scripts: here->PROCESSOR_SENDTO, step 0
void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position) { void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position) {
if(destination & LOCATION_ONFIELD) if(destination & LOCATION_ONFIELD)
...@@ -287,7 +287,7 @@ void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uin ...@@ -287,7 +287,7 @@ void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uin
return; return;
if(destination == target->current.location && playerid == target->current.controler) if(destination == target->current.location && playerid == target->current.controler)
return; return;
target->operation_param = (move_player << 24) + (playerid << 16) + (destination << 8) + positions; target->to_field_param = (move_player << 24) + (playerid << 16) + (destination << 8) + positions;
add_process(PROCESSOR_MOVETOFIELD, 0, 0, (group*)target, enable, ret + (is_equip << 8)); add_process(PROCESSOR_MOVETOFIELD, 0, 0, (group*)target, enable, ret + (is_equip << 8));
} }
void field::change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable) { void field::change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable) {
...@@ -2490,10 +2490,10 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui ...@@ -2490,10 +2490,10 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
return TRUE; return TRUE;
} }
int32 field::special_summon_step(uint16 step, group * targets, card * target) { int32 field::special_summon_step(uint16 step, group * targets, card * target) {
uint8 playerid = (target->operation_param >> 24) & 0xf; uint8 playerid = (target->spsummon_param >> 24) & 0xf;
uint8 nocheck = (target->operation_param >> 16) & 0xff; uint8 nocheck = (target->spsummon_param >> 16) & 0xff;
uint8 nolimit = (target->operation_param >> 8) & 0xff; uint8 nolimit = (target->spsummon_param >> 8) & 0xff;
uint8 positions = target->operation_param & 0xff; uint8 positions = target->spsummon_param & 0xff;
switch(step) { switch(step) {
case 0: { case 0: {
returns.ivalue[0] = FALSE; returns.ivalue[0] = FALSE;
...@@ -2803,7 +2803,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2803,7 +2803,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
rep->current.reason = REASON_EFFECT | REASON_DESTROY | REASON_REPLACE; rep->current.reason = REASON_EFFECT | REASON_DESTROY | REASON_REPLACE;
rep->current.reason_effect = 0; rep->current.reason_effect = 0;
rep->current.reason_player = rep->current.controler; rep->current.reason_player = rep->current.controler;
rep->operation_param = (POS_FACEUP << 24) + (((int32)rep->owner) << 16) + (LOCATION_GRAVE << 8); rep->operation_param = (POS_FACEUP << 24) + (((uint32)rep->owner) << 16) + (LOCATION_GRAVE << 8);
targets->container.insert(rep); targets->container.insert(rep);
} }
} }
...@@ -3121,7 +3121,6 @@ int32 field::release(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3121,7 +3121,6 @@ int32 field::release(uint16 step, group * targets, effect * reason_effect, uint3
int32 field::send_to(uint16 step, group * targets, card * target) { int32 field::send_to(uint16 step, group * targets, card * target) {
uint8 playerid = (target->operation_param >> 16) & 0xff; uint8 playerid = (target->operation_param >> 16) & 0xff;
uint8 dest = (target->operation_param >> 8) & 0xff; uint8 dest = (target->operation_param >> 8) & 0xff;
//uint8 seq = (target->operation_param) & 0xff;
if(targets->container.find(target) == targets->container.end()) if(targets->container.find(target) == targets->container.end())
return TRUE; return TRUE;
if(target->current.location == dest && target->current.controler == playerid) { if(target->current.location == dest && target->current.controler == playerid) {
...@@ -3290,7 +3289,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3290,7 +3289,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
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) if(check_cb)
pcard->operation_param = (pcard->operation_param & 0xff0fffff) | (1 << 20); pcard->operation_param = (pcard->operation_param & 0xff0fffff) | (0x1u << 20);
} }
return FALSE; return FALSE;
} }
...@@ -3752,11 +3751,13 @@ int32 field::discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reaso ...@@ -3752,11 +3751,13 @@ int32 field::discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reaso
} }
return TRUE; return TRUE;
} }
// move a card from anywhere to field, including sp_summon, Duel.MoveToField(), Duel.ReturnToField()
// call move_card() in step 2
int32 field::move_to_field(uint16 step, card * target, uint32 enable, uint32 ret, uint32 is_equip) { int32 field::move_to_field(uint16 step, card * target, uint32 enable, uint32 ret, uint32 is_equip) {
uint32 move_player = (target->operation_param >> 24) & 0xff; uint32 move_player = (target->to_field_param >> 24) & 0xff;
uint32 playerid = (target->operation_param >> 16) & 0xff; uint32 playerid = (target->to_field_param >> 16) & 0xff;
uint32 location = (target->operation_param >> 8) & 0xff; uint32 location = (target->to_field_param >> 8) & 0xff;
uint32 positions = (target->operation_param) & 0xff; uint32 positions = (target->to_field_param) & 0xff;
switch(step) { switch(step) {
case 0: { case 0: {
returns.ivalue[0] = FALSE; returns.ivalue[0] = FALSE;
...@@ -3871,6 +3872,7 @@ int32 field::move_to_field(uint16 step, card * target, uint32 enable, uint32 ret ...@@ -3871,6 +3872,7 @@ int32 field::move_to_field(uint16 step, card * target, uint32 enable, uint32 ret
pduel->write_buffer32(target->get_info_location()); pduel->write_buffer32(target->get_info_location());
if(target->overlay_target) if(target->overlay_target)
target->overlay_target->xyz_remove(target); target->overlay_target->xyz_remove(target);
// call move_card()
move_card(playerid, target, location, target->temp.sequence); move_card(playerid, target, location, target->temp.sequence);
target->current.position = returns.ivalue[0]; target->current.position = returns.ivalue[0];
if((target->previous.location & LOCATION_ONFIELD) && (location & LOCATION_ONFIELD)) if((target->previous.location & LOCATION_ONFIELD) && (location & LOCATION_ONFIELD))
......
...@@ -2938,7 +2938,7 @@ int32 field::process_battle_command(uint16 step) { ...@@ -2938,7 +2938,7 @@ int32 field::process_battle_command(uint16 step) {
core.select_cards.clear(); core.select_cards.clear();
auto atype = get_attack_target(core.attacker, &core.select_cards, core.chain_attack); auto atype = get_attack_target(core.attacker, &core.select_cards, core.chain_attack);
// direct attack // direct attack
if(core.attacker->operation_param) { if(core.attacker->direct_attackable) {
if(core.select_cards.size() == 0) { if(core.select_cards.size() == 0) {
returns.ivalue[0] = -2; returns.ivalue[0] = -2;
core.units.begin()->step = 5; core.units.begin()->step = 5;
...@@ -3450,12 +3450,8 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3450,12 +3450,8 @@ int32 field::process_battle_command(uint16 step) {
group* ng = pduel->new_group(); group* ng = pduel->new_group();
ng->container.swap(des); ng->container.swap(des);
ng->is_readonly = TRUE; ng->is_readonly = TRUE;
std::unordered_map<card*, uint32>* card_op_params = new std::unordered_map<card*, uint32>;
for(auto cit = ng->container.begin(); cit != ng->container.end(); ++cit)
card_op_params->insert(std::make_pair(*cit, (*cit)->operation_param));
add_process(PROCESSOR_DESTROY, 10, 0, ng, REASON_BATTLE, PLAYER_NONE); add_process(PROCESSOR_DESTROY, 10, 0, ng, REASON_BATTLE, PLAYER_NONE);
core.units.begin()->ptarget = ng; core.units.begin()->ptarget = ng;
core.units.begin()->ptr1 = card_op_params;
} }
return FALSE; return FALSE;
} }
...@@ -3504,15 +3500,11 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3504,15 +3500,11 @@ int32 field::process_battle_command(uint16 step) {
case 32: { case 32: {
group* des = core.units.begin()->ptarget; group* des = core.units.begin()->ptarget;
if(des) { if(des) {
auto card_op_params = (std::unordered_map<card*, uint32>*)core.units.begin()->ptr1;
for(auto cit = des->container.begin(); cit != des->container.end();) { for(auto cit = des->container.begin(); cit != des->container.end();) {
auto rm = cit++; auto rm = cit++;
(*rm)->operation_param = card_op_params->find((*rm))->second;
if((*rm)->current.location != LOCATION_MZONE || ((*rm)->fieldid_r != core.pre_field[0] && (*rm)->fieldid_r != core.pre_field[1])) if((*rm)->current.location != LOCATION_MZONE || ((*rm)->fieldid_r != core.pre_field[0] && (*rm)->fieldid_r != core.pre_field[1]))
des->container.erase(rm); des->container.erase(rm);
} }
delete card_op_params;
core.units.begin()->ptr1 = 0;
add_process(PROCESSOR_DESTROY, 3, 0, des, REASON_BATTLE, PLAYER_NONE); add_process(PROCESSOR_DESTROY, 3, 0, des, REASON_BATTLE, PLAYER_NONE);
} }
adjust_all(); adjust_all();
...@@ -5093,7 +5085,6 @@ int32 field::adjust_step(uint16 step) { ...@@ -5093,7 +5085,6 @@ int32 field::adjust_step(uint16 step) {
ref = pcard->refresh_control_status(); ref = pcard->refresh_control_status();
if(cur != ref && pcard->is_capable_change_control()) { if(cur != ref && pcard->is_capable_change_control()) {
core.control_adjust_set[p].insert(pcard); core.control_adjust_set[p].insert(pcard);
pcard->operation_param = ref;
} }
} }
} }
......
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