How many cargo subtypes I can add?

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

How many cargo subtypes I can add?

Post by maquinista »

I have tried to add 14 cargo subtypes in a single train, but It doesn't work (It works fine with 12). I don't know if there is a limit or If my code is wrong. There is a limit for cargo subtypes? How many cargo subtypes I can add in a single train?
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: How many cargo subtypes I can add?

Post by PikkaBird »

12 sounds like an unusual number for a limit. I wonder though if there's a limit (256 perhaps?) on the total number of refit options displayable?

Otherwise;

a) define "doesn't work"; what happens?
b) what game/version are you testing in?
c) post your code if you want an opinion on if it's correct. :)
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

Re: How many cargo subtypes I can add?

Post by maquinista »

PikkaBird wrote:12 sounds like an unusual number for a limit. I wonder though if there's a limit (256 perhaps?) on the total number of refit options displayable?

Otherwise;

a) define "doesn't work"; what happens?
b) what game/version are you testing in?
c) post your code if you want an opinion on if it's correct. :)
A) The cargo subtypes are not shown.
B) I have tested It in TTDPatch and OpenTTD, a build with this patch. I'm using it because It makes easier the development when there are various passenger cargos (tourist, passengers...).
C)The code is based on the previous code written by Death.
If this problem can't be fixed, I can try to remove the two first options, and leave only the options that forces a certain livery.
I don't know if I have duplicated an action 2 entry, and I prefer to ask if there is a limit of cargo subtypes, because I have added a lot of it, and maybe It could be a limit.


This is the code. The train have three parts (front, middle or rear), and It is loaded purchasing a locomotive and two regional wagons.

Select graphic (front, middle or rear) depending on the position. The Sprites are loaded previously. This code was not modified:

Code: Select all

//									middle		end			middle		end		first
 1761 * 28	 02 00 20 81 40 80 FF    00 06    04    11 00 01 01    01 00 02 02    11 00 04 04    01 00 05 05    00 00
 1762 * 14	 02 00 30 81 DA 08 FF    01    01 00 FF FF    20 00  // Azul
 1763 * 28	 02 00 21 81 40 80 FF    00 06    04    12 00 01 01    03 00 02 02    12 00 04 04    03 00 05 05    02 00
 1764 * 14	 02 00 31 81 DA 08 FF    01    03 00 FF FF    21 00  // Regional
 1765 * 28	 02 00 22 81 40 80 FF    00 06    04    06 00 01 01    05 00 02 02    06 00 04 04    05 00 05 05    04 00
 1766 * 14	 02 00 32 81 DA 08 FF    01    05 00 FF FF    22 00  // Cercanías
 1767 * 28	 02 00 23 81 40 80 FF    00 06    04    13 00 01 01    08 00 02 02    13 00 04 04    08 00 05 05    07 00
 1768 * 14	 02 00 33 81 DA 08 FF    01    08 00 FF FF    23 00  // Reformado cercanías pant
 1769 * 28	 02 00 24 81 40 80 FF    00 06    04    0E 00 01 01    0D 00 02 02    0E 00 04 04    0D 00 05 05    0C 00
 1770 * 14	 02 00 34 81 DA 08 FF    01    0D 00 FF FF    24 00  // Reformado cercanías
 1771 * 28	 02 00 25 81 40 80 FF    00 06    04    0B 00 01 01    0A 00 02 02    0B 00 04 04    0A 00 05 05    09 00
 1772 * 14	 02 00 35 81 DA 08 FF    01    0A 00 FF FF    25 00  // Regional naranja
 1773 * 28	 02 00 26 81 40 80 FF    00 06    04    14 00 01 01    10 00 02 02    14 00 04 04    10 00 05 05    0F 00
 1774 * 14	 02 00 36 81 DA 08 FF    01    10 00 FF FF    26 00  // Regional blanco
 1775 * 28	 02 00 27 81 40 80 FF    00 06    04    1C 00 01 01    16 00 02 02    1C 00 04 04    16 00 05 05    15 00
 1776 * 14	 02 00 37 81 DA 08 FF    01    16 00 FF FF    27 00  // 470 naranja
 1777 * 28	 02 00 28 81 40 80 FF    00 06    04    19 00 01 01    18 00 02 02    19 00 04 04    18 00 05 05    17 00
 1778 * 14	 02 00 38 81 DA 08 FF    01    18 00 FF FF    28 00  // 470 azul
 1779 * 28	 02 00 29 81 40 80 FF    00 06    04    1D 00 01 01    1B 00 02 02    1D 00 04 04    1B 00 05 05    1A 00
 1780 * 14	 02 00 39 81 DA 08 FF    01    1B 00 FF FF    29 00  // 470 pantone
 1781 * 28	 02 00 2A 81 40 80 FF    00 06    04    3F 00 01 01    1F 00 02 02    3F 00 04 04    1F 00 05 05    1E 00
 1782 * 14	 02 00 3A 81 DA 08 FF    01    1F 00 FF FF    2A 00  // Regional no reformado Pantone
