[patch]Picking and placing single houses
Moderator: OpenTTD Developers
[patch]Picking and placing single houses
This patch allows you to place houses manually in scenario editor.
Credits to oberhümer for his stirring patch.
DOWNLOAD: Older versions: https://www.dropbox.com/sh/9lsrb260acgqgda/8p3_i2afGa
SCREENSHOT: TECHNICAL INFO:
To keep backward compatibility with NewGRFs, house callbacks will be provided with fake house and town variables. Details here in the zip package.
// ORIGINAL POST
I'm preparing to extend functionality of the Clipboard patch to scenario editor. To provide a mechanism for copy-pasting houses I must implement a command that can place a certain house at a certain location. This is just a step from custom house placement tool in scenario editor, it just needs a GUI picker. So perhaps this is the thing that should be developed, I'll try.
Do you have any advices to me? I'm asking because I'm not a GRF master and there may be traps waiting. How can I brake things up? What can be specifically difficult? Any links to former discussions? (found this: My patch(es) (place house manually))
From what I can see, Action0 house callbacks are not very complicated. Steps that I should do (watch if I'm missing something):
While making a list of houses:
1. Use property 15 to filter out replaced houses (will the HouseSpec be just replaced for a given HouseID?)
2. Use property 0A to filter out unavailable houses (based on current date)
3. Use property 13 to filter out houses unavailable in current climate
While placing a house do similar checks like when growing a town:
1. Check if there is at least one town on the map.
2. Slope check (property 09 bit 1 - "This building can be built only on flat land").
3. Snowline check (property 13)
4. Ignore the town zone property? (bits 0..4 of property 13)
5. Allow one church/stadium per town (property 09)
6. Ignore the town road layout (allow to place houses on tiles meant for roads)
7. Check all the tiles of the house (1x1, 1x2, 2x2, 2x1 - property 09)
8. Build the house
9. Grow town zones?
I'm not quite sure what to do with town zones. Can I ignore them while placing a house? Maybe not? Maybe that can break things?
Credits to oberhümer for his stirring patch.
DOWNLOAD: Older versions: https://www.dropbox.com/sh/9lsrb260acgqgda/8p3_i2afGa
SCREENSHOT: TECHNICAL INFO:
To keep backward compatibility with NewGRFs, house callbacks will be provided with fake house and town variables. Details here in the zip package.
// ORIGINAL POST
I'm preparing to extend functionality of the Clipboard patch to scenario editor. To provide a mechanism for copy-pasting houses I must implement a command that can place a certain house at a certain location. This is just a step from custom house placement tool in scenario editor, it just needs a GUI picker. So perhaps this is the thing that should be developed, I'll try.
Do you have any advices to me? I'm asking because I'm not a GRF master and there may be traps waiting. How can I brake things up? What can be specifically difficult? Any links to former discussions? (found this: My patch(es) (place house manually))
From what I can see, Action0 house callbacks are not very complicated. Steps that I should do (watch if I'm missing something):
While making a list of houses:
1. Use property 15 to filter out replaced houses (will the HouseSpec be just replaced for a given HouseID?)
2. Use property 0A to filter out unavailable houses (based on current date)
3. Use property 13 to filter out houses unavailable in current climate
While placing a house do similar checks like when growing a town:
1. Check if there is at least one town on the map.
2. Slope check (property 09 bit 1 - "This building can be built only on flat land").
3. Snowline check (property 13)
4. Ignore the town zone property? (bits 0..4 of property 13)
5. Allow one church/stadium per town (property 09)
6. Ignore the town road layout (allow to place houses on tiles meant for roads)
7. Check all the tiles of the house (1x1, 1x2, 2x2, 2x1 - property 09)
8. Build the house
9. Grow town zones?
I'm not quite sure what to do with town zones. Can I ignore them while placing a house? Maybe not? Maybe that can break things?
Last edited by adf88 on 10 Jul 2017 06:13, edited 23 times in total.
![Pleased :]](./images/smilies/pleased.gif)
-
- Tycoon
- Posts: 5954
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Picking and placing single houses in scenario editor
"Action0" and "callbacks" are different things, since properties are static but callbacks are dynamic.adf88 wrote: From what I can see, Action0 house callbacks are not very complicated. Steps that I should do (watch if I'm missing something):
Good question. I´m not sure what it does/means in OTTD, since (normally) you can´t load/unload newGRFs (like in TTDPatch).adf88 wrote: While making a list of houses:
1. Use property 15 to filter out replaced houses (will the HouseSpec be just replaced for a given HouseID?)
Yes.adf88 wrote: 2. Use property 0A to filter out unavailable houses (based on current date)
3. Use property 13 to filter out houses unavailable in current climate
Mind you that most house sets are doing fancy stuff with callbacks, mainly with CB 17, e.g. check population of town, count of house types either in town or on map, etc.adf88 wrote: While placing a house do similar checks like when growing a town: [...]
There might be interference with house sets which use town zone or changes of town zone for the house´s design or its life span.adf88 wrote: I'm not quite sure what to do with town zones. Can I ignore them while placing a house? Maybe not? Maybe that can break things?
I´m sure there will be more "traps", needs a bit of experimenting.

regards
Michael
Re: Picking and placing single houses in scenario editor
You do not need to mess with those properties. Most of them are already resolved on loading the GRFs.
If you need a list of houses, that are available, take a look at BuildTownHouse().
It creates a list of all options, and then picks one randomly (weighted with the appearancy probability).
If you need a list of houses, that are available, take a look at BuildTownHouse().
It creates a list of all options, and then picks one randomly (weighted with the appearancy probability).
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Picking and placing single houses in scenario editor
For the scenario editor I can imagine that it could allow to pick houses similar to how one can build stations ingame. With the added ceavat that not every house can be built at every spot as the NewGRF (if any) has a say in that.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Picking and placing single houses in scenario editor
Yes, sorry, my mistake. While I was saying "callbacks" I meant all the GRF communication canals.michael blunck wrote:"Action0" and "callbacks" are different things[...]
While town grows it puts house by house randomly. Building houses with the new tool can behave like if it was a process of growing, this should be fine. I mean things should not break. Process of growing a town is not truly random but GRF makes should be treating it like if it was e.g. assume that even a single house can be placed far from the town centre. It appears to me very unlikely that someone could do otherwise. To fill the gap, maybe a new varaction can be provided so CB 17 can check whether a house is being built because of a town grow or because of a manual placement. Also a new house property to define whether house can be placed manually (and will appear in a picker window).michael blunck wrote:Mind you that most house sets are doing fancy stuff with callbacks, mainly with CB 17, e.g. check population of town, count of house types either in town or on map, etc.
That's clear to me now. Callbacks can freak out while reading unexpected value from variable 42 (town zone).michael blunck wrote:There might be interference with house sets which use town zone or changes of town zone for the house´s design or its life span.adf88 wrote:I'm not quite sure what to do with town zones. Can I ignore them while placing a house? Maybe not? Maybe that can break things?
Yes, I know, the HouseSpec. I used GRF language to make things clear.frosch wrote:You do not need to mess with those properties. Most of them are already resolved on loading the GRFs.
I'm thinking the same. List of house sets (text) + list of houses (images).planetmaker wrote:For the scenario editor I can imagine that it could allow to pick houses similar to how one can build stations ingame.
CB 17 looks perfect for this task. Like I said, maybe it just needs a novelization (new varaction and new property).planetmaker wrote:With the added ceavat that not every house can be built at every spot as the NewGRF (if any) has a say in that.
I was studying the GRF documentation related to houses. I was in these places:
http://newgrf-specs.tt-wiki.net/wiki/Callbacks (Feature(s)=Houses)
http://newgrf-specs.tt-wiki.net/wiki/Action0/Houses
http://newgrf-specs.tt-wiki.net/wiki/Va ... on2/Houses
Looks it will be OK

![Pleased :]](./images/smilies/pleased.gif)
Re: Picking and placing single houses in scenario editor
the found town function has a mode where it uses the <expected> town size/zone for construction, instead of the current one. maybe that should apply to the whole scenario editor
Re: Picking and placing single houses in scenario editor
I'm not sure if I'm getting... Houses will be put at certain towns (basically the nearest town will be chosen, with CTRL a pop-up will appear similar to the "station to join" selection). Town zone of this certain town will be checked. It is also possible to automatically chose nearest town which not disallows the building because of the house zone. Town layout will be ignored unless GRFs are allowed to read this parameter through some varaction (I didn't find one but I wasn't looking yet). Otherwise... I don't know yet, but the global layout has nothing to say here.
![Pleased :]](./images/smilies/pleased.gif)
Re: [patch]Picking and placing single houses (scenedit)
OK, the patch is ready. Everything went fine. I tested it on many different house sets.
Next step will be to add some changes to the NewGRF protocol:
Next step will be to add some changes to the NewGRF protocol:
- new house property - whether to show the house in the GUI picker
- new house variable (for various callbacks) - reason of calling (similar to vehicle VAR 10):
- house tile - callback is called for a certain house on the map
- house type - callback is called for a type of houses (GUI purposes) - new house variable (for house CB 17 construction check) - reason of house construction:
- manual house placement
- expending a town
- crating a town
- generating a map
![Pleased :]](./images/smilies/pleased.gif)
Re: [patch]Picking and placing single houses in scenario edi
Very excited here, but it crashes for me:
1. build town in scenario editor
2. click on house button in landscape toolbar
Code: Select all
*** OpenTTD Crash Report ***
Crash at: Thu Dec 12 16:49:29 2013
In game date: 3000-01-01 (0)
Crash reason:
Signal: Aborted (6)
Message: Assertion failed at line 582 of /home/tijl/svnopenttd/src/fontcache.cpp: IsPrintable(key)
OpenTTD version:
Version: r26139M (2)
NewGRF ver: 1400661b
Bits: 64
Endian: little
Dedicated: no
Build date: Dec 12 2013 17:45:28
Stacktrace:
[00] /home/tijl/svnopenttd/bin/openttd(_ZNK12CrashLogUnix13LogStacktraceEPcPKc+0x37) [0x6ff037]
[01] /home/tijl/svnopenttd/bin/openttd(_ZNK8CrashLog12FillCrashLogEPcPKc+0xeb) [0x5d35bb]
[02] /home/tijl/svnopenttd/bin/openttd(_ZNK8CrashLog12MakeCrashLogEv+0x7c) [0x5d384c]
[03] /home/tijl/svnopenttd/bin/openttd() [0x6fefa5]
[04] /lib/x86_64-linux-gnu/libc.so.6(+0x370b0) [0x7ff6180e70b0]
[05] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7ff6180e7037]
[06] /lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7ff6180ea698]
[07] /home/tijl/svnopenttd/bin/openttd() [0x6eaa4f]
[08] /home/tijl/svnopenttd/bin/openttd() [0x5f9824]
[09] /usr/lib/x86_64-linux-gnu/libicule.so.48(_ZNK6icu_4814LEFontInstance16mapCharsToGlyphsEPKtiiaPKNS_12LECharMapperEaRNS_14LEGlyphStorageE+0x137) [0x7ff618990997]
[10] /usr/lib/x86_64-linux-gnu/libicule.so.48(_ZN6icu_4812LayoutEngine16mapCharsToGlyphsEPKtiiaaRNS_14LEGlyphStorageER11LEErrorCode+0xb7) [0x7ff618993b37]
[11] /usr/lib/x86_64-linux-gnu/libicule.so.48(_ZN6icu_4820OpenTypeLayoutEngine15glyphProcessingEPKtiiiaRNS_14LEGlyphStorageER11LEErrorCode+0xa8) [0x7ff618990f28]
[12] /usr/lib/x86_64-linux-gnu/libicule.so.48(_ZN6icu_4820OpenTypeLayoutEngine13computeGlyphsEPKtiiiaRNS_14LEGlyphStorageER11LEErrorCode+0x1f0) [0x7ff6189919f0]
[13] /usr/lib/x86_64-linux-gnu/libicule.so.48(_ZN6icu_4812LayoutEngine11layoutCharsEPKtiiiaffR11LEErrorCode+0x120) [0x7ff6189937e0]
[14] /usr/lib/x86_64-linux-gnu/libiculx.so.48(_ZN6icu_4815ParagraphLayoutC2EPKtiPKNS_8FontRunsEPKNS_9ValueRunsES8_PKNS_10LocaleRunsEhaR11LEErrorCode+0x370) [0x7ff618783d40]
[15] /home/tijl/svnopenttd/bin/openttd(_ZN8LayouterC2EPKci10TextColour8FontSize+0x5c0) [0x628280]
[16] /home/tijl/svnopenttd/bin/openttd(_Z20GetStringBoundingBoxPKc8FontSize+0x1b) [0x62146b]
[17] /home/tijl/svnopenttd/bin/openttd(_Z20GetStringBoundingBoxt+0x37) [0x621517]
[18] /home/tijl/svnopenttd/bin/openttd(_ZN11NWidgetLeaf17SetupSmallestSizeEP6Windowb+0x202) [0x850c22]
[19] /home/tijl/svnopenttd/bin/openttd(_ZN15NWidgetVertical17SetupSmallestSizeEP6Windowb+0x68) [0x8513d8]
[20] /home/tijl/svnopenttd/bin/openttd(_ZN17NWidgetHorizontal17SetupSmallestSizeEP6Windowb+0x68) [0x851618]
[21] /home/tijl/svnopenttd/bin/openttd(_ZN15NWidgetVertical17SetupSmallestSizeEP6Windowb+0x68) [0x8513d8]
[22] /home/tijl/svnopenttd/bin/openttd(_ZN17NWidgetBackground17SetupSmallestSizeEP6Windowb+0x47) [0x850847]
[23] /home/tijl/svnopenttd/bin/openttd(_ZN14NWidgetStacked17SetupSmallestSizeEP6Windowb+0x12f) [0x85129f]
[24] /home/tijl/svnopenttd/bin/openttd(_ZN15NWidgetVertical17SetupSmallestSizeEP6Windowb+0x68) [0x8513d8]
[25] /home/tijl/svnopenttd/bin/openttd(_ZN6Window14InitializeDataEi+0x61) [0x85a1d1]
[26] /home/tijl/svnopenttd/bin/openttd(_ZN6Window16FinishInitNestedEi+0x10) [0x85ad80]
[27] /home/tijl/svnopenttd/bin/openttd(_Z20ShowBuildHousePickerP6Window+0x13d) [0x80924d]
[28] /home/tijl/svnopenttd/bin/openttd(_ZN39ScenarioEditorLandscapeGenerationWindow7OnClickE5Pointii+0x50) [0x7ec6b0]
[29] /home/tijl/svnopenttd/bin/openttd(_Z17HandleMouseEventsv+0x129c) [0x85cd1c]
[30] /home/tijl/svnopenttd/bin/openttd(_ZN15VideoDriver_SDL9PollEventEv+0x105) [0x83ff35]
[31] /home/tijl/svnopenttd/bin/openttd(_ZN15VideoDriver_SDL8MainLoopEv+0x88) [0x8401f8]
[32] /home/tijl/svnopenttd/bin/openttd(_Z12openttd_mainiPPc+0x14aa) [0x6ec2ea]
[33] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7ff6180d1ea5]
[34] /home/tijl/svnopenttd/bin/openttd() [0x528181]
Operating system:
Name: Linux
Release: 3.11.8-031108-generic
Version: #201311122252 SMP Wed Nov 13 03:53:29 UTC 2013
Machine: x86_64
Compiler: GCC 4.7.3 "4.7.3"
Configuration:
Blitter: 8bpp-optimized
Graphics set: OpenGFX (1021)
Language: /home/tijl/svnopenttd/bin/lang/english.lng
Music driver: extmidi
Music set: NoMusic (0)
Network: no
Sound driver: sdl
Sound set: NoSound (2)
Video driver: sdl
AI Configuration (local: 16):
Libraries:
FontConfig: 2.10.2
FreeType: 2.4.11
ICU: 4.8.1.1
LZMA: 5.1.0alpha
LZO: 2.06
PNG: 1.2.49
SDL: 1.2.15
Zlib: 1.2.7
---- gamelog start ----
Tick 0: new game started
Revision text changed to r26139M, savegame version 187, modified, _openttd_newgrf_version = 0x1400661b
New game mode: 2 landscape: 1
---- gamelog end ----
*** End of OpenTTD Crash Report ***
2. click on house button in landscape toolbar
Last edited by zooks on 13 Dec 2013 13:13, edited 1 time in total.
Re: [patch]Picking and placing single houses in scenario edi
Hmmm ... broken translation??? Please, do the following:
1. Run the game and confirm that the problem still exists.
2. Replace bin/lang/english.lng file with this one --> https://www.dropbox.com/s/203gi4byax5spvq/english.lng
3. Run the game again (don't recompile!).
1. Run the game and confirm that the problem still exists.
2. Replace bin/lang/english.lng file with this one --> https://www.dropbox.com/s/203gi4byax5spvq/english.lng
3. Run the game again (don't recompile!).
![Pleased :]](./images/smilies/pleased.gif)
Re: [patch]Picking and placing single houses in scenario edi
Gives me the same error..adf88 wrote:Hmmm ... broken translation??? Please, do the following:
1. Run the game and confirm that the problem still exists.
2. Replace bin/lang/english.lng file with this one --> https://www.dropbox.com/s/203gi4byax5spvq/english.lng
3. Run the game again (don't recompile!).
Re: [patch]Picking and placing single houses in scenario edi
Same error here, could be related
https://bugs.openttd.org/task/5829
It does only happen for me when using this patch though
https://bugs.openttd.org/task/5829
It does only happen for me when using this patch though
Re: [patch]Picking and placing single houses in scenario edi
I tried to apply this patch to r26357. It still crashes with same assert.
Re: [patch]Picking and placing single houses in scenario edi
New version released (v2). The mentioned bug is fixed now.
![Pleased :]](./images/smilies/pleased.gif)
Re: [patch]Picking and placing single houses in scenario edi
New release - v3. Updated along with recent changes in the trunk.
![Pleased :]](./images/smilies/pleased.gif)
- Fairyfloss
- Traffic Manager
- Posts: 162
- Joined: 03 Aug 2011 14:10
- Location: Yes
Re: [patch]Picking and placing single houses in scenario edi
So.. how do I use it? I don't think I can just place it somewhere and it works, am I right?
Can someone explain how I can get this to work ingame? I'd love to be able to use this...
Can someone explain how I can get this to work ingame? I'd love to be able to use this...
Re: [patch]Picking and placing single houses in scenario edi
Please read the sticky at the top of this subforum.Darthrafael wrote:So.. how do I use it? I don't think I can just place it somewhere and it works, am I right?
Can someone explain how I can get this to work ingame? I'd love to be able to use this...

