Help with changing introduction date

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
JustMoreMemes
Engineer
Engineer
Posts: 47
Joined: 08 Dec 2018 18:09

Help with changing introduction date

Post by JustMoreMemes »

I'm working on reverse engineering Generic Cars to make the vehicles appear earlier, for now it's just a personal project as I want to learn how to make a NewGRF and don't want to sort licensing, but I can't find the introduction dates or much documentation on where they might be.

There should be an intro date somewhere in this code I believe, but where? Can someone with any kind of NFO skills take a look:
91 * 9 02 01 00 01 01 00 00 00 00
92 * 16 02 01 E1 85 7F 0A "@ÿÿã" 00 01 00 00 00 80
93 * 16 02 01 E2 85 7F 0A "@ÿÿ²" 00 01 00 00 00 80
94 * 16 02 01 E3 85 7F 0A "@ÿÿÝ" 00 01 00 00 00 80
95 * 16 02 01 E4 85 7F 0A "@ÿÿU" 00 01 00 00 00 80
96 * 16 02 01 E5 85 7F 0A "@ÿÿÌ" 00 01 00 00 00 80
97 * 16 02 01 E6 85 7F 0A 40 FF FF 08 00 01 00 00 00 80
98 * 16 02 01 E7 85 7F 0A "@ÿÿô" 00 01 00 00 00 80
99 * 16 02 01 E8 85 7F 0A "@ÿÿv" 00 01 00 00 00 80
100 * 23 02 01 EE 80 00 00 08 E1 00 E2 00 E3 00 E4 00 E5 00 E6 00 E7 00 E8 00
101 * 11 02 01 33 80 00 00 02 4D 80 4E 80
102 * 14 02 01 33 81 46 08 7F 01 33 00 7F 7F 00 00
103 * 15 02 01 33 81 7F 00 00 01 01 00 00 01 01 33 00
104 * 22 02 01 33 81 10 00 FF 03 50 80 01 01 49 80 03 03 33 00 07 07 00 00
105 * 18 02 01 00 81 0C 00 FF 02 EE 00 2D 2D 33 00 33 33 00 00
106 * 9 03 01 01 FF 66 3C 00 00 00
107 * 4 01 01 01 08

My guess is line 101 * 11, since it's the only line that's significantly different to the equivalent line for the next vehicle, but I can't work out how the numbers would convert to a date.
JustMoreMemes
Engineer
Engineer
Posts: 47
Joined: 08 Dec 2018 18:09

Re: Help with changing introduction date

Post by JustMoreMemes »

Actually, I think it might be in here instead: 20 * 64 00 01 18 01 FF 66 3A 00 00 00 02 00 03 1E 04 3C 06 07 07 02 08 60 09 00 0A 48 4C 00 00 13 03 14
04 0E FF 0F 02 10 00 11 00 12 17 15 18 16 00 00 00 00 17 C0 1A 00 1B 01 1C 02 1D 00 00 1E 00 00
There's several lines of similar code which seems to be setting up all the vehicles in order.
JustMoreMemes
Engineer
Engineer
Posts: 47
Joined: 08 Dec 2018 18:09

Re: Help with changing introduction date

Post by JustMoreMemes »

I figured out where the date is with the help of YAGL but I can't figure out how to get a date pre-1920, even trying to use code from EGRVTS2 isn't working.
JustMoreMemes
Engineer
Engineer
Posts: 47
Joined: 08 Dec 2018 18:09

Re: Help with changing introduction date

Post by JustMoreMemes »

My main issue now is that I can't make the pre-1920 dates work, even using a long introduction date that works in both NARS2.03 and EGRVTS2, it just won't work for my GRF and instead causes the vehicle to not show up. If anyone knows how to fix this please tell me how.
JustMoreMemes
Engineer
Engineer
Posts: 47
Joined: 08 Dec 2018 18:09

Re: Help with changing introduction date

Post by JustMoreMemes »

