Commit 2a5b5bba authored by VanillaSalt's avatar VanillaSalt

update

parent c07b9172
......@@ -1108,7 +1108,10 @@ bool ClientField::CheckSelectSum() {
selable.insert(selectsum_all[i]);
}
for(size_t i = 0; i < selected_cards.size(); ++i) {
selected_cards[i]->is_selectable = true;
if(i < must_select_count)
selected_cards[i]->is_selectable = false;
else
selected_cards[i]->is_selectable = true;
selected_cards[i]->is_selected = true;
selable.erase(selected_cards[i]);
}
......@@ -1194,7 +1197,7 @@ bool ClientField::check_min(std::set<ClientCard*>& left, std::set<ClientCard*>::
return (min > m && check_min(left, index, min - m, max - m))
|| check_min(left, index, min, max);
}
bool ClientField::check_sel_sum_s(std::set<ClientCard*>& left, int index, int acc) {
bool ClientField::check_sel_sum_s(const std::set<ClientCard*>& left, int index, int acc) {
if (index == (int)selected_cards.size()) {
if (acc == 0)
return true;
......@@ -1210,9 +1213,9 @@ bool ClientField::check_sel_sum_s(std::set<ClientCard*>& left, int index, int ac
res2 = check_sel_sum_s(left, index + 1, acc - l2);
return res1 || res2;
}
void ClientField::check_sel_sum_t(std::set<ClientCard*>& left, int acc) {
std::set<ClientCard*>::iterator sit;
for (sit = left.begin(); sit != left.end(); ++sit) {
void ClientField::check_sel_sum_t(const std::set<ClientCard*>& left, int acc) {
int count = selected_cards.size() + 1;
for (auto sit = left.begin(); sit != left.end(); ++sit) {
if (selectsum_cards.find(*sit) != selectsum_cards.end())
continue;
std::set<ClientCard*> testlist(left);
......@@ -1220,16 +1223,16 @@ void ClientField::check_sel_sum_t(std::set<ClientCard*>& left, int acc) {
int l = (*sit)->opParam;
int l1 = l & 0xffff;
int l2 = l >> 16;
if (check_sum(testlist, testlist.begin(), acc - l1, selected_cards.size() + 1)
|| (l2 > 0 && check_sum(testlist, testlist.begin(), acc - l2, selected_cards.size() + 1))) {
if (check_sum(testlist.begin(), testlist.end(), acc - l1, count)
|| (l2 > 0 && check_sum(testlist.begin(), testlist.end(), acc - l2, count))) {
selectsum_cards.insert(*sit);
}
}
}
bool ClientField::check_sum(std::set<ClientCard*>& testlist, std::set<ClientCard*>::iterator index, int acc, int count) {
bool ClientField::check_sum(std::set<ClientCard*>::const_iterator index, std::set<ClientCard*>::const_iterator end, int acc, int count) {
if (acc == 0)
return count >= select_min && count <= select_max;
if (acc < 0 || index == testlist.end())
if (acc < 0 || index == end)
return false;
int l = (*index)->opParam;
int l1 = l & 0xffff;
......@@ -1237,8 +1240,8 @@ bool ClientField::check_sum(std::set<ClientCard*>& testlist, std::set<ClientCard
if ((l1 == acc || (l2 > 0 && l2 == acc)) && (count + 1 >= select_min) && (count + 1 <= select_max))
return true;
++index;
return (acc > l1 && check_sum(testlist, index, acc - l1, count + 1))
|| (l2 > 0 && acc > l2 && check_sum(testlist, index, acc - l2, count + 1))
|| check_sum(testlist, index, acc, count);
return (acc > l1 && check_sum(index, end, acc - l1, count + 1))
|| (l2 > 0 && acc > l2 && check_sum(index, end, acc - l2, count + 1))
|| check_sum(index, end, acc, count);
}
}
......@@ -50,6 +50,7 @@ public:
int selected_field;
int select_min;
int select_max;
int must_select_count;
int select_sumval;
int select_cancelable;
int select_mode;
......@@ -96,9 +97,9 @@ public:
void FadeCard(ClientCard* pcard, int alpha, int frame);
bool CheckSelectSum();
bool check_min(std::set<ClientCard*>& left, std::set<ClientCard*>::iterator index, int min, int max);
bool check_sel_sum_s(std::set<ClientCard*>& left, int index, int acc);
void check_sel_sum_t(std::set<ClientCard*>& left, int acc);
bool check_sum(std::set<ClientCard*>& testlist, std::set<ClientCard*>::iterator index, int acc, int count);
bool check_sel_sum_s(const std::set<ClientCard*>& left, int index, int acc);
void check_sel_sum_t(const std::set<ClientCard*>& left, int acc);
bool check_sum(std::set<ClientCard*>::const_iterator index, std::set<ClientCard*>::const_iterator end, int acc, int count);
irr::gui::IGUIElement* panel;
std::vector<int> ancard;
......
......@@ -1416,20 +1416,30 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.select_sumval = BufferIO::ReadInt32(pbuf);
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_max = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
mainGame->dField.must_select_count = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectsum_all.clear();
mainGame->dField.selected_cards.clear();
mainGame->dField.selectsum_cards.clear();
int c, l, s;
unsigned int code;
bool panelmode = false;
ClientCard* pcard;
for (int i = 0; i < mainGame->dField.must_select_count; ++i) {
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->opParam = BufferIO::ReadInt32(pbuf);
pcard->select_seq = 0;
mainGame->dField.selected_cards.push_back(pcard);
}
int count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = (unsigned int)BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->opParam = BufferIO::ReadInt32(pbuf);
......
......@@ -308,6 +308,8 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
pbuf += 6;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 11;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 11;
return ReadReplayResponse();
}
case MSG_SORT_CARD:
......
......@@ -727,6 +727,8 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
pbuf += 6;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 11;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 11;
WaitforResponse(player);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
......
......@@ -257,6 +257,8 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf += 6;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 11;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 11;
if(!DuelClient::ClientAnalyze(offset, pbuf - offset)) {
mainGame->singleSignal.Reset();
mainGame->singleSignal.Wait();
......
......@@ -660,6 +660,8 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
pbuf += 6;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 11;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 11;
WaitforResponse(player);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
......
Subproject commit dcde72e410c233b44a71cf2dd4112d036cc2d25e
Subproject commit e92e8c0b75f7fc3ba01f3c266667c5000baf168a
Subproject commit 9f8bf9e40dfb023a2c95a14f708cd52c7e7d9521
Subproject commit eeefb35c2a6b85ae7ed68075818894886bd5a89a
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