Select livery from year. This code is new and It could have the bug.

Code: Select all

 // Colours by year regional wagons
 1783 * 22	 02 00 51 81 C4 00 FF    03    30 00 00 45    36 00 46 4B    37 00 4C 54    3A 00
 // Colors by year commuter wagons
 1784 * 22	 02 00 52 81 C4 00 FF    03    30 00 00 45    32 00 46 4B    34 00 4C 54    33 00
Code that select the cargo subtype (livery). The two first options will change the livery with the purchase year (These two lines of code are new and They could have the bug).
The other options forces a certain livery:

Code: Select all

 1785 * 1	 0C
 1786 * 1	 0C
 1787 * 1	 0C
 1788 * 1	 0C
 1789 * 1	 0C

 1790 * 62	 02 00 53 81 F2    00 FF    0D   // select livery locomotive pant
   51 00  00 00  // regional by year --> new options added
   52 00  01 01  // commuter by year
 30 00  02 02 // Original
 32 00  03 03 // commuter
 34 00  04 04 // commuter refurbished
 33 00  05 05 // commuter refurbished 2005
 36 00  06 06 // regional 1
 31 00  07 07 // regional 2
 35 00  08 08 // regional 3
 36 00  09 09 // regional 4 -->Not added yet (uses regional 1 livery)
 3A 00  0A 0A // Regional 2005
 37 00  0B 0B // Regional refurbished
 38 00  0C 0C // Regional refurbished azul
 39 00 // Regional refurbished 2005
The same, but this code is for first wagon (locomotive):

Code: Select all

 // Colours by year regional locomotive
 1791 * 22	 02 00 4A 81 C4 00 FF    03    00 00 00 45    0F 00 46 4B    15 00 4C 54    1E 00
 // Colours by year commuter locomotive
 1792 * 22	 02 00 4B 81 C4 00 FF    03    00 00 00 45    04 00 46 4B    0C 00 4C 54    07 00

 1793 * 1	 0C
 1794 * 1	 0C
 1795 * 1	 0C
 1796 * 1	 0C
 1797 * 1	 0C

 1798 * 62	 02 00 48 81 F2    00 FF    0D   // select livery locomotive
   4A 00  00 00  // regional by year
   4B 00  01 01  // commuter by year
 00 00  02 02 // Original
 04 00  03 03 // Cercanías
 0C 00  04 04 // Cercanías reformada
 07 00  05 05 // Cercanías reformada 2005
 0F 00  06 06 // Regional 1
 02 00  07 07 // Regional 2
 09 00  08 08 // Regional 3
 02 00  09 09 // Regional 4 -->añadir aqui
 1E 00  0A 0A // Regional 2005
 15 00  0B 0B // Regional reformada
 17 00  0C 0C // Regional reformada azul
 1A 00 // Regional reformada 2005
This code changes the livery in the purchase list:

Code: Select all

 1799 * 18	 02 00 49 81 01 00 FF    02    00 00 00 45    02 00 46 54    07 00 // 'Locomotive' on purchase screen
Callbacks:

