Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update check extra link #664

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,18 +1276,18 @@ uint32 card::get_rscale() {
temp.rscale = UINT32_MAX;
return rscale;
}
uint32 card::get_link_marker() {
uint32 card::get_link_marker() const {
if(!(data.type & TYPE_LINK))
return 0;
return data.link_marker;
}
int32 card::is_link_marker(uint32 dir) {
return (int32)(get_link_marker() & dir);
uint32 card::is_link_marker(uint32 dir) const {
return get_link_marker() & dir;
}
uint32 card::get_linked_zone() {
uint32 card::get_linked_zone() const {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field())
return 0;
int32 zones = 0;
uint32 zones = 0;
int32 s = current.sequence;
if(s > 0 && s <= 4 && is_link_marker(LINK_MARKER_LEFT))
zones |= 1u << (s - 1);
Expand Down Expand Up @@ -1340,26 +1340,26 @@ void card::get_linked_cards(card_set* cset) {
pduel->game_field->get_cards_in_zone(cset, linked_zone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p, LOCATION_MZONE);
}
uint32 card::get_mutual_linked_zone() {
uint32 card::get_mutual_linked_zone() const {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field())
return 0;
int32 zones = 0;
uint32 zones = 0;
int32 p = current.controler;
int32 s = current.sequence;
uint32 linked_zone = get_linked_zone();
uint32 icheck = 0x1U;
for(int32 i = 0; i < 7; ++i, icheck <<= 1) {
if(icheck & linked_zone) {
card* pcard = pduel->game_field->player[p].list_mzone[i];
if(pcard && (pcard->get_linked_zone() & (1u << s)))
if(pcard && (pcard->get_linked_zone() & (0x1u << s)))
zones |= icheck;
}
}
icheck = 0x10000;
icheck = 0x10000U;
for(uint32 i = 0; i < 7; ++i, icheck <<= 1) {
if(icheck & linked_zone) {
card* pcard = pduel->game_field->player[1 - p].list_mzone[i];
if(pcard && (pcard->get_linked_zone() & (1u << (s + 16))))
if(pcard && (pcard->get_linked_zone() & (0x1u << (s + 16))))
zones |= icheck;
}
}
Expand All @@ -1383,28 +1383,28 @@ int32 card::is_link_state() {
return TRUE;
int32 p = current.controler;
uint32 linked_zone = pduel->game_field->get_linked_zone(p);
if((linked_zone >> current.sequence) & 1)
if((linked_zone >> current.sequence) & 0x1U)
return TRUE;
return FALSE;
}
int32 card::is_extra_link_state() {
if(current.location != LOCATION_MZONE)
return FALSE;
uint32 checked = 1u << current.sequence;
uint32 checked = 0x1U << current.sequence;
uint32 linked_zone = get_mutual_linked_zone();
const auto& list_mzone0 = pduel->game_field->player[current.controler].list_mzone;
const auto& list_mzone1 = pduel->game_field->player[1 - current.controler].list_mzone;
while(true) {
if(((linked_zone >> 5) | (linked_zone >> (16 + 6))) & ((linked_zone >> 6) | (linked_zone >> (16 + 5))) & 1)
if(((linked_zone >> 5) | (linked_zone >> (16 + 6))) & ((linked_zone >> 6) | (linked_zone >> (16 + 5))) & 0x1U)
return TRUE;
int32 checking = (int32)(linked_zone & ~checked);
uint32 checking = linked_zone & ~checked;
if(!checking)
return FALSE;
int32 rightmost = checking & (-checking);
checked |= (uint32)rightmost;
if(rightmost < 0x10000) {
uint32 rightmost = checking & (-checking);
checked |= rightmost;
if(rightmost < 0x10000U) {
for(int32 i = 0; i < 7; ++i) {
if(rightmost & 1) {
if(rightmost & 0x1U) {
card* pcard = list_mzone0[i];
linked_zone |= pcard->get_mutual_linked_zone();
break;
Expand All @@ -1414,7 +1414,7 @@ int32 card::is_extra_link_state() {
} else {
rightmost >>= 16;
for(int32 i = 0; i < 7; ++i) {
if(rightmost & 1) {
if(rightmost & 0x1U) {
card* pcard = list_mzone1[i];
uint32 zone = pcard->get_mutual_linked_zone();
linked_zone |= (zone << 16) | (zone >> 16);
Expand All @@ -1426,7 +1426,7 @@ int32 card::is_extra_link_state() {
}
return FALSE;
}
int32 card::is_position(int32 pos) {
int32 card::is_position(uint32 pos) const {
return current.position & pos;
}
void card::set_status(uint32 x, int32 enabled) {
Expand Down Expand Up @@ -1522,7 +1522,7 @@ uint32 card::get_select_info_location(uint8 *deck_seq_pointer) {
return get_info_location();
}
}
int32 card::is_treated_as_not_on_field() {
int32 card::is_treated_as_not_on_field() const {
return get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED | STATUS_SPSUMMON_STEP);
}
void card::equip(card* target, uint32 send_msg) {
Expand Down
12 changes: 6 additions & 6 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ class card {
uint32 get_grave_race(uint8 playerid);
uint32 get_lscale();
uint32 get_rscale();
uint32 get_link_marker();
int32 is_link_marker(uint32 dir);
uint32 get_linked_zone();
uint32 get_link_marker() const;
uint32 is_link_marker(uint32 dir) const;
uint32 get_linked_zone() const;
void get_linked_cards(card_set* cset);
uint32 get_mutual_linked_zone();
uint32 get_mutual_linked_zone() const;
void get_mutual_linked_cards(card_set * cset);
int32 is_link_state();
int32 is_extra_link_state();
int32 is_position(int32 pos);
int32 is_position(uint32 pos) const;
void set_status(uint32 status, int32 enabled);
int32 get_status(uint32 status) const;
int32 is_status(uint32 status) const;
Expand All @@ -279,7 +279,7 @@ class card {
int32 is_all_column();
uint8 get_select_sequence(uint8 *deck_seq_pointer);
uint32 get_select_info_location(uint8 *deck_seq_pointer);
int32 is_treated_as_not_on_field();
int32 is_treated_as_not_on_field() const;

void equip(card* target, uint32 send_msg = TRUE);
void unequip();
Expand Down
24 changes: 12 additions & 12 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,11 +804,11 @@ int32 field::get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason) {
}
uint32 field::get_linked_zone(int32 playerid) {
uint32 zones = 0;
for(auto& pcard : player[playerid].list_mzone) {
for(const auto& pcard : player[playerid].list_mzone) {
if(pcard)
zones |= pcard->get_linked_zone() & 0xff;
zones |= pcard->get_linked_zone() & 0xffff;
}
for(auto& pcard : player[1 - playerid].list_mzone) {
for(const auto& pcard : player[1 - playerid].list_mzone) {
if(pcard)
zones |= pcard->get_linked_zone() >> 16;
}
Expand Down Expand Up @@ -872,19 +872,19 @@ int32 field::check_extra_link(int32 playerid) {
if(!player[playerid].list_mzone[5] || !player[playerid].list_mzone[6])
return FALSE;
card* pcard = player[playerid].list_mzone[5];
uint32 checked = 1u << 5;
uint32 checked = 0x1u << 5;
uint32 linked_zone = pcard->get_mutual_linked_zone();
while(true) {
if((linked_zone >> 6) & 1)
if((linked_zone >> 6) & 0x1U)
return TRUE;
int32 checking = (int32)(linked_zone & ~checked);
uint32 checking = linked_zone & ~checked;
if(!checking)
return FALSE;
int32 rightmost = checking & (-checking);
checked |= (uint32)rightmost;
if(rightmost < 0x10000) {
uint32 rightmost = checking & (-checking);
checked |= rightmost;
if(rightmost < 0x10000U) {
for(int32 i = 0; i < 7; ++i) {
if(rightmost & 1) {
if(rightmost & 0x1U) {
pcard = player[playerid].list_mzone[i];
linked_zone |= pcard->get_mutual_linked_zone();
break;
Expand All @@ -894,7 +894,7 @@ int32 field::check_extra_link(int32 playerid) {
} else {
rightmost >>= 16;
for(int32 i = 0; i < 7; ++i) {
if(rightmost & 1) {
if(rightmost & 0x1U) {
pcard = player[1 - playerid].list_mzone[i];
uint32 zone = pcard->get_mutual_linked_zone();
linked_zone |= (zone << 16) | (zone >> 16);
Expand Down Expand Up @@ -1662,7 +1662,7 @@ int32 field::filter_field_card(uint8 self, uint32 location1, uint32 location2, g
}
if (pgroup)
pgroup->container.insert(result.begin(), result.end());
return result.size();
return (int32)result.size();
}
effect* field::is_player_affected_by_effect(uint8 playerid, uint32 code) {
auto rg = effects.aura_effect.equal_range(code);
Expand Down