Removing an invocation of `pickRandom` doesn't invalidate another. (Worst case is that in DE the AI might not be serializeable.)
I tried to bisect it but wasn't successful there are always like 10 units idle.
To fix the issue, the map has to somehow expose the restrictions. Those restrictions could then also be read by the random selection algorithm.
At least that's how I think of it.
Oh, so you choose random as placement - I understand now.
I think it would be a hard to delay the random selection to the mapgen script. One would also have to change replay-summary: there it shouldn't be displayed as "random".
The more complete solution is the one stated in the ticket.
I don't know of a remaining issue of persistent map settings. Also the name of a game should be causally unrelated to the placement.
I know #8148 which is related especially this link.
You need to import the functions you are using something like
import { addAnimals, addBerries, addBluffs, addDecoration, addForests, addHills, addLayeredPatches,
addMetal, addStone, addStragglerTrees, createBluffsPassages, markPlayerAvoidanceArea } from
"maps/random/rmgen2/gaia.js";
I added a section in https://gitea.wildfiregames.com/0ad/0ad/wiki/PortA27ToR28 which links to https://gitea.wildfiregames.com/0ad/0ad/wiki/ModdingGuiAndSimulation.
The "append" keyword has to be used where modules are used. It's tracked here. Note: Modules are enabled in the GUI doesn't mean that in the whole GUI modules are used (IIRC in R28 only in pregame and splashscreen). I wouldn't make .append the default. It serves as distinction between appendixes and plain files.
@GrapjasYes that's the (my) desired way of doing it. And it's weird that it doesn't work. (I tested appending multiple files. I think it's something about the content of the files. The next line is appended without a newline. Maybe the implicit semicolon doesn't work at the end of a file.)
When the file would get to big you could also import some variables:
import { menuEntry } from "gui/pregame/grapjasAdditions.js";
mainMenuItems.unshift(menuEntry);