OpenTTD

Tasklist

FS#1090 - town road cleanup

Attached to Project: OpenTTD
Opened by Benedikt Brüggemeier (skidd13) - Sunday, 29 July 2007, 22:12 GMT
Type Patch
Category Core
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

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.
This task depends upon

Closed by  Remko Bijker (Rubidium)
Wednesday, 26 September 2007, 16:12 GMT
Reason for closing:  Implemented
Additional comments about closing:  In r11172
Comment by Benedikt Brüggemeier (skidd13) - Tuesday, 31 July 2007, 00:22 GMT
I changed the behavior of the patch with railway to get better results.

Please comment. And sorry for the huge ammount of code. ;)
Comment by Benedikt Brüggemeier (skidd13) - Thursday, 02 August 2007, 11:16 GMT
Update again. Reduced diff size and removed some needless code parts.
Comment by Benedikt Brüggemeier (skidd13) - Thursday, 02 August 2007, 12:57 GMT
As requested: Moved the functions from road_map to road.
Comment by Benedikt Brüggemeier (skidd13) - Friday, 03 August 2007, 15:41 GMT
Update and some cleanups
Comment by Benedikt Brüggemeier (skidd13) - Monday, 06 August 2007, 18:52 GMT
Fixed the possibility to generate roads with no roadbits. :( sorry for the bug. Thanks to Rubidium for spotting this.
Comment by Benedikt Brüggemeier (skidd13) - Saturday, 11 August 2007, 08:21 GMT
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.
Comment by Benedikt Brüggemeier (skidd13) - Friday, 17 August 2007, 19:30 GMT
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)
Comment by Benedikt Brüggemeier (skidd13) - Saturday, 15 September 2007, 13:33 GMT
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.
Comment by Benedikt Brüggemeier (skidd13) - Monday, 17 September 2007, 17:02 GMT
Added patch options
Comment by Benedikt Brüggemeier (skidd13) - Wednesday, 19 September 2007, 15:37 GMT
Damn forget to remove some unneeded stuff. Sorry.
Comment by Benedikt Brüggemeier (skidd13) - Thursday, 20 September 2007, 12:49 GMT
Removed slope checks cause they are unnecessary now.
Comment by Benedikt Brüggemeier (skidd13) - Saturday, 22 September 2007, 11:05 GMT
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.
Comment by Benedikt Brüggemeier (skidd13) - Saturday, 22 September 2007, 11:10 GMT
Damn forgot to add the road.cpp
   road.cpp (1.9 KiB)
Comment by Remko Bijker (Rubidium) - Saturday, 22 September 2007, 13:50 GMT
+ 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.
Comment by Benedikt Brüggemeier (skidd13) - Saturday, 22 September 2007, 16:44 GMT
I hope I fixed all issues.
Comment by Benedikt Brüggemeier (skidd13) - Tuesday, 25 September 2007, 18:16 GMT
Did some cleanup and naming stuff.

Loading...