From 8277673502dceb23bea0824cb3b1303389767eca Mon Sep 17 00:00:00 2001 From: Nanahira <78877@qq.com> Date: Tue, 28 May 2024 14:59:18 +0800 Subject: [PATCH] hide deck sequence for own deck only (#595) * preserve deck sequence for own deck only * fix * Update card.cpp * Update playerop.cpp --- card.cpp | 6 +++--- field.h | 1 + playerop.cpp | 39 +++++++++++++++++---------------------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/card.cpp b/card.cpp index 620b3169d..0d9d283bb 100644 --- a/card.cpp +++ b/card.cpp @@ -97,7 +97,7 @@ bool card::card_operation_sort(card* c1, card* c2) { return c1->overlay_target->current.sequence < c2->overlay_target->current.sequence; else return c1->current.sequence < c2->current.sequence; - } else if (c1->current.location & LOCATION_DECK && !pduel->game_field->core.select_deck_seq_preserved) { + } else if (c1->current.location & LOCATION_DECK && cp1 == pduel->game_field->core.selecting_player && !pduel->game_field->core.select_deck_seq_preserved) { // if deck reversed and the card being at the top, it should go first if(pduel->game_field->core.deck_reversed) { if(c1->current.sequence == pduel->game_field->player[cp1].list_main.size() - 1) @@ -1518,8 +1518,8 @@ int32 card::is_all_column() { return FALSE; } uint8 card::get_select_sequence(uint8 *deck_seq_pointer) { - if(current.location == LOCATION_DECK && !pduel->game_field->core.select_deck_seq_preserved) { - return deck_seq_pointer[current.controler]++; + if(current.location == LOCATION_DECK && current.controler == pduel->game_field->core.selecting_player && !pduel->game_field->core.select_deck_seq_preserved) { + return (*deck_seq_pointer)++; } else { return current.sequence; } diff --git a/field.h b/field.h index 739be9cf7..5fc259519 100644 --- a/field.h +++ b/field.h @@ -348,6 +348,7 @@ struct processor { uint8 current_player{ PLAYER_NONE }; uint8 conti_player{ PLAYER_NONE }; uint8 select_deck_seq_preserved{ FALSE }; + uint8 selecting_player{ PLAYER_NONE }; std::unordered_map> summon_counter; std::unordered_map> normalsummon_counter; std::unordered_map> spsummon_counter; diff --git a/playerop.cpp b/playerop.cpp index 19e256932..82667a1d7 100644 --- a/playerop.cpp +++ b/playerop.cpp @@ -226,6 +226,7 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi returns.bvalue[0] = 0; if(max == 0 || core.select_cards.empty()) return TRUE; + core.selecting_player = playerid; std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort); if (core.select_cards.size() > UINT8_MAX) core.select_cards.resize(UINT8_MAX); @@ -248,12 +249,10 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi pduel->write_buffer8(min); pduel->write_buffer8(max); pduel->write_buffer8((uint8)core.select_cards.size()); - uint8 deck_seq_pointer[2]; - deck_seq_pointer[0] = 0; - deck_seq_pointer[1] = 0; + uint8 deck_seq_pointer = 0; for(auto& pcard : core.select_cards) { pduel->write_buffer32(pcard->data.code); - pduel->write_buffer32(pcard->get_select_info_location(deck_seq_pointer)); + pduel->write_buffer32(pcard->get_select_info_location(&deck_seq_pointer)); } return FALSE; } else { @@ -287,6 +286,7 @@ int32 field::select_unselect_card(uint16 step, uint8 playerid, uint8 cancelable, returns.bvalue[i + 1] = i; return TRUE; } + core.selecting_player = playerid; std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort); if (core.select_cards.size() > UINT8_MAX) core.select_cards.resize(UINT8_MAX); @@ -299,17 +299,15 @@ int32 field::select_unselect_card(uint16 step, uint8 playerid, uint8 cancelable, pduel->write_buffer8(min); pduel->write_buffer8(max); pduel->write_buffer8((uint8)core.select_cards.size()); - uint8 deck_seq_pointer[2]; - deck_seq_pointer[0] = 0; - deck_seq_pointer[1] = 0; + uint8 deck_seq_pointer = 0; for(auto& pcard : core.select_cards) { pduel->write_buffer32(pcard->data.code); - pduel->write_buffer32(pcard->get_select_info_location(deck_seq_pointer)); + pduel->write_buffer32(pcard->get_select_info_location(&deck_seq_pointer)); } pduel->write_buffer8((uint8)core.unselect_cards.size()); for(auto& pcard : core.unselect_cards) { pduel->write_buffer32(pcard->data.code); - pduel->write_buffer32(pcard->get_select_info_location(deck_seq_pointer)); + pduel->write_buffer32(pcard->get_select_info_location(&deck_seq_pointer)); } return FALSE; } else { @@ -507,6 +505,7 @@ int32 field::select_tribute(uint16 step, uint8 playerid, uint8 cancelable, uint8 returns.bvalue[0] = 0; if(max == 0 || core.select_cards.empty()) return TRUE; + core.selecting_player = playerid; std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort); if (core.select_cards.size() > UINT8_MAX) core.select_cards.resize(UINT8_MAX); @@ -526,14 +525,12 @@ int32 field::select_tribute(uint16 step, uint8 playerid, uint8 cancelable, uint8 pduel->write_buffer8(min); pduel->write_buffer8(max); pduel->write_buffer8((uint8)core.select_cards.size()); - uint8 deck_seq_pointer[2]; - deck_seq_pointer[0] = 0; - deck_seq_pointer[1] = 0; + uint8 deck_seq_pointer = 0; for(auto& pcard : core.select_cards) { pduel->write_buffer32(pcard->data.code); pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.location); - pduel->write_buffer8(pcard->get_select_sequence(deck_seq_pointer)); + pduel->write_buffer8(pcard->get_select_sequence(&deck_seq_pointer)); pduel->write_buffer8(pcard->release_param); } return FALSE; @@ -597,15 +594,14 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin pduel->write_buffer16(countertype); pduel->write_buffer16(count); pduel->write_buffer8((uint8)core.select_cards.size()); + core.selecting_player = playerid; std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort); - uint8 deck_seq_pointer[2]; - deck_seq_pointer[0] = 0; - deck_seq_pointer[1] = 0; + uint8 deck_seq_pointer = 0; for(auto& pcard : core.select_cards) { pduel->write_buffer32(pcard->data.code); pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.location); - pduel->write_buffer8(pcard->get_select_sequence(deck_seq_pointer)); + pduel->write_buffer8(pcard->get_select_sequence(&deck_seq_pointer)); pduel->write_buffer16(pcard->get_counter(countertype)); } return FALSE; @@ -640,6 +636,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 returns.bvalue[0] = 0; if(core.select_cards.empty()) return TRUE; + core.selecting_player = playerid; std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort); if (core.select_cards.size() > UINT8_MAX) core.select_cards.resize(UINT8_MAX); @@ -657,14 +654,12 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 pduel->write_buffer8(min); pduel->write_buffer8(max); pduel->write_buffer8((uint8)core.must_select_cards.size()); - uint8 deck_seq_pointer[2]; - deck_seq_pointer[0] = 0; - deck_seq_pointer[1] = 0; + uint8 deck_seq_pointer = 0; for(auto& pcard : core.must_select_cards) { pduel->write_buffer32(pcard->data.code); pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.location); - pduel->write_buffer8(pcard->get_select_sequence(deck_seq_pointer)); + pduel->write_buffer8(pcard->get_select_sequence(&deck_seq_pointer)); pduel->write_buffer32(pcard->sum_param); } pduel->write_buffer8((uint8)core.select_cards.size()); @@ -672,7 +667,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 pduel->write_buffer32(pcard->data.code); pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.location); - pduel->write_buffer8(pcard->get_select_sequence(deck_seq_pointer)); + pduel->write_buffer8(pcard->get_select_sequence(&deck_seq_pointer)); pduel->write_buffer32(pcard->sum_param); } return FALSE;