Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Oct 22, 2018 1:09 pm

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: coding help
PostPosted: Sat Dec 22, 2007 10:06 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Jan 01, 2007 5:29 pm
Posts: 93
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.


Top
   
 Post subject: Re: coding help
PostPosted: Sat Dec 22, 2007 10:12 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Feb 09, 2006 7:15 pm
Posts: 3815
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).


Top
   
 Post subject: Re: coding help
PostPosted: Sun Dec 23, 2007 12:57 am 
Offline
Engineer
Engineer
User avatar

Joined: Mon Jan 01, 2007 5:29 pm
Posts: 93
wow I never knew that! learn something new every day. cheers for your help!


Top
   
 Post subject: Re: coding help
PostPosted: Sun Dec 23, 2007 4:00 am 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.