Commit 9b37cb12 authored by nanahira's avatar nanahira

improve

parent dbdb767c
...@@ -1424,16 +1424,27 @@ void ClientField::UpdateDeclarableCodeType(bool enter) { ...@@ -1424,16 +1424,27 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
bool use_cache = false; bool try_cache = false;
if(pname[0] == 0 || pname[1] == 0) { if(pname[0] == 0 || pname[1] == 0) {
if(!enter) if(!enter)
return; return;
use_cache = (mainGame->dInfo.announce_cache.size() != 0); try_cache = true;
} }
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
if(try_cache && mainGame->dInfo.announce_cache.size()) {
for(int i = 0; i < mainGame->dInfo.announce_cache.size(); ++i) {
unsigned int cache_code = mainGame->dInfo.announce_cache[i];
if(dataManager.GetString(cache_code, &cstr) && dataManager.GetData(cache_code, &cd) && is_declarable(cd, opcode)) {
mainGame->lstANCard->addItem(cstr.name.c_str());
ancard.push_back(cache_code);
}
}
if(ancard.size())
return;
}
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if((!use_cache && cit->second.name.find(pname) != std::wstring::npos) || (use_cache && std::find(mainGame->dInfo.announce_cache.begin(), mainGame->dInfo.announce_cache.end(), cit->first) != mainGame->dInfo.announce_cache.end())) { if(cit->second.name.find(pname) != std::wstring::npos) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias //datas.alias can be double card names or alias
if(is_declarable(cp->second, declarable_type)) { if(is_declarable(cp->second, declarable_type)) {
...@@ -1460,16 +1471,27 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) { ...@@ -1460,16 +1471,27 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
bool use_cache = false; bool try_cache = false;
if(pname[0] == 0 || pname[1] == 0) { if(pname[0] == 0 || pname[1] == 0) {
if(!enter) if(!enter)
return; return;
use_cache = (mainGame->dInfo.announce_cache.size() != 0); try_cache = true;
} }
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
if(try_cache && mainGame->dInfo.announce_cache.size()) {
for(int i = 0; i < mainGame->dInfo.announce_cache.size(); ++i) {
unsigned int cache_code = mainGame->dInfo.announce_cache[i];
if(dataManager.GetString(cache_code, &cstr) && dataManager.GetData(cache_code, &cd) && is_declarable(cd, opcode)) {
mainGame->lstANCard->addItem(cstr.name.c_str());
ancard.push_back(cache_code);
}
}
if(ancard.size())
return;
}
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if((!use_cache && cit->second.name.find(pname) != std::wstring::npos) || (use_cache && std::find(mainGame->dInfo.announce_cache.begin(), mainGame->dInfo.announce_cache.end(), cit->first) != mainGame->dInfo.announce_cache.end())) { if(cit->second.name.find(pname) != std::wstring::npos) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias //datas.alias can be double card names or alias
if(is_declarable(cp->second, opcode)) { if(is_declarable(cp->second, opcode)) {
......
...@@ -338,7 +338,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -338,7 +338,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(sel == -1) if(sel == -1)
break; break;
DuelClient::SetResponseI(ancard[sel]); DuelClient::SetResponseI(ancard[sel]);
mainGame->dInfo.announce_cache.push_back(ancard[sel]); mainGame->dInfo.announce_cache.insert(mainGame->dInfo.announce_cache.begin(), ancard[sel]);
mainGame->HideElement(mainGame->wANCard, true); mainGame->HideElement(mainGame->wANCard, true);
break; break;
} }
......
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