It's actually working oh my god, EGRVTS and NARS2's code didn't work but for some reason I was able to reverse engineer Bob's British Buses and that does work. Now I only need to redo the sprites and my NewGRF is finished for personal use. The sprites are quite low res but I don't know how to change the sprite specifications, so this will have to do for now.
User avatar
kamnet
Moderator
Moderator
Posts: 8588
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Help with changing introduction date

Post by kamnet »

I would suggest taking the time to learn NML instead. A much better investment than trying to wrangle with NFO.
arikover
Route Supervisor
Route Supervisor
Posts: 466
Joined: 15 Jun 2007 09:27
Skype: madchimiste
Location: Berlin, Deutschland

Re: Help with changing introduction date

Post by arikover »

JustMoreMemes wrote: 09 Nov 2022 13:45 Actually, I think it might be in here instead: 20 * 64 00 01 18 01 FF 66 3A 00 00 00 02 00 03 1E 04 3C 06 07 07 02 08 60 09 00 0A 48 4C 00 00 13 03 14
04 0E FF 0F 02 10 00 11 00 12 17 15 18 16 00 00 00 00 17 C0 1A 00 1B 01 1C 02 1D 00 00 1E 00 00
There's several lines of similar code which seems to be setting up all the vehicles in order.
This is the Action0, which defines the properties:

Code: Select all

20 * 64 // Line# * Length
    00 //Action0, Doc = https://newgrf-specs.tt-wiki.net/wiki/Action0
    01 //Feature 01 = Road Vehicle
    18 //Number of properties in this Action0: x18 = 24
    01 //Number of vehicles
    FF 66 3A //ID of the first vehicle: 3A66

    //Properties 00 - 07 are documented here: https://newgrf-specs.tt-wiki.net/wiki/Action0/Vehicles
    00          //01/24: Prop 00 = Date of introduction, 1920-based
        00 00            // 1920-01-01 I guess
        
    02          //02/24: Prop 02 = Reliability decay speed
        00               // 0 = never decays
        
    03          //03/24: Prop 03 = Vehicle life
        1E               // old after 30 years
        
    04          //04/24: Prop 04 = Model life
        3C               // disappears after 60 years
        
    06          //05/24: Prop 06 = Climate availability
        07               // all, except toyland
        
    07          //06/24: Prop 07 = Loading speed
        02               // 2 units every 20 game ticks

    //Properties 08+ are documented here: https://newgrf-specs.tt-wiki.net/wiki/Action0/Vehicles/RoadVehicles
    08          //07/24: Prop 08 = Speed
        60               // ~30 mph
        
    09          //08/24: Prop 09 = Running cost factor
        00               // normal I guess
        
    0A          //09/24: Prop 0A = Cost base
        48 4C 00 00      // that's standard
        
    13          //10/24: Prop 13 = Power
        03               // 30 hp
        
    14          //11/24: Prop 14 = Weight
        04               // 1 ton
        
    0E          //12/24: Prop 0E = Sprite ID
        FF               // FF means new graphics
        
    0F          //13/24: Prop 0F = Capacity
        02               // 2
        
    10          //14/24: Prop 10 = Cargo types
        00               // Passengers
        
    11          //15/24: Prop 11 = Cost factor
        00               // free
        
    12          //16/24: Prop 12 = Sound effect
        17               // normal
        
    15          //17/24: Prop 15 = Speed 
        18               // 24/0.8 = 30 mph also
        
    16          //18/24: Prop 16 = bitmask for cargo refit
        00 00 00 00
        
    17          //19/24: Prop 17 = Callback flags
        C0               //80 (Sound effect) + 40 (Color mapping)
        
    1A          //20/24: Prop 1A = refit cost
        00
        
    1B          //21/24: Prop 1B = retire vehicle early
        01
        
    1C          //22/24: Prop 1C = misc vehicle flags
        02               //use 2 company colors
        
    1D          //23/24: Prop 1D = refitable cargo classes
        00 00
        
    1E          //24/24: Prop 1E = non refitable cargo classes
        00 00
