Commit 6ad3fd52 authored by mercury233's avatar mercury233 Committed by GitHub

fix select_place accept selecting same field twice (#382)

parent a5de4ce1
...@@ -432,16 +432,23 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count) ...@@ -432,16 +432,23 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count)
return FALSE; return FALSE;
} else { } else {
uint8 pt = 0; uint8 pt = 0;
uint32 selected = 0;
for(int8 i = 0; i < count; ++i) { for(int8 i = 0; i < count; ++i) {
uint8 p = returns.bvalue[pt]; uint8 p = returns.bvalue[pt];
uint8 l = returns.bvalue[pt + 1]; uint8 l = returns.bvalue[pt + 1];
uint8 s = returns.bvalue[pt + 2]; uint8 s = returns.bvalue[pt + 2];
uint32 sel = 0x1u << (s + (p == playerid ? 0 : 16) + (l == LOCATION_MZONE ? 0 : 8));
if((p != 0 && p != 1) if((p != 0 && p != 1)
|| ((l != LOCATION_MZONE) && (l != LOCATION_SZONE)) || ((l != LOCATION_MZONE) && (l != LOCATION_SZONE))
|| ((0x1u << s) & (flag >> (((p == playerid) ? 0 : 16) + ((l == LOCATION_MZONE) ? 0 : 8))))) { || (sel & flag) || (sel & selected)) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
if(sel & (0x1 << 5))
sel |= 0x1 << (16 + 6);
if(sel & (0x1 << 6))
sel |= 0x1 << (16 + 5);
selected |= sel;
pt += 3; pt += 3;
} }
return TRUE; return TRUE;
......
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