The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: knightly on April 21, 2009, 08:27:02 am

Title: Unnecessary Code in stadt_t::step_p****agiere()?
Post by: knightly on April 21, 2009, 08:27:02 am
Version : R2432

I have this question on my mind for a long time. May I know whether line 1475-78 of simcity.cc inside step_p****agiere() is unnecessary?

Quote

if(will_return != town_return) {
   // restore normal mail amount => more mail from attractions and factories than going to them
   pax.menge = pax_left_to_do;
}


I have checked the code below these lines for a few times and cannot find any further reference to this local object pax. In that case, should these lines be removed?

Thank you very much for your attention!
Title: Re: Unnecessary Code in stadt_t::step_p****agiere()?
Post by: Dwachs on April 21, 2009, 09:13:38 am
A wild guess would be that line 1498 should read
Code: [Select]
return_pax.menge = pax.menge;
maybe prissi can tell more
Title: Re: Unnecessary Code in stadt_t::step_p****agiere()?
Post by: VS on April 21, 2009, 09:24:11 am
Second possibility is that pax is object whose reference is added to some system earlier and now only its values are changed... but that doesn't seem to be the case.
Title: Re: Unnecessary Code in stadt_t::step_p****agiere()?
Post by: prissi on April 21, 2009, 11:17:33 am
I would say those are leftovers. Thank you for spotting this out. (I think there are many more such gems hidden, as usually there has been seldomly one doing code review of my code.)
Title: Re: Unnecessary Code in stadt_t::step_p****agiere()?
Post by: z9999 on April 21, 2009, 03:31:35 pm
I may be wrong but ...

simcity.cc:1384
Code: [Select]
int pax_left_to_do = min(7, num_pax - pax_routed);

simcity.cc:1440
Code: [Select]
pax.menge = (wtyp == warenbauer_t::p****agiere ? pax_left_to_do : max(1, pax_left_to_do >> 2));

So, mail packet is always 1, isn't it ?
Code: [Select]
pax.menge = (wtyp == warenbauer_t::p****agiere ? pax_left_to_do : 1);
Title: Re: Unnecessary Code in stadt_t::step_p****agiere()?
Post by: prissi on April 22, 2009, 06:06:30 pm
Should be changed indeed.