For an introduction date before 1920, add the property 1F, which can be set to the number of days since year 0 (1920-01-01 is 701265, that is 51 B3 0A 00).

Not very user friendly (if you practice it everyday, maybe you begin seeing the matrix), but really interesting.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Help with changing introduction date

Post by PikkaBird »

arikover wrote: 09 Nov 2022 17:14the number of days since year 0 [...] 51 B3 0A 00 [...] Not very user friendly
"\d1-1-1920" also works. If you're just changing (or adding, since the grf predates it) a property in a decompiled file like this, you could also just tag additional sprites on the end of the file, rather than trying to find where the property is (or would be) set and changing it there.

Code: Select all

1 * 1 00 01 \b1 \b1 ff 66 3a 1f \d1-1-1920 // Model T
1 * 1 00 01 \b1 \b1 ff 66 3b 1f \d1-1-1940 // Ford
1 * 1 00 01 \b1 \b1 ff 66 3c 1f \d1-1-1960 // Beetle
1 * 1 00 01 \b1 \b1 ff 66 3d 1f \d1-1-1980 // Astra
1 * 1 00 01 \b1 \b1 ff 66 3e 1f \d1-1-2000 // Punto
1 * 1 00 01 \b1 \b1 ff 66 3f 1f \d1-1-2020 // Futuristic
Of course, if you change the introduction dates, you're perhaps going to have issues with model life, etc. :)

If you're trying to make your own grf with your own vehicles, which is what it sounds like you're doing, then yes, you'd be much better off learning to code a grf from scratch (using NML) rather than decompiling and modifying existing sets.
JustMoreMemes
Engineer
Engineer
Posts: 47
Joined: 08 Dec 2018 18:09

Re: Help with changing introduction date

Post by JustMoreMemes »

kamnet wrote: 09 Nov 2022 15:43 I would suggest taking the time to learn NML instead. A much better investment than trying to wrangle with NFO.
I think you're right, I decided to work with NFO because I figured that it must be the one most people use, I'd misunderstood NML and assumed it was a basic language for beginners that most modders ignore but it just seems objectively better. At the moment I'm using a combination of NFO and YAGL for writing and it works quite well but I'll probably be learning NML for my first non-reverse engineered products.
JustMoreMemes
Engineer
Engineer
Posts: 47
Joined: 08 Dec 2018 18:09

Re: Help with changing introduction date

Post by JustMoreMemes »

arikover wrote: 09 Nov 2022 17:14
JustMoreMemes wrote: 09 Nov 2022 13:45 Actually, I think it might be in here instead: 20 * 64 00 01 18 01 FF 66 3A 00 00 00 02 00 03 1E 04 3C 06 07 07 02 08 60 09 00 0A 48 4C 00 00 13 03 14
04 0E FF 0F 02 10 00 11 00 12 17 15 18 16 00 00 00 00 17 C0 1A 00 1B 01 1C 02 1D 00 00 1E 00 00
There's several lines of similar code which seems to be setting up all the vehicles in order.
This is the Action0, which defines the properties:

Code: Select all

