Skip to main content
Topic: [bug r3008] Crash when selecting a factory in factory builder using Pak96.Comic (Read 1894 times) previous topic - next topic

[bug r3008] Crash when selecting a factory in factory builder using Pak96.Comic

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.


Re: [bug r3008] Crash when selecting a factory in factory builder using Pak96.Comic

Reply #2
The game should never crash just because of the data in a pakset.
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.

Re: [bug r3008] Crash when selecting a factory in factory builder using Pak96.Comic

Reply #3
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. ;)