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

Make town_cmd a bit more readable #1161

Closed
DorpsGek opened this issue Aug 26, 2007 · 21 comments
Closed

Make town_cmd a bit more readable #1161

DorpsGek opened this issue Aug 26, 2007 · 21 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'm thinking over a partitial rewrite of the town_cmd cause the stuff in there is not for everyone readable. Therefor I started with the tile getting code. Hope someone of the dev's could improve my thoughts. ATM I'm working only in town_cmd.cpp. My plan is to get a nice readable(!!) and smaller code.

The directions used by the town growth are mirrored DiagDirections. IMO it would be nicer and cleaner to convert them to DiagDirections. That will cause a lot of work so I'd be pleased if someone would assist or even recode some parts.

This is what i've done so far.

Attachments

Reported version: trunk
Operating system: All


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

skidd13 wrote:

Did a few renamings,rearrangements and rewrites. Hope you like it.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment1981

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Did some further work on the basic stuff.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment1988

@DorpsGek
Copy link
Member Author

skidd13 wrote:

So further suff is now at the patch. Now I need to move the int to DiagDir. Hope it's now better possible.
Fully rewritten IsNeighborRoadTile. Should increase performance.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment1991

@DorpsGek
Copy link
Member Author

skidd13 wrote:

This time I moved some subcode to functions. Converting the town growth to a abstract class in mind.

A side note the Functions to handle the TownGrowth directions are temporary.

My plans so far ATM:

  1. Convert the int dir (dir is pos of the set bit in the planded roadbits) to a more native dir (DiagDir). I hope the code gets more readable then.
  2. Convert the whole stuff to an abstract class where the growth is implementated diffrent for each layout (with growth I'm talking of "is this a nice tile to plant a road" and "which roadbits we want to plant here") The implementation of the target-tile algorithm (on which side the town grows further) will remain in the main class.

Point 2 needs some further thinking where to initiate the object and if we want to have one object for each town or one for each algorithm or one for all towns.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment1993

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Split off of the IsNeighborRoadTile optimisation. Another few "outsourced" parts will follow.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment1997

@DorpsGek
Copy link
Member Author

skidd13 wrote:

So next one is here: town bridge check and creation

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2005

@DorpsGek
Copy link
Member Author

skidd13 wrote:

Update (cause of r11015)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2008

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 1, 2007

skidd13 wrote:

Simplyfied the improved_IsNeighborRoadTile.patch

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2018

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 2, 2007

skidd13 wrote:

So part one is more or less done! :D
There is the need of optimisation now. But this should now be a smaller problem cause the code is more human readable now.

Patch should apply against 11039.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2039

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 2, 2007

skidd13 wrote:

Oops I forgot to say that I'd like to hear some comments.
Optimisation proposals are very welcome.


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2040

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 3, 2007

skidd13 wrote:

1st Update of part1. Mainly optimisations and cleanup.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2047

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 4, 2007

skidd13 wrote:

Updated comments and a missing NOT.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2055

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 4, 2007

skidd13 wrote:

I thought a bit over the change to the TownGrowth object.
I made 2 graphs to see how the whole stuff is working ATM and will work as Object.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2056

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 6, 2007

skidd13 wrote:

Added a nicer solution for the grid algorithm. #1207 should be solved partialy.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2078

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 9, 2007

skidd13 wrote:

Sorry! Fixed some conditions that could cause the stop of town growth.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2095

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 9, 2007

skidd13 wrote:

I noticed a bug of the current trunk and it appears also with my current patch applyed.
In the attached scenario there is a sign which marks a tile.
If you place a small town there it stops to grow immediately.
I'm working on it.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2096

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 9, 2007

Rubidium wrote:

You changed the maximum length of bridges by one (or rather, it tries to build a bridge one more time)
for (int i = -11; ++i != 0;) is not the same as for (int i = 0; i++ > 11;)


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2097

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 9, 2007

skidd13 wrote:

oops, thanks for the annotation.


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2098

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 9, 2007

skidd13 wrote:

So fixed the bridge thing.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2099

@DorpsGek
Copy link
Member Author

skidd13 wrote:

This should be the final version of part1.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/1161#comment2111

@DorpsGek
Copy link
Member Author

Belugas closed the ticket.

Reason for closing: Implemented

r11091 now bears the code you've patiently built.
Thanks


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

@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