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

town road cleanup #1090

Closed
DorpsGek opened this issue Jul 30, 2007 · 17 comments
Closed

town road cleanup #1090

DorpsGek opened this issue Jul 30, 2007 · 17 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

skidd13 opened the ticket and wrote:

I wrote a function which cleans up the roadbits depending on the surrounding tiles. This is used during the town growth and added to the command "Found local road construction". Consequential I updated the way how town owned bridges are calculated and simplified parts of the town layout calculation.

Attachments

Reported version: trunk
Operating system: All


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

skidd13 wrote:

I changed the behavior of the patch with railway to get better results.

Please comment. And sorry for the huge ammount of code. ;)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment1750

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 2, 2007

skidd13 wrote:

Update again. Reduced diff size and removed some needless code parts.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment1766

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 2, 2007

skidd13 wrote:

As requested: Moved the functions from road_map to road.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment1767

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 3, 2007

skidd13 wrote:

Update and some cleanups

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment1775

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 6, 2007

skidd13 wrote:

Fixed the possibility to generate roads with no roadbits. :( sorry for the bug. Thanks to Rubidium for spotting this.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment1810

@DorpsGek
Copy link
Member Author

skidd13 wrote:

I split off the new bridge generator from the road clean up itself. Hope this makes including the patch easier.

[con]
* more cpu cycles for the town growth
* things build after the roads can still cause unlovely road junctions

[pro]
* visually better road layouts in the towns
* less cpu cycles needed for "pathfinding" to search through the town
* "Found local road construction" has now a positive thing too.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment1858

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Another update. I think the behavior with roads leading towards water is now better handled (opticaly).

Now it's even harder to split the patch. So I post it uncut.

I could split it into:

  1. new functions for road.h (IsPossibleCrossing, MirrorRoadBits, RotateRoadbits CountBits)
  2. Function CleanupRoadBits
    2.a) expand "Found local road construction"
    2.b) "Cleanup town roads" at construction stage (Removes also now unneeded calculations of the old algorithm)
  3. Improved town bridge behavior (will fix roads leading into water)

It would be nice to hear comments (not only on IRC)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment1884

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Main rewrite of the patch. There a a few things to think about.

- Roads leading into water seem to be a fault of the command. That needs some deeper checking.
- IMO the patch needs 2 new settings: enable global. enable modified road construction.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2125

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Added patch options

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2138

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Damn forget to remove some unneeded stuff. Sorry.


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2150

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Removed slope checks cause they are unnecessary now.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2169

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Changed some stuff in the BUILD_ROAD command. It's now able to handle one bit on more slopes :)
The cleaner town roads should be fine now.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2182

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Damn forgot to add the road.cpp

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2183

@DorpsGek
Copy link
Member Author

Rubidium wrote:

+ RoadBits road_bits = pieces | existing;
+
+ /
Single bits on slopes.
+ * We check for the roads that need at least 2 bits */
+ if (_patches.build_on_slopes && !_is_old_ai_player &&
+ (COUNTBITS(road_bits) + COUNTBITS(*pieces)) == 2 &&
+ (_valid_tileh_slopes_road[2][tileh] & *pieces) == ROAD_NONE) {
+ return CommandCost(_price.terraform);
+ }
The roadbit counting algorithm looks broken to me. If *pieces has one bit set and there are no existing bits, COUNTBITS(road_bits) + COUNTBITS(*pieces)) == 2 will succeed. Furthermore it will not succeed if existing has two bits set and pieces one bit.

Furthermore the coding style (consistency) is lacking at some places. No spaces after some commas, spaces before semicolons, no newline before the { of a function body and probably more.


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2184

@DorpsGek
Copy link
Member Author

skidd13 wrote:

I hope I fixed all issues.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2185

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Did some cleanup and naming stuff.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1090#comment2199

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Implemented

In r11172


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

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant