fix show_decktop in field::send_to#833
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts field::send_to’s deck-top update behavior when GLOBALFLAG_DECK_REVERSE_CHECK is enabled, aiming to ensure MSG_DECK_TOP is only emitted when the deck-top visibility truly needs recalculation based on the actual deck top.
Changes:
- Simplifies deck-top tracking by treating
show_decktopas “deck modified, needs check” and marking it when cards leave/enter the deck. - Removes an always-false condition when cards move into the deck and centralizes
MSG_DECK_TOPemission in step/case 9. - Adds an empty-deck guard and unifies the per-player
MSG_DECK_TOPemission via a loop.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if(core.deck_reversed || (ptop->current.position == POS_FACEUP_DEFENSE)) { | ||
| pduel->write_buffer8(MSG_DECK_TOP); | ||
| pduel->write_buffer8(p); | ||
| pduel->write_buffer8(0); | ||
| if(ptop->current.position != POS_FACEUP_DEFENSE) | ||
| pduel->write_buffer32(ptop->data.code); | ||
| else | ||
| pduel->write_buffer32(ptop->data.code | 0x80000000); |
There was a problem hiding this comment.
MSG_DECK_TOP is now always emitted with an offset/count of 0 (the third byte). Previously this logic computed how many consecutive cards were removed from the top of each deck during this send_to (similar to discard_deck and move_to_field), and sent that offset so clients can correctly shift any known/revealed deck-top state when multiple top cards leave the deck in one operation. With the offset hardcoded to 0, removing 1+ top cards via send_to will no longer convey the shift amount.
Suggested fix: track per-player “top cards removed” count in exargs (compute it in case 4 using the cards’ original LOCATION_DECK sequences before movement), and write that count instead of 0 when emitting MSG_DECK_TOP in case 9 (skipping emission when the deck becomes empty).
| if(ptop->current.position != POS_FACEUP_DEFENSE) | ||
| pduel->write_buffer32(ptop->data.code); | ||
| else | ||
| pduel->write_buffer32(ptop->data.code | 0x80000000); |
There was a problem hiding this comment.
I suspect there’s a game scenario where we need to hint to the client the identity of the top face-down card.
Even in scenarios like revealing 寄生虫パラサイド under 天変地異, we should only hint the game state to the client, not expose any code-level information.
There was a problem hiding this comment.
There was a problem hiding this comment.
if(ptop->current.position != POS_FACEUP_DEFENSE)
pduel->write_buffer32(ptop->data.code);
Sorry I should reply on these lines.
|
Have been waiting for a ruling. Before KONAMI responds to the ruling, I suggest we merge this first to fix the potential crash issue. |
|
Got answer from KONAMI. They also do not know whether, when there is a face-up card in the deck, it is possible to determine that card’s sequence within the deck. |
问题
见 #821
修复
show_decktop重新定义为 “卡组被动过,需要检查”。case 4(卡片移动前)
MSG_DECK_TOP的复杂逻辑show_decktopcase 6(卡片实际移动)
pcard->current.position == POS_FACEUP_DEFENSE(原因:移入卡组的卡在
move_card的add_card中会被强制设为POS_FACEDOWN,该条件永远不成立)show_decktopcase 9(所有移动完成后)
MSG_DECK_TOP:deck_reversed生效reverse_in_deck翻面 (POS_FACEUP_DEFENSE)Issue
See #821
Fix
show_decktopis redefined as: "the deck has been modified and needs to be checked."Case 4 (Before card movement)
MSG_DECK_TOPin advanceshow_decktopwhen a card leaves the deckCase 6 (During actual card movement)
pcard->current.position == POS_FACEUP_DEFENSE(Reason: cards moved into the deck are forcibly set to
POS_FACEDOWNinadd_cardwithinmove_card, so this condition never holds)show_decktopwhen a card enters the deckCase 9 (After all movements are completed)
MSG_DECK_TOPis sent only when necessary:deck_reversedis activereverse_in_deck(POS_FACEUP_DEFENSE)