1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Attempt to fix automatic segment heights

This commit is contained in:
Marijn van der Werf
2016-10-17 00:31:53 +02:00
parent deb266c443
commit 1bd87537eb
3 changed files with 64 additions and 6 deletions

View File

@@ -14,6 +14,8 @@
*****************************************************************************/
#pragma endregion
#include <map>
#include "SegmentSupportHeightCall.hpp"
extern "C" {
@@ -110,3 +112,41 @@ bool SegmentSupportHeightCall::CallsEqual(std::vector<SegmentSupportCall> lhs, s
return true;
}
std::vector<SegmentSupportCall>* SegmentSupportHeightCall::FindMostCommonSupportCall(std::vector<SegmentSupportCall> *calls) {
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;
}
}
if (map.size() == 1) {
return &calls[0];
}
if (map.size() == 2) {
for (auto &&item : map) {
if (item.second == 3) {
return (std::vector<SegmentSupportCall> *)&item.first;
}
}
return nullptr;
}
if (map.size() == 3) {
for (auto &&item : map) {
if (item.second == 2) {
return (std::vector<SegmentSupportCall> *)&item.first;
}
}
return nullptr;
}
return nullptr;
}