Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: grid lines do not show in certain circumstances #13372

Open
Sadret opened this issue Nov 4, 2020 · 4 comments
Open

Bug: grid lines do not show in certain circumstances #13372

Sadret opened this issue Nov 4, 2020 · 4 comments
Labels
bug Something went wrong.

Comments

@Sadret
Copy link
Contributor

Sadret commented Nov 4, 2020

There are two issues with the grid lines not showing up when they should.

First issue

To reproduce the first issue, do one of:

  • Place a shop while auto-open is enabled.

or

  • Open the construction window for any shop or ride, including flat rides, excluding prebuilt coasters, then, without placing anything, do one of:
    • Press the Escape key.
    • Open the scenery or footpath placement window.
    • Open the construction window for anything else.
    • Many more. Basically: activate another tool.

Now, the gridlines will not be shown and will never show up again until the game is reloaded.
Note that enabling gridlines in the config still overwrites this.

The cause for this issue is in RideConstruction.cpp L613 and L627, which leads to hide_gridlines() being called twice, which in turn sets Viewport->gShowGridLinesRefCount to a negative value.
gShowGridLinesRefCount is a number (and not a boolean) because apparently when activating another tool, first the new tool is activated, then the old tool is deactivated. So, in the scenarios above, the counter goes from 0 to 1 to 2, and then back to 0 (because hide is called twice), while the second tool is still active. When the second tool is deactivated, the counter goes down to -1.

Second issue

The second issue is maybe more of a problem of the plugin API, but I believe that they are connected. If a custom tool is activated, its onStart method is called before the current tool is cancelled.

  1. Open the scenery window or a construction window so that grid lines are shown.
  2. Activate a custom tool with the plugin API, where, in the onStart method, the gridlines flag is set.

The expected result should be, that the first tool is deactivated first, then the onStart method is called and sets the gridlines flag. In reality, it happens the other way around and the flag is overwritten in the hide_gridlines() method.

Common problem and possible solution

While these two issues could be fixed in different, independent ways, I think that they both have the same core problem:
The second tool is activated before the first tool is deactivated.

If this is fixed, the second issue is solved immediately, while the first issue could then be fixed by substituting gShowGridLinesRefCount with a boolean.

June 2023 Update

The current state of this issue seems to be the following:

Option Gridlines on Landscape disabled:

  • Open tool such that gridlines show (construction windows, see above).
  • Activate custom tool that sets gridlines flag.

Expected: Gridlines stay visible.
Observed: Gridlines disappear.

Option Gridlines on Landscape enabled:

  • Execute ui.mainViewport.visibilityFlags ^= (1 << 7)

Expected: Gridlines stay visible.
Observed: Gridlines disappear.

Option Gridlines on Landscape enabled:

  • Open tool such that gridlines show (construction windows, see above).
  • Disable option Gridlines on Landscape.

Expected: Gridlines stay visible.
Observed: Gridlines disappear.

Note: In all cases, gridlines do not break, they still appear if you switch to any other tool that activates them.

@Gymnasiast Gymnasiast added the bug Something went wrong. label Nov 4, 2020
@RichardWong8
Copy link

Hi. I'm new and looking to help out on this project! Is this an issue that I'd be able to pick up and work on?

@duncanspumpkin
Copy link
Contributor

Its not an easy one to work on I suspect as there is a lot of interactions. Have a look at issues labelled good first issue / hacktoberfest.

@dragonofmercy
Copy link

2 years ago, any news of this issue?

@Sadret
Copy link
Contributor Author

Sadret commented Jun 21, 2023

I added the current state of the bug as an edit to the original post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something went wrong.
Projects
None yet
Development

No branches or pull requests

5 participants