Commit d15cdb16 authored by VanillaSalt's avatar VanillaSalt

fix CheckSelectSum()

parent 75068c1a
...@@ -1207,28 +1207,31 @@ bool ClientField::CheckSelectSum() { ...@@ -1207,28 +1207,31 @@ bool ClientField::CheckSelectSum() {
} }
return ret; return ret;
} else { } else {
int op1, op2, mm = -1, ms, m, max = 0, sumc = 0, sums; int mm = -1, mx = -1, max = 0, sumc = 0;
bool ret = false; bool ret = false;
for (size_t i = 0; i < selected_cards.size(); ++i) { for (size_t i = 0; i < selected_cards.size(); ++i) {
op1 = selected_cards[i]->opParam & 0xffff; int op1 = selected_cards[i]->opParam & 0xffff;
op2 = selected_cards[i]->opParam >> 16; int op2 = selected_cards[i]->opParam >> 16;
m = (op2 > 0 && op1 > op2) ? op2 : op1; int opmin = (op2 > 0 && op1 > op2) ? op2 : op1;
max += op2 > op1 ? op2 : op1; int opmax = op2 > op1 ? op2 : op1;
if (mm == -1 || m < mm) if (mm == -1 || opmin < mm)
mm = m; mm = opmin;
sumc += m; if (mx == -1 || opmax < mx)
mx = opmax;
sumc += opmin;
max += opmax;
} }
if (select_sumval <= sumc) if (select_sumval <= sumc)
return true; return true;
if (select_sumval <= max) if (select_sumval <= max && select_sumval > max - mx)
ret = true; ret = true;
for(sit = selable.begin(); sit != selable.end(); ++sit) { for(sit = selable.begin(); sit != selable.end(); ++sit) {
op1 = (*sit)->opParam & 0xffff; int op1 = (*sit)->opParam & 0xffff;
op2 = (*sit)->opParam >> 16; int op2 = (*sit)->opParam >> 16;
m = op1; int m = op1;
sums = sumc; int sums = sumc;
sums += m; sums += m;
ms = mm; int ms = mm;
if (ms == -1 || m < ms) if (ms == -1 || m < ms)
ms = m; ms = m;
if (sums >= select_sumval) { if (sums >= select_sumval) {
......
Subproject commit 96bbbedb6e828f4a227cf5405ed8e284b0def2cc Subproject commit f524c6bfe7055405efba5ea98ac8bc688b1ecad4
Subproject commit 5485784eac297306878f20f2c6cd4a0a51698653 Subproject commit 83adfae3f0e9da818082db24e055a6077d8b7c6b
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