The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Topic started by: ivansanchez on December 31, 2009, 02:47:28 AM

Title: Crash when replacing vehicles
Post by: ivansanchez on December 31, 2009, 02:47:28 AM
Hi all,

It seems that I'm able to crash simutrans experimental when trying to upgrade horses to light tractors. The crash looks like this:
(http://ivan.sanchezortega.es/2009-12-31_033930.png)
Then, when pressing any key, simutrans crashes.

In order to reproduce this crash, download http://ivan.sanchezortega.es/foo34.sve (http://ivan.sanchezortega.es/foo34.sve), and bulk-replace all the horses with tractors. Then fast-forward until you hit a new year.

If that doesn't crash, try http://ivan.sanchezortega.es/foo35-replaced.sve (http://ivan.sanchezortega.es/foo35-replaced.sve) - it should crash instantly.

Edit: I've fiddled with this for a bit, and it seems that there is no need for replacing - the bug triggers with a "withdraw all" on any road line carrying piece goods, and then waiting until next year, or trying to save.

Edit: Weird. You don't need to do anything at all. Just wait until the next year or try to save.
Title: Re: Crash when replacing vehicles
Post by: jamespetts on December 31, 2009, 11:22:24 AM
Ivan,

thank you very much for your report. I am currently away from home and not able to get to my copy of the development code or a fast enough computer to test this, but I'll look into this when I get home next week, and try to reproduce/fix it.
Title: Re: Crash when replacing vehicles
Post by: Bernd Gabriel on December 31, 2009, 01:05:22 PM
Ivan,

I can't load http://ivan.sanchezortega.es/foo35-replaced.sve, too.

In http://ivan.sanchezortega.es/foo34.sve withdrawing all convoys from "Newcastle-Cambridge cattle convoy" crashes the game. I continue investigating this...

Congradulations: 800 convoys in 1 line could be a new world record!  :award:
Title: Re: Crash when replacing vehicles
Post by: Bernd Gabriel on December 31, 2009, 02:33:29 PM
Fixed 2 errors in the "withdraw" related code.
Will be fixed in Exp.7.2.
Title: Re: Crash when replacing vehicles
Post by: ivansanchez on December 31, 2009, 02:53:52 PM
Quote from: Bernd Gabriel on December 31, 2009, 01:05:22 PMCongratulations: 800 convoys in 1 line could be a new world record!  :award:

What can I say, cattle drovers were the only way to make a profit in a 1830 game :-)

By the way: did you try to load foo34.sve and just fast-forward until next year?
Title: Re: Crash when replacing vehicles
Post by: Bernd Gabriel on December 31, 2009, 03:05:35 PM
Yes: I'm getting an error while autosaving the fabconnection of an ai_good "Kohle". :(
Title: Re: Crash when replacing vehicles
Post by: ivansanchez on December 31, 2009, 03:11:06 PM
The goods AIs in that game behaved a bit strange. They just build roads and then bulldoze them, without building stations or convoys for them.

I'm just guessing here: maybe it's because the AI plotted a route from an industry that got closed afterwards? Several sheep farms and orchards have already been closed down in that game.

Well, that's two bug reports for the price of one. Ain't you happy? :-D
Title: Re: Crash when replacing vehicles
Post by: jamespetts on December 31, 2009, 03:14:58 PM
Ivan,

thank you very much for your further report.

Bernd,

thank you very much for the fix!
Title: Re: Crash when replacing vehicles
Post by: Bernd Gabriel on December 31, 2009, 03:34:15 PM
@jamespetts
Closing fabs is an experimental feature, isn't it?
Is so, can you give me a hint, where I can find the closing code?
Title: Re: Crash when replacing vehicles
Post by: jamespetts on December 31, 2009, 03:37:43 PM
Closing factories is indeed specific to Simutrans-Experimental. The code for deciding whether they are closed is in the new month method of karte_t (simworld.cc), and the code for what happens when they do close is in fabrik_t (simfab.cc).
Title: Re: Crash when replacing vehicles
Post by: Bernd Gabriel on January 01, 2010, 08:58:45 PM
Removing a factory, no matter if done by experimental closing code or by 'destroy/remove' tool of player 'public service', now notifies all players, that a factory is going to be deleted. Thus ai_goods player is able to check and eventually clean up its various references to factories.

Loading a savegame with references to no longer existing factories and/or types of goods in ai_goods will remove those erroneous data.

This makes foo34.sve playable again.

Will be fixed in Exp. 7.2.
Title: Re: Crash when replacing vehicles
Post by: jamespetts on January 01, 2010, 09:54:30 PM
Excellent - good work Bernd!
Title: Re: Crash when replacing vehicles
Post by: ivansanchez on January 02, 2010, 01:22:19 AM
Quote from: Bernd Gabriel on January 01, 2010, 08:58:45 PMLoading a savegame with references to no longer existing factories and/or types of goods in ai_goods will remove those erroneous data.

Kudos for fixing this!