[code help] Introduction date before 1920

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
fistersn
Engineer
Engineer
Posts: 23
Joined: 31 Dec 2003 10:43

[code help] Introduction date before 1920

Post by fistersn »

Hello. I a totaly new with grf coding. Since the lacking for ships for from 1800, I have made my first attempt to make a sailingship.
My drawing is not that good, but I have used GRF Maker and managed to get the ship into the game. My problem is that GRF Maker only support introduction date down to 1920 and not 1800.

I have tried to figured out how to edit the NFO file to replace 1920 to 1800, with no succses.
Anyone how can helo me with this?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: [code help] Introduction date before 1920

Post by DaleStan »

First figure out how to manually change the 1920 to 1940. Then use that as a clue for making the intro date 1/1/1800 instead.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Purno
Tycoon
Tycoon
Posts: 16659
Joined: 30 Mar 2004 12:30
Location: Almere, The Netherlands

Re: [code help] Introduction date before 1920

Post by Purno »

GRFMaker can't set the date before 1920. If you need features which GRFMaker doesn't support, you're probably best of writing the whole NFO code yourself. I think that will make you understand your piece of code better, than when you auto-generate most with GRFMaker.

Though, GRFMaker can include a NFO block in it's project file...
Contributor to the The 2cc Set and Dutch Trainset. Inventor of the Metro concept. Retired Graphics Artist.
Image Image
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [code help] Introduction date before 1920

Post by Roujin »

Since GRFMaker does not support it, you'll have to start understanding NFO yourself. Just start here: http://wiki.ttdpatch.net/tiki-index.php ... RFTutorial

Once you know how it works in general, I'm sure you'll pretty soon be able to change what you need.
Just some directions:
The introduction date is defined inside an Action 0.
There are two different properties inside action 0 that define an introduction date: the normal one (property 0), which counts from 1920 onwards (can be found under "Action 0 General"), and the long format one (property # depends on vehicle type, for ships it's 1A), which you'll need (can be found under "Action 0 Ships").
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: [code help] Introduction date before 1920

Post by AndersI »

As Purno said: GRFMaker can embed *any* NFO in a 'generic NFO block', so all you have to do is find out the NFO code for setting the start year, and embed that. You don't have to redo your whole project.
User avatar
Purno
Tycoon
Tycoon
Posts: 16659
Joined: 30 Mar 2004 12:30
Location: Almere, The Netherlands

Re: [code help] Introduction date before 1920

Post by Purno »

True, just use a vehicle data block to define all stats in GRFMaker, than use a little piece of NFO (NFO block) to overwrite the start year (and nothing else).

Should solve the issue.
Contributor to the The 2cc Set and Dutch Trainset. Inventor of the Metro concept. Retired Graphics Artist.
Image Image
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
fistersn
Engineer
Engineer
Posts: 23
Joined: 31 Dec 2003 10:43

Re: [code help] Introduction date before 1920

Post by fistersn »

Oki. Thanks, I will see what I can find out.

For now the only difference I can find in the NFO files one from 1920 and the other is 2000. Is following

For 1920

Code: Select all

    4 * 32	 00 02 0B 01 02 00 00 00 03 20 04 96 06 0F 0A 63 0B 40 0C 00 0D 1E 00 0F 63 11 05 00 00 00 13 01 
For 2000

Code: Select all

   4 * 32	 00 02 0B 01 02 00 10 72 03 20 04 96 06 0F 0A 63 0B 40 0C 00 0D 1E 00 0F 63 11 05 00 00 00 13 01 
The only difference I can see is 00 00 replaced with 10 72 in the 2000 version.
Don't now is this is the right part to do the introduction date?
User avatar
OzTrans
Tycoon
Tycoon
Posts: 1714
Joined: 04 Mar 2005 01:07

Re: [code help] Introduction date before 1920

Post by OzTrans »

To put you out of your misery ...

You have asked your query in TTDPatch. a TTDPatch game cannot start before January 1, 1921, therefore you cannot make use of a 1800 start. Although it could be coded, but would simply be ignored.

An OpenTTD game can start earlier. In order to make a vehicle (ship) available earlier, you need to set 2 properties :

a] property 0x00 = year of introduction, where 0x0000 = 1920 [in days starting from 1 Jan 1920].
b] property 0x1A = long format introduction date in days, where 0x00000000 = January 1, 0000

You already have property 0x00. However you cannot set property 0x00 earlier than 1920. So this one is set to 1 Jan 1920 or 0. Your date of 1 Jan 1800 is defined via property 0x1A, which you need to add. You need to calculate it first though.

01 January 1800 is approximately = 1800 years times 365.25 = 657,450 days. In hex this is 0x000A082A (any good calculator can do that for you). In little endian the whole thing you need to add looks like this : 1A 2A 08 0A 00.

Now lets add that to your code. You have 2 ways to do that. Either modify the existing action-00 or add a new one after the existing one :

a] modify existing action-00 :

Code: Select all

4 * 37     00 02 0C 01 02 00 00 00 03 20 04 96 06 0F 0A 63 0B 40 0C 00 0D 1E 00 0F 63 11 05 00 00 00 13 01 1A 2A 08 0A 00
1] 4 * 32 becomes 4 * 37 as you add 5 more bytes (you can ignore that if you use NFORenum as it would take care of that).
2] the 0B in 00 02 0B becomes 0C as you add one more property.
3] 1A 2A 08 0A 00 is then added to the end.
4] the 00 00 00 in 00 02 0C 01 02 00 00 00 remains unchanged; that's property 0x00 or needs to be set to 1920 = 0x0000.

b] add another action-00 :

Code: Select all

 4 * 32     00 02 0B 01 02 00 00 00 03 20 04 96 06 0F 0A 63 0B 40 0C 00 0D 1E 00 0F 63 11 05 00 00 00 13 01 
-1 * 10     00 02 01 01 02 1A 2A 08 0A 00
In detail :
00 = action-00
02 = for ships
01 = one property
01 = for one vehicle
02 = ID of ship
1A ... = the property to change plus data

To make it all work, let it run through NFORenum (it will find any errors and fix the things it can), then GRFCodec.
fistersn
Engineer
Engineer
Posts: 23
Joined: 31 Dec 2003 10:43

Re: [code help] Introduction date before 1920

Post by fistersn »

Thanks A LOT. I haven't have time before today to look at this issues.
But your solutions seems to work.

I even think I have managed to make 1700 has introduction date.

Code: Select all

4 * 37     00 02 0C 01 02 00 00 00 03 20 04 96 06 0F 0A 63 0B 40 0C 00 0D 1E 00 0F 63 11 05 00 00 00 13 01 1A 7D 79 09 00
It seems to work in openttd.
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Google [Bot], luxtram and 5 guests