Hey Yankes! Meridian and I have been trying to track down a bug with the auto-equip key, first reported in this thread:
https://openxcom.org/forum/index.php/topic,5047.msg77589.html#msg77589When pressing "Z" or whatever key auto-equip is bound to, the game Segfaults sometimes when trying to move or interact with an item that was moved by the auto-equip function. I've tested this in a clean Ubuntu build of your OpenXcomExtended branch, no mods loaded. This seems to be an issue with how the items are moved between classes when auto-equipping, and I think it has to do with the 'dummy' SavedBattleGame you use when calling this function (
https://github.com/Yankes/OpenXcom/blob/OpenXcomExtended/src/Battlescape/InventoryState.cpp#L821). I was able to prevent the CTD by changing 'dummy' on this line to '_battleGame,' but this causes issues later when the SavedBattleGame is cleaned up. My guess is that when the dummy SavedBattleGame is removed at the end of InventoryState::onAutoequip, this re-allocates the memory for the pointers to the BattleItems (dummy's _items list is deleted), and so the pointer to the item may or may not be available after this function call.
To replicate:
- Delete options.cfg and battle.cfg
- Run game and load quick battle
- Click 'OK' to bring up the briefing, then inventory screen
- Press 'X' to clear the current soldier's inventory, then 'Z' to autoequip
- Either trying another action (clicking or key press), or even waiting for a few seconds, causes Segfault for me
The above does not work in all cases though - Meridian hasn't been able to reproduce the bug this way, and some other Windows users have been able to use it just fine, but I get CTD on Linux every time I try using auto-equip. Would you mind testing this?
Edit: As a matter of curiosity, what was the reasoning behind moving addItem from BattlescapeGenerator to SavedBattleGame during the merge with the nightly to include this feature?