The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Leartin on December 15, 2020, 04:53:09 PM

Title: Remove the Goods-Tab in powerplants that don't require goods
Post by: Leartin 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)

Title: Re: Remove the Goods-Tab in powerplants that don't require goods
Post by: prissi on December 16, 2020, 05:03:27 AM
Your patch is not even C++ but I get the idea. In in r9502
Title: Re: Remove the Goods-Tab in powerplants that don't require goods
Post by: Leartin 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)
Title: Re: Remove the Goods-Tab in powerplants that don't require goods
Post by: prissi 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.
Title: Re: Remove the Goods-Tab in powerplants that don't require goods
Post by: Leartin on December 16, 2020, 02:14:44 PM
Well...
https://www.includehelp.com/cpp-tutorial/alternative-tokens.aspx
https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#C++_operator_synonyms
https://stackoverflow.com/questions/2376448/the-written-versions-of-the-logical-operators

Also, is your compiler msvc?

https://stackoverflow.com/questions/24414124/why-does-vs-not-define-the-alternative-tokens-for-logical-operators

Sure, if Visual Studio can't deal with them and experienced programmers like yourself don't know they exist, it's bad style to use them. Won't do it anymore.
Title: Re: Remove the Goods-Tab in powerplants that don't require goods
Post by: prissi 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.