Skip to content

Commit

Permalink
Merge branch 'patch-count' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
salix5 committed Feb 15, 2025
2 parents 8b896da + a8c9e81 commit 4c00ba2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion card.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ class card {
uint8_t attack_controler{};
uint64_t cardid{};
uint32_t fieldid{};
uint32_t fieldid_r{};
uint32_t fieldid_r{}; //real field id, updated when moving to new location
uint32_t activate_count_id{}; //updated when moving to new location or flipping
uint16_t turnid{};
uint16_t turn_counter{};
uint8_t unique_pos[2]{};
Expand Down
7 changes: 2 additions & 5 deletions effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ int32_t effect::is_single_ready() {
int32_t res = pduel->lua->check_condition(condition, 1);
return res;
}
// reset_count: count of effect reset
// count_limit: left count of activation
// count_limit_max: max count of activation
int32_t effect::check_count_limit(uint8_t playerid) {
if(is_flag(EFFECT_FLAG_COUNT_LIMIT)) {
if(count_limit == 0)
Expand All @@ -171,7 +168,7 @@ int32_t effect::check_count_limit(uint8_t playerid) {
uint32_t limit_type = count_code & 0xf0000000U;
int32_t count = count_limit_max;
if(limit_code == EFFECT_COUNT_CODE_SINGLE) {
if(pduel->game_field->get_effect_code(limit_type | get_handler()->fieldid, PLAYER_NONE) >= count)
if(pduel->game_field->get_effect_code(limit_type | get_handler()->activate_count_id, PLAYER_NONE) >= count)
return FALSE;
} else {
if(pduel->game_field->get_effect_code(count_code, playerid) >= count)
Expand Down Expand Up @@ -680,7 +677,7 @@ void effect::dec_count(uint8_t playerid) {
uint32_t limit_code = count_code & MAX_CARD_ID;
uint32_t limit_type = count_code & 0xf0000000;
if(limit_code == EFFECT_COUNT_CODE_SINGLE)
pduel->game_field->add_effect_code(limit_type | get_handler()->fieldid, PLAYER_NONE);
pduel->game_field->add_effect_code(limit_type | get_handler()->activate_count_id, PLAYER_NONE);
else
pduel->game_field->add_effect_code(count_code, playerid);
}
Expand Down
4 changes: 2 additions & 2 deletions effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class effect {
uint16_t range{ 0 };
uint16_t s_range{ 0 };
uint16_t o_range{ 0 };
uint8_t count_limit{ 0 };
uint8_t count_limit_max{ 0 };
uint8_t count_limit{ 0 }; //left count of activation
uint8_t count_limit_max{ 0 }; //max count of activation
uint16_t status{ 0 };
int32_t reset_count{ 0 };
uint32_t reset_flag{ 0 };
Expand Down
1 change: 1 addition & 0 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ void field::add_card(uint8_t playerid, card* pcard, uint8_t location, uint8_t se
pcard->apply_field_effect();
pcard->fieldid = infos.field_id++;
pcard->fieldid_r = pcard->fieldid;
pcard->activate_count_id = pcard->fieldid;
if(check_unique_onfield(pcard, pcard->current.controler, pcard->current.location))
pcard->unique_fieldid = UINT_MAX;
pcard->turnid = infos.turn_id;
Expand Down
2 changes: 2 additions & 0 deletions operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,7 @@ int32_t field::flip_summon(uint16_t step, uint8_t sumplayer, card * target, uint
target->summon_player = sumplayer;
target->summon_info |= SUMMON_TYPE_FLIP;
target->fieldid = infos.field_id++;
target->activate_count_id = target->fieldid;
core.phase_action = TRUE;
pduel->write_buffer8(MSG_FLIPSUMMONING);
pduel->write_buffer32(target->data.code);
Expand Down Expand Up @@ -4909,6 +4910,7 @@ int32_t field::change_position(uint16_t step, group * targets, effect * reason_e
core.hint_timing[pcard->current.controler] |= TIMING_POS_CHANGE;
if((opos & POS_FACEDOWN) && (npos & POS_FACEUP)) {
pcard->fieldid = infos.field_id++;
pcard->activate_count_id = pcard->fieldid;
if(check_unique_onfield(pcard, pcard->current.controler, pcard->current.location))
pcard->unique_fieldid = UINT_MAX;
if(pcard->current.location == LOCATION_MZONE) {
Expand Down

0 comments on commit 4c00ba2

Please sign in to comment.