Skip to main content
Topic: Unnecessary Code in stadt_t::step_p****agiere()? (Read 3349 times) previous topic - next topic

Unnecessary Code in stadt_t::step_p****agiere()?

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!

Re: Unnecessary Code in stadt_t::step_p****agiere()?

Reply #1
A wild guess would be that line 1498 should read
Code: [Select]
return_pax.menge = pax.menge;
maybe prissi can tell more
Parsley, sage, rosemary, and maggikraut.

Re: Unnecessary Code in stadt_t::step_p****agiere()?

Reply #2
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.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Re: Unnecessary Code in stadt_t::step_p****agiere()?

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

Re: Unnecessary Code in stadt_t::step_p****agiere()?

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

 

Re: Unnecessary Code in stadt_t::step_p****agiere()?

Reply #5
Should be changed indeed.