News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

Large-scale cleanup of walking time code

Started by neroden, June 10, 2013, 08:30:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

neroden

I removed several bugs, mostly in the "destination walking" code. 

More importantly, the calculations for converting from distance to walking time (and actually for other travel time too) are now written in only *one place*, in simworld.h, which should prevent future bugs of this sort from appearing.  (OK, I lie: they're actually written in a second place, but it's only used as a cache, in saved halts in simhalt.cc; it will be recomputed on halt alternation.)

The routines for this have been arranged so that the necessary values for the computation will be cached directly in the karte_t object for the world, which should eliminate a lot of pointer indirection and therefore speed the game up.  In addition, the access routines will all be inlined, which should make this even faster.  However, this should be transparent to the rest of the code, which can call these routines as if they are computed fresh every time.  (The numbers only change on game load or settings load or in a new game.)

This has been tested and works right.  So this completes the first half of my promise to write the walking time code.  :-)

I've been lazy about branching, and so all of this is on the emergency-depot-bugfix branch.

jamespetts

Thank you for this - I have fixed a compile bug for MSVC++ in my local branch in respect of this code. This seems to be a sensible improvement (more maintainable, certainly), although I have not yet tested the performance. This is much appreciated.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.