Currently a lot of unused macros are included when parsing certain script files.
These files should include any macros they need, without concern of what those files might also include.
An entry uses macros A_1 and B_1. It includes files A.macros and B.macros
A.macros has a couple of macros that use macro B_2, and should include B.macros
Other entries also use A_1 or B_1, but not always both.
For more concrete examples:
species.macros is a good example of macros that rely on each other.
Most of the tech entries are examples of loading a much larger list of macros for a single macro (TECH_COST_MULTIPLIER).
I've created a PR that initially does the following:
* Limit the #include statement to only include a file once.
* Replace any base path (a leading '/') with default/ (specifically, GetResourceDir() ).
* Allow a leading asterisk wildcard in the filename
I omitted adding a separate #include_once and limited the other options to keep from a need to parse the files multiple times.
If there is a method to have both #include and #include_once, without needing to pre-process, the logic escaped me.
The base path was redirected since absolute paths should never be used, and any traversal beyond default/ would potentially fail if the resource directory is changed.
The wildcard is probably the most controversial bit. I wanted to give a method for including a specific batch of files, but a separate directive leads me to need multiple passes.
Full wildcard support would add more complexity for what I felt would be seldom used. e.g. How many times would #include "asteroid??_small.txt" be needed, a sub-directory could just as easily be created for those files and use #include "asteroids/*_small.txt" if a batch inclusion was desired.
For what's not in 'Top Priority Game Design'. Post your ideas, visions, suggestions for the game, rules, modifications, etc.
1 post • Page 1 of 1