Commit dbdb767c authored by nanahira's avatar nanahira

add announce card cache

parent d9b2ea95
...@@ -1424,12 +1424,16 @@ void ClientField::UpdateDeclarableCodeType(bool enter) { ...@@ -1424,12 +1424,16 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
if((pname[0] == 0 || pname[1] == 0) && !enter) bool use_cache = false;
return; if(pname[0] == 0 || pname[1] == 0) {
if(!enter)
return;
use_cache = (mainGame->dInfo.announce_cache.size() != 0);
}
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(cit->second.name.find(pname) != std::wstring::npos) { 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())) {
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)) {
...@@ -1456,12 +1460,16 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) { ...@@ -1456,12 +1460,16 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
if((pname[0] == 0 || pname[1] == 0) && !enter) bool use_cache = false;
return; if(pname[0] == 0 || pname[1] == 0) {
if(!enter)
return;
use_cache = (mainGame->dInfo.announce_cache.size() != 0);
}
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(cit->second.name.find(pname) != std::wstring::npos) { 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())) {
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)) {
......
...@@ -576,6 +576,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -576,6 +576,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dInfo.time_left[1] = 0; mainGame->dInfo.time_left[1] = 0;
mainGame->dInfo.time_player = 2; mainGame->dInfo.time_player = 2;
mainGame->dInfo.isReplaySwapped = false; mainGame->dInfo.isReplaySwapped = false;
mainGame->dInfo.announce_cache.clear();
mainGame->is_building = false; mainGame->is_building = false;
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
mainGame->wInfos->setVisible(true); mainGame->wInfos->setVisible(true);
...@@ -651,6 +652,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -651,6 +652,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->dInfo.announce_cache.clear();
mainGame->is_building = false; mainGame->is_building = false;
mainGame->wDeckEdit->setVisible(false); mainGame->wDeckEdit->setVisible(false);
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
......
...@@ -338,6 +338,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -338,6 +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->HideElement(mainGame->wANCard, true); mainGame->HideElement(mainGame->wANCard, true);
break; break;
} }
......
...@@ -74,6 +74,7 @@ struct DuelInfo { ...@@ -74,6 +74,7 @@ struct DuelInfo {
unsigned short time_limit; unsigned short time_limit;
unsigned short time_left[2]; unsigned short time_left[2];
bool isReplaySwapped; bool isReplaySwapped;
std::vector<unsigned int> announce_cache;
}; };
struct BotInfo { struct BotInfo {
......
...@@ -51,6 +51,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -51,6 +51,7 @@ int SingleMode::SinglePlayThread(void* param) {
BufferIO::CopyWStr(mainGame->ebNickName->getText(), mainGame->dInfo.hostname, 20); BufferIO::CopyWStr(mainGame->ebNickName->getText(), mainGame->dInfo.hostname, 20);
mainGame->dInfo.clientname[0] = 0; mainGame->dInfo.clientname[0] = 0;
mainGame->dInfo.turn = 0; mainGame->dInfo.turn = 0;
mainGame->dInfo.announce_cache.clear();
char filename[256]; char filename[256];
size_t slen = 0; size_t slen = 0;
if(open_file) { if(open_file) {
......
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