Commit ca04a9a0 authored by VanillaSalt's avatar VanillaSalt

replace status==STATUS_IS_PUBLIC with position==POS_FACEUP (introduced from ygopro2)

parent 70b98b61
......@@ -179,7 +179,7 @@ uint32 card::get_infos(byte* buf, int32 query_flag, int32 use_cache) {
query_flag &= ~QUERY_IS_DISABLED;
}
if(query_flag & QUERY_IS_PUBLIC)
*p++ = (status & STATUS_IS_PUBLIC) ? 1 : 0;
*p++ = is_position(POS_FACEUP) ? 1 : 0;
if(!use_cache) {
if(query_flag & QUERY_LSCALE) q_cache.lscale = *p++ = get_lscale();
if(query_flag & QUERY_RSCALE) q_cache.rscale = *p++ = get_rscale();
......
......@@ -404,7 +404,7 @@ public:
#define STATUS_ACTIVATED 0x800000
#define STATUS_JUST_POS 0x1000000
#define STATUS_CONTINUOUS_POS 0x2000000
#define STATUS_IS_PUBLIC 0x4000000
//#define STATUS_IS_PUBLIC 0x4000000
#define STATUS_ACT_FROM_HAND 0x8000000
#define STATUS_OPPO_BATTLE 0x10000000
#define STATUS_FLIP_SUMMON_TURN 0x20000000
......
......@@ -157,15 +157,17 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence
pcard->current.controler = playerid;
pcard->current.location = location;
switch (location) {
case LOCATION_MZONE:
case LOCATION_MZONE: {
player[playerid].list_mzone[sequence] = pcard;
pcard->current.sequence = sequence;
break;
case LOCATION_SZONE:
}
case LOCATION_SZONE: {
player[playerid].list_szone[sequence] = pcard;
pcard->current.sequence = sequence;
break;
case LOCATION_DECK:
}
case LOCATION_DECK: {
if (sequence == 0) { //deck top
player[playerid].list_main.push_back(pcard);
pcard->current.sequence = player[playerid].list_main.size() - 1;
......@@ -182,27 +184,34 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence
pcard->current.position = POS_FACEDOWN;
}
break;
case LOCATION_HAND:
}
case LOCATION_HAND: {
player[playerid].list_hand.push_back(pcard);
pcard->current.sequence = player[playerid].list_hand.size() - 1;
uint32 pos = pcard->is_affected_by_effect(EFFECT_PUBLIC) ? POS_FACEUP : POS_FACEDOWN;
pcard->operation_param = (pcard->operation_param & 0x00ffffff) | (pos << 24);
if(!(pcard->current.reason & REASON_DRAW) && !core.shuffle_check_disabled)
core.shuffle_hand_check[playerid] = TRUE;
break;
case LOCATION_GRAVE:
}
case LOCATION_GRAVE: {
player[playerid].list_grave.push_back(pcard);
pcard->current.sequence = player[playerid].list_grave.size() - 1;
break;
case LOCATION_REMOVED:
}
case LOCATION_REMOVED: {
player[playerid].list_remove.push_back(pcard);
pcard->current.sequence = player[playerid].list_remove.size() - 1;
break;
case LOCATION_EXTRA:
}
case LOCATION_EXTRA: {
player[playerid].list_extra.push_back(pcard);
pcard->current.sequence = player[playerid].list_extra.size() - 1;
if((pcard->data.type & TYPE_PENDULUM) && ((pcard->operation_param >> 24) & POS_FACEUP))
++player[playerid].extra_p_count;
break;
}
}
pcard->apply_field_effect();
pcard->fieldid = infos.field_id++;
pcard->fieldid_r = pcard->fieldid;
......@@ -518,7 +527,7 @@ void field::shuffle(uint8 playerid, uint8 location) {
if(location == LOCATION_HAND) {
bool shuffle = false;
for(auto cit = svector.begin(); cit != svector.end(); ++cit)
if(!(*cit)->is_status(STATUS_IS_PUBLIC))
if(!(*cit)->is_position(POS_FACEUP))
shuffle = true;
if(!shuffle) {
core.shuffle_hand_check[playerid] = FALSE;
......@@ -703,7 +712,7 @@ void field::tag_swap(uint8 playerid) {
else
pduel->write_buffer32(0);
for(auto cit = player[playerid].list_hand.begin(); cit != player[playerid].list_hand.end(); ++cit)
pduel->write_buffer32((*cit)->data.code | ((*cit)->is_status(STATUS_IS_PUBLIC) ? 0x80000000 : 0));
pduel->write_buffer32((*cit)->data.code | ((*cit)->is_position(POS_FACEUP) ? 0x80000000 : 0));
for(auto cit = player[playerid].list_extra.begin(); cit != player[playerid].list_extra.end(); ++cit)
pduel->write_buffer32((*cit)->data.code | ((*cit)->is_position(POS_FACEUP) ? 0x80000000 : 0));
}
......
......@@ -1708,7 +1708,7 @@ int32 scriptlib::card_is_public(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
if(pcard->is_status(STATUS_IS_PUBLIC))
if(pcard->is_position(POS_FACEUP))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
......
......@@ -316,6 +316,7 @@ int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reaso
core.overdraw[playerid] = TRUE;
break;
}
bool is_public = false;
drawed++;
pcard = *(player[playerid].list_main.rbegin());
pcard->enable_field_effect(FALSE);
......@@ -330,12 +331,15 @@ int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reaso
pcard->current.reason_player = reason_player;
pcard->current.reason = reason | REASON_DRAW;
pcard->current.location = 0;
if(pcard->current.position == POS_FACEUP_ATTACK)
is_public = true;
add_card(playerid, pcard, LOCATION_HAND, 0);
pcard->enable_field_effect(TRUE);
if((pcard->current.position == POS_FACEUP_ATTACK) || pcard->is_affected_by_effect(EFFECT_PUBLIC)) {
if(pcard->is_affected_by_effect(EFFECT_PUBLIC))
is_public = true;
if(is_public) {
public_count++;
if(pcard->current.position != POS_FACEUP_ATTACK)
pcard->set_status(STATUS_IS_PUBLIC, TRUE);
pcard->current.position = POS_FACEUP;
}
cv.push_back(pcard);
pcard->reset(RESET_TOHAND, RESET_EVENT);
......@@ -365,7 +369,7 @@ int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reaso
pduel->write_buffer8(playerid);
pduel->write_buffer8(drawed);
for(uint32 i = 0; i < drawed; ++i)
pduel->write_buffer32(cv[i]->data.code | (cv[i]->is_status(STATUS_IS_PUBLIC) ? 0x80000000 : 0));
pduel->write_buffer32(cv[i]->data.code | (cv[i]->is_position(POS_FACEUP) ? 0x80000000 : 0));
if(core.deck_reversed && (public_count < drawed)) {
pduel->write_buffer8(MSG_CONFIRM_CARDS);
pduel->write_buffer8(1 - playerid);
......
......@@ -1612,7 +1612,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
bool act = true;
if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE)
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE || (clit->triggering_location & 0x3)
|| !(peffect->handler->current.location & 0x3) || peffect->handler->is_status(STATUS_IS_PUBLIC))) {
|| !(peffect->handler->current.location & 0x3) || peffect->handler->is_position(POS_FACEUP))) {
if(peffect->is_flag(EFFECT_FLAG_CHAIN_UNIQUE)) {
if(tp == infos.turn_player) {
for(auto tpit = core.tpchain.begin(); tpit != core.tpchain.end(); ++tpit) {
......@@ -1715,7 +1715,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
bool act = true;
if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE)
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE || (clit->triggering_location & 0x3)
|| !(peffect->handler->current.location & 0x3) || peffect->handler->is_status(STATUS_IS_PUBLIC))) {
|| !(peffect->handler->current.location & 0x3) || peffect->handler->is_position(POS_FACEUP))) {
if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && clit->triggering_location == LOCATION_HAND
&& (((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)) && peffect->handler->is_has_relation(peffect))
|| (peffect->range & LOCATION_HAND))) {
......@@ -1776,7 +1776,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
bool act = true;
if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE)
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE || (clit->triggering_location & 0x3)
|| !(peffect->handler->current.location & 0x3) || peffect->handler->is_status(STATUS_IS_PUBLIC))) {
|| !(peffect->handler->current.location & 0x3) || peffect->handler->is_position(POS_FACEUP))) {
if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && clit->triggering_location == LOCATION_HAND
&& (((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)) && peffect->handler->is_has_relation(peffect))
|| (peffect->range & LOCATION_HAND))) {
......@@ -4668,7 +4668,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
case 10: {
effect* peffect = cait->triggering_effect;
card* pcard = peffect->handler;
if((cait->flag & CHAIN_HAND_EFFECT) && !pcard->is_status(STATUS_IS_PUBLIC) && (pcard->current.location == LOCATION_HAND))
if((cait->flag & CHAIN_HAND_EFFECT) && !pcard->is_position(POS_FACEUP) && (pcard->current.location == LOCATION_HAND))
shuffle(pcard->current.controler, LOCATION_HAND);
if(cait->target_cards && cait->target_cards->container.size()) {
for(auto cit = cait->target_cards->container.begin(); cit != cait->target_cards->container.end(); ++cit)
......@@ -5220,16 +5220,16 @@ int32 field::adjust_step(uint16 step) {
for(uint32 i = 0; i < player[0].list_hand.size(); ++i) {
card* pcard = player[0].list_hand[i];
int32 pub = pcard->is_affected_by_effect(EFFECT_PUBLIC) ? TRUE : FALSE;
if(!pub && (pcard->status & STATUS_IS_PUBLIC))
if(!pub && pcard->is_position(POS_FACEUP))
core.shuffle_hand_check[0] = TRUE;
pcard->set_status(STATUS_IS_PUBLIC, pub);
pcard->current.position = pub ? POS_FACEUP : POS_FACEDOWN;
}
for(uint32 i = 0; i < player[1].list_hand.size(); ++i) {
card* pcard = player[1].list_hand[i];
int32 pub = pcard->is_affected_by_effect(EFFECT_PUBLIC) ? TRUE : FALSE;
if(!pub && (pcard->status & STATUS_IS_PUBLIC))
if(!pub && pcard->is_position(POS_FACEUP))
core.shuffle_hand_check[1] = TRUE;
pcard->set_status(STATUS_IS_PUBLIC, pub);
pcard->current.position = pub ? POS_FACEUP : POS_FACEDOWN;
}
if(core.shuffle_hand_check[infos.turn_player])
shuffle(infos.turn_player, LOCATION_HAND);
......
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