Jump to content

Survival of the Fittest: no more enemy waves after loading a saved game


wasname321
 Share

Recommended Posts

On Survival of the Fittest, if you save the game and load it again, no more enemy waves come.

attackerUnitTemplates in maps/random/survivalofthefittest_triggers.js is a script global that only InitSurvival fills (on OnInitGame). Script globals aren't saved and OnInitGame doesn't run on load, so after a load the table is empty and the next wave fails with:

```
ERROR: Error in timer on entity 1, IID104, function DoAction: TypeError: can't access property "heroes", attackerUnitTemplates[civ] is undefined
```

After that no further waves spawn.

To reproduce:
1. Start Survival of the Fittest.
2. Save before the first wave and load the save.
3. Wait for the wave: the error above shows up and no attackers come.

A rejoin is not affected, because a rejoining client runs InitGame before it receives the state. I checked that with two peers.

Fix: reload the templates if the table is empty when a wave starts:

```
 Trigger.prototype.StartAnEnemyWave = function()
 {
+    if (!Object.keys(attackerUnitTemplates).length)
+        this.LoadAttackerTemplates();
```

With this, loaded games stay identical to the running game across the waves I tested.

Tested on main 47f5fb4f;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...