Openrct2: Use rotate_map_coordinates to rotate coordinate

Created on 19 Feb 2019  路  5Comments  路  Source: OpenRCT2/OpenRCT2

There are many many cases of this throughout the code base. All of them should be using rotate_map_coordinates. In addition CoordsXY, TileCoordsXY should have a rotate method.

For example this:

       switch (trackDirection)
        {
            default:
            case 0:
                offsetX = trackBlock->x;
                offsetY = trackBlock->y;
                break;
            case 1:
                offsetX = trackBlock->y;
                offsetY = -trackBlock->x;
                break;
            case 2:
                offsetX = -trackBlock->x;
                offsetY = -trackBlock->y;
                break;
            case 3:
                offsetX = -trackBlock->y;
                offsetY = trackBlock->x;
                break;
        }

Should ideally be:

CoordsXY offsets = { offsetX, offsetY };
CoordsXY track = { trackBlock->x, trackBlock->y };
offsets += track.Rotate(trackDirection);

This:

    int16_t tmp;
    switch (trackDirection & 3)
    {
        case 1:
            tmp = x;
            x = y;
            y = -tmp;
            break;
        case 2:
            x = -x;
            y = -y;
            break;
        case 3:
            tmp = x;
            x = -y;
            y = tmp;
            break;
        case 0:
            break;
    }

should be:

rotate_map_coordinates(&x, &y);
good first issue refactor

Most helpful comment

Me and my team would like to work on this issue, We will update it as we work on it.

All 5 comments

Me and my team would like to work on this issue, We will update it as we work on it.

Great. Just to warn you I'm adjusting the function track_place so try to avoid that to prevent merge issues.

@bdupree5 did you get round to make an implementation?

Unfortunately we did not. I apologize for forgetting and not letting you know sooner

Once I've finalized the related issue 9288, I'll take on this one as well.

Was this page helpful?
0 / 5 - 0 ratings