1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 16:54:52 +01:00

Fix General/SegmentSupportHeightCalls

This commit is contained in:
Marijn van der Werf
2016-10-17 23:12:54 +02:00
parent 4f10555002
commit a44745e2fa
6 changed files with 50 additions and 48 deletions

View File

@@ -114,40 +114,39 @@ bool SegmentSupportHeightCall::CallsEqual(std::vector<SegmentSupportCall> lhs, s
return true;
}
std::vector<SegmentSupportCall>* SegmentSupportHeightCall::FindMostCommonSupportCall(std::vector<SegmentSupportCall> *calls) {
bool SegmentSupportHeightCall::FindMostCommonSupportCall(std::vector<SegmentSupportCall> calls[4], std::vector<SegmentSupportCall> *out) {
std::map<std::vector<SegmentSupportCall>, int> map;
for (int i = 0; i < 4; ++i) {
if (map.count(calls[i]) == 0) {
map[calls[i]] = 1;
} else {
map[calls[i]] += 1;
}
map[calls[i]] += 1;
}
if (map.size() == 1) {
return &calls[0];
(*out) = calls[0];
return true;
}
if (map.size() == 2) {
for (auto &&item : map) {
if (item.second == 3) {
return (std::vector<SegmentSupportCall> *)&item.first;
(*out) = item.first;
return true;
}
}
return nullptr;
return false;
}
if (map.size() == 3) {
for (auto &&item : map) {
if (item.second == 2) {
return (std::vector<SegmentSupportCall> *)&item.first;
(*out) = item.first;
return true;
}
}
return nullptr;
return false;
}
return nullptr;
return false;
}