Commit 7e1c4b75 authored by Chen Bill's avatar Chen Bill Committed by GitHub

check second_code in is_declarable() (#2625)

parent 298b43a8
...@@ -1397,8 +1397,7 @@ bool ClientField::check_sum_trib(std::set<ClientCard*>::const_iterator index, st ...@@ -1397,8 +1397,7 @@ bool ClientField::check_sum_trib(std::set<ClientCard*>::const_iterator index, st
|| check_sum_trib(index, end, acc + l2) || check_sum_trib(index, end, acc + l2)
|| check_sum_trib(index, end, acc); || check_sum_trib(index, end, acc);
} }
template <class T> static bool is_declarable(const CardData& cd, const std::vector<unsigned int>& opcode) {
static bool is_declarable(T const& cd, const std::vector<int>& opcode) {
std::stack<int> stack; std::stack<int> stack;
for(auto it = opcode.begin(); it != opcode.end(); ++it) { for(auto it = opcode.begin(); it != opcode.end(); ++it) {
switch(*it) { switch(*it) {
...@@ -1448,7 +1447,7 @@ static bool is_declarable(T const& cd, const std::vector<int>& opcode) { ...@@ -1448,7 +1447,7 @@ static bool is_declarable(T const& cd, const std::vector<int>& opcode) {
stack.pop(); stack.pop();
int lhs = stack.top(); int lhs = stack.top();
stack.pop(); stack.pop();
stack.push(lhs && rhs); stack.push(static_cast<int>(lhs && rhs));
} }
break; break;
} }
...@@ -1458,7 +1457,7 @@ static bool is_declarable(T const& cd, const std::vector<int>& opcode) { ...@@ -1458,7 +1457,7 @@ static bool is_declarable(T const& cd, const std::vector<int>& opcode) {
stack.pop(); stack.pop();
int lhs = stack.top(); int lhs = stack.top();
stack.pop(); stack.pop();
stack.push(lhs || rhs); stack.push(static_cast<int>(lhs || rhs));
} }
break; break;
} }
...@@ -1474,7 +1473,7 @@ static bool is_declarable(T const& cd, const std::vector<int>& opcode) { ...@@ -1474,7 +1473,7 @@ static bool is_declarable(T const& cd, const std::vector<int>& opcode) {
if (stack.size() >= 1) { if (stack.size() >= 1) {
int val = stack.top(); int val = stack.top();
stack.pop(); stack.pop();
stack.push(!val); stack.push(static_cast<int>(!val));
} }
break; break;
} }
...@@ -1527,8 +1526,9 @@ static bool is_declarable(T const& cd, const std::vector<int>& opcode) { ...@@ -1527,8 +1526,9 @@ static bool is_declarable(T const& cd, const std::vector<int>& opcode) {
} }
if(stack.size() != 1 || stack.top() == 0) if(stack.size() != 1 || stack.top() == 0)
return false; return false;
return cd.code == CARD_MARINE_DOLPHIN || cd.code == CARD_TWINKLE_MOSS if (cd.type & TYPE_TOKEN)
|| (!cd.alias && (cd.type & (TYPE_MONSTER + TYPE_TOKEN)) != (TYPE_MONSTER + TYPE_TOKEN)); return false;
return !cd.alias || second_code.find(cd.code) != second_code.end();
} }
void ClientField::UpdateDeclarableList() { void ClientField::UpdateDeclarableList() {
const wchar_t* pname = mainGame->ebANCard->getText(); const wchar_t* pname = mainGame->ebANCard->getText();
......
...@@ -69,7 +69,7 @@ public: ...@@ -69,7 +69,7 @@ public:
std::vector<ClientCard*> selected_cards; std::vector<ClientCard*> selected_cards;
std::set<ClientCard*> selectsum_cards; std::set<ClientCard*> selectsum_cards;
std::vector<ClientCard*> selectsum_all; std::vector<ClientCard*> selectsum_all;
std::vector<int> declare_opcodes; std::vector<unsigned int> declare_opcodes;
std::vector<ClientCard*> display_cards; std::vector<ClientCard*> display_cards;
std::vector<int> sort_list; std::vector<int> sort_list;
std::map<int, int> player_desc_hints[2]; std::map<int, int> player_desc_hints[2];
...@@ -158,8 +158,6 @@ public: ...@@ -158,8 +158,6 @@ public:
} }
//special cards //special cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#define CARD_QUESTION 38723936 #define CARD_QUESTION 38723936
#endif //CLIENT_FIELD_H #endif //CLIENT_FIELD_H
...@@ -3644,7 +3644,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -3644,7 +3644,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
int count = BufferIO::ReadUInt8(pbuf); int count = BufferIO::ReadUInt8(pbuf);
mainGame->dField.declare_opcodes.clear(); mainGame->dField.declare_opcodes.clear();
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
mainGame->dField.declare_opcodes.push_back(BufferIO::ReadInt32(pbuf)); mainGame->dField.declare_opcodes.push_back(buffer_read<uint32_t>(pbuf));
if(select_hint) if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint)); myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, dataManager.GetSysString(564)); else myswprintf(textBuffer, dataManager.GetSysString(564));
......
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