Commit 383238e4 authored by nanahira's avatar nanahira

use get_original_code_rule for recursive alias handle

parent 62d11a3b
......@@ -1918,7 +1918,7 @@ void DeckBuilder::pop_side(int seq) {
GetHoveredCard();
}
bool DeckBuilder::check_limit(code_pointer pointer) {
auto limitcode = pointer->second.alias ? pointer->second.alias : pointer->first;
auto limitcode = get_original_code_rule(pointer->first, pointer->second.alias, DataManager::CardReader);
int limit = 3;
auto flit = filterList->content.find(limitcode);
if(flit != filterList->content.end())
......@@ -1947,15 +1947,15 @@ bool DeckBuilder::check_limit(code_pointer pointer) {
};
auto limitcode_has_credit = filterList->credits.find(limitcode) != filterList->credits.end();
auto handle_card = [&](ygo::code_pointer& card) {
if (card->first == limitcode || card->second.alias == limitcode) {
auto card_code = get_original_code_rule(card->first, card->second.alias, DataManager::CardReader);
if (card_code == limitcode) {
limit--;
if(limit < 0)
return false;
}
if(!limitcode_has_credit)
return true;
auto code = card->second.alias ? card->second.alias : card->first;
return spend_credit(code);
return spend_credit(card_code);
};
for (auto& card : deckManager.current_deck.main) {
if(!handle_card(card))
......
......@@ -226,7 +226,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
return (gameruleDeckError << 28) | cit->first;
if (cit->second.type & (TYPES_EXTRA_DECK | TYPE_TOKEN))
return (DECKERROR_MAINCOUNT << 28);
int code = cit->second.alias ? cit->second.alias : cit->first;
int code = get_original_code_rule(cit->first, cit->second.alias, DataManager::CardReader);
ccount[code]++;
int dc = ccount[code];
if(dc > 3)
......@@ -244,7 +244,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
return (gameruleDeckError << 28) | cit->first;
if (!(cit->second.type & TYPES_EXTRA_DECK) || cit->second.type & TYPE_TOKEN)
return (DECKERROR_EXTRACOUNT << 28);
int code = cit->second.alias ? cit->second.alias : cit->first;
int code = get_original_code_rule(cit->first, cit->second.alias, DataManager::CardReader);
ccount[code]++;
int dc = ccount[code];
if(dc > 3)
......@@ -262,7 +262,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
return (gameruleDeckError << 28) | cit->first;
if (cit->second.type & TYPE_TOKEN)
return (DECKERROR_SIDECOUNT << 28);
int code = cit->second.alias ? cit->second.alias : cit->first;
int code = get_original_code_rule(cit->first, cit->second.alias, DataManager::CardReader);
ccount[code]++;
int dc = ccount[code];
if(dc > 3)
......
......@@ -1201,9 +1201,7 @@ void Game::WaitFrameSignal(int frame) {
}
void Game::DrawThumb(code_pointer cp, irr::core::vector2di pos, const LFList* lflist, bool drag) {
auto code = cp->first;
auto lcode = cp->second.alias;
if(lcode == 0)
lcode = code;
auto lcode = get_original_code_rule(cp->first, cp->second.alias, DataManager::CardReader);
irr::video::ITexture* img = imageManager.GetTextureThumb(code);
if(img == nullptr)
return; //nullptr->getSize() will cause a crash
......
......@@ -1868,8 +1868,9 @@ void Game::ShowCardInfo(int code, bool resize) {
if (is_valid && !gameConf.hide_setname) {
auto& cd = cit->second;
auto target = cit;
if (cd.alias && _datas.find(cd.alias) != _datas.end()) {
target = _datas.find(cd.alias);
auto orig = get_original_code_rule(cd.code, cd.alias, DataManager::CardReader);
if (orig != cd.code && _datas.find(orig) != _datas.end()) {
target = _datas.find(orig);
}
if (target->second.setcode[0]) {
offset = 23;// *yScale;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment