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