diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index 8124f1f28..3c938dca4 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -113,6 +113,11 @@ int ObjectFunctions::GetObjectLockLevel(unsigned int i) noexcept return readObjectList->baseObjects.at(i).lockLevel; } +bool ObjectFunctions::GetObjectSummonState(unsigned int i) noexcept +{ + return readObjectList->baseObjects.at(i).isSummon; +} + double ObjectFunctions::GetObjectSummonDuration(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).summonDuration; @@ -263,9 +268,9 @@ void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept tempObject.isDisarmed = disarmState; } -void ObjectFunctions::SetObjectMasterState(bool masterState) noexcept +void ObjectFunctions::SetObjectSummonState(bool summonState) noexcept { - tempObject.hasMaster = masterState; + tempObject.isSummon = summonState; } void ObjectFunctions::SetObjectPosition(double x, double y, double z) noexcept diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index d844fcce8..acc10cd0c 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -24,6 +24,7 @@ {"GetObjectState", ObjectFunctions::GetObjectState},\ {"GetObjectDoorState", ObjectFunctions::GetObjectDoorState},\ {"GetObjectLockLevel", ObjectFunctions::GetObjectLockLevel},\ + {"GetObjectSummonState", ObjectFunctions::GetObjectSummonState},\ {"GetObjectSummonDuration", ObjectFunctions::GetObjectSummonDuration},\ {"GetObjectPosX", ObjectFunctions::GetObjectPosX},\ {"GetObjectPosY", ObjectFunctions::GetObjectPosY},\ @@ -57,7 +58,7 @@ {"SetObjectLockLevel", ObjectFunctions::SetObjectLockLevel},\ {"SetObjectDisarmState", ObjectFunctions::SetObjectDisarmState},\ {"SetObjectSummonDuration", ObjectFunctions::SetObjectSummonDuration},\ - {"SetObjectMasterState", ObjectFunctions::SetObjectMasterState},\ + {"SetObjectSummonState", ObjectFunctions::SetObjectSummonState},\ {"SetObjectPosition", ObjectFunctions::SetObjectPosition},\ {"SetObjectRotation", ObjectFunctions::SetObjectRotation},\ \ @@ -252,6 +253,16 @@ public: */ static int GetObjectLockLevel(unsigned int i) noexcept; + /** + * \brief Check whether the object at a certain index in the read object list's object changes + * is a summon. + * + * Only living actors can have be summoned. + * + * \return The summon state. + */ + static bool GetObjectSummonState(unsigned int i) noexcept; + /** * \brief Get the summon duration of the object at a certain index in the read object list's object * changes. @@ -539,15 +550,15 @@ public: static void SetObjectDisarmState(bool disarmState) noexcept; /** - * \brief Set the master state of the temporary object stored on the server. + * \brief Set the summon state of the temporary object stored on the server. * - * This only affects living actors and determines whether they are followers of another + * This only affects living actors and determines whether they are summons of another * living actor. * - * \param masterState The master state. + * \param summonState The summon state. * \return void */ - static void SetObjectMasterState(bool masterState) noexcept; + static void SetObjectSummonState(bool summonState) noexcept; /** * \brief Set the position of the temporary object stored on the server. diff --git a/apps/openmw/mwmp/ObjectList.cpp b/apps/openmw/mwmp/ObjectList.cpp index ee7187870..84de022b4 100644 --- a/apps/openmw/mwmp/ObjectList.cpp +++ b/apps/openmw/mwmp/ObjectList.cpp @@ -338,7 +338,7 @@ void ObjectList::spawnObjects(MWWorld::CellStore* cellStore) newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, baseObject.position); - if (baseObject.hasMaster) + if (baseObject.isSummon) { MWWorld::Ptr masterPtr; @@ -839,8 +839,8 @@ void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr) baseObject.refId = ptr.getCellRef().getRefId(); baseObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; baseObject.mpNum = 0; + baseObject.isSummon = false; baseObject.summonDuration = -1; - baseObject.hasMaster = false; // Make sure we send the RefData position instead of the CellRef one, because that's what // we actually see on this client @@ -857,10 +857,9 @@ void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& mas baseObject.refId = ptr.getCellRef().getRefId(); baseObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; baseObject.mpNum = 0; + baseObject.isSummon = true; baseObject.summonDuration = duration; - baseObject.hasMaster = true; - if (master == MWBase::Environment::get().getWorld()->getPlayerPtr()) { baseObject.master.isPlayer = true; diff --git a/components/openmw-mp/Base/BaseObject.hpp b/components/openmw-mp/Base/BaseObject.hpp index c40a7f132..a10efe3ec 100644 --- a/components/openmw-mp/Base/BaseObject.hpp +++ b/components/openmw-mp/Base/BaseObject.hpp @@ -57,9 +57,9 @@ namespace mwmp bool isDisarmed; bool droppedByPlayer; + bool isSummon; float summonDuration; Target master; - bool hasMaster; bool hasContainer; diff --git a/components/openmw-mp/Packets/Object/PacketObjectSpawn.cpp b/components/openmw-mp/Packets/Object/PacketObjectSpawn.cpp index 8ce99788f..9073d2557 100644 --- a/components/openmw-mp/Packets/Object/PacketObjectSpawn.cpp +++ b/components/openmw-mp/Packets/Object/PacketObjectSpawn.cpp @@ -15,9 +15,9 @@ void PacketObjectSpawn::Object(BaseObject &baseObject, bool send) RW(baseObject.position, send); RW(baseObject.summonDuration, send); - RW(baseObject.hasMaster, send); + RW(baseObject.isSummon, send); - if (baseObject.hasMaster) + if (baseObject.isSummon) { RW(baseObject.master.isPlayer, send);