coding help

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
tigerface
Engineer
Engineer
Posts: 93
Joined: 01 Jan 2007 17:29

coding help

Post by tigerface »

Hi,

I need a bit of help setting the introduction date of vehicles, I just can't get it right! :(

On the wiki it says 1-1-1920 is 701265 days from year 0. well thats 701280 days from year 0...?

While I'm here.. Hex is not a strong point. 701265 is 51 B3 0A 00? Is that in little-endian order?

Sorry for all my nooby questions.. :oops:

Jr.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: coding help

Post by Rubidium »

thanet-bomber wrote:On the wiki it says 1-1-1920 is 701265 days from year 0. well thats 701280 days from year 0...?
A year usually consists of 365 days, except for leap years. You assume that there is a leap year every four year (701280/1920 = 365.25). This is 'wrong' because when the year is dividable by 100 it is non a leap year (-19), unless it is dividable by 400 because then it is a leap year (+4).
User avatar
tigerface
Engineer
Engineer
Posts: 93
Joined: 01 Jan 2007 17:29

Re: coding help

Post by tigerface »

wow I never knew that! learn something new every day. cheers for your help!
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: coding help

Post by DaleStan »

thanet-bomber wrote:Hex is not a strong point. 701265 is 51 B3 0A 00? Is that in little-endian order?
Then don't use it. "\d701265" will encode that number in a dword, exactly as you want, with no hassles about endianness. (But don't use that either.) If you want to know how it came out on the other end, just encode and decode, and read the decoded sprite. (And, yes, it is LE.)

The proper way to encode January 1, 1920, for the long-date properties, is one of "\d1/1/1920", "\d1-1-1920", "\d1920/1/1", or "\d1920-1-1". This is either YMD or DMY order. No middle-endian silliness is supported, even if I[0] do live in a country that chooses to use that format.

[0] I wrote this part of the spec, hence why my preferences have bearing here.
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
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Google Adsense [Bot] and 15 guests