Industry Tiles use 'correct' terrain sprite, minimise ID use
Moderator: Graphics Moderators
- andythenorth
- Tycoon
- Posts: 5656
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Industry Tiles use 'correct' terrain sprite, minimise ID use
I have this sandpit industry that needs to allow the ground tile to show through at the edges (replacing the current green grass, which I drew, and looks wrong in non-temperate climate).
This could be done by providing multiple action 2s for each tile, with different ground sprites for each terrain type, then
using a varaction 2 checking tile variable 41.
However to preserve total industry tile IDs, all tiles for this industry are the same ID, and use a position check varaction 2 to decide which graphics to show.
My concern is that
(a) we end up with a lot of code just to define the different ground tiles (waste, possibility of errors)
(b) might run out of action 2 IDs (extremely likely if we animate this industry)
(c) it's a pain.
I wondered if there was / should be a way to specify 'make the ground tile whatever the current ground tile would be'? The information must be in the map, or var 41 wouldn't be able to get it.
Or, if a branching varaction chain is the only way to do this, then I'd better get on with it - and add extra tile IDs if I run out of action 2 IDs
This could be done by providing multiple action 2s for each tile, with different ground sprites for each terrain type, then
using a varaction 2 checking tile variable 41.
However to preserve total industry tile IDs, all tiles for this industry are the same ID, and use a position check varaction 2 to decide which graphics to show.
My concern is that
(a) we end up with a lot of code just to define the different ground tiles (waste, possibility of errors)
(b) might run out of action 2 IDs (extremely likely if we animate this industry)
(c) it's a pain.
I wondered if there was / should be a way to specify 'make the ground tile whatever the current ground tile would be'? The information must be in the map, or var 41 wouldn't be able to get it.
Or, if a branching varaction chain is the only way to do this, then I'd better get on with it - and add extra tile IDs if I run out of action 2 IDs
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
This patch draws the landscape ground tile under the industry ground tile if bit 1 of industry tile prop 12 (special flags) is set. It's untested and just a demonstration of how it could be implemented.
I have no idea if this is the way to go or if a special value for groundsprite in the industry tile action2 would be better.
Planetmaker said the same should be done for houses. It's easy to code whenI have a bit to check, maybe prop 19 (extra flags) bit 4?
I have no idea if this is the way to go or if a special value for groundsprite in the industry tile action2 would be better.
Planetmaker said the same should be done for houses. It's easy to code whenI have a bit to check, maybe prop 19 (extra flags) bit 4?
- Attachments
-
- ground_under_industrytile.diff
- (1.72 KiB) Downloaded 140 times
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
abit off topic, but the same would be quite awsome for tracks and streets of all kinds... just an "overlay" of the terrain...
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
For that I'll refer you to petern and his railtypes branch (wiki, mercurial branch).DJ Nekkid wrote:abit off topic, but the same would be quite awsome for tracks and streets of all kinds... just an "overlay" of the terrain...
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
I really support this idea, any way to make coding houses, industries, infrastructure etc. more flexible with respect to ground tiles is an excellent idea.
On a side note do you know if (the default) airport tiles are drawn over the normal ground tiles? I know in the past this was not the case, but if the latest versions of OpenTTD do then it would make a nice little improvement to OpenGFX.
On a side note do you know if (the default) airport tiles are drawn over the normal ground tiles? I know in the past this was not the case, but if the latest versions of OpenTTD do then it would make a nice little improvement to OpenGFX.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
And if they don't: adding that flag there would seem reasonable, tooZephyris wrote:I really support this idea, any way to make coding houses, industries, infrastructure etc. more flexible with respect to ground tiles is an excellent idea.
On a side note do you know if (the default) airport tiles are drawn over the normal ground tiles? I know in the past this was not the case, but if the latest versions of OpenTTD do then it would make a nice little improvement to OpenGFX.
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: Industry Tiles use 'correct' terrain sprite, minimise ID use
In OpenTTD trunk they are not drawn over normal ground tiles, in my newgrf airports branch they are always drawn over normal ground tiles (so no flag), although depending on the outcome of this topic maybe I'll at a flag to draw the normal ground conditionally.planetmaker wrote:And if they don't: adding that flag there would seem reasonable, tooZephyris wrote:I really support this idea, any way to make coding houses, industries, infrastructure etc. more flexible with respect to ground tiles is an excellent idea.
On a side note do you know if (the default) airport tiles are drawn over the normal ground tiles? I know in the past this was not the case, but if the latest versions of OpenTTD do then it would make a nice little improvement to OpenGFX.
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
If (when ) the newairports gets to this stage drawing ground tiles under the original airport by default would be good...... maybe I'll at a flag to draw the normal ground conditionally.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
Ah, thanks for the info. In that case I'd propose the same approach as for industry and house tiles; it would allow to define your own airport ground sprites making their location also stick out even, if stations are set to invisible.Yexo wrote:In OpenTTD trunk they are not drawn over normal ground tiles, in my newgrf airports branch they are always drawn over normal ground tiles (so no flag), although depending on the outcome of this topic maybe I'll at a flag to draw the normal ground conditionally.
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: Industry Tiles use 'correct' terrain sprite, minimise ID use
Hmm, I don't get this
I think andy starts from wrong assumptions.
To make a tile capable of all climates you do not need 6 tiles for temperate grass, arctic grass, arctic snow, tropic grass, tropic desert, toyland grass. Two are enough. All grass tiles share the same spritenumber, and desert and snow also share the same.
So you might safe two tile definitions. But IMO that is not true either. I cannot imagine any tile where the ground is affected by snow, but the buildings on it are not.
So the only case remaining is a tile which is pure grass/snow/desert without any building on it. But OTOH, this only requires two layouts for the whole file, as they can be shared for all industries with such tiles. (Though the snowtiles will look ugly as industries have only one snow density, while normal tiles have four)
On a sidenote: Simliar is possible with water tiles. IIRC drawing watertiles as groundsprites makes them even look canalish/riverish if the industry was built on such a tile.
Second sidenote: A related task is that you cannot use corner shores or certain foundations in spritelayouts as they are only defined by Action5 and have no fixed TTD sprite. There is some FS task about that. (I guess by george)
Third sidenote: A sandpit in the desert? Sounds like big business
I think andy starts from wrong assumptions.
To make a tile capable of all climates you do not need 6 tiles for temperate grass, arctic grass, arctic snow, tropic grass, tropic desert, toyland grass. Two are enough. All grass tiles share the same spritenumber, and desert and snow also share the same.
So you might safe two tile definitions. But IMO that is not true either. I cannot imagine any tile where the ground is affected by snow, but the buildings on it are not.
So the only case remaining is a tile which is pure grass/snow/desert without any building on it. But OTOH, this only requires two layouts for the whole file, as they can be shared for all industries with such tiles. (Though the snowtiles will look ugly as industries have only one snow density, while normal tiles have four)
On a sidenote: Simliar is possible with water tiles. IIRC drawing watertiles as groundsprites makes them even look canalish/riverish if the industry was built on such a tile.
Second sidenote: A related task is that you cannot use corner shores or certain foundations in spritelayouts as they are only defined by Action5 and have no fixed TTD sprite. There is some FS task about that. (I guess by george)
Third sidenote: A sandpit in the desert? Sounds like big business
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
- andythenorth
- Tycoon
- Posts: 5656
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
Yup, frosch is right. Problem solvedfrosch wrote:I think andy starts from wrong assumptions.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
I fail to see how you can even come close to running out of action 2 IDs, unless you're branching your action 2s in a really weird way. Every time you branch you can reuse the same block of IDs for the same mirrored part; in fact, it makes sense to do so.andythenorth wrote: (b) might run out of action 2 IDs (extremely likely if we animate this industry)
For an industry tile with 24 different position graphics each with 8 frames of animation (192 tile sprites):
24 tiles (* 8 )
branches to ^
8 position check
branches to ^
1 animation check
= 201 action 2s with 33 IDs used (and there's no reason you can't reuse the animation check ID as one of the position check IDs, so 32 IDs used).
Add an extra variation (say, 4 completely different layouts resulting in 768 tile sprites):
24 tiles (*8*4)
branches to ^
8 position check (*4)
branches to ^
4 animation check
branches to ^
1 layout check
= 805 action 2s, 36 IDs used.
- andythenorth
- Tycoon
- Posts: 5656
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
You just saved me a lot of copy-paste-edit-ID painPikkaBird wrote:Every time you branch you can reuse the same block of IDs for the same mirrored part; in fact, it makes sense to do so.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
- andythenorth
- Tycoon
- Posts: 5656
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: Industry Tiles use 'correct' terrain sprite, minimise ID use
My Sand Pit is now more snow / desert terrain aware
This isn't 100% perfect, transition tiles are still a problem. Far as I can see, that's not solvable using existing var 41. I think the existing results are good enough though.
There will be snow sprites for the industry later. Code relies on some preprocessor includes, these reduce duplication and generally make the code easier to work with.
This isn't 100% perfect, transition tiles are still a problem. Far as I can see, that's not solvable using existing var 41. I think the existing results are good enough though.
There will be snow sprites for the industry later. Code relies on some preprocessor includes, these reduce duplication and generally make the code easier to work with.
Code: Select all
// include tiles and layouts, ! Action 2 IDs here are deliberately repeated by the various tile includes
#include "i_sandpit_tiles_layouts/sandpit_tiles_standard.pnfo"
#include "i_sandpit_tiles_layouts/sandpit_layouts.pnfo"
-1 * 0 02 09 A1
82 44 //check layout number (lowest byte of related industry)
00 FF //don't shift, don't mask
\b2 //number of ranges to check (number of layouts)
\wxB0 \b1 \b1 //<set-id \w> <low-range> <high-range>
\wxB1 \b2 \b2 //<set-id \w> <low-range> <high-range>
\wx00 //<default> (first tile layout available)
#include "i_sandpit_tiles_layouts/sandpit_tiles_desert.pnfo"
#include "i_sandpit_tiles_layouts/sandpit_layouts.pnfo"
-1 * 0 02 09 A2
82 44 //check layout number (lowest byte of related industry)
00 FF //don't shift, don't mask
\b2 //number of ranges to check (number of layouts)
\wxB0 \b1 \b1 //<set-id \w> <low-range> <high-range>
\wxB1 \b2 \b2 //<set-id \w> <low-range> <high-range>
\wx00 //<default> (first tile layout available)
#include "i_sandpit_tiles_layouts/sandpit_tiles_snow.pnfo"
#include "i_sandpit_tiles_layouts/sandpit_layouts.pnfo"
-1 * 0 02 09 A3
82 44 //check layout number (lowest byte of related industry)
00 FF //don't shift, don't mask
\b2 //number of ranges to check (number of layouts)
\wxB0 \b1 \b1 //<set-id \w> <low-range> <high-range>
\wxB1 \b2 \b2 //<set-id \w> <low-range> <high-range>
\wx00 //<default> (first tile layout available)
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Who is online
Users browsing this forum: No registered users and 4 guests