mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #5087 from marijnvdwerf/fix/vertical-tunnels
Test vertical tunnels properly
This commit is contained in:
commit
f6b55b4a0d
|
@ -45,6 +45,10 @@ uint8 gRightTunnelCount;
|
|||
uint8 gVerticalTunnelHeight;
|
||||
#endif
|
||||
|
||||
#ifdef __TESTPAINT__
|
||||
uint16 testPaintVerticalTunnelHeight;
|
||||
#endif
|
||||
|
||||
static void blank_tiles_paint(sint32 x, sint32 y);
|
||||
static void sub_68B3FB(sint32 x, sint32 y);
|
||||
|
||||
|
@ -333,6 +337,9 @@ void paint_util_push_tunnel_right(uint16 height, uint8 type)
|
|||
|
||||
void paint_util_set_vertical_tunnel(uint16 height)
|
||||
{
|
||||
#ifdef __TESTPAINT__
|
||||
testPaintVerticalTunnelHeight = height;
|
||||
#endif
|
||||
gVerticalTunnelHeight = height / 16;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,10 @@ extern uint8 gVerticalTunnelHeight;
|
|||
#define gVerticalTunnelHeight RCT2_GLOBAL(0x009E323C, uint8)
|
||||
#endif
|
||||
|
||||
#ifdef __TESTPAINT__
|
||||
extern uint16 testPaintVerticalTunnelHeight;
|
||||
#endif
|
||||
|
||||
extern bool gShowSupportSegmentHeights;
|
||||
|
||||
extern const rct_xy16 BannerBoundBoxes[][2];
|
||||
|
|
|
@ -3062,7 +3062,7 @@ void bolliger_mabillard_track_60_deg_up_to_90_deg_up(uint8 rideIndex, uint8 trac
|
|||
if (direction == 0 || direction == 3) {
|
||||
paint_util_push_tunnel_rotated(direction, height - 8, TUNNEL_7);
|
||||
}
|
||||
paint_util_set_vertical_tunnel(height + 48);
|
||||
paint_util_set_vertical_tunnel(height + 56);
|
||||
paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
|
||||
paint_util_set_general_support_height(height + 56, 0x20);
|
||||
break;
|
||||
|
|
|
@ -3526,7 +3526,7 @@ static void compact_inverted_rc_track_60_deg_up_to_90_deg_up(uint8 rideIndex, ui
|
|||
if (direction == 0 || direction == 3) {
|
||||
paint_util_push_tunnel_rotated(direction, height - 8, TUNNEL_4);
|
||||
}
|
||||
paint_util_set_vertical_tunnel(height + 48);
|
||||
paint_util_set_vertical_tunnel(height + 56);
|
||||
paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
|
||||
paint_util_set_general_support_height(height + 72, 0x20);
|
||||
break;
|
||||
|
|
|
@ -371,7 +371,7 @@ static void inverted_impulse_rc_track_60_deg_up_to_90_deg_up(uint8 rideIndex, ui
|
|||
if (direction == 0 || direction == 3) {
|
||||
paint_util_push_tunnel_rotated(direction, height - 8, TUNNEL_4);
|
||||
}
|
||||
paint_util_set_vertical_tunnel(height + 48);
|
||||
paint_util_set_vertical_tunnel(height + 56);
|
||||
paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
|
||||
paint_util_set_general_support_height(height + 72, 0x20);
|
||||
break;
|
||||
|
|
|
@ -971,7 +971,7 @@ static void lim_launched_rc_track_60_deg_up_to_90_deg_up(uint8 rideIndex, uint8
|
|||
if (direction == 0 || direction == 3) {
|
||||
paint_util_push_tunnel_rotated(direction, height - 8, TUNNEL_1);
|
||||
}
|
||||
paint_util_set_vertical_tunnel(height + 48);
|
||||
paint_util_set_vertical_tunnel(height + 56);
|
||||
paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
|
||||
paint_util_set_general_support_height(height + 56, 0x20);
|
||||
break;
|
||||
|
|
|
@ -4182,7 +4182,7 @@ static void multi_dimension_rc_track_60_deg_up_to_90_deg_up(uint8 rideIndex, uin
|
|||
if (direction == 0 || direction == 3) {
|
||||
paint_util_push_tunnel_rotated(direction, height - 8, TUNNEL_7);
|
||||
}
|
||||
paint_util_set_vertical_tunnel(height + 48);
|
||||
paint_util_set_vertical_tunnel(height + 56);
|
||||
paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
|
||||
paint_util_set_general_support_height(height + 56, 0x20);
|
||||
break;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "VerticalTunnelCall.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <openrct2/paint/map_element/map_element.h>
|
||||
#include <openrct2/paint/supports.h>
|
||||
#include <openrct2/ride/ride.h>
|
||||
#include <openrct2/ride/track.h>
|
||||
|
@ -700,15 +701,21 @@ static uint8 TestTrackElementVerticalTunnels(uint8 rideType, uint8 trackType, ui
|
|||
TestPaint::ResetEnvironment();
|
||||
TestPaint::ResetTunnels();
|
||||
|
||||
uint8 verticalTunnelHeight[4];
|
||||
uint16 verticalTunnelHeights[4];
|
||||
|
||||
for (int direction = 0; direction < 4; direction++) {
|
||||
gVerticalTunnelHeight = 0;
|
||||
CallOriginal(rideType, trackType, direction, trackSequence, height, &mapElement);
|
||||
verticalTunnelHeight[direction] = gVerticalTunnelHeight;
|
||||
uint8 tunnelHeights[3] = {0};
|
||||
|
||||
for (uint8 i = 0; i < 3; i++) {
|
||||
gVerticalTunnelHeight = 0;
|
||||
CallOriginal(rideType, trackType, direction, trackSequence, height - 8 + i * 8, &mapElement);
|
||||
tunnelHeights[i] = gVerticalTunnelHeight;
|
||||
}
|
||||
|
||||
verticalTunnelHeights[direction] = VerticalTunnelCall::GetTunnelHeight(height, tunnelHeights);
|
||||
}
|
||||
|
||||
if (!VerticalTunnelCall::HeightIsConsistent(verticalTunnelHeight)) {
|
||||
if (!VerticalTunnelCall::HeightIsConsistent(verticalTunnelHeights)) {
|
||||
*error += String::Format(
|
||||
"Original vertical tunnel height is inconsistent, skipping test. [trackSequence:%d]\n",
|
||||
trackSequence
|
||||
|
@ -716,30 +723,33 @@ static uint8 TestTrackElementVerticalTunnels(uint8 rideType, uint8 trackType, ui
|
|||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
uint8 referenceHeight = verticalTunnelHeight[0];
|
||||
uint16 referenceHeight = verticalTunnelHeights[0];
|
||||
|
||||
for (int direction = 0; direction < 4; direction++) {
|
||||
gVerticalTunnelHeight = 0;
|
||||
|
||||
testpaint_clear_ignore();
|
||||
CallOriginal(rideType, trackType, direction, trackSequence, height, &mapElement);
|
||||
|
||||
testPaintVerticalTunnelHeight = 0;
|
||||
CallNew(rideType, trackType, direction, trackSequence, height, &mapElement);
|
||||
|
||||
if (testpaint_is_ignored(direction, trackSequence)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gVerticalTunnelHeight != referenceHeight) {
|
||||
if (gVerticalTunnelHeight == 0) {
|
||||
if (testPaintVerticalTunnelHeight != referenceHeight) {
|
||||
if (referenceHeight == 0) {
|
||||
*error += String::Format(
|
||||
"Expected no tunnel. Actual: %d [trackSequence:%d]\n",
|
||||
gVerticalTunnelHeight, trackSequence
|
||||
"Expected no tunnel. Actual: %s [trackSequence:%d]\n",
|
||||
Printer::PrintHeightOffset(testPaintVerticalTunnelHeight, height).c_str(),
|
||||
trackSequence
|
||||
);
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
*error += String::Format(
|
||||
"Expected vertical tunnel height to be `%s`, was `%s`. [trackSequence:%d direction:%d]\n",
|
||||
Printer::PrintHeightOffset((referenceHeight * 16), height).c_str(),
|
||||
Printer::PrintHeightOffset((gVerticalTunnelHeight * 16), height).c_str(),
|
||||
Printer::PrintHeightOffset(referenceHeight, height).c_str(),
|
||||
Printer::PrintHeightOffset(testPaintVerticalTunnelHeight, height).c_str(),
|
||||
trackSequence,
|
||||
direction
|
||||
);
|
||||
|
|
|
@ -16,7 +16,24 @@
|
|||
|
||||
#include "VerticalTunnelCall.hpp"
|
||||
|
||||
bool VerticalTunnelCall::HeightIsConsistent(uint8 heights[4]) {
|
||||
uint16 VerticalTunnelCall::GetTunnelHeight(uint16 baseHeight, uint8 *calls) {
|
||||
if (calls[0] == 0 && calls[1] == 0 && calls[2] == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (sint16 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;
|
||||
|
||||
return baseHeight + offset;
|
||||
}
|
||||
|
||||
log_error("Unknown tunnel height. (%d, %d, %d)", calls[0], calls[1], calls[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VerticalTunnelCall::HeightIsConsistent(uint16 *heights) {
|
||||
for (int i = 1; i < 4; ++i) {
|
||||
if (heights[i] != heights[0]) return false;
|
||||
}
|
||||
|
|
|
@ -19,5 +19,6 @@
|
|||
#include <openrct2/common.h>
|
||||
|
||||
namespace VerticalTunnelCall {
|
||||
bool HeightIsConsistent(uint8 heights[4]);
|
||||
uint16 GetTunnelHeight(uint16 baseHeight, uint8 *calls);
|
||||
bool HeightIsConsistent(uint16 *heights);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue