Query about cargo refitting

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Query about cargo refitting

Post by andythenorth »

I am working with an nfo kindly created by Zephyris. It contains a cargo translation table (copied below), and an action 0 for a vehicle that can be refitted to mineral cargoes (including those provided by Pikka's Industries).

I would like to add additional refit options for wood and tropical wood to this vehicle. What would be the correct implementation of action 0 to do that? The action 0 for the vehicle is also copied below.

As background, I am now familiar with what (edited - changed incorrect use of 'parameters') road vehicles properties 16, 1D and 1E do, and *think* I can work out how to define words correctly. I am hazy on bitmasks, and I wouldn't like to be cross-examined on the relationship of cargo ids, cargo labels, cargo classes, and positions in the translation table.

Thanks for any suggestions.

cheers,

Andy

Code: Select all

    2 * 170	 00 08 01 29 00 09 "PASSCOALMAILOIL_LVSTGOODGRAIWOODIORESTELVALU"
	 "PAPRFOODFRUTCOREWATRRUBRSUGRTOYSBATTSWETTOFFCOLACT"
	 "CDBUBLPLSTFZDRWHEAGOLDMAIZTWODDIAM___A___B___C___D"
	 "___E___F___G___H___I"

Code: Select all

  748 * 67	 00 01 19 01 94 
    00 00 00
    02 20
    03 11
    04 23
    06 0F
    07 05
    08 80
    09 1E 0A 48 4C 00 00 13 14 14 18 
    0E FF
    0F 00
    10 FF
    11 34
    12 17
    15 20
    16 40 00 00 00
    17 16
    1A 00
    1B 00
    1C 02
    1D 10 00          // Refittable cargo classes
    1E 00 00          // Non-refittable cargo classes
    1F 60 B3 0A 00
Last edited by andythenorth on 08 Nov 2008 21:28, edited 2 times in total.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Query about cargo refitting

Post by frosch »

andythenorth wrote:parameters 16, 1D and 1E
Please call them "road vehicle properties". "Parameters" are used in action6/7/9/D. Also add "road vehicles" as the properties are differently numbered for different "features".

Let's see. You have to read the properties in this order to understand their meaning:
andythenorth wrote:1D 10 00 // Refittable cargo classes
It shall transport bulk freight
andythenorth wrote:1E 00 00 // Non-refittable cargo classes
and it shall not exclude any bulk freight which also belongs to other classes.
16 40 00 00 00 // bit mask of cargo bits, for which the refittability shall be inverted
The membership of cargo 6 shall be inverted.

So what is cargo 6?
0 PASS 01 00 00 00
1 COAL 02 00 00 00
2 MAIL 04 00 00 00
3 OIL_ 08 00 00 00
4 LVST 10 00 00 00
5 GOOD 20 00 00 00
6 GRAI 40 00 00 00
7 WOOD 80 00 00 00
8 IORE 00 01 00 00
9 STEL 00 02 00 00
10 VALU 00 04 00 00
11 PAPR 00 08 00 00
12 FOOD 00 10 00 00
13 FRUT 00 20 00 00
14 CORE 00 40 00 00
15 WATR 00 80 00 00
16 RUBR 00 00 01 00
17 SUGR 00 00 02 00
18 TOYS 00 00 04 00
19 BATT 00 00 08 00
20 SWET 00 00 10 00
21 TOFF 00 00 20 00
22 COLA 00 00 40 00
23 CTCD 00 00 80 00
24 BUBL 00 00 00 01
25 PLST 00 00 00 02
26 FZDR 00 00 00 04
27 WHEA 00 00 00 08
28 GOLD 00 00 00 10
29 MAIZ 00 00 00 20
30 TWOD 00 00 00 40
31 DIAM 00 00 00 80
It is grain.
Unless you define your own cargos, you should look up grain in http://wiki.ttdpatch.net/tiki-index.php?page=CargoTypes
So grain belongs to "bulk cargo". I.e. as property 1D/1E said to transport bulk cargo, property 16 says "but not grain".

For your wood and tropic wood you have to do the reverse procedure. Look up which cargo classes they belong to. Figure out whether property 1D/1E include them. If they do not, add them to property 16 to include them for refitting.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Query about cargo refitting

Post by andythenorth »

frosch wrote:
andythenorth wrote:parameters 16, 1D and 1E
Please call them "road vehicle properties". "Parameters" are used in action6/7/9/D. Also add "road vehicles" as the properties are differently numbered for different "features".
(corrected above)
For your wood and tropic wood you have to do the reverse procedure. Look up which cargo classes they belong to. Figure out whether property 1D/1E include them. If they do not, add them to property 16 to include them for refitting.
Thanks Frosch, most helpful. I'll try this.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Query about cargo refitting

Post by PikkaBird »

You will make life easier for yourself if you space your cargo translation table out a bit. ;) This is like frosch's table, but in a format that will still work as an actual translation table in NFO.

Code: Select all

    // Cargo Translation Table
