Situation
When an air unit is to be spawned by veafSpawn.findSpawnableAircraftGroupname looks for a group matching an input name in a pre-established list of templates. These templates are all the groups of the mission with a name starting with veafSpawn-.


Among these groups, will be preselected those that regex match either:
- A regex built around the input name
".*" .. (nameUpper or ".*") .. ".*", so all the groups with a name that contain the input name. In this case, it is expected of the caller to give an input name that is a usable regex.
- Exactly the input name, after it has been cleaned of potential regex characters by
veaf.escapeRegex.
Problems
veafSpawn- prefix is too limitative
veafSpawn is used:
- With predetermined group templates, which will be hard coded in specific commands (
-afac and -cap).
- From a user trigger in a unit of the ME or directly from a marker in-game.
In the first case, since the names as hard coded, no need for a filter. On exception may be when the input name is empty (-cap), in that case the filter could be kept.
In the second one, the filter is actually a bad thing because the end-used, mission maker or player, must be aware of this mechanic to be able to efficiently use veafSpawn. We can also note that the veafSpawnableAircraftsEditor tool will override all veafSpawn- groups when the mission is built (build.cmd), complicated again the usage.
So, there is no need to limit the groups eligible. All groups should be considered.
Name matching is not great
Regex cleanup is not great. The double matching seems sketchy.
There is no need for a full regex matching. A simple "starts with matching" is sufficient and way clearer.
An exact matching would also be better in some cases, but maybe it is too complicated to implement both modes. Unless, maybe with something in the content of the input name, like "name*" would match starting with "name"?
Remediation
What I want to do is rethink veafSpawn.findSpawnableAircraftGroupname.
All regex mechanic will be removed.
The name parameter will be optional.
When name is provided
The method will try to find a group matching name among all groups in the mission.
If the name parameter ends with a "*", all groups with a name that matches or starts with the parameter value will be eligible.
If the name parameter DOES NOT end with a "*", only the groups with a name matching exactly the parameter value will be eligible (so, only one group).
When name is NOT provided
The method will select a group among the groups with a name starting with the veafSpawn- prefix.
Usage
Check all usages of the method.
-cap should not provide name
-afac should give a correct value ending with "*" (this will have to be sync with veafSpawnableAircraftsEditor as well, see below)
Additional remarks
Specifically for the -afac.
veafSpawnableAircraftsEditor needs to have its contents clarified.
- In the current MC
settings.lua does not contain ant Reaper group.
- In older
settings.lua in the MC it contains Reapers with names like "veafSpawn-mq9-hellfire".
- In the MCT there is some with names like "veafSpawn-MQ-9 - AFAC - JTAC - DRONE".
Which one is used? What should be the correct content?
Another issue should be opened to study these problems.
Situation
When an air unit is to be spawned by


veafSpawn.findSpawnableAircraftGroupnamelooks for a group matching an input name in a pre-established list of templates. These templates are all the groups of the mission with a name starting withveafSpawn-.Among these groups, will be preselected those that regex match either:
".*" .. (nameUpper or ".*") .. ".*", so all the groups with a name that contain the input name. In this case, it is expected of the caller to give an input name that is a usable regex.veaf.escapeRegex.Problems
veafSpawn- prefix is too limitative
veafSpawn is used:
-afacand-cap).In the first case, since the names as hard coded, no need for a filter. On exception may be when the input name is empty (
-cap), in that case the filter could be kept.In the second one, the filter is actually a bad thing because the end-used, mission maker or player, must be aware of this mechanic to be able to efficiently use veafSpawn. We can also note that the veafSpawnableAircraftsEditor tool will override all
veafSpawn-groups when the mission is built (build.cmd), complicated again the usage.So, there is no need to limit the groups eligible. All groups should be considered.
Name matching is not great
Regex cleanup is not great. The double matching seems sketchy.
There is no need for a full regex matching. A simple "starts with matching" is sufficient and way clearer.
An exact matching would also be better in some cases, but maybe it is too complicated to implement both modes. Unless, maybe with something in the content of the input name, like "name*" would match starting with "name"?
Remediation
What I want to do is rethink
veafSpawn.findSpawnableAircraftGroupname.All regex mechanic will be removed.
The name parameter will be optional.
When
nameis providedThe method will try to find a group matching name among all groups in the mission.
If the
nameparameter ends with a "*", all groups with a name that matches or starts with the parameter value will be eligible.If the
nameparameter DOES NOT end with a "*", only the groups with a name matching exactly the parameter value will be eligible (so, only one group).When
nameis NOT providedThe method will select a group among the groups with a name starting with the
veafSpawn-prefix.Usage
Check all usages of the method.
-capshould not providename-afacshould give a correct value ending with "*" (this will have to be sync with veafSpawnableAircraftsEditor as well, see below)Additional remarks
Specifically for the
-afac.veafSpawnableAircraftsEditor needs to have its contents clarified.
settings.luadoes not contain ant Reaper group.settings.luain the MC it contains Reapers with names like "veafSpawn-mq9-hellfire".Which one is used? What should be the correct content?
Another issue should be opened to study these problems.