|
|
|
@ -638,11 +638,18 @@ void LocalPlayer::addItems()
|
|
|
|
|
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
|
|
|
|
|
|
|
|
|
for (const auto &item : inventoryChanges.items)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer);
|
|
|
|
|
if (item.charge != -1)
|
|
|
|
|
itemPtr.getCellRef().setCharge(item.charge);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception&)
|
|
|
|
|
{
|
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "- Ignored addition of invalid inventory item %s", item.refId.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocalPlayer::addSpells()
|
|
|
|
@ -651,34 +658,39 @@ void LocalPlayer::addSpells()
|
|
|
|
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
|
|
|
|
|
|
|
|
|
for (const auto &spell : spellbookChanges.spells)
|
|
|
|
|
{
|
|
|
|
|
if(spell.mId.find("$dynamic") != string::npos)
|
|
|
|
|
{
|
|
|
|
|
//custom spell
|
|
|
|
|
MWBase::Environment::get().getWorld()->createRecord(spell);
|
|
|
|
|
ptrSpells.add(&spell);
|
|
|
|
|
}else{
|
|
|
|
|
// Only add spells that are ensured to exist
|
|
|
|
|
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spell.mId))
|
|
|
|
|
ptrSpells.add(spell.mId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "- Ignored addition of invalid spell %s", spell.mId.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocalPlayer::addJournalItems()
|
|
|
|
|
{
|
|
|
|
|
for (const auto &journalItem : journalChanges.journalItems)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptrFound;
|
|
|
|
|
|
|
|
|
|
if (journalItem.type == JournalItem::ENTRY)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptrFound = MWBase::Environment::get().getWorld()->searchPtr(journalItem.actorRefId, false);
|
|
|
|
|
ptrFound = MWBase::Environment::get().getWorld()->searchPtr(journalItem.actorRefId, false);
|
|
|
|
|
|
|
|
|
|
if (!ptrFound)
|
|
|
|
|
ptrFound = getPlayerPtr();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (journalItem.type == JournalItem::ENTRY)
|
|
|
|
|
MWBase::Environment::get().getJournal()->addEntry(journalItem.quest, journalItem.index, ptrFound);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
MWBase::Environment::get().getJournal()->setJournalIndex(journalItem.quest, journalItem.index);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception&)
|
|
|
|
|
{
|
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "- Ignored addition of invalid journal quest %s", journalItem.quest.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocalPlayer::addTopics()
|
|
|
|
@ -903,12 +915,20 @@ void LocalPlayer::setEquipment()
|
|
|
|
|
return Misc::StringUtils::ciEqual(a.getCellRef().getRefId(), currentItem.refId);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (it == ptrInventory.end()) // if not exists add item
|
|
|
|
|
if (it == ptrInventory.end()) // If the item is not in our inventory, add it
|
|
|
|
|
{
|
|
|
|
|
auto equipped = equipedItems[slot];
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
auto addIter = ptrInventory.ContainerStore::add(equipped.refId.c_str(), equipped.count, ptrPlayer);
|
|
|
|
|
ptrInventory.equip(slot, addIter, ptrPlayer);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception&)
|
|
|
|
|
{
|
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "- Ignored addition of invalid equipment item %s", equipped.refId.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ptrInventory.equip(slot, it, ptrPlayer);
|
|
|
|
|
}
|
|
|
|
|