2 * 170    00 08 01 29 00 09 
"PASS" "COAL" "MAIL" "OIL_"     // 00 - 03, 01 - 08
"LVST" "GOOD" "GRAI" "WOOD"     // 04 - 07, 10 - 80
"IORE" "STEL" "VALU" "PAPR"     // 08 - 0B, 01^ - 08^
"FOOD" "FRUT" "CORE" "WATR"     // 0C - 0F, 10^ - 80^
"RUBR" "SUGR" "TOYS" "BATT"     // 10 - 13, 01^^ - 08^^
"SWET" "TOFF" "COLA" "CTCD"     // 14 - 17, 10^^ - 80^^
"BUBL" "PLST" "FZDR" "WHEA"     // 18 - 1B, 01^^^ - 08^^^
"GOLD" "MAIZ" "TWOD" "DIAM"     // 1C - 1F, 10^^^ - 80^^^
"___A" "___B" "___C" "___D"
"___E" "___F" "___G" "___H"
"___I"
So, having set 1D and 1E to carry bulk freight, we then need to use prop 16 to XOR the special cases. These are; Grain, Wheat and Maize (bulk cargos that we don't want), and wood and twod (non-bulk cargos that we do want).

The bits, from the translation table, are:

Grain - 40
Wheat - 08^^^
Maize - 20^^^
Wood - 80
Twod - 40^^^

Add 'em together, and you get... C0 00 00 68. Right? :o
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Query about cargo refitting

Post by andythenorth »

PikkaBird wrote:You will make life easier for yourself if you space your cargo translation table out a bit. ;) This is like frosch's table, but in a format that will still work as an actual translation table in NFO.
Will do thanks - the one above is what came out of grfcodec when I decoded a grf Zephyris created for me. I've find Grf2HTML very handy so far - it shows a nicely formatted version of the translation table :D
Grain - 40
Wheat - 08^^^
Maize - 20^^^
Wood - 80
Twod - 40^^^

Add 'em together, and you get... C0 00 00 68. Right? :o
Yep that worked thanks. I've also added in fruit using C0 20 00 68. It also appears to play happily with PBI and UKRS brick chain which is important to me.

The only tricky bit is the vehicle's default cargo: in tropic it's defaulting to rubber, which is not a valid refit. This is an articulated RV, and the bitmask above applies to the lead vehicle which carries no cargo. I believe the trailer (which is refittable to all cargoes except passengers) is defaulting to rubber when it's first built. I will have a look at that later (time for work now), but would value any tips to solve it.
refits.png
refits.png (59.92 KiB) Viewed 2580 times
cheers,

Andy
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Query about cargo refitting

Post by PikkaBird »

andythenorth wrote:The only tricky bit is the vehicle's default cargo: in tropic it's defaulting to rubber, which is not a valid refit.
The problem is that rubber takes coal's place as cargo slot 01 in tropic.

The easiest solution is to create an additional action 0 which sets the default cargo to copper ore (08), and then use an action 7 to skip it in the other climates. This is what I do with the hoppers in NARS, for example.

Code: Select all

1 * 6	 07 83 01 \7! 02 01 // tropic only
1 * 9	 00 00 01 01 1D 15 08 // copper ore default
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Query about cargo refitting

Post by andythenorth »

PikkaBird wrote: The problem is that rubber takes coal's place as cargo slot 01 in tropic....The easiest solution is to create an additional action 0 which sets the default cargo to copper ore (08), and then use an action 7 to skip it in the other climates.
Thanks Pikka. I've modified the action 0 for RVs, setting property 10 (cargo type) to 14, which is copper ore in my cargo table. 05 is the ID of the trailer vehicle; I've also got another action 0 applying the same cargo type to the lead vehicle in the consist.

These action 0s come after the initial action 0 for each vehicle. However it doesn't appear to work. (The action 07 is clearly fine, because I managed to write an action 0 that crashed the game in tropic but not other climates!).

Am I missing something obvious?

Code: Select all

  378 * 6	 07 83 01 \7! 02 01 // tropic only
  379 * 7	 00 01 01 01 05 10 14// copper ore default


cheers,

Andy
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Query about cargo refitting

Post by PikkaBird »

andythenorth wrote:Am I missing something obvious?
You need the untranslatable cargo slot (Column B from the wiki page), not the position in the translation table.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Query about cargo refitting

Post by andythenorth »

PikkaBird wrote: You need the untranslatable cargo slot (Column B from the wiki page), not the position in the translation table.
Ach, I should read documentation more closely. Thanks Pikka, that's nailed it.

Actually it took a bit more fiddling because there are multiple road vehicles in the articulated consist - some of them should have had FF set for prop 10, and didn't. Once I fixed those the action 7 worked perfectly to set cargo 08 default in tropic. Nice tip, thanks.

My next challenge will be to change the cargo capacity of an RV trailer based on a property of the lead vehicle (such as vehicle ID, or maybe vehicle hp (prop 13). I'll read the documentation tonight to see if I can figure this out - however if anyone thinks I am starting on an impossible fool's errand, it would be nice to know!

cheers,

Andy
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Query about cargo refitting

Post by andythenorth »

@Pikka: I am providing PBI support in the HEQS set (I like PBI a lot) :)

I'm wondering what the best way is to provide sprite support for gravel and clay? My vehicles refit to them ok, but don't use the right loaded sprites for those two cargoes.

I am fine with creating the nfo code, but I am unsure of the best way to support the cargoes. I'd prefer to use the cargo translation table, but am unsure if PBI brick chain uses labels for gravel / clay (I have had a peek into the grf with grf2html, but possibly I missed the labels?).

Obviously I could use the cargo bits directly (I'm reading them as 24 and 26?), but that doesn't look like a robust solution. My assumption would be that I should use the labels defined here: http://wiki.ttdpatch.net/tiki-index.php?page=CargoTypes

EDIT: I've been reading the extended discussions on the 'right' way to structure cargo translation tables. http://www.tt-forums.net/viewtopic.php? ... le#p671409 That produced a significant amount of 'Ow' in my poor brain.

Any help appreciated :)

cheers,

Andy
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 8 guests