Commit a1c19506 authored by salix5's avatar salix5

add CardDataC::get_duel_code

parent 4165a715
...@@ -51,6 +51,13 @@ struct CardDataC { ...@@ -51,6 +51,13 @@ struct CardDataC {
} }
return false; return false;
} }
uint32_t get_duel_code() const {
if (rule_code)
return rule_code;
if (alias)
return alias;
return code;
}
}; };
constexpr int DESC_COUNT = 16; constexpr int DESC_COUNT = 16;
struct CardString { struct CardString {
......
...@@ -1875,21 +1875,21 @@ void DeckBuilder::pop_side(int seq) { ...@@ -1875,21 +1875,21 @@ 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 = pointer->second.get_duel_code();
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())
limit = flit->second; limit = flit->second;
for (auto& card : deckManager.current_deck.main) { for (auto& card : deckManager.current_deck.main) {
if (card->first == limitcode || card->second.alias == limitcode) if (card->second.get_duel_code() == limitcode)
limit--; limit--;
} }
for (auto& card : deckManager.current_deck.extra) { for (auto& card : deckManager.current_deck.extra) {
if (card->first == limitcode || card->second.alias == limitcode) if (card->second.get_duel_code() == limitcode)
limit--; limit--;
} }
for (auto& card : deckManager.current_deck.side) { for (auto& card : deckManager.current_deck.side) {
if (card->first == limitcode || card->second.alias == limitcode) if (card->second.get_duel_code() == limitcode)
limit--; limit--;
} }
return limit > 0; return limit > 0;
......
...@@ -105,7 +105,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r ...@@ -105,7 +105,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; auto code = cit->second.get_duel_code();
ccount[code]++; ccount[code]++;
int dc = ccount[code]; int dc = ccount[code];
if(dc > 3) if(dc > 3)
...@@ -120,7 +120,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r ...@@ -120,7 +120,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; auto code = cit->second.get_duel_code();
ccount[code]++; ccount[code]++;
int dc = ccount[code]; int dc = ccount[code];
if(dc > 3) if(dc > 3)
...@@ -135,7 +135,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r ...@@ -135,7 +135,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; auto code = cit->second.get_duel_code();
ccount[code]++; ccount[code]++;
int dc = ccount[code]; int dc = ccount[code];
if(dc > 3) if(dc > 3)
......
...@@ -1125,9 +1125,7 @@ void Game::WaitFrameSignal(int frame) { ...@@ -1125,9 +1125,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 = cp->second.get_duel_code();
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
......
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