Maintenance Madness

by Arcitos

Adds a complete new game mechanic: Maintenance! Create a sophisticated spare parts logistics and bring your mall to its absolute limits! UPS-friendly and MP-tested - Now with a fancy GUI!

Tweaks
3 years ago
0.17 - 0.18
16

b failure when `mm-enable-low-tech-bonus` is enabled and forces are dynamically created

3 years ago

G'day. I've hit a bug in your code in a fairly non-standard state. I have the "Biter Factions" mod installed, as well as MM with mm-enable-low-tech-bonus turned on. I also have "QoL Research" installed, which shows up in the stack trace, but I'm not certain it is necessary.

"Biter Factions" creates five factions dynamically, to assign new spawners, etc, to. It creates those at the start of the control phase, using game.create_force, as you would expect.

With that installed I see a stack trace when starting a new game, touching on QoL Research (redoing internal bonus calculations for the force) and then MM handling on_research_completed for the force.

This hits the first if statement in the handler, and then fails trying to index nil in global.lowTechModifier[fi].techs[name] ~= nil

The global.lowTechModifier table is configured early, with whatever forces exist in the game at that time. Apparently Biter Factions creates their forces after that, so there is no entry for their five new forces in lowTechModifier.

I worked around it myself by adding an extra check for nil there, but it would be better to handle on_force_created and initialize the lowTechModifier table then.

Biter Factions + QoL Research triggers this failure when creating a new game, but I'm pretty certain from looking at your code that it'll fail the first time a research is completed if any forces were created after your mod initialized global. (or possibly the first time the new force completes a research. IDK.)

Regardless, it'd be nice to handle this cleanly. Once again, thank you for the mod, I'm very much enjoying the additional challenge and requirements. Most of the time, at least, but then, if it wasn't going to frustrate at least occasionally, it wouldn't be game changing, would it? ;)

New response