Skip to main content
Topic: [bug] increase_industry_density doesn't check cannot_save() (Read 2372 times) previous topic - next topic

[bug] increase_industry_density doesn't check cannot_save()

When a new factory chain is build, map will be rotated to find saveable direction.
But when a factory chain extended, it won't be rotated.
As a result, player can't save this map or simutrans quits.

Reason:
When a factory chain extended, parent is not NULL.

fabrikbauer.cc:449-507
Quote
   // rotate until we can save it, if one of the factory is non-rotateable ...
   if(welt->cannot_save()  &&  parent==NULL  &&  !can_factory_tree_rotate(info)  ) {
      org_rotation = welt->get_einstellungen()->get_rotation();
      for(  int i=0;  i<3  &&  welt->cannot_save();  i++  ) {
         pos->rotate90( welt->get_groesse_y()-info->get_haus()->get_h(rotate) );
         welt->rotate90();
      }
      ****ert( !welt->cannot_save() );
   }

So, we need to add similar code here.

fabrikbauer.cc:852-
Quote
   // first: do we have to continue unfinished buissness?
   if(last_built_consumer  &&  last_built_consumer_ware < last_built_consumer->get_besch()->get_lieferanten()) {

      int org_rotation = -1;
   // rotate until we can save it, if one of the factory is non-rotateable ...
   if(welt->cannot_save()  &&  !can_factory_tree_rotate(last_built_consumer->get_besch())) ) {
      org_rotation = welt->get_einstellungen()->get_rotation();
      for(  int i=0;  i<3  &&  welt->cannot_save();  i++  ) {
         welt->rotate90();
      }
      ****ert( !welt->cannot_save() );
   }


      uint32 last_suppliers = last_built_consumer->get_suppliers().get_count();
      do {
         nr += baue_link_hierarchie( last_built_consumer, last_built_consumer->get_besch(), last_built_consumer_ware, welt->get_spieler(1) );
         last_built_consumer_ware ++;
      } while(  last_built_consumer_ware < last_built_consumer->get_besch()->get_lieferanten()  &&  last_built_consumer->get_suppliers().get_count()==last_suppliers  );

      // must rotate back?
      if(org_rotation>=0) {
         for(  int i=0;  i<4  &&  welt->get_einstellungen()->get_rotation()!=org_rotation;  i++  ) {
            welt->rotate90();
         }
         welt->update_map();
      }



Re: [bug] increase_industry_density doesn't check cannot_save()

Reply #1
Thank you for spotting this out.