Code: Select all

 1800 * 62	 02 00 4C 81 F2 00 FF 0D // Text in reffiting window
 1C 00  00 00  // regional by year
 1D 00  01 01  // regional by year
 16 80  02 02 // Original
 0C 80  03 03 // Cercanías
 0D 80  04 04 // Cercanías reformada
 11 80  05 05 // Cercanías reformada 2005
 12 80  06 06 // Regional 1
 13 80  07 07 // Regional 2
 14 80  08 08 // Regional 3
 15 80  09 09 // Regional 4
 0E 80  0A 0A // Regional 2005
 0B 80  0B 0B // Regional reformada
 0F 80  0C 0C // Regional reformada azul
 10 80 // Regional reformada 2005

 1801 * 18	 02 00 4D 81 C6 00 FF 02 // Select wagons to allow attach
 FE FF    1B 1D
 06 FF    1E 2B
 FF FF

 1802 * 14	 02 00 4E 81 0C 00 FF    01    02 FF 23 23    49 00 // 23-Additional text in purchase screen
 1803 * 18	 02 00 5F 81 0C 00 FF    02    4D 00 1D 1D    4C 00 19 19    48 00 // 1D-Can wagon be attached
Action 3:

Code: Select all

 1804 * 10	 03 00 01    3E    01    FF 4E 00    5F 00 // "Locomotive"
 1805 * 8	 03 00 82    1C 1D    00    53 00
Attachments
What happens.
What happens.
problem.png (2.77 KiB) Viewed 3584 times
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: How many cargo subtypes I can add?

Post by PikkaBird »

maquinista wrote:The two first options will change the livery with the purchase year (These two lines of code are new and They could have the bug)
It's hard to tell without studying it in more depth and seeing all the code together, but I'm wondering if this, or something else you've added, isn't skipping the cargo subtype callback altogether? :)
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: How many cargo subtypes I can add?

Post by frosch »

The maximum is 255 subtypes per cargo. 0 to 254.

Check your varaction2 chains, the subcargos need to be consecutive. Querying is stopped if the callback fails or returns 0xFF.

Edit: So, as you modified the first two subtypes, that may very well be the case. However, I cannot see any callback results in the code you pasted.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

Re: How many cargo subtypes I can add?

Post by maquinista »

frosch wrote:Edit: So, as you modified the first two subtypes, that may very well be the case. However, I cannot see any callback results in the code you pasted.
Thanks!, It was the error.

I want add livery selection in Spain set to allow the users to choose their favourite liveries. Also, I want keep a option like the previous version, that uses a livery according to the purchase year.
Attachments
Bug
Bug
bug.png (1.23 KiB) Viewed 3525 times
Fixed.
Fixed.
fixed.png (12.92 KiB) Viewed 3525 times
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
User avatar
SAC
Tycoon
Tycoon
Posts: 1519
Joined: 03 Jun 2004 16:35
Location: Gothenburg, Sweden

Re: How many cargo subtypes I can add?

Post by SAC »

Speaking of refitting, I just had a tiny plane crash on a small airfield in Vännäs, and when replacing it with a new one I noticed a lot of refit options even for passengers - some which I haven't seen before... Is there a wiki for all the refitting models, (TTDP), available somewhere? I tried a search, but couldn't find any...
Simuscape - Chose Your Destination;
Simuscape | Visual Studio | INFRA Diary

INFRA Downloads - Chose Your Destination;
Simuscape | INFRA - A World of its own
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

Re: How many cargo subtypes I can add?

Post by maquinista »

SAC wrote:Speaking of refitting, I just had a tiny plane crash on a small airfield in Vännäs, and when replacing it with a new one I noticed a lot of refit options even for passengers - some which I haven't seen before... Is there a wiki for all the refitting models, (TTDP), available somewhere? I tried a search, but couldn't find any...
Are You interested in adding new livery options?

I can try to help You a bit. I'm not an expert, but It works well in OpenTTD.
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: How many cargo subtypes I can add?

Post by PikkaBird »

SAC wrote:Is there a wiki for all the refitting models, (TTDP), available somewhere? I tried a search, but couldn't find any...
Assuming you're using Av8, SAC, then in the latest version all planes have 4 different livery options. A few planes also have a (Combi) refit option, which gives them a different passenger / mail ratio.
User avatar
SAC
Tycoon
Tycoon
Posts: 1519
Joined: 03 Jun 2004 16:35
Location: Gothenburg, Sweden

Re: How many cargo subtypes I can add?

Post by SAC »

Thank you both! I found out what it ment... I was a bit surprised at first when I noticed the new refitting options... But it's all clear to me now... :))
Simuscape - Chose Your Destination;
Simuscape | Visual Studio | INFRA Diary

INFRA Downloads - Chose Your Destination;
Simuscape | INFRA - A World of its own
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests