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