OpenRCT2/test/testpaint/VerticalTunnelCall.cpp

45 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"
2018-06-22 22:29:03 +02:00
uint16_t VerticalTunnelCall::GetTunnelHeight(uint16_t baseHeight, uint8_t* calls)
{
if (calls[0] == 0 && calls[1] == 0 && calls[2] == 0)
{
2017-01-17 23:57:53 +01:00
return 0;
}
2018-06-22 22:29:03 +02:00
for (int16_t offset = 0; offset <= 256; offset += 8)
{
if (calls[0] != (baseHeight - 8 + offset) / 16)
continue;
if (calls[1] != (baseHeight + 0 + offset) / 16)
continue;
if (calls[2] != (baseHeight + 8 + offset) / 16)
continue;
2017-01-17 23:57:53 +01:00
return baseHeight + offset;
}
log_error("Unknown tunnel height. (%d, %d, %d)", calls[0], calls[1], calls[2]);
return 0;
}
2018-06-22 22:29:03 +02:00
bool VerticalTunnelCall::HeightIsConsistent(uint16_t* heights)
{
for (int i = 1; i < 4; ++i)
{
if (heights[i] != heights[0])
return false;
2016-10-17 12:22:15 +02:00
}
return true;
}