The International Simutrans Forum

 

Author Topic: Remove the Goods-Tab in powerplants that don't require goods  (Read 431 times)

0 Members and 1 Guest are viewing this topic.

Offline Leartin

  • Oh no, not him again!
  • Devotee
  • *
  • Posts: 1575
  • PAK-DEV P192C
  • Languages: DE, EN
Remove the Goods-Tab in powerplants that don't require goods
« on: December 15, 2020, 04:53:09 PM »
There are several powerplants in the game that don't require any goods to function - solar, wind, geothermic etc.
Currently, they all still show a goods-tab with an empty diagram. This patch removes the goods tab if there is neither an input nor an output, similar to how the details-tab is optional.

It does so by getting the input and output count a bit earlier and packing everything in an if clause for when either is larger zero.

I attached the patch more or less for completions sake - probably faster to just do it manually then to try and see what I changed (due to indentation, many lines were changed, while practically 5 lines were moved and an if-clause added)


Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: Remove the Goods-Tab in powerplants that don't require goods
« Reply #1 on: December 16, 2020, 05:03:27 AM »
Your patch is not even C++ but I get the idea. In in r9502

Offline Leartin

  • Oh no, not him again!
  • Devotee
  • *
  • Posts: 1575
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Remove the Goods-Tab in powerplants that don't require goods
« Reply #2 on: December 16, 2020, 09:12:06 AM »
Could you be more specific so I don't make the same mistake in the future?

Are you referring to the file itself (I thought a git diff is what's required) or is it the use of "or" instead of "||"? (It's part of the language, it should work with any compiler, but since it's not what C-programmers normally use, I can see it as a style problem)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: Remove the Goods-Tab in powerplants that don't require goods
« Reply #3 on: December 16, 2020, 12:15:04 PM »
or is neither a reserved keyword nor an existing operator in vanilla C++ Maybe boost defines or, but my compiler just gives the error message for undefined symbol.

Offline Leartin

  • Oh no, not him again!
  • Devotee
  • *
  • Posts: 1575
  • PAK-DEV P192C
  • Languages: DE, EN

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: Remove the Goods-Tab in powerplants that don't require goods
« Reply #5 on: December 16, 2020, 02:45:03 PM »
Ok, I did know about trigraph (or rather their lack of support in GCC), but this was new to me.

It seems, their usage is only safe when including the header file <iso646.h> resp. <ciso646>. Cxx++ Compilers do not need to natively support them, if I completely follow this, although I could not really find the statement when this xx actually changed. (Which makes sense, I even have written C programs where "or" stood for over_range (and "ur" for under_range), and I vaguely remember some numerical recipes code [which predates C95 of course].) So having these keywords optional is a good idea.