kyranf / robotarmyfactorio

A mod to add robot troop units and perhaps associated support buildings and items to produce and control them.
MIT License
35 stars 12 forks source link

Unexpected crash while robots were waiting #127

Closed LaTrissTitude closed 6 years ago

LaTrissTitude commented 6 years ago

All my robots were waiting due to every biters being dead in a large perimeter, I was doing something totally unrelated (making modular rail system blueprints) when the map crashed and thrown me on the main menu.

Here is the error shown by the game log: 5431.487 Error MainLoop.cpp:1013: Exception at tick 3265447: Error while running event robotarmy::on_tick (ID 0) robotarmy/robolib/Squad.lua:658: attempt to perform arithmetic on field '?' (a nil value)

kyranf commented 6 years ago

Thanks for the report, I will attempt to fix that case. It looks like the value "squad.mostRecentUnitGroupRemovalTick[key]" was nil for this squad being processed, for whatever reason. I will add some extra value checking which should stop that from happening, but i'm not sure what would cause that situation and why it doesn't happen more often (this is the first time i've seen this issue, code has not changed for a long time now in that section)

kyranf commented 6 years ago

Have you had this issue again? Is there any way I can reproduce this better? I guess trying to make a map with no biters alive and have some squads sitting idle. I'll try to do this now.

georgehank commented 6 years ago

Got this twice today:

Error while running event robotarmy::on_tick (ID 0) robotarmy/robolib/Squad.lua:658: attempt to perform arithmetic on field '?' (a nil value)

Same map, so it's weird since I reloaded the auto-save and it then ran twenty minutes til crashing (auto-save interval the default five minutes). Something really weird going on.

Oh, and first time IIRC that I got this, never before (I think, but it's been a while since I last actually used the army, I only had the mod loaded).

kyranf commented 6 years ago

thanks, i'll be putting a guard around that line and trying to avoid it crashing the game at least - not sure what situations can actually cause this yet, but the first step to fixing this is to prevent full-on crashes/script errors for the users. If a squad has a logic break it's not the end of the world...

I'm closing this, because i'll do the code change right now!