The International Simutrans Forum

 

Author Topic: "Length" must be misspelled ("max_lenght" parameter)  (Read 2471 times)

0 Members and 1 Guest are viewing this topic.

Offline wlindley

  • Devotee
  • *
  • Posts: 1064
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
"Length" must be misspelled ("max_lenght" parameter)
« 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?

Code: [Select]
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

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5691
  • Languages: EN, NO
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #1 on: December 23, 2012, 04:15:42 PM »
That won't work as I think you intend.

Offline Combuijs

  • Web Team
  • Devotee
  • *
  • Posts: 1406
  • Maintainer of maps.simutrans.com
    • Combuijs
  • Languages: EN, NL
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #2 on: December 23, 2012, 04:23:55 PM »
That won't work as I think you intend.

 ;D Classic one, that...

Offline Iluvalar

  • *
  • Posts: 136
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #3 on: December 23, 2012, 05:13:09 PM »
That's true

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #4 on: December 23, 2012, 05:40:32 PM »
Both should be accepted, with the wrong one deprecated but for compatibility.

Offline wlindley

  • Devotee
  • *
  • Posts: 1064
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #5 on: December 23, 2012, 05:58:53 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:

Code: [Select]
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
}

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5691
  • Languages: EN, NO
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #6 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10636
  • Languages: De,EN,JP
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #7 on: December 23, 2012, 08:40:52 PM »
There was already even an incorrect try to fix this in the code ...

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4869
  • Languages: EN, DE, AT
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #8 on: December 28, 2012, 09:47:11 AM »
What exactly is not working with max_length ?

Offline wlindley

  • Devotee
  • *
  • Posts: 1064
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #9 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4869
  • Languages: EN, DE, AT
Re: "Length" must be misspelled ("max_lenght" parameter)
« Reply #10 on: December 28, 2012, 04:20:09 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:
Code: [Select]
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