OpenRCT2/test/testpaint/VerticalTunnelCall.cpp

36 lines
1.2 KiB
C++
Raw Normal View History

2016-10-17 12:22:15 +02:00
/*****************************************************************************
* Copyright (c) 2014-2018 OpenRCT2 developers
2016-10-17 12:22:15 +02:00
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
2016-10-17 12:22:15 +02:00
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
2016-10-17 12:22:15 +02:00
*****************************************************************************/
#include "VerticalTunnelCall.hpp"
uint16_t VerticalTunnelCall::GetTunnelHeight(uint16_t baseHeight, uint8_t *calls) {
2017-01-17 23:57:53 +01:00
if (calls[0] == 0 && calls[1] == 0 && calls[2] == 0) {
return 0;
}
for (int16_t offset = 0; offset <= 256; offset += 8) {
2017-01-17 23:57:53 +01:00
if (calls[0] != (baseHeight - 8 + offset) / 16) continue;
if (calls[1] != (baseHeight + 0 + offset) / 16) continue;
if (calls[2] != (baseHeight + 8 + offset) / 16) continue;
return baseHeight + offset;
}
log_error("Unknown tunnel height. (%d, %d, %d)", calls[0], calls[1], calls[2]);
return 0;
}
bool VerticalTunnelCall::HeightIsConsistent(uint16_t *heights) {
2016-10-17 12:22:15 +02:00
for (int i = 1; i < 4; ++i) {
if (heights[i] != heights[0]) return false;
}
return true;
}