mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 07:32:00 -04:00
[Client] Only add valid inventory & equipment items to LocalPlayer
Also add related debug information.
This commit is contained in:
parent
c3d1eada89
commit
134dd06d48
@ -635,11 +635,18 @@ void LocalPlayer::addItems()
|
|||||||
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
||||||
|
|
||||||
for (const auto &item : inventoryChanges.items)
|
for (const auto &item : inventoryChanges.items)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer);
|
MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer);
|
||||||
if (item.charge != -1)
|
if (item.charge != -1)
|
||||||
itemPtr.getCellRef().setCharge(item.charge);
|
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()
|
void LocalPlayer::addSpells()
|
||||||
@ -651,6 +658,8 @@ void LocalPlayer::addSpells()
|
|||||||
// Only add spells that are ensured to exist
|
// Only add spells that are ensured to exist
|
||||||
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spell.mId))
|
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spell.mId))
|
||||||
ptrSpells.add(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()
|
void LocalPlayer::addJournalItems()
|
||||||
@ -891,12 +900,20 @@ void LocalPlayer::setEquipment()
|
|||||||
return Misc::StringUtils::ciEqual(a.getCellRef().getRefId(), currentItem.refId);
|
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];
|
auto equipped = equipedItems[slot];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
auto addIter = ptrInventory.ContainerStore::add(equipped.refId.c_str(), equipped.count, ptrPlayer);
|
auto addIter = ptrInventory.ContainerStore::add(equipped.refId.c_str(), equipped.count, ptrPlayer);
|
||||||
ptrInventory.equip(slot, addIter, 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
|
else
|
||||||
ptrInventory.equip(slot, it, ptrPlayer);
|
ptrInventory.equip(slot, it, ptrPlayer);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ namespace mwmp
|
|||||||
{
|
{
|
||||||
if (isLocal())
|
if (isLocal())
|
||||||
{
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_EQUIPMENT about LocalPlayer from server");
|
||||||
|
|
||||||
if (isRequest())
|
if (isRequest())
|
||||||
static_cast<LocalPlayer*>(player)->updateEquipment(true);
|
static_cast<LocalPlayer*>(player)->updateEquipment(true);
|
||||||
else
|
else
|
||||||
|
@ -21,6 +21,8 @@ namespace mwmp
|
|||||||
{
|
{
|
||||||
if (!isLocal()) return;
|
if (!isLocal()) return;
|
||||||
|
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_INVENTORY about LocalPlayer from server");
|
||||||
|
|
||||||
if (isRequest())
|
if (isRequest())
|
||||||
static_cast<LocalPlayer*>(player)->updateInventory(true);
|
static_cast<LocalPlayer*>(player)->updateInventory(true);
|
||||||
else
|
else
|
||||||
|
@ -22,6 +22,8 @@ namespace mwmp
|
|||||||
{
|
{
|
||||||
if (!isLocal()) return;
|
if (!isLocal()) return;
|
||||||
|
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_SPELLBOOK about LocalPlayer from server");
|
||||||
|
|
||||||
if (isRequest())
|
if (isRequest())
|
||||||
static_cast<LocalPlayer*>(player)->sendSpellbook();
|
static_cast<LocalPlayer*>(player)->sendSpellbook();
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user