Ok, done.
But we have another bad iterator problem, adding timers in response to timers.
Not going to be hard to fix, just need to queue new timers rather than adding them straight away, then add any queued at the end of ScriptManager::onTimer().
If it's good and stable this will probably be in 0.2.13, yes.
My test rig:
<?xml version="1.0" standalone="yes" ?>
<scenario>
<difficulty value="2"/>
<players>
<player control="human" faction="tech" team="1"/>
<player control="closed" />
<player control="closed" />
<player control="closed" />
</players>
<map value="conflict"/>
<tileset value="dark_forest"/>
<tech-tree value="magitech"/>
<default-resources value="false"/>
<default-units value="false"/>
<default-victory-conditions value="false"/>
<scripts>
<startup>
setTimer ( 'stopSwords', 'real', 10, false )
setTimer ( 'swordman', 'real', 2, true )
setTimer ( 'machine', 'game', 40*5, true )
setTimer ( 'stopMachines', 'game', 40*20, false )
</startup>
<timer name="swordman">
createUnit ( "swordman", 0, startLocation(0) );
</timer>
<timer name="stopSwords">
stopTimer ( 'swordman' );
</timer>
<timer name="machine">
createUnit ( "battle_machine", 0, startLocation(0) );
</timer>
<timer name="stopMachines">
stopTimer ( 'machine' );
</timer>
</scripts>
</scenario>
If you move the calls to setTimer() for 'machine' and 'stopMahines' into the handler for 'stopSwords' you get the invalid iterator in ScriptManager::onTimer()