The International Simutrans Forum

 

Author Topic: Redundant code or possible error in simcity.cc  (Read 1374 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Redundant code or possible error in simcity.cc
« on: December 17, 2017, 01:55:11 PM »
Running a static analysis on Simutrans-Extended has revealed an error which also appears to be in Simutrans-Standard.

Line 2938 of simcity.cc is:

Code: [Select]
if (h == NULL  &&  sum_industrial > sum_residential  &&  sum_industrial > sum_residential) {

This simply repeats sum_industrial > sum_residential. Presumably, this was not intended, but it is not clear what was intended here.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4593
  • Languages: EN, DE, AT
Re: Redundant code or possible error in simcity.cc
« Reply #1 on: December 17, 2017, 10:13:18 PM »
Looks like the second check should be
Code: [Select]
sum_industrial > sum_commercial
thanks for spotting

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Redundant code or possible error in simcity.cc
« Reply #2 on: December 17, 2017, 10:23:14 PM »
Splendid, thank you. Now incorporated in Extended.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4593
  • Languages: EN, DE, AT
Re: Redundant code or possible error in simcity.cc
« Reply #3 on: December 19, 2017, 06:29:08 PM »
in r8355