As i suggested this - Save Equipment - feature, i want to discuss about its implementation.
I've ispected the code which deploys the items, and i have some ideas.
I think the code of this feature should start in BattlescapeGenerator::run(), in line 344.
We have to copy the for-cycle in lines 346-349, and put the copy before that cycle.
Because we have to sweep the soldiers first with the layout restoration, and after that we fill in the holes with the for-cycle with the classic auto-equip.
We need a new BattlescapeGenerator::addItem(BattleItem *item). (for eg. with a name addItemWithLayout or we can make a new overload of the name addItem)
This new method sweeps the soldiers with a cycle and finds the first empty slot (which corresponds to the layout stored) for the item, and places it there.
I think we need to save the layout on a per-soldier basis.
Of course we need to save the primed-state of a grenade, and ammo-state of a weapon with the layout.
And of course we need to save the layout to the savegame, WITH backwards compatibility, i mean that this layout can be absent (per-soldier) in the savegame. (and in the memory when a game is loaded)
What i'm unsure right now, is how do we need to store the layout?
My ideas:
std::map<std::string, std::string>
std::map<RuleInventory, BattleItem>
std::map<BattleItem, RuleInventory>
Or maybe i could make a new class to store these relations?
Any ideas? Daiky? Or anyone?