The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Spike on February 29, 2012, 11:10:28 AM

Title: Metric units?
Post by: Spike on February 29, 2012, 11:10:28 AM
I came across this:

  const int left_shift = ticks_per_world_month_shift - YARDS_PER_TILE_SHIFT;

Can we agree to use metric units, if we need to use real world units in the code? Metric units have the benefit that they can be converted into each other by powers of 10, and not with a 3 or 12 base, or even a fractional base.
Title: Re: Metric units?
Post by: Dwachs on February 29, 2012, 11:24:30 AM
These yards are an artificial small unit, they do not correspond to a real unit. They were introduced to give names to hard-coded bit-shifts in the vehicle movement code.
Title: Re: Metric units?
Post by: Spike on February 29, 2012, 11:45:30 AM
Ok. You see you already confused one person by re-using a word with a new semantic :D

For artificial time units I often see "ticks" being used. I don't really know something like that for distances. "step" is already used in Simutrans - If I would know that the "YARDS_PER_TILE_SHIFT" is actually doing, I might be able to find a good name.


Title: Re: Metric units?
Post by: Dwachs on February 29, 2012, 12:49:33 PM
simunits.h:

* 5 -- "yards" -- tiny distance units used internally
        -- 2^12 per vehicle steps, by definition
-- 2^16 per vehicle steps in older code
-- chosen to maximize precision of certain interfaces


Why call it yard? Probably there are no other 4-letter words (step is already taken) ?