mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Block segments before drawing supports
This commit is contained in:
@@ -368,10 +368,23 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
void ExtractMetalSupportCalls(std::vector<function_call> calls[4], std::vector<function_call> output[4])
|
||||
{
|
||||
for (int direction = 0; direction < 4; direction++) {
|
||||
|
||||
auto cutPoint = std::find_if(calls[direction].begin(), calls[direction].end(), [](function_call call) {
|
||||
return (call.function == SUPPORTS_METAL_A || call.function == SUPPORTS_METAL_B);
|
||||
});
|
||||
output[direction].insert(output[direction].begin(), cutPoint, calls[direction].end());
|
||||
calls[direction].erase(cutPoint, calls[direction].end());
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateTrackSequence(int tabs, int trackType, int trackSequence)
|
||||
{
|
||||
int height = 48;
|
||||
_conditionalSupports = false;
|
||||
bool blockSegmentsBeforeSupports = false;
|
||||
|
||||
std::vector<function_call> calls[4], chainLiftCalls[4], cableLiftCalls[4];
|
||||
Intercept2::TunnelCall tileTunnelCalls[4][4];
|
||||
@@ -399,6 +412,13 @@ private:
|
||||
int numCalls = intercept_get_calls(callBuffer);
|
||||
calls[direction].insert(calls[direction].begin(), callBuffer, callBuffer + numCalls);
|
||||
|
||||
for (auto &&call : calls[direction]) {
|
||||
if (call.function == SET_SEGMENT_HEIGHT) {
|
||||
blockSegmentsBeforeSupports = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
segmentSupportCalls[direction] = Intercept2::getSegmentCalls(gSupportSegments, direction);
|
||||
generalSupports[direction] = gSupport;
|
||||
if (gSupport.slope != 0xFF && gSupport.height != 0)
|
||||
@@ -444,6 +464,13 @@ private:
|
||||
GetTunnelCalls(trackType, direction, trackSequence, height, &mapElement, tileTunnelCalls, verticalTunnelHeights);
|
||||
}
|
||||
|
||||
std::vector<function_call> supportCalls[4], chainLiftSupportCalls[4], cableLiftSupportCalls[4];
|
||||
if (blockSegmentsBeforeSupports) {
|
||||
ExtractMetalSupportCalls(calls, supportCalls);
|
||||
ExtractMetalSupportCalls(cableLiftCalls, cableLiftSupportCalls);
|
||||
ExtractMetalSupportCalls(chainLiftCalls, chainLiftSupportCalls);
|
||||
}
|
||||
|
||||
if (_rideType == RIDE_TYPE_GIGA_COASTER && !CompareFunctionCalls(calls, cableLiftCalls))
|
||||
{
|
||||
WriteLine(tabs, "if (track_element_is_cable_lift(mapElement)) {");
|
||||
@@ -472,8 +499,33 @@ private:
|
||||
GenerateCalls(tabs, calls, height);
|
||||
}
|
||||
|
||||
if (blockSegmentsBeforeSupports) {
|
||||
if (_rideType == RIDE_TYPE_GIGA_COASTER && !CompareFunctionCalls(supportCalls, cableLiftSupportCalls)) {
|
||||
printf("Error: Supports differ for cable lift.\n");
|
||||
} else if (!CompareFunctionCalls(supportCalls, chainLiftSupportCalls)) {
|
||||
printf("Error: Supports differ for chain lift\n");
|
||||
}
|
||||
WriteLine();
|
||||
GenerateSegmentSupportCall(tabs, segmentSupportCalls);
|
||||
|
||||
bool conditionalSupports = _conditionalSupports;
|
||||
_conditionalSupports = false;
|
||||
if (conditionalSupports) {
|
||||
WriteLine(tabs, "if (track_paint_util_should_paint_supports(gPaintMapPosition)) {");
|
||||
tabs++;
|
||||
}
|
||||
GenerateCalls(tabs, supportCalls, height);
|
||||
if (conditionalSupports) {
|
||||
tabs--;
|
||||
WriteLine(tabs, "}");
|
||||
}
|
||||
WriteLine();
|
||||
}
|
||||
|
||||
GenerateTunnelCall(tabs, tileTunnelCalls, verticalTunnelHeights);
|
||||
GenerateSegmentSupportCall(tabs, segmentSupportCalls);
|
||||
if (!blockSegmentsBeforeSupports) {
|
||||
GenerateSegmentSupportCall(tabs, segmentSupportCalls);
|
||||
}
|
||||
GenerateGeneralSupportCall(tabs, generalSupports);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user