Commit 39279c42 authored by VanillaSalt's avatar VanillaSalt

ShuffleSetCard: use Fisher-Yates shuffle

parent 416b733f
...@@ -1135,13 +1135,9 @@ int32 scriptlib::duel_shuffle_setcard(lua_State *L) { ...@@ -1135,13 +1135,9 @@ int32 scriptlib::duel_shuffle_setcard(lua_State *L) {
seq[ct] = pcard->current.sequence; seq[ct] = pcard->current.sequence;
ct++; ct++;
} }
for(uint32 p = 0; p < 2; ++p) { for(int32 i = ct - 1; i > 0; --i) {
for(uint32 i = 0; i < ct; ++i) { int32 s = pduel->get_next_integer(0, i);
uint8 s = pduel->get_next_integer(0, ct - 1); std::swap(ms[i], ms[s]);
pcard = ms[s];
ms[s] = ms[i];
ms[i] = pcard;
}
} }
pduel->write_buffer8(MSG_SHUFFLE_SET_CARD); pduel->write_buffer8(MSG_SHUFFLE_SET_CARD);
pduel->write_buffer8(ct); pduel->write_buffer8(ct);
......
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