News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

outgoing_private_cars not loaded just when loading savedata

Started by suitougreentea, November 14, 2017, 12:52:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

suitougreentea

Hello,

I was suffering from the fact that some cities didn't grow at all even though I used city growth tool.
Today I downloaded the source code and investigated the cause, then I found that (all of these happen in simcity.cc):


  • When loading savedata and first stadt_t::city_growth_get_factors() called, stadt_t::outgoing_private_cars is not loaded yet (and therefore 0)
  • Then city_growth_factor_previous[0].supplied is just h[HIST_PAS_TRANSPORTED] + h[HIST_PAS_WALKED] + h[HIST_CITYCARS] (outgoing_private_cars not subtracted)
  • When step_grow_city() called first and again factors calculated, outgoing_private_cars is already loaded and then factors[0].supplied hugely drops
  • So city_growth_base() returns large negative value
  • Then new_unsupplied_city_growth also indicates large negative value and also unsupplied_city_growth

I could not create a patch because I am not sure yet about how save/load works....
Hope that helps and issue will be fixed.

jamespetts

Thank you very much for this. The fix to this requires altering the saved game version to load/save the data for outgoing private cars earlier. I have now pushed a fix to this on the passenger-and-mail-classes branch (because that branch is ahead in version numbering, and it would cause conflicts if I were to try to implement this on the master branch). This fix, however, will only work when loading a game last saved with an executable with the fix applied.

I am hoping that the passenger-and-mail-classes branch will be able to be merged into the master branch quite soon.

Thank you again for your work on this: this is most helpful.
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.

suitougreentea

Now I tried the latest nightly and confirmed it was fixed. Thank you very much!

For users who have a problem of cities not growing: the easiest way to reset unsupplied_city_growth is to check "Allow city growth" and uncheck it after a while (for a month is enough I think).