Commit 949f8d23 authored by DailyShana's avatar DailyShana

fix client_card_sort

to satisfy strict weak ordering
parent 7680c3c3
...@@ -213,14 +213,17 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { ...@@ -213,14 +213,17 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
else return c1->sequence < c2->sequence; else return c1->sequence < c2->sequence;
else { else {
if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) { if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) {
for(size_t i = 0; i < mainGame->dField.chains.size(); ++i) { auto it1 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c1](const auto& ch) {
auto chit = mainGame->dField.chains[i]; return c1 == ch.chain_card || ch.target.find(c1) != ch.target.end();
if(c1 == chit.chain_card || chit.target.find(c1) != chit.target.end()) });
return true; auto it2 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c2](const auto& ch) {
return c2 == ch.chain_card || ch.target.find(c2) != ch.target.end();
});
if(it1 != mainGame->dField.chains.rend() || it2 != mainGame->dField.chains.rend()) {
return it1 < it2;
} }
return c1->sequence > c2->sequence; return c1->sequence > c2->sequence;
} } else
else
return c1->sequence < c2->sequence; return c1->sequence < c2->sequence;
} }
} }
......
...@@ -72,6 +72,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -72,6 +72,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <time.h> #include <time.h>
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include <algorithm>
#include "bufferio.h" #include "bufferio.h"
#include "myfilesystem.h" #include "myfilesystem.h"
#include "mysignal.h" #include "mysignal.h"
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "sound_manager.h" #include "sound_manager.h"
#include "game.h" #include "game.h"
#include "duelclient.h" #include "duelclient.h"
#include <algorithm>
namespace ygo { namespace ygo {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include "data_manager.h" #include "data_manager.h"
#include "network.h" #include "network.h"
#include "game.h" #include "game.h"
#include <algorithm>
namespace ygo { namespace ygo {
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "game.h" #include "game.h"
#include "replay.h" #include "replay.h"
#include "replay_mode.h" #include "replay_mode.h"
#include <algorithm>
namespace ygo { namespace ygo {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "single_mode.h" #include "single_mode.h"
#include "materials.h" #include "materials.h"
#include "../ocgcore/common.h" #include "../ocgcore/common.h"
#include <algorithm>
namespace ygo { namespace ygo {
......
#include "replay.h" #include "replay.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h" #include "../ocgcore/common.h"
#include <algorithm>
#include "lzma/LzmaLib.h" #include "lzma/LzmaLib.h"
namespace ygo { namespace ygo {
......
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