Patches aren't easy-to-use, because they create features that didn't exist before.
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
- Fairyfloss
- Traffic Manager
- Posts: 162
- Joined: 03 Aug 2011 14:10
- Location: Yes
Re: [patch]Picking and placing single houses in scenario edi
Okay, but I don't understand how to do that, can someone please be so nice and give me a download to OpenTTD with this patch applied to it?FLHerne wrote:Please read the sticky at the top of this subforum.Darthrafael wrote:So.. how do I use it? I don't think I can just place it somewhere and it works, am I right?
Can someone explain how I can get this to work ingame? I'd love to be able to use this...![]()
Patches aren't easy-to-use, because they create features that didn't exist before.
Re: [patch]Picking and placing single houses in scenario edi
All you have to do is follow the directions. It's not simple, but it is not difficult either.
Alternative, the Spring 2013 Patch Pack was just updated a few weeks ago, and includes this patch along with many others.
Alternative, the Spring 2013 Patch Pack was just updated a few weeks ago, and includes this patch along with many others.
Do you like drones, quadcopters & flying toys? Check out Drone Strike Force!

Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets

Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: [patch]Picking and placing single houses in scenario edi
Minor update to r27356. And an uninitialized variable warning:
Code: Select all
/***/src/town_gui.cpp: In member function ‘virtual void HousePickerWindow::OnInit()’:
/***/src/town_gui.cpp:1317: warning: ‘last_set’ may be used uninitialized in this function
/***/src/town_gui.cpp:1317: note: ‘last_set’ was declared here
- Attachments
-
- house_placing_r27356.diff
- (97.32 KiB) Downloaded 908 times
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
Who is online
Users browsing this forum: No registered users and 7 guests