News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

"Length" must be misspelled ("max_lenght" parameter)

Started by wlindley, December 23, 2012, 02:07:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wlindley

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

Ters


Combuijs

Bob Marley: No woman, no cry

Programmer: No user, no bugs




Fabio

Both should be accepted, with the wrong one deprecated but for compatibility.

wlindley

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
}

Ters

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.

prissi

There was already even an incorrect try to fix this in the code ...

Dwachs

Parsley, sage, rosemary, and maggikraut.

wlindley

If you spell max_length correctly, it will be ignored as only the incorrect spelling is recognized.  Both should be accepted.

Dwachs

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
Parsley, sage, rosemary, and maggikraut.