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

GSRoad::RemoveRoadFull() does not remove N/S half road pieces #5344

Closed
DorpsGek opened this issue Oct 25, 2012 · 6 comments
Closed

GSRoad::RemoveRoadFull() does not remove N/S half road pieces #5344

DorpsGek opened this issue Oct 25, 2012 · 6 comments
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

xOR opened the ticket and wrote:

If GSRoad::RemoveRoadFull() is called with the same tile for start and end (so to remove only the road pieces on one tile) it does not remove single half road pieces if they are in north our south of the tile, only if they are in east or west.

Reported version: 1.2.2
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5344
@DorpsGek
Copy link
Member Author

Zuu wrote:

We had a discussion among the devs, and agreed that the ScriptRoaod::RemoveRoad and ScriptRoaod::RemoveRoadFull functions are intended only for use when start != end.

In r24628 we have enforced this precondition and improved the documentation on this matter.

Before resolving this report there was a discussion at # openttd.dev which may be of interest:
http://webster.openttdcoop.org/?channel=openttd.dev&date=1351123200

For removal of road bits on a tile you should be able to use RemoveRoad and use a start and end tile that are neighbours. If you plan to open up a feature request for a way to remove individual road bits, it would be useful if you provide a useful case when the current API doesn't provide a solution.

Thank you for the report.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5344#comment11621

@DorpsGek
Copy link
Member Author

Zuu closed the ticket.

Reason for closing: Fixed

Improved precondition check in r24628. See task comment for further details.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5344

@DorpsGek
Copy link
Member Author

xOR wrote:

In my code the start and end is dynamic depending on other things, it can be a single tile or more tiles. So my workaround when I found this problem was to put the code like this:
if (start == end)
  GSTile.DemolishTile(start);
else
{
  GSRoad.SetCurrentRoadType(clearroadtype);
  GSRoad.RemoveRoadFull(start, end);
}

Works well, just looks a bit strange to me. I am tempted to ask the question "why can a RemoveRoad function not...remove road? in all cases?".

But I guess there is some internal technical limitation that makes it hard to enable that function to be used for a single tile? Anyway, I don't think a feature request is necessary here, from the chat log I saw the suggestion to just use the clear function for single tiles and this is what I am doing already, so no need for further changes on my side.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5344#comment11622

@DorpsGek
Copy link
Member Author

Yexo wrote:

Because RemoveRoad detects the direction in which to remove road from it's parameters. If you remove road with a crossing in between the result will not be the same as using DemolishTile on all tiles. Because for a single tile no direction can be inferred from the start/end pair, there is nothing "good" to do. Removing both directions of road would be inconsistent with the multi-tile case, as is removing no road. The only sensible thing to do is to make start!=end a precondition and check for that, making it explicit in the documentation that that special case is not allowed.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5344#comment11627

@DorpsGek
Copy link
Member Author

Yexo wrote:

Might I also ask why you use RemoveRoadFull instead of RemoveRoad?


This comment was imported from FlySpray: https://bugs.openttd.org/task/5344#comment11628

@DorpsGek
Copy link
Member Author

xOR wrote:

Thanks for the explanation, it makes sense now. I am using RemoveRoadFull because that's what I want: have the full road removed (so the full tile cleared from road tiles).


This comment was imported from FlySpray: https://bugs.openttd.org/task/5344#comment11629

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) Goal/Game script labels Apr 7, 2018
@frosch123 frosch123 added the component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) label Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

2 participants