[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; .containerItems.at(itemIndex).actionCount;
} }
bool ObjectFunctions::DoesObjectHaveContainer(unsigned int i) noexcept
{
return readObjectList->baseObjects.at(i).hasContainer;
}
void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept
{ {
writeObjectList.cell = Utils::getCellFromDescription(cellDescription); writeObjectList.cell = Utils::getCellFromDescription(cellDescription);

@ -38,6 +38,8 @@
{"GetContainerItemEnchantmentCharge", ObjectFunctions::GetContainerItemEnchantmentCharge},\ {"GetContainerItemEnchantmentCharge", ObjectFunctions::GetContainerItemEnchantmentCharge},\
{"GetContainerItemActionCount", ObjectFunctions::GetContainerItemActionCount},\ {"GetContainerItemActionCount", ObjectFunctions::GetContainerItemActionCount},\
\ \
{"DoesObjectHaveContainer", ObjectFunctions::DoesObjectHaveContainer},\
\
{"SetObjectListCell", ObjectFunctions::SetObjectListCell},\ {"SetObjectListCell", ObjectFunctions::SetObjectListCell},\
{"SetObjectListAction", ObjectFunctions::SetObjectListAction},\ {"SetObjectListAction", ObjectFunctions::SetObjectListAction},\
{"SetObjectListConsoleCommand", ObjectFunctions::SetObjectListConsoleCommand},\ {"SetObjectListConsoleCommand", ObjectFunctions::SetObjectListConsoleCommand},\
@ -360,6 +362,18 @@ public:
*/ */
static int GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept; 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. * \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.charge = ptr.getCellRef().getCharge();
baseObject.enchantmentCharge = ptr.getCellRef().getEnchantmentCharge(); baseObject.enchantmentCharge = ptr.getCellRef().getEnchantmentCharge();
baseObject.droppedByPlayer = droppedByPlayer; 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 // Make sure we send the RefData position instead of the CellRef one, because that's what
// we actually see on this client // we actually see on this client

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

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

Loading…
Cancel
Save