diff --git a/test/testpaint/compat.c b/test/testpaint/compat.c index 5abcc01db6..989c87a4cb 100644 --- a/test/testpaint/compat.c +++ b/test/testpaint/compat.c @@ -155,3 +155,8 @@ bool track_element_is_lift_hill(rct_map_element *trackElement) { return trackElement->type & 0x80; } + +bool track_element_is_cable_lift(rct_map_element *trackElement) +{ + return trackElement->properties.track.colour & TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT; +} diff --git a/test/testpaint/generate.cpp b/test/testpaint/generate.cpp index 496272aadc..8008e04ade 100644 --- a/test/testpaint/generate.cpp +++ b/test/testpaint/generate.cpp @@ -285,7 +285,7 @@ private: { int height = 48; - std::vector calls[4]; + std::vector calls[4], chainLiftCalls[4], cableLiftCalls[4]; Intercept2::TunnelCall tileTunnelCalls[4][4]; std::vector segmentSupportCalls[4]; support_height generalSupports[4] = { 0 }; @@ -306,10 +306,55 @@ private: generalSupports[direction] = gSupport; generalSupports[direction].height -= height; + // Get chain lift calls + mapElement.type |= 0x80; + intercept_clear_calls(); + CallOriginal(trackType, direction, trackSequence, height, &mapElement); + numCalls = intercept_get_calls(callBuffer); + chainLiftCalls[direction].insert(chainLiftCalls[direction].begin(), callBuffer, callBuffer + numCalls); + + // Get cable lift calls (giga coaster only) + if (_rideType == RIDE_TYPE_GIGA_COASTER) + { + mapElement.type = 0; + mapElement.properties.track.colour = 8; + intercept_clear_calls(); + CallOriginal(trackType, direction, trackSequence, height, &mapElement); + numCalls = intercept_get_calls(callBuffer); + cableLiftCalls[direction].insert(cableLiftCalls[direction].begin(), callBuffer, callBuffer + numCalls); + } + GetTunnelCalls(trackType, direction, trackSequence, height, &mapElement, tileTunnelCalls); } - GenerateCalls(tabs, calls, height); + if (!CompareFunctionCalls(calls, cableLiftCalls)) + { + WriteLine(tabs, "if (track_element_is_cable_lift(mapElement)) {"); + GenerateCalls(tabs + 1, cableLiftCalls, height); + + if (!CompareFunctionCalls(calls, chainLiftCalls)) + { + WriteLine(tabs, "} else if (track_element_is_lift_hill(mapElement)) {"); + GenerateCalls(tabs + 1, chainLiftCalls, height); + } + + WriteLine(tabs, "} else {"); + GenerateCalls(tabs + 1, calls, height); + WriteLine(tabs, "}"); + } + else if (!CompareFunctionCalls(calls, chainLiftCalls)) + { + WriteLine(tabs, "if (track_element_is_lift_hill(mapElement)) {"); + GenerateCalls(tabs + 1, chainLiftCalls, height); + WriteLine(tabs, "} else {"); + GenerateCalls(tabs + 1, calls, height); + WriteLine(tabs, "}"); + } + else + { + GenerateCalls(tabs, calls, height); + } + GenerateTunnelCall(tabs, tileTunnelCalls); GenerateSegmentSupportCall(tabs, segmentSupportCalls); GenerateGeneralSupportCall(tabs, generalSupports); @@ -457,6 +502,18 @@ private: return commonCalls; } + bool CompareFunctionCalls(const std::vector a[4], const std::vector b[4]) + { + for (size_t i = 0; i < 4; i++) + { + if (!CompareFunctionCalls(a[i], b[i])) + { + return false; + } + } + return true; + } + bool CompareFunctionCalls(const std::vector &a, const std::vector &b) { if (a.size() != b.size()) return false; @@ -722,7 +779,7 @@ private: (int) trackDirectionList, direction, height, - (int) &mapElement, + (int)mapElement, 0 * sizeof(rct_ride), trackSequence );