News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Bad line of code in simhalt.cc

Started by ACarlotti, June 21, 2019, 11:34:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ACarlotti

So this line of code (simhalt.cc:1511 approximately) is clearly incorrect - it is comparing a variable to itself. I suspect there may have been some confusion about order of precedence of operators. I don't know what was intended here - perhaps James can remember or work out his intentions here in 2017.

const uint32 max_iteration = average_waiting_time > average_waiting_time ? min(8, iter.value.month) : 1;

(I happened to notice gcc warning about this during repeated recompilations while I worked out how to indicate the correct data types elsewhere in the file.)

jamespetts

Splendid, thank you for spotting that. I have pushed a fix to set this to what I believe was intended, which was to check whether the average waiting times were higher than the estimated waiting times, and, if so, flush the stale times more aggressively to prevent temporary blockages causing high waiting times to linger for a long time.
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.