mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 21:52:55 +01:00
Extract tunnel/segment resetting
This commit is contained in:
@@ -38,9 +38,9 @@ uint16 gUnk141E9DC;
|
||||
rct_xy16 gPaintMapPosition;
|
||||
bool gDidPassSurface;
|
||||
rct_map_element * gSurfaceElement;
|
||||
tunnel_entry gLeftTunnels[65];
|
||||
tunnel_entry gLeftTunnels[TUNNEL_MAX_COUNT];
|
||||
uint8 gLeftTunnelCount;
|
||||
tunnel_entry gRightTunnels[65];
|
||||
tunnel_entry gRightTunnels[TUNNEL_MAX_COUNT];
|
||||
uint8 gRightTunnelCount;
|
||||
uint8 gVerticalTunnelHeight;
|
||||
#endif
|
||||
|
||||
@@ -80,15 +80,17 @@ enum
|
||||
G141E9DB_FLAG_2 = 2,
|
||||
};
|
||||
|
||||
#define TUNNEL_MAX_COUNT 65
|
||||
|
||||
#ifdef NO_RCT2
|
||||
extern uint8 g141E9DB;
|
||||
extern uint16 gUnk141E9DC;
|
||||
extern rct_xy16 gPaintMapPosition;
|
||||
extern bool gDidPassSurface;
|
||||
extern rct_map_element * gSurfaceElement;
|
||||
extern tunnel_entry gLeftTunnels[65];
|
||||
extern tunnel_entry gLeftTunnels[TUNNEL_MAX_COUNT];
|
||||
extern uint8 gLeftTunnelCount;
|
||||
extern tunnel_entry gRightTunnels[65];
|
||||
extern tunnel_entry gRightTunnels[TUNNEL_MAX_COUNT];
|
||||
extern uint8 gRightTunnelCount;
|
||||
extern uint8 gVerticalTunnelHeight;
|
||||
#else
|
||||
|
||||
@@ -632,7 +632,7 @@ static void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height,
|
||||
// Normal walls
|
||||
while (curHeight > tunnelArray[0].height) {
|
||||
// TODO: Should probably be done by just keeping track of the current index
|
||||
memmove(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * 64);
|
||||
memmove(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * (TUNNEL_MAX_COUNT - 1));
|
||||
}
|
||||
|
||||
if (curHeight != tunnelArray[0].height) {
|
||||
@@ -680,7 +680,7 @@ static void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height,
|
||||
curHeight += stru_97B570[tunnelType][0];
|
||||
|
||||
// TODO: Should probably be done by just keeping track of the current index
|
||||
memmove(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * 64);
|
||||
memmove(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * (TUNNEL_MAX_COUNT - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,7 +902,7 @@ static void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height
|
||||
// Normal walls
|
||||
while (curHeight > tunnelArray[0].height) {
|
||||
// TODO: Should probably be done by just keeping track of the current index
|
||||
memmove(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * 64);
|
||||
memmove(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * (TUNNEL_MAX_COUNT - 1));
|
||||
}
|
||||
|
||||
sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation);
|
||||
@@ -948,7 +948,7 @@ static void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height
|
||||
curHeight += stru_97B570[tunnelType][0];
|
||||
|
||||
// TODO: Should probably be done by just keeping track of the current index
|
||||
memmove(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * 64);
|
||||
memmove(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * (TUNNEL_MAX_COUNT - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1312,18 +1312,18 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement)
|
||||
log_verbose("eax: %d", eax);
|
||||
}
|
||||
|
||||
tunnel_entry backupLeftTunnels[65];
|
||||
tunnel_entry backupRightTunnels[65];
|
||||
tunnel_entry backupLeftTunnels[TUNNEL_MAX_COUNT];
|
||||
tunnel_entry backupRightTunnels[TUNNEL_MAX_COUNT];
|
||||
|
||||
#ifdef __MINGW32__
|
||||
// The other code crashes mingw 4.8.2, as available on Travis
|
||||
for (int i = 0; i < 65; i++) {
|
||||
for (int i = 0; i < TUNNEL_MAX_COUNT; i++) {
|
||||
backupLeftTunnels[i] = gLeftTunnels[i];
|
||||
backupRightTunnels[i] = gRightTunnels[i];
|
||||
}
|
||||
#else
|
||||
memcpy(backupLeftTunnels, gLeftTunnels, sizeof(tunnel_entry) * 65);
|
||||
memcpy(backupRightTunnels, gRightTunnels, sizeof(tunnel_entry) * 65);
|
||||
memcpy(backupLeftTunnels, gLeftTunnels, sizeof(tunnel_entry) * TUNNEL_MAX_COUNT);
|
||||
memcpy(backupRightTunnels, gRightTunnels, sizeof(tunnel_entry) * TUNNEL_MAX_COUNT);
|
||||
#endif
|
||||
|
||||
viewport_surface_draw_land_side_top(EDGE_TOPLEFT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[3]);
|
||||
@@ -1334,13 +1334,13 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement)
|
||||
|
||||
#ifdef __MINGW32__
|
||||
// The other code crashes mingw 4.8.2, as available on Travis
|
||||
for (int i = 0; i < 65; i++) {
|
||||
for (int i = 0; i < TUNNEL_MAX_COUNT; i++) {
|
||||
gLeftTunnels[i] = backupLeftTunnels[i];
|
||||
gRightTunnels[i] = backupRightTunnels[i];
|
||||
}
|
||||
#else
|
||||
memcpy(gLeftTunnels, backupLeftTunnels, sizeof(tunnel_entry) * 65);
|
||||
memcpy(gRightTunnels, backupRightTunnels, sizeof(tunnel_entry) * 65);
|
||||
memcpy(gLeftTunnels, backupLeftTunnels, sizeof(tunnel_entry) * TUNNEL_MAX_COUNT);
|
||||
memcpy(gRightTunnels, backupRightTunnels, sizeof(tunnel_entry) * TUNNEL_MAX_COUNT);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -737,8 +737,8 @@ private:
|
||||
Intercept2::TunnelCall tileTunnelCalls[4][4],
|
||||
sint16 verticalTunnelHeights[4])
|
||||
{
|
||||
gLeftTunnelCount = 0;
|
||||
gRightTunnelCount = 0;
|
||||
intercept_reset_tunnels();
|
||||
|
||||
for (int offset = -8; offset <= 8; offset += 8)
|
||||
{
|
||||
CallOriginal(trackType, direction, trackSequence, height + offset, mapElement);
|
||||
@@ -1005,6 +1005,7 @@ private:
|
||||
void CallOriginal(int trackType, int direction, int trackSequence, int height, rct_map_element *mapElement)
|
||||
{
|
||||
intercept_reset_environment();
|
||||
intercept_reset_segment_heights();
|
||||
|
||||
uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[_rideType][trackType];
|
||||
// Have to call from this point as it pushes esi and expects callee to pop it
|
||||
|
||||
@@ -368,11 +368,9 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string error,
|
||||
RCT2_GLOBAL(0x009DE56E, sint16) = 64; // y
|
||||
gDidPassSurface = true; // Above surface
|
||||
gSurfaceElement = &surfaceElement;
|
||||
g141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2;
|
||||
|
||||
intercept_clear_calls();
|
||||
|
||||
memcpy(gSupportSegments, DefaultSegmentHeight, sizeof(support_height) * 9);
|
||||
intercept_reset_segment_heights();
|
||||
|
||||
uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType];
|
||||
|
||||
@@ -396,7 +394,8 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string error,
|
||||
intercept_clear_calls();
|
||||
|
||||
testpaint_clear_ignore();
|
||||
memcpy(gSupportSegments, DefaultSegmentHeight, sizeof(support_height) * 9);
|
||||
intercept_reset_segment_heights();
|
||||
|
||||
newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement);
|
||||
if (testpaint_is_ignored(direction, trackSequence)) {
|
||||
snprintf(error, len, "[ IGNORED ] [direction:%d trackSequence:%d chainLift:%d inverted:%d]\n",
|
||||
|
||||
@@ -86,6 +86,8 @@ extern "C"
|
||||
void intercept_clear_calls();
|
||||
int intercept_get_calls(function_call * buffer);
|
||||
void intercept_reset_environment();
|
||||
void intercept_reset_segment_heights();
|
||||
void intercept_reset_tunnels();
|
||||
void intercept_simulate_wooden_supports(bool enabled);
|
||||
bool assertFunctionCallEquals(function_call expected, function_call actual);
|
||||
|
||||
|
||||
@@ -51,6 +51,23 @@ namespace Intercept2
|
||||
gRideList[0] = ride;
|
||||
gRideEntries[0] = &rideEntry;
|
||||
|
||||
g141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2;
|
||||
}
|
||||
|
||||
static void ResetTunnels() {
|
||||
gLeftTunnelCount = 0;
|
||||
gRightTunnelCount = 0;
|
||||
|
||||
for (int i = 0; i < TUNNEL_MAX_COUNT; i++) {
|
||||
gLeftTunnels[i] = (tunnel_entry) {0, 0};
|
||||
gRightTunnels[i] = (tunnel_entry) {0, 0};
|
||||
}
|
||||
|
||||
gLeftTunnels[0] = (tunnel_entry) {0xFF, 0xFF};
|
||||
gRightTunnels[0] = (tunnel_entry) {0xFF, 0xFF};
|
||||
}
|
||||
|
||||
static void ResetSegmentHeights() {
|
||||
for (int s = 0; s < 9; ++s)
|
||||
{
|
||||
gSupportSegments[s].height = 0;
|
||||
@@ -59,7 +76,6 @@ namespace Intercept2
|
||||
|
||||
gSupport.height = 0;
|
||||
gSupport.slope = 0xFF;
|
||||
g141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2;
|
||||
}
|
||||
|
||||
static bool SortSegmentSupportCalls(SegmentSupportCall lhs, SegmentSupportCall rhs)
|
||||
@@ -331,6 +347,7 @@ namespace Intercept2
|
||||
surfaceElement.base_height = 2;
|
||||
|
||||
ResetEnvironment();
|
||||
ResetTunnels();
|
||||
|
||||
int height = 48;
|
||||
|
||||
@@ -349,14 +366,7 @@ namespace Intercept2
|
||||
SupportCall tileGeneralSupportCalls[4];
|
||||
|
||||
for (int direction = 0; direction < 4; direction++) {
|
||||
for (int s = 0; s < 9; ++s) {
|
||||
gSupportSegments[s].height = 0;
|
||||
gSupportSegments[s].slope = 0xFF;
|
||||
}
|
||||
|
||||
gSupport.height = 0;
|
||||
gSupport.slope = 0xFF;
|
||||
g141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2;
|
||||
ResetSegmentHeights();
|
||||
|
||||
uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType];
|
||||
|
||||
@@ -391,10 +401,7 @@ namespace Intercept2
|
||||
}
|
||||
|
||||
for (int direction = 0; direction < 4; direction++) {
|
||||
for (int s = 0; s < 9; ++s) {
|
||||
gSupportSegments[s].height = 0;
|
||||
gSupportSegments[s].slope = 0xFF;
|
||||
}
|
||||
ResetSegmentHeights();
|
||||
|
||||
testpaint_clear_ignore();
|
||||
TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction);
|
||||
@@ -438,8 +445,7 @@ namespace Intercept2
|
||||
|
||||
|
||||
for (int direction = 0; direction < 4; direction++) {
|
||||
gSupport.height = 0;
|
||||
gSupport.slope = 0xFF;
|
||||
ResetSegmentHeights();
|
||||
|
||||
testpaint_clear_ignore();
|
||||
TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction);
|
||||
@@ -523,8 +529,7 @@ namespace Intercept2
|
||||
TunnelCall tileTunnelCalls[4][4];
|
||||
|
||||
for (int direction = 0; direction < 4; direction++) {
|
||||
gLeftTunnelCount = 0;
|
||||
gRightTunnelCount = 0;
|
||||
ResetTunnels();
|
||||
|
||||
uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType];
|
||||
|
||||
@@ -849,4 +854,14 @@ extern "C"
|
||||
void intercept_reset_environment() {
|
||||
Intercept2::ResetEnvironment();
|
||||
}
|
||||
|
||||
void intercept_reset_segment_heights() {
|
||||
Intercept2::ResetSegmentHeights();
|
||||
}
|
||||
|
||||
void intercept_reset_tunnels() {
|
||||
Intercept2::ResetTunnels();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user