Skip to content

Commit

Permalink
hide deck sequence for own deck only (Fluorohydride#595)
Browse files Browse the repository at this point in the history
* preserve deck sequence for own deck only

* fix

* Update card.cpp

* Update playerop.cpp
  • Loading branch information
purerosefallen committed May 28, 2024
1 parent 4367d7a commit 8277673
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
6 changes: 3 additions & 3 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions field.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32, std::pair<uint32, uint32>> summon_counter;
std::unordered_map<uint32, std::pair<uint32, uint32>> normalsummon_counter;
std::unordered_map<uint32, std::pair<uint32, uint32>> spsummon_counter;
Expand Down
39 changes: 17 additions & 22 deletions playerop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -657,22 +654,20 @@ 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());
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_buffer32(pcard->sum_param);
}
return FALSE;
Expand Down

0 comments on commit 8277673

Please sign in to comment.