Commit dcd334a2 authored by nanahira's avatar nanahira

Revert "revert announce"

This reverts commit 8a0bdc06.
parent c7fc49a4
...@@ -1457,10 +1457,25 @@ void ClientField::UpdateDeclarableCodeType(bool enter) { ...@@ -1457,10 +1457,25 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
if((pname[0] == 0 || pname[1] == 0) && !enter) bool try_cache = false;
if(pname[0] == 0 || pname[1] == 0) {
if(!enter)
return; return;
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, declarable_type)) {
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(cit->second.name.find(pname) != std::wstring::npos) { 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
...@@ -1489,10 +1504,25 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) { ...@@ -1489,10 +1504,25 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
if((pname[0] == 0 || pname[1] == 0) && !enter) bool try_cache = false;
if(pname[0] == 0 || pname[1] == 0) {
if(!enter)
return; return;
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(cit->second.name.find(pname) != std::wstring::npos) { 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
......
...@@ -601,6 +601,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -601,6 +601,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->RefreshTimeDisplay(); mainGame->RefreshTimeDisplay();
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);
...@@ -678,6 +679,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -678,6 +679,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.insert(mainGame->dInfo.announce_cache.begin(), ancard[sel]);
mainGame->HideElement(mainGame->wANCard, true); mainGame->HideElement(mainGame->wANCard, true);
break; break;
} }
......
...@@ -89,6 +89,7 @@ struct DuelInfo { ...@@ -89,6 +89,7 @@ struct DuelInfo {
wchar_t str_card_count[2][16]; wchar_t str_card_count[2][16];
video::SColor card_count_color[2]; video::SColor card_count_color[2];
bool isReplaySwapped; bool isReplaySwapped;
std::vector<unsigned int> announce_cache;
}; };
struct BotInfo { struct BotInfo {
......
...@@ -55,6 +55,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -55,6 +55,7 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->dInfo.clientname[0] = 0; mainGame->dInfo.clientname[0] = 0;
mainGame->dInfo.player_type = 0; mainGame->dInfo.player_type = 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