The International Simutrans Forum

 

Author Topic: Unnecessary Code in stadt_t::step_passagiere()?  (Read 2154 times)

0 Members and 1 Guest are viewing this topic.

knightly

  • Guest
Unnecessary Code in stadt_t::step_passagiere()?
« 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_passagiere() 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!

Online Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4897
  • Languages: EN, DE, AT
Re: Unnecessary Code in stadt_t::step_passagiere()?
« Reply #1 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

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Unnecessary Code in stadt_t::step_passagiere()?
« Reply #2 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10818
  • Languages: De,EN,JP
Re: Unnecessary Code in stadt_t::step_passagiere()?
« Reply #3 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.)

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: Unnecessary Code in stadt_t::step_passagiere()?
« Reply #4 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::passagiere ? 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::passagiere ? pax_left_to_do : 1);

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10818
  • Languages: De,EN,JP
Re: Unnecessary Code in stadt_t::step_passagiere()?
« Reply #5 on: April 22, 2009, 06:06:30 PM »
Should be changed indeed.