Commit 9b37cb12 authored by nanahira's avatar nanahira

improve

parent dbdb767c
......@@ -1424,16 +1424,27 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
ancard.push_back(trycode);
return;
}
bool use_cache = false;
bool try_cache = false;
if(pname[0] == 0 || pname[1] == 0) {
if(!enter)
return;
use_cache = (mainGame->dInfo.announce_cache.size() != 0);
try_cache = true;
}
mainGame->lstANCard->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) {
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
//datas.alias can be double card names or alias
if(is_declarable(cp->second, declarable_type)) {
......@@ -1460,16 +1471,27 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
ancard.push_back(trycode);
return;
}
bool use_cache = false;
bool try_cache = false;
if(pname[0] == 0 || pname[1] == 0) {
if(!enter)
return;
use_cache = (mainGame->dInfo.announce_cache.size() != 0);
try_cache = true;
}
mainGame->lstANCard->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) {
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
//datas.alias can be double card names or alias
if(is_declarable(cp->second, opcode)) {
......
......@@ -338,7 +338,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(sel == -1)
break;
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);
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