From e7a81b579a066461a269f858ae6ddcb614f20710 Mon Sep 17 00:00:00 2001 From: InvisibleMoon Date: Wed, 3 Aug 2016 22:39:24 +0800 Subject: [PATCH 1/3] mul search test --- gframe/deck_con.cpp | 114 ++++++++++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 41 deletions(-) diff --git a/gframe/deck_con.cpp b/gframe/deck_con.cpp index 2ec75440..6639d2c0 100644 --- a/gframe/deck_con.cpp +++ b/gframe/deck_con.cpp @@ -763,7 +763,7 @@ void DeckBuilder::FilterCards() { results.clear(); const wchar_t* pstr = mainGame->ebCardName->getText(); int trycode = BufferIO::GetVal(pstr); - if(dataManager.GetData(trycode, 0)) { + if (dataManager.GetData(trycode, 0)) { auto ptr = dataManager.GetCodePointer(trycode); // verified by GetData() results.push_back(ptr); mainGame->scrFilter->setVisible(false); @@ -771,31 +771,50 @@ void DeckBuilder::FilterCards() { myswprintf(result_string, L"%d", results.size()); return; } - unsigned int set_code = 0; - if(pstr[0] == L'@') - set_code = dataManager.GetSetCode(&pstr[1]); - else - set_code = dataManager.GetSetCode(&pstr[0]); - if(pstr[0] == 0 || (pstr[0] == L'$' && pstr[1] == 0) || (pstr[0] == L'@' && pstr[1] == 0)) - pstr = 0; + std::wstring str = std::wstring(pstr); + std::vector query_elements; + std::vector::iterator> query_elements_track; + size_t element_start = 0; + while (1) { + size_t element_end = str.find_first_of(L' ', element_start); + if (element_end == std::wstring::npos) { + break; + } + query_elements.push_back(str.substr(element_start, element_end - element_start)); + element_start = element_end + 1; + } + query_elements.push_back(str.substr(element_start)); + std::unordered_map set_code_map; + for (auto elements_iterator = query_elements.begin(); elements_iterator != query_elements.end(); elements_iterator++) { + const wchar_t* element_pointer = elements_iterator->c_str(); + if (element_pointer[0] == L'@') + set_code_map[*elements_iterator] = dataManager.GetSetCode(&element_pointer[1]); + else + set_code_map[*elements_iterator] = dataManager.GetSetCode(&element_pointer[0]); + if (element_pointer[0] == 0 || (element_pointer[0] == L'$' && element_pointer[1] == 0) || (element_pointer[0] == L'@' && element_pointer[1] == 0)) + query_elements_track.push_back(elements_iterator); + } + for (auto elements_track_iterator = query_elements_track.begin(); elements_track_iterator != query_elements_track.end(); elements_track_iterator++) { + query_elements.erase(*elements_track_iterator); + } auto strpointer = dataManager._strings.begin(); - for(code_pointer ptr = dataManager._datas.begin(); ptr != dataManager._datas.end(); ++ptr, ++strpointer) { + for (code_pointer ptr = dataManager._datas.begin(); ptr != dataManager._datas.end(); ++ptr, ++strpointer) { const CardDataC& data = ptr->second; const CardString& text = strpointer->second; - if(data.type & TYPE_TOKEN) + if (data.type & TYPE_TOKEN) continue; - switch(filter_type) { + switch (filter_type) { case 1: { - if(!(data.type & TYPE_MONSTER) || (data.type & filter_type2) != filter_type2) + if (!(data.type & TYPE_MONSTER) || (data.type & filter_type2) != filter_type2) continue; - if(filter_race && data.race != filter_race) + if (filter_race && data.race != filter_race) continue; - if(filter_attrib && data.attribute != filter_attrib) + if (filter_attrib && data.attribute != filter_attrib) continue; - if(filter_atktype) { - if((filter_atktype == 1 && data.attack != filter_atk) || (filter_atktype == 2 && data.attack < filter_atk) - || (filter_atktype == 3 && data.attack <= filter_atk) || (filter_atktype == 4 && (data.attack > filter_atk || data.attack < 0)) - || (filter_atktype == 5 && (data.attack >= filter_atk || data.attack < 0)) || (filter_atktype == 6 && data.attack != -2)) + if (filter_atktype) { + if ((filter_atktype == 1 && data.attack != filter_atk) || (filter_atktype == 2 && data.attack < filter_atk) + || (filter_atktype == 3 && data.attack <= filter_atk) || (filter_atktype == 4 && (data.attack > filter_atk || data.attack < 0)) + || (filter_atktype == 5 && (data.attack >= filter_atk || data.attack < 0)) || (filter_atktype == 6 && data.attack != -2)) continue; } if(filter_deftype) { @@ -805,12 +824,13 @@ void DeckBuilder::FilterCards() { || (data.type & TYPE_LINK)) continue; } - if(filter_lvtype) { - if((filter_lvtype == 1 && data.level != filter_lv) || (filter_lvtype == 2 && data.level < filter_lv) - || (filter_lvtype == 3 && data.level <= filter_lv) || (filter_lvtype == 4 && data.level > filter_lv) - || (filter_lvtype == 5 && data.level >= filter_lv) || filter_lvtype == 6) + if (filter_lvtype) { + if ((filter_lvtype == 1 && data.level != filter_lv) || (filter_lvtype == 2 && data.level < filter_lv) + || (filter_lvtype == 3 && data.level <= filter_lv) || (filter_lvtype == 4 && data.level > filter_lv) + || (filter_lvtype == 5 && data.level >= filter_lv) || filter_lvtype == 6) continue; } + if(filter_scltype) { if((filter_scltype == 1 && data.lscale != filter_scl) || (filter_scltype == 2 && data.lscale < filter_scl) || (filter_scltype == 3 && data.lscale <= filter_scl) || (filter_scltype == 4 && (data.lscale > filter_scl || data.lscale == 0)) @@ -821,56 +841,68 @@ void DeckBuilder::FilterCards() { break; } case 2: { - if(!(data.type & TYPE_SPELL)) + if (!(data.type & TYPE_SPELL)) continue; - if(filter_type2 && data.type != filter_type2) + if (filter_type2 && data.type != filter_type2) continue; break; } case 3: { - if(!(data.type & TYPE_TRAP)) + if (!(data.type & TYPE_TRAP)) continue; - if(filter_type2 && data.type != filter_type2) + if (filter_type2 && data.type != filter_type2) continue; break; } } - if(filter_effect && !(data.category & filter_effect)) + if (filter_effect && !(data.category & filter_effect)) continue; if(filter_marks && (data.link_marker & filter_marks)!= filter_marks) continue; if(filter_lm) { if(filter_lm <= 3 && (!filterList->count(ptr->first) || (*filterList)[ptr->first] != filter_lm - 1)) continue; - if(filter_lm == 4 && data.ot != 1) + if (filter_lm == 4 && data.ot != 1) continue; - if(filter_lm == 5 && data.ot != 2) + if (filter_lm == 5 && data.ot != 2) continue; if(filter_lm == 6 && data.ot != 3) continue; if(filter_lm == 7 && data.ot != 4) continue; } - if(pstr) { - if(pstr[0] == L'$') { - if(!CardNameContains(text.name, &pstr[1])) - continue; - } else if(pstr[0] == L'@' && set_code) { - if(!check_set_code(data, set_code)) continue; + bool is_target = true; + for (auto elements_iterator = query_elements.begin(); elements_iterator != query_elements.end(); elements_iterator++) { + const wchar_t* element_pointer = elements_iterator->c_str(); + if (element_pointer[0] == L'$') { + if(!CardNameContains(text.name, &element_pointer[1])){ + is_target = false; + break; + } + } + else if (element_pointer[0] == L'@' && set_code_map[*elements_iterator]) { + if(!check_set_code(data, set_code_map[*elements_iterator])) break; } else { - if(!CardNameContains(text.name, pstr) && wcsstr(text.text, pstr) == 0 - && (!set_code || !check_set_code(data, set_code))) - continue; + if (!CardNameContains(text.name, elements_iterator->c_str()) && wcsstr(text.text, elements_iterator->c_str()) == 0 + && (!set_code_map[*elements_iterator] || !check_set_code(data, set_code_map[*elements_iterator]))) { + is_target = false; + break; + } } } - results.push_back(ptr); + if (is_target) { + results.push_back(ptr); + } else { + continue; + } } myswprintf(result_string, L"%d", results.size()); - if(results.size() > 7) { + if (results.size() > 7) { mainGame->scrFilter->setVisible(true); mainGame->scrFilter->setMax(results.size() - 7); mainGame->scrFilter->setPos(0); - } else { + } + else { mainGame->scrFilter->setVisible(false); mainGame->scrFilter->setPos(0); } From 26ba0a75293cde2399d8d237d4e8d11d52459f3e Mon Sep 17 00:00:00 2001 From: purerosefallen <78877@qq.com> Date: Sat, 17 Feb 2018 10:32:34 +0800 Subject: [PATCH 2/3] col --- gframe/deck_con.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gframe/deck_con.cpp b/gframe/deck_con.cpp index 6639d2c0..54c81ba2 100644 --- a/gframe/deck_con.cpp +++ b/gframe/deck_con.cpp @@ -226,7 +226,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { } case BUTTON_SIDE_OK: { if(deckManager.current_deck.main.size() != pre_mainc || deckManager.current_deck.extra.size() != pre_extrac - || deckManager.current_deck.side.size() != pre_sidec) { + || deckManager.current_deck.side.size() != pre_sidec) { mainGame->env->addMessageBox(L"", dataManager.GetSysString(1410)); break; } @@ -819,9 +819,9 @@ void DeckBuilder::FilterCards() { } if(filter_deftype) { if((filter_deftype == 1 && data.defense != filter_def) || (filter_deftype == 2 && data.defense < filter_def) - || (filter_deftype == 3 && data.defense <= filter_def) || (filter_deftype == 4 && (data.defense > filter_def || data.defense < 0)) - || (filter_deftype == 5 && (data.defense >= filter_def || data.defense < 0)) || (filter_deftype == 6 && data.defense != -2) - || (data.type & TYPE_LINK)) + || (filter_deftype == 3 && data.defense <= filter_def) || (filter_deftype == 4 && (data.defense > filter_def || data.defense < 0)) + || (filter_deftype == 5 && (data.defense >= filter_def || data.defense < 0)) || (filter_deftype == 6 && data.defense != -2) + || (data.type & TYPE_LINK)) continue; } if (filter_lvtype) { @@ -833,9 +833,9 @@ void DeckBuilder::FilterCards() { if(filter_scltype) { if((filter_scltype == 1 && data.lscale != filter_scl) || (filter_scltype == 2 && data.lscale < filter_scl) - || (filter_scltype == 3 && data.lscale <= filter_scl) || (filter_scltype == 4 && (data.lscale > filter_scl || data.lscale == 0)) - || (filter_scltype == 5 && (data.lscale >= filter_scl || data.lscale == 0)) || filter_scltype == 6 - || !(data.type & TYPE_PENDULUM)) + || (filter_scltype == 3 && data.lscale <= filter_scl) || (filter_scltype == 4 && (data.lscale > filter_scl || data.lscale == 0)) + || (filter_scltype == 5 && (data.lscale >= filter_scl || data.lscale == 0)) || filter_scltype == 6 + || !(data.type & TYPE_PENDULUM)) continue; } break; From 7681698b3d38e46101674db0269a4470820da3c4 Mon Sep 17 00:00:00 2001 From: Smile-DK <2236141431@qq.com> Date: Sat, 17 Feb 2018 14:04:36 +0800 Subject: [PATCH 3/3] fix --- gframe/deck_con.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gframe/deck_con.cpp b/gframe/deck_con.cpp index 54c81ba2..ba086c50 100644 --- a/gframe/deck_con.cpp +++ b/gframe/deck_con.cpp @@ -881,7 +881,10 @@ void DeckBuilder::FilterCards() { } } else if (element_pointer[0] == L'@' && set_code_map[*elements_iterator]) { - if(!check_set_code(data, set_code_map[*elements_iterator])) break; + if(!check_set_code(data, set_code_map[*elements_iterator])) { + is_target = false; + break; + } } else { if (!CardNameContains(text.name, elements_iterator->c_str()) && wcsstr(text.text, elements_iterator->c_str()) == 0 && (!set_code_map[*elements_iterator] || !check_set_code(data, set_code_map[*elements_iterator]))) {