[Ruleset] Something like C preprocessor for override directory

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
Lachu
Elite
Posts: 472
Joined: Sat May 04, 2013 2:19 pm

[Ruleset] Something like C preprocessor for override directory

Post by Lachu »

It makes sense to use preprocessor construction in override ruleset directory, so player can incorporate with more ruleset than once. For example:

Code: Select all

#if ruleset_name("civ2civ3")
some code
#else
some other code
#endif
Other example:

Code: Select all

#if nation_exist("Polish")
[unittype_wing_husar]
some code
#endif
Instead of making preprocessor, you can add needed code to lua interpreter.
User avatar
dunnoob
Elite
Posts: 327
Joined: Mon Dec 23, 2013 3:13 am
Location: Hamburg
Contact:

Re: [Ruleset] Something like C preprocessor for override directory

Post by dunnoob »

Lachu wrote:

Code: Select all

#if ruleset_name("civ2civ3")
some code
#else
some other code
#endif
Yes, I also wished that something like your idea existed in ruleset files, but "rejected" it (=never put it on the wish list here or submitted it as feature request) as violation of the KISS principle: If it is important it can be implemented as requirement (for effects, etc.), with the else-part covered by present=FALSE. For our personal purposes we could roll our own .c-ruleset.i-ruleset: make file rules. :D
Lachu
Elite
Posts: 472
Joined: Sat May 04, 2013 2:19 pm

Re: [Ruleset] Something like C preprocessor for override directory

Post by Lachu »

So we can fork C preprocessor to make program to generate new rulest from many ruleset or implement lua api to generate ruleset before game starts.

In my opinion, second way is better, but if we decided to one, then I propose to make preprocesor layered. In some step preprocesor will handle file one and in next give result on this step to input of next step.

Layers could be nested in this way:
1, Freeciv original ruleset
2. Not important general changes/settings
3. Selected override directory definitions
4. Important general changes/settings
Post Reply