mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Unify metal support type a and b offsetting and crossbeam drawing
This commit is contained in:
@@ -321,6 +321,7 @@ static bool MetalASupportsPaintSetup(
|
||||
int32_t currentHeight = height;
|
||||
const uint32_t supportType = EnumValue(supportTypeMember);
|
||||
|
||||
// Offset the support and draw a crossbeam if necessary
|
||||
const uint8_t originalSegment = EnumValue(placement);
|
||||
uint8_t segment = originalSegment;
|
||||
uint16_t segmentHeight = 0xFFFF;
|
||||
@@ -333,21 +334,20 @@ static bool MetalASupportsPaintSetup(
|
||||
if (currentHeight < 0)
|
||||
return false;
|
||||
|
||||
const uint8_t* esi = &(kMetalSupportSegmentOffsets[session.CurrentRotation * 2]);
|
||||
|
||||
uint8_t newSegment = esi[segment * 8];
|
||||
uint16_t baseIndex = session.CurrentRotation * 2;
|
||||
uint8_t newSegment = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[newSegment].height)
|
||||
{
|
||||
esi += kMetalSupportSkip;
|
||||
newSegment = esi[segment * 8];
|
||||
baseIndex += kMetalSupportSkip;
|
||||
newSegment = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[newSegment].height)
|
||||
{
|
||||
esi += kMetalSupportSkip;
|
||||
newSegment = esi[segment * 8];
|
||||
baseIndex += kMetalSupportSkip;
|
||||
newSegment = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[newSegment].height)
|
||||
{
|
||||
esi += kMetalSupportSkip;
|
||||
newSegment = esi[segment * 8];
|
||||
baseIndex += kMetalSupportSkip;
|
||||
newSegment = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[newSegment].height)
|
||||
{
|
||||
return false;
|
||||
@@ -356,17 +356,16 @@ static bool MetalASupportsPaintSetup(
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ebp = esi[segment * 8 + 1];
|
||||
const uint8_t crossBeamIndex = kMetalSupportSegmentOffsets[baseIndex + segment * 8 + 1];
|
||||
|
||||
auto offset = CoordsXYZ{ kMetalSupportBoundBoxOffsets[segment] + kMetalSupportCrossBeamBoundBoxOffsets[ebp],
|
||||
currentHeight };
|
||||
auto boundBoxLength = CoordsXYZ(kMetalSupportCrossBeamBoundBoxLengths[ebp], 1);
|
||||
|
||||
auto image_id = imageTemplate.WithIndex(kMetalSupportTypeToCrossbeamImages[supportType][ebp]);
|
||||
PaintAddImageAsParent(session, image_id, offset, boundBoxLength);
|
||||
PaintAddImageAsParent(
|
||||
session, imageTemplate.WithIndex(kMetalSupportTypeToCrossbeamImages[supportType][crossBeamIndex]),
|
||||
{ kMetalSupportBoundBoxOffsets[segment] + kMetalSupportCrossBeamBoundBoxOffsets[crossBeamIndex], currentHeight },
|
||||
{ kMetalSupportCrossBeamBoundBoxLengths[crossBeamIndex], 1 });
|
||||
|
||||
segment = newSegment;
|
||||
}
|
||||
|
||||
const int16_t crossbeamHeight = currentHeight;
|
||||
|
||||
// Draw support bases
|
||||
@@ -491,53 +490,52 @@ static bool MetalBSupportsPaintSetup(
|
||||
int32_t currentHeight = height;
|
||||
const uint32_t supportType = EnumValue(supportTypeMember);
|
||||
|
||||
// Offset the support and draw a crossbeam if necessary
|
||||
const uint8_t originalSegment = EnumValue(placement);
|
||||
uint8_t segment = originalSegment;
|
||||
uint16_t segmentHeight = 0xFFFF;
|
||||
SupportHeight* const supportSegments = session.SupportSegments;
|
||||
if (height < supportSegments[segment].height)
|
||||
if (currentHeight < supportSegments[segment].height)
|
||||
{
|
||||
segmentHeight = height;
|
||||
segmentHeight = currentHeight;
|
||||
|
||||
currentHeight -= kMetalSupportTypeToHeight[supportType];
|
||||
if (currentHeight < 0)
|
||||
{
|
||||
return false; // AND
|
||||
}
|
||||
return false;
|
||||
|
||||
uint16_t baseIndex = session.CurrentRotation * 2;
|
||||
|
||||
uint8_t ebp = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[ebp].height)
|
||||
uint8_t newSegment = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[newSegment].height)
|
||||
{
|
||||
baseIndex += kMetalSupportSkip; // 9 segments, 4 directions, 2 values
|
||||
uint8_t ebp2 = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[ebp2].height)
|
||||
baseIndex += kMetalSupportSkip;
|
||||
newSegment = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[newSegment].height)
|
||||
{
|
||||
baseIndex += kMetalSupportSkip;
|
||||
uint8_t ebp3 = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[ebp3].height)
|
||||
newSegment = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[newSegment].height)
|
||||
{
|
||||
baseIndex += kMetalSupportSkip;
|
||||
uint8_t ebp4 = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[ebp4].height)
|
||||
newSegment = kMetalSupportSegmentOffsets[baseIndex + segment * 8];
|
||||
if (currentHeight <= supportSegments[newSegment].height)
|
||||
{
|
||||
return true; // STC
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ebp = kMetalSupportSegmentOffsets[baseIndex + segment * 8 + 1];
|
||||
if (ebp >= 4)
|
||||
{
|
||||
return true; // STC
|
||||
}
|
||||
const uint8_t crossBeamIndex = kMetalSupportSegmentOffsets[baseIndex + segment * 8 + 1];
|
||||
|
||||
if (crossBeamIndex >= 4)
|
||||
return false;
|
||||
|
||||
PaintAddImageAsParent(
|
||||
session, imageTemplate.WithIndex(kMetalSupportTypeToCrossbeamImages[supportType][ebp]),
|
||||
{ kMetalSupportBoundBoxOffsets[segment] + kMetalSupportCrossBeamBoundBoxOffsets[ebp], currentHeight },
|
||||
{ kMetalSupportCrossBeamBoundBoxLengths[ebp], 1 });
|
||||
session, imageTemplate.WithIndex(kMetalSupportTypeToCrossbeamImages[supportType][crossBeamIndex]),
|
||||
{ kMetalSupportBoundBoxOffsets[segment] + kMetalSupportCrossBeamBoundBoxOffsets[crossBeamIndex], currentHeight },
|
||||
{ kMetalSupportCrossBeamBoundBoxLengths[crossBeamIndex], 1 });
|
||||
|
||||
segment = newSegment;
|
||||
}
|
||||
|
||||
const int32_t crossbeamHeight = currentHeight;
|
||||
|
||||
Reference in New Issue
Block a user