[General] Make it possible to check which placed objects have containers

pull/453/head
David Cernat 7 years ago
parent f20f94a886
commit 914b79fcc9

@ -178,6 +178,11 @@ int ObjectFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsig
.containerItems.at(itemIndex).actionCount;
}
bool ObjectFunctions::DoesObjectHaveContainer(unsigned int i) noexcept
{
return readObjectList->baseObjects.at(i).hasContainer;
}
void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept
{
writeObjectList.cell = Utils::getCellFromDescription(cellDescription);

@ -38,6 +38,8 @@
{"GetContainerItemEnchantmentCharge", ObjectFunctions::GetContainerItemEnchantmentCharge},\
{"GetContainerItemActionCount", ObjectFunctions::GetContainerItemActionCount},\
\
{"DoesObjectHaveContainer", ObjectFunctions::DoesObjectHaveContainer},\
\
{"SetObjectListCell", ObjectFunctions::SetObjectListCell},\
{"SetObjectListAction", ObjectFunctions::SetObjectListAction},\
{"SetObjectListConsoleCommand", ObjectFunctions::SetObjectListConsoleCommand},\
@ -360,6 +362,18 @@ public:
*/
static int GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Check whether the object at a certain index in the read object list's object
* changes has a container.
*
* Note: Only ObjectLists from ObjectPlace packets contain this information. Objects from
* received ObjectSpawn packets can always be assumed to have a container.
*
* \param i The index of the object.
* \return Whether the object has a container.
*/
static bool DoesObjectHaveContainer(unsigned int i) noexcept;
/**
* \brief Set the cell of the temporary object list stored on the server.
*

@ -809,6 +809,7 @@ void ObjectList::addObjectPlace(const MWWorld::Ptr& ptr, bool droppedByPlayer)
baseObject.charge = ptr.getCellRef().getCharge();
baseObject.enchantmentCharge = ptr.getCellRef().getEnchantmentCharge();
baseObject.droppedByPlayer = droppedByPlayer;
baseObject.hasContainer = ptr.getClass().hasContainerStore(ptr);
// Make sure we send the RefData position instead of the CellRef one, because that's what
// we actually see on this client

@ -60,6 +60,8 @@ namespace mwmp
Target master;
bool hasMaster;
bool hasContainer;
std::vector<ContainerItem> containerItems;
unsigned int containerItemCount;

@ -18,4 +18,5 @@ void PacketObjectPlace::Object(BaseObject &baseObject, bool send)
RW(baseObject.goldValue, send);
RW(baseObject.position, send);
RW(baseObject.droppedByPlayer, send);
RW(baseObject.hasContainer, send);
}

Loading…
Cancel
Save