20 * 64 // Line# * Length
    00 //Action0, Doc = https://newgrf-specs.tt-wiki.net/wiki/Action0
    01 //Feature 01 = Road Vehicle
    18 //Number of properties in this Action0: x18 = 24
    01 //Number of vehicles
    FF 66 3A //ID of the first vehicle: 3A66

    //Properties 00 - 07 are documented here: https://newgrf-specs.tt-wiki.net/wiki/Action0/Vehicles
    00          //01/24: Prop 00 = Date of introduction, 1920-based
        00 00            // 1920-01-01 I guess
        
    02          //02/24: Prop 02 = Reliability decay speed
        00               // 0 = never decays
        
    03          //03/24: Prop 03 = Vehicle life
        1E               // old after 30 years
        
    04          //04/24: Prop 04 = Model life
        3C               // disappears after 60 years
        
    06          //05/24: Prop 06 = Climate availability
        07               // all, except toyland
        
    07          //06/24: Prop 07 = Loading speed
        02               // 2 units every 20 game ticks

    //Properties 08+ are documented here: https://newgrf-specs.tt-wiki.net/wiki/Action0/Vehicles/RoadVehicles
    08          //07/24: Prop 08 = Speed
        60               // ~30 mph
        
    09          //08/24: Prop 09 = Running cost factor
        00               // normal I guess
        
    0A          //09/24: Prop 0A = Cost base
        48 4C 00 00      // that's standard
        
    13          //10/24: Prop 13 = Power
        03               // 30 hp
        
    14          //11/24: Prop 14 = Weight
        04               // 1 ton
        
    0E          //12/24: Prop 0E = Sprite ID
        FF               // FF means new graphics
        
    0F          //13/24: Prop 0F = Capacity
        02               // 2
        
    10          //14/24: Prop 10 = Cargo types
        00               // Passengers
        
    11          //15/24: Prop 11 = Cost factor
        00               // free
        
    12          //16/24: Prop 12 = Sound effect
        17               // normal
        
    15          //17/24: Prop 15 = Speed 
        18               // 24/0.8 = 30 mph also
        
    16          //18/24: Prop 16 = bitmask for cargo refit
        00 00 00 00
        
    17          //19/24: Prop 17 = Callback flags
        C0               //80 (Sound effect) + 40 (Color mapping)
        
    1A          //20/24: Prop 1A = refit cost
        00
        
    1B          //21/24: Prop 1B = retire vehicle early
        01
        
    1C          //22/24: Prop 1C = misc vehicle flags
        02               //use 2 company colors
        
    1D          //23/24: Prop 1D = refitable cargo classes
        00 00
        
    1E          //24/24: Prop 1E = non refitable cargo classes
        00 00
For an introduction date before 1920, add the property 1F, which can be set to the number of days since year 0 (1920-01-01 is 701265, that is 51 B3 0A 00).

Not very user friendly (if you practice it everyday, maybe you begin seeing the matrix), but really interesting.
Thanks for the information. it's very useful, YAGL and the TT wiki helped me understand some of this but not all of it. I'm probably gonna try to learn NML but I'll be finishing this project in NFO.
JustMoreMemes
Engineer
Engineer
Posts: 47
Joined: 08 Dec 2018 18:09

Re: Help with changing introduction date

Post by JustMoreMemes »

PikkaBird wrote: 09 Nov 2022 21:03
arikover wrote: 09 Nov 2022 17:14the number of days since year 0 [...] 51 B3 0A 00 [...] Not very user friendly
"\d1-1-1920" also works. If you're just changing (or adding, since the grf predates it) a property in a decompiled file like this, you could also just tag additional sprites on the end of the file, rather than trying to find where the property is (or would be) set and changing it there.

Code: Select all

1 * 1 00 01 \b1 \b1 ff 66 3a 1f \d1-1-1920 // Model T
1 * 1 00 01 \b1 \b1 ff 66 3b 1f \d1-1-1940 // Ford
1 * 1 00 01 \b1 \b1 ff 66 3c 1f \d1-1-1960 // Beetle
1 * 1 00 01 \b1 \b1 ff 66 3d 1f \d1-1-1980 // Astra
1 * 1 00 01 \b1 \b1 ff 66 3e 1f \d1-1-2000 // Punto
1 * 1 00 01 \b1 \b1 ff 66 3f 1f \d1-1-2020 // Futuristic
Of course, if you change the introduction dates, you're perhaps going to have issues with model life, etc. :)

