The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Simutrans-Extended bug reports => Topic started by: PJMack on April 15, 2022, 10:25:37 PM

Title: [assert] factorylist_stats_t.cc:60 assert(max_capacity>0);
Post by: PJMack on April 15, 2022, 10:25:37 PM
Assertion occurs when changing from operation rate to ... what the next item is in the factory dialog.  Difficult to reproduce on a new game.
Title: Re: [assert] factorylist_stats_t.cc:60 assert(max_capacity>0);
Post by: jamespetts on May 01, 2022, 03:59:38 PM
Quote from: PJMack on April 15, 2022, 10:25:37 PMAssertion occurs when changing from operation rate to ... what the next item is in the factory dialog.  Difficult to reproduce on a new game.

Thank you for the report. Is there any reliable reproduction case for this?
Title: Re: [assert] factorylist_stats_t.cc:60 assert(max_capacity>0);
Post by: PJMack on May 07, 2022, 12:17:14 AM
So far, the issue has only appeared on a specific map (and has consistently appeared on that map).  I have been using the map for testing of other features, however since I did not touch any of the industry code, I do not think it is anything I did.  Unfortunately, the map is far too large to attach.
Title: Re: [assert] factorylist_stats_t.cc:60 assert(max_capacity>0);
Post by: jamespetts on May 14, 2022, 04:36:30 PM
I do not think that I will feasibly be able to look into this without a reliable reproduction case, I am afraid.
Title: Re: [assert] factorylist_stats_t.cc:60 assert(max_capacity>0);
Post by: PJMack on May 18, 2022, 10:34:49 PM
PR#539 fixes the crash.  It was caused by an apothecary that for some reason has a maximum capacity of zero.
Title: Re: [assert] factorylist_stats_t.cc:60 assert(max_capacity>0);
Post by: Ranran(retired) on May 19, 2022, 11:37:25 AM
PR#539 appears to be a change that is only intended to avoid crashes by avoiding division by zero.
I don't have a clear way to reproduce that, so I can't confirm it, but I think it will break the display. (Perhaps the bar pops out of the frame because the width is not calculated accurately).

The essence of the problem is that the capacity is not supposed to be zero, yet it is getting zero. I think that for some reason the factory is not getting the data or there is an industry with a capacity of 0 due to an anomaly in the calculation.
If the storage capacity is 0, it means that shipping or consumption cannot be done correctly, so I don't think it would take such a value.

Anyway, I think it would be smarter not to display the bar by changing assert to return and terminating the process.