The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: wlindley on December 23, 2012, 02:07:21 PM

Title: "Length" must be misspelled ("max_lenght" parameter)
Post by: wlindley on December 23, 2012, 02:07:21 PM
In file besch/writer/bridge_writer.cc, the parameter for the maximum length of a bridge is called max_lenght (sic).  Can we please accept the proper spelling of "max_length" ?  The variable is spelled correctly in the source, but the dat files must misspell it.

Like this, perhaps?

uint8  max_length    = obj.get_int("max_length",0) || obj.get_int("max_lenght",0); // max_length==0: unlimited


...although I forget if C's || operator works like Perl's... hmm
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: Ters on December 23, 2012, 04:15:42 PM
That won't work as I think you intend.
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: Combuijs on December 23, 2012, 04:23:55 PM
Quote from: Ters on December 23, 2012, 04:15:42 PM
That won't work as I think you intend.

;D Classic one, that...
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: Iluvalar on December 23, 2012, 05:13:09 PM
That's true
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: Fabio on December 23, 2012, 05:40:32 PM
Both should be accepted, with the wrong one deprecated but for compatibility.
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: wlindley on December 23, 2012, 05:58:53 PM
Quote from: Ters on December 23, 2012, 04:15:42 PM
That won't work as I think you intend.

That's why I still love Perl.  In C I believe you have to write it out pedantically, because C does not let values percolate through the boolean operators:

uint8  max_length    = obj.get_int("max_length",0); // max_length==0: unlimited
if (!max_length)  {
max_length = obj.get_int("max_lenght",0); // compatibility with old misspelling
}
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: Ters on December 23, 2012, 06:00:58 PM
I might have made a mistake. As long as the default value is 0, it probably will work. Performance-wise, the most used spelling should come first, but this isn't really performace critical.
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: prissi on December 23, 2012, 08:40:52 PM
There was already even an incorrect try to fix this in the code ...
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: Dwachs on December 28, 2012, 09:47:11 AM
What exactly is not working with max_length ?
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: wlindley on December 28, 2012, 03:34:41 PM
If you spell max_length correctly, it will be ignored as only the incorrect spelling is recognized.  Both should be accepted.
Title: Re: "Length" must be misspelled ("max_lenght" parameter)
Post by: Dwachs on December 28, 2012, 04:20:09 PM
Quote from: wlindley on December 28, 2012, 03:34:41 PM
If you spell max_length correctly, it will be ignored as only the incorrect spelling is recognized.  Both should be accepted.
which is not true, I checked it right now. Of course you should use a recent makeobj version (from 2009 or newer).

This is the current source code:

uint8  max_length    = obj.get_int("max_lenght",0); // max_lenght==0: unlimited
max_length    = obj.get_int("max_length",max_length); // with correct spelling