Better statue placement

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Better statue placement

Post by pavel1269 »

The normal placement just searches for first tile, which it can replace (house/tree/nothing) and do that. Often in smaller cities or cities which bizarre layout, it can replace "majority" (like 1-3 in city and one of them got replaced) of bigger houses. This patch is providing that it will search a little around for free tile (trees/nothing) and place statue there. If it fails, it will work as before.

EDIT: Added last revision of the patch.
Attachments
statue_placement_r22254.patch
(2.09 KiB) Downloaded 213 times
statue_placement_r24094.patch
(3.25 KiB) Downloaded 175 times
Last edited by pavel1269 on 08 Apr 2012 17:47, edited 3 times in total.

User avatar
JacobD88
Chief Executive
Chief Executive
Posts: 675
Joined: 16 Aug 2008 17:51
Location: Long Eaton, Nottinghamshire. UK
Contact:

Re: Better statue placement

Post by JacobD88 »

Brilliant, thanks Pavel :bow:

It's little patches like this i love, might go back to placing statues again now, as i was always annoyed that sometimes, where the appropriate building was few in number placing a statue could stop a town accepting say goods (as that requires several buildings being present to change station acceptance) as the building, usually at the town centre, got built on :roll: Hopefully this will reduce that considerably :D

User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Better statue placement

Post by pavel1269 »

A little update to current trunk, see first post. I will keep here also older version, because of nightly es.

User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Better statue placement

Post by pavel1269 »

Update to trunk

User avatar
JacobD88
Chief Executive
Chief Executive
Posts: 675
Joined: 16 Aug 2008 17:51
Location: Long Eaton, Nottinghamshire. UK
Contact:

Re: Better statue placement

Post by JacobD88 »

Thanks Pavel, still using this patch :bow:

I'm surprised no-one else has commented here, as mentioned in my last post, it's a very small change, but makes a big difference for small towns and some cargo types such as goods acceptance. Any devs tried this patch out? If so, what would pavel need to do for it to make it into trunk?

User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: Better statue placement

Post by belugas »

I just wanted to mention that duplicate code, with very little difference is not a good coding style.
It's just my hint, code style wise.
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones

User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Better statue placement

Post by pavel1269 »

Thanks for your remark. Here's patch with updated coding style.

There is still one global variable. It could be removed as well, but would require (at least from my point of view) a structure given to the CircularSearch and this seems, again for me, better way.

EDIT: Patch removed.
Last edited by pavel1269 on 08 Apr 2012 17:44, edited 1 time in total.

User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Better statue placement

Post by pavel1269 »

Update to current trunk.

EDIT: Fixed coding style and stuff. (Thanks Alberth)
EDIT2: While fixing coding style, I created bug. Fortunately no one downloaded that bugged version. (Thanks Alberth)
EDIT3: Patch removed, in trunk (yay). Last revision of my patch in first post.
Last edited by pavel1269 on 08 Apr 2012 17:44, edited 1 time in total.

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4754
Joined: 09 Sep 2007 05:03
Location: home

Re: Better statue placement

Post by Alberth »

It's in trunk!

Code: Select all

changeset:   19206:2a301ee800ca
tag:         tip
user:        alberth
date:        Sun Apr 08 17:30:20 2012 +0000
summary:     (svn r24105) -Feature: Be more careful with the population of a small town while placing a statue.

changeset:   19205:ffc3cdc27a30
user:        alberth
date:        Sun Apr 08 17:29:00 2012 +0000
summary:     (svn r24104) -Codechange: Output the resulting tile through the user data.

changeset:   19204:90b494b476b1
user:        alberth
date:        Sun Apr 08 17:27:47 2012 +0000
summary:     (svn r24103) -Codechange: Handle clear tiles separately from house tiles.

changeset:   19203:ab4ae39b95d1
user:        alberth
date:        Sun Apr 08 17:26:59 2012 +0000
summary:     (svn r24102) -Codechange: Refactor tile clearability test out of the statue callback.

changeset:   19202:0519840052c3
user:        alberth
date:        Sun Apr 08 17:26:01 2012 +0000
summary:     (svn r24101) -Codechange: Reverse a condition for increased readability.
Compared to the last version we exchanged, I eliminated _statue_house, and split out the clear tiles as a separate problem.
An other dev prefered struct, so I changed that too.

Thank you for your work.

User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Better statue placement

Post by pavel1269 »

Nice. I thank you, for picking this patch.


bremerjoe
Engineer
Engineer
Posts: 97
Joined: 24 May 2011 21:01

Re: Better statue placement

Post by bremerjoe »

@ Pavel1269: Looks like a very useful upgrade/addition for the game. Congratulations for having provided a patch that actually made it to trunk! :D
Everybody can contribute to OTTD! It does not require you to be an IT specialist or designer. And it does not take days or weeks of your time either.
There are many simple yet important tasks like translations, investigating facts and details and many other that need work and if you help a bit then the experienced developers can focus more on making OTTD even more awesome!
OTTD = Awesomeness created by a whole lot of volunteers, be one of them if you like the game!

User avatar
PaulC
Director
Director
Posts: 616
Joined: 31 Jul 2006 12:40
Location: Lancs, England
Contact:

Re: Better statue placement

Post by PaulC »

Perhaps I'm being dense, but what does this feature actually do? I just gave it a quick try in the lastet nightly and in one town the statue wiped out a 2x2 shopping mall!

User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Better statue placement

Post by pavel1269 »

pavel1269 wrote:The normal placement just searches for first tile, which it can replace (house/tree/nothing) and do that. Often in smaller cities or cities which bizarre layout, it can replace "majority" (like 1-3 in city and one of them got replaced) of bigger houses. This patch is providing that it will search a little around for free tile (trees/nothing) and place statue there. If it fails, it will work as before.
Little around, means 5 * 5 square. Center tile is center of the town. So mostly, only small towns aka villages are affected.

That should explain everything. Anything more?

User avatar
PaulC
Director
Director
Posts: 616
Joined: 31 Jul 2006 12:40
Location: Lancs, England
Contact:

Re: Better statue placement

Post by PaulC »

OK, I see. :) That's certainly useful, but some suggestions for improvement:

* Avoid replacing buildings with certain flags set, i.e. multi-tile buildings, churches, stadiums
* For cities search a wider area, e.g. 7*7
* Thinking outside the box here, but what about placing statues manually?

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4754
Joined: 09 Sep 2007 05:03
Location: home

Re: Better statue placement

Post by Alberth »

You're in the wrong forum now ;)

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 2 guests