If you're trying to make your own grf with your own vehicles, which is what it sounds like you're doing, then yes, you'd be much better off learning to code a grf from scratch (using NML) rather than decompiling and modifying existing sets.
Thanks for the info, my plan is to make a similar NewGRF to generic cars that adds vehicles across 1700-1900, specifically 1705, 1788, 1815, 1858, 1883, and 1886, since for the latter 5 I'm using real designs and dates. It's gonna have new graphics and will likely only share some generic code for the vehicles albeit with changed stats and graphics. At the moment the artwork is under construction and I'm still fine tuning the stats but here's my list of vehicles, barring future changes if I can't make a sprite work for one of them or something. I eventually managed to add the date in a different way though.
Still using the original Generic cars while I make new sprites
Still using the original Generic cars while I make new sprites
Unnamed, 1st Jan 1905.png (21.16 KiB) Viewed 1047 times
I'll probably be learning NML for my next project after this one, which I'll be finishing in NFO with some YAGL, my next one will probably be fully originally written rather than reverse engineered.
User avatar
Svartypops
Engineer
Engineer
Posts: 28
Joined: 20 Nov 2022 15:15

Re: Help with changing introduction date

Post by Svartypops »

JustMoreMemes wrote: 09 Nov 2022 13:38 I'm working on reverse engineering Generic Cars to make the vehicles appear earlier, for now it's just a personal project as I want to learn how to make a NewGRF and don't want to sort licensing, but I can't find the introduction dates or much documentation on where they might be.

There should be an intro date somewhere in this code I believe, but where? Can someone with any kind of NFO skills take a look:
91 * 9 02 01 00 01 01 00 00 00 00
92 * 16 02 01 E1 85 7F 0A "@ÿÿã" 00 01 00 00 00 80
93 * 16 02 01 E2 85 7F 0A "@ÿÿ²" 00 01 00 00 00 80
94 * 16 02 01 E3 85 7F 0A "@ÿÿÝ" 00 01 00 00 00 80
95 * 16 02 01 E4 85 7F 0A "@ÿÿU" 00 01 00 00 00 80
96 * 16 02 01 E5 85 7F 0A "@ÿÿÌ" 00 01 00 00 00 80
97 * 16 02 01 E6 85 7F 0A 40 FF FF 08 00 01 00 00 00 80
98 * 16 02 01 E7 85 7F 0A "@ÿÿô" 00 01 00 00 00 80
99 * 16 02 01 E8 85 7F 0A "@ÿÿv" 00 01 00 00 00 80
100 * 23 02 01 EE 80 00 00 08 E1 00 E2 00 E3 00 E4 00 E5 00 E6 00 E7 00 E8 00
101 * 11 02 01 33 80 00 00 02 4D 80 4E 80
102 * 14 02 01 33 81 46 08 7F 01 33 00 7F 7F 00 00
103 * 15 02 01 33 81 7F 00 00 01 01 00 00 01 01 33 00
104 * 22 02 01 33 81 10 00 FF 03 50 80 01 01 49 80 03 03 33 00 07 07 00 00
105 * 18 02 01 00 81 0C 00 FF 02 EE 00 2D 2D 33 00 33 33 00 00
106 * 9 03 01 01 FF 66 3C 00 00 00
107 * 4 01 01 01 08

My guess is line 101 * 11, since it's the only line that's significantly different to the equivalent line for the next vehicle, but I can't work out how the numbers would convert to a date.
I can do hex editing. If you know what numbers to look for, you can convert to hex and search for them, but remember that oftentimes games store data in LITTLE ENDIAN, which means reversing the "pairs" of digits in a four-byte block.

See that other block 01 00 00 00? That's 00 00 00 01 in little endian = 1.

In your data block, the second number on each line seems to indicate how many bytes on that line, but it's not always true, so presumably this, "@ÿÿã" is 4 bytes.
---
[edit]
I just read some of the replies... my comment has been covered above. Anyway, I wanted to just say...
701265 days = 0a B3 51
which is stored in little endian as shown above: 51 B3 0A 00
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: RoyalExamination9410, UnicycleBloke and 75 guests