The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: knightly on January 06, 2010, 06:16:55 pm

Title: [bug r3008] Crash when selecting a factory in factory builder using Pak96.Comic
Post by: knightly on January 06, 2010, 06:16:55 pm
As title. I encounter this bug when I try to test my patch for the builders.

The cause of crash is that, Pak96.Comic sets the productivity's range [i.e. fab_besch->get_bereich()] to 0 for many of the factories (I didn't check all), and thus when 0 is fed into sim_async_rand(), division-by-zero error occurs.

Relevant code below :
Quote
void factory_edit_frame_t::change_item_info(sint32 entry)
{
   if(entry>=0  &&  entry<(sint32)fablist.get_count()) {

      const fabrik_besch_t *new_fab_besch = fablist[entry];
      if(new_fab_besch!=fab_besch) {

         fab_besch = new_fab_besch;
         production = (fab_besch->get_produktivitaet()+sim_async_rand(fab_besch->get_bereich()) )<<(welt->ticks_bits_per_tag-18);

I don't know whether setting productivity range to 0 is valid or not, so I will leave it to Prissi/Dwachs to decide on how to fix it.

Edit :

Forgot to mention, the Pak96.Comic I used for testing is the latest version, v0.4.6.
Title: Re: [bug r3008] Crash when selecting a factory in factory builder using Pak96.Comic
Post by: sojo on January 06, 2010, 08:42:36 pm
No prob to change this. I can use 1 in future. What do you think about it?
Title: Re: [bug r3008] Crash when selecting a factory in factory builder using Pak96.Comic
Post by: jamespetts on January 06, 2010, 08:57:39 pm
The game should never crash just because of the data in a pakset.
Title: Re: [bug r3008] Crash when selecting a factory in factory builder using Pak96.Comic
Post by: knightly on January 07, 2010, 07:31:47 am
Problem sovled. Thank you Prissi. :)


@Sojo

No prob to change this. I can use 1 in future. What do you think about it?

Judging from the change, Prissi has chosen to allow 0 for productivity range, so you don't need to change your pakset. ;)