Bug #1629

Review conversion for speed property

Added by planetmaker about 9 years ago. Updated about 8 years ago.

Status:ClosedStart date:2010-10-11
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-
Target version:0.2.0

Description

With road vehicles I get 60 km/h (NML) --> 57 km/h (OpenTTD), 80 km/h (NML) --> 77 km/h (OpenTTD). See for example the trams in OpenGFX+ Vehicles

nml_units.diff Magnifier (6.85 KB) planetmaker, 2011-11-15 20:46

1629.diff Magnifier (10.2 KB) yexo, 2011-11-20 14:06


Related issues

Related to NewGRF Meta Language - Feature #930: sanity / rounding error check on supplied values New 2010-05-10

Associated revisions

Revision 1716:3b16e927f4e6
Added by yexo about 8 years ago

Fix #1629: change the value written for the speed property to that the displayed value in OpenTTD matches the original value

Revision 1716:3b16e927f4e6
Added by yexo about 8 years ago

Fix #1629: change the value written for the speed property to that the displayed value in OpenTTD matches the original value

History

#1 Updated by yexo about 9 years ago

Road vehicles:
60 km/h (NML) --> 57 km/h (OpenTTD)
60 km/h (NML) --> 59 km/h (TTDPatch)

So actually OpenTTD should probably be changed to match TTDPatch here.

#2 Updated by Hirundo almost 9 years ago

Rounding was improved recently (nearest instead of floor) for all units except speed:

http://vcs.openttd.org/hg/openttd/trunk.hg/rev/648b3317d839

#3 Updated by Hirundo over 8 years ago

  • Target version set to 0.2.0

I noticed this also, when coding the train example.
We should trace all (rounding) steps between the value entered in NML and the value displayed on screen and then basically do as follows:

while nml_value_to_screen(val) < wanted_val: val += 1
if nml_value_to_screen(val) != wanted_val: warn("we're sorry, rounding is just really messed up")

where nml_value_to_screen(val) replicates all rounding steps.

#4 Updated by planetmaker about 8 years ago

Not yet quite working... it results in a speed limit of 0km/h with OpenGFX+Trains. But the principle...

#5 Updated by Hirundo about 8 years ago

... seems right indeed (the principle, that is)

#6 Updated by yexo about 8 years ago

This patch works for the action0 property 'speed' for all features. However it doesn't work for units when used in varaction2 ranges. Is that used by anyone?

#7 Updated by yexo about 8 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Applied in changeset 3b16e927f4e6.

Also available in: Atom PDF