News: Portal
Our Simutrans site. You can find everything about Simutrans from here.

Unification of CamelCase and snake_case in datfiles

Started by Leartin, February 06, 2021, 05:56:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Writing the tutorial, it once again hits me how inconsistent Simutrans is in naming parameters. Most of the time, a parameter consisting of two words is just written as one word (eg. backimage) and since Simutrans doesn't care for case sensitivity in them, I usually see those written in CamelCase (eg. BackImage - each word starts with a capital letter). But there are some that use snake_case (eg. electricity_boost or has_snow, with underscores)

It's impossible by now to remove one of those two, as all kinds of dat-files would need to be rewritten. But I'm wondering if it might be beneficial if makeobj could just 'ignore' all underscores in parameters, just like it ignores uppercase letters (by turning them into lowercase), and we change all parameters with underscores to the same words without underscore internally. That is, make "has_snow" equal to "HasSnow" equal to "H_a_S_s_N_o_W", since makeobj would read them all just as "hassnow" anyway.

I know the benefit is minimal, but it just seems right to do it - a bit akin to translating German in the code. I only know how easy it would be to get makeobj to get rid of underscores and don't know how spread out the parameter definitions are in the code though.

Isaac Eiland-Hall

Not that it is the slightest bit important to the discussion at hand... but camelCase is different from PascalCase. :)


Except the very article you link pretty much says that both PascalCase and dromedaryCase are (C/c)amelCase and only some people restrict camelCase to lower letter. Camels have two humps after all (unless they are dromedarys). Makes me wonder if some nerd calls it BactrianCamelCase xD


Originally the pak64  text was backimage ... But ignoring underscores will require a new routine for string matching, which ignores underscores (and then replace all uses of the STRICMP in the writer routines, so it is not too big effort, just tedious.