2015-01-19 11:22:51 +00:00
|
|
|
#include "convertinventory.hpp"
|
|
|
|
|
2022-08-02 22:00:54 +00:00
|
|
|
#include <components/misc/strings/lower.hpp>
|
|
|
|
|
2016-01-25 13:13:16 +00:00
|
|
|
#include <cstdlib>
|
2015-01-19 11:22:51 +00:00
|
|
|
|
|
|
|
namespace ESSImport
|
|
|
|
{
|
|
|
|
|
|
|
|
void convertInventory(const Inventory& inventory, ESM::InventoryState& state)
|
|
|
|
{
|
2023-10-24 15:51:12 +00:00
|
|
|
uint32_t index = 0;
|
2020-06-10 06:30:37 +00:00
|
|
|
for (const auto& item : inventory.mItems)
|
2015-01-19 11:22:51 +00:00
|
|
|
{
|
|
|
|
ESM::ObjectState objstate;
|
|
|
|
objstate.blank();
|
2020-06-10 06:30:37 +00:00
|
|
|
objstate.mRef = item;
|
2022-10-06 17:39:46 +00:00
|
|
|
objstate.mRef.mRefID = ESM::RefId::stringRefId(item.mId);
|
2023-12-31 17:12:46 +00:00
|
|
|
objstate.mRef.mCount = item.mCount;
|
2015-01-23 15:45:47 +00:00
|
|
|
state.mItems.push_back(objstate);
|
2020-06-10 06:30:37 +00:00
|
|
|
if (item.mRelativeEquipmentSlot != -1)
|
2015-01-23 15:45:47 +00:00
|
|
|
// Note we should really write the absolute slot here, which we do not know about
|
|
|
|
// Not a big deal, OpenMW will auto-correct to a valid slot, the only problem is when
|
|
|
|
// an item could be equipped in two different slots (e.g. equipped two rings)
|
2020-06-10 06:30:37 +00:00
|
|
|
state.mEquipmentSlots[index] = item.mRelativeEquipmentSlot;
|
2015-01-23 15:45:47 +00:00
|
|
|
++index;
|
2015-01-19 11:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|