News:

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

11.9007 (commit 16a8ed2) cannot start with factories

Started by MCollett, June 01, 2013, 02:16:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MCollett

I have a freshly-compiled version of the latest 11.x branch commit from Github (16a8ed2), on Mac OS X 10.8.  Any attempt to start a new game results in a fatal error being reported by fabrik_t::recalc_nearby_halts that some factory "has no location on the map!".    Choosing to start the game with 0 factories avoids the problem, allowing the game to start normally.  Sufficiently old games with existing factories also appear to load OK; more recent games do not, but I presume that has to do with savefile format changes rather than this bug.   

Best wishes,
Matthew

neroden

Thanks very much for reporting this.

OK.  So what's going on is, get_tile_list is returning garbage (or an empty list) when the factory is in the process of being built. 

This is because there is no gebauede_t associated with the factory yet.  This is because the factory hasn't actually been built at the time of the call....

It seems like the call to fabrik_t::baue ought to be in the constructor for fabrik_t -- it is in the other constructor for fabrik_t, and that one works -- but I couldn't quite make that work.  In the meantime, moving yet more code from fabrik_t into fabrikbauer_t does the trick.

So, temporary fix on the 11x-fixes branch.

jamespetts

Thank you very much for the speedy fix, and for the report, respectively! I'm not able to test at present, but will check and integrate when I get back home.
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.

neroden

Quote from: jamespetts on June 01, 2013, 11:26:24 AM
Thank you very much for the speedy fix, and for the report, respectively! I'm not able to test at present, but will check and integrate when I get back home.

While I was there, I fixed a subtle bug introduced during your last merger of my 11x-fixes branch -- now on the 11x-fixes branch. 

----
I also added some comments related to future planning.  Currently factories are recognized for every point in their tile list, but attractions are handled entirely improperly, with a single "top left corner" tile being credited as the entire attraction.  This makes it very hard to run bus lines which stop to the south or east of large attractions (everyone "walks around to the back side"), and I've already noticed this problem.  City halls have a similar problem, though less acute because they're smaller. 

So the "tile_list" system used for factories will need to be copied for attractions and city halls.  And it probably needs to be made faster: we should probably start storing the tile list with the factory/attraction/city hall, and I'm going to think about how to do that.

jamespetts

Thank you for your work and thoughts on this - very helpful! Yes, it would be good to have attractions handled consistenlty. In Standard, I think that the intention is to have each individual tile of an attraction sort of count as a city building in its own right, which is (sort of) internally consistent if counter-intuitive. It is possible that I have inadvertently introduced inconsistencies in the handling for Experimental; but handling attractions and town halls like factories is probably the better solution in the long-term.
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.