[General] Replace BaseObject's hasMaster variable with isSummon

Additionally, add a GetObjectSummonState() script function to the server.
0.6.3
David Cernat 7 years ago
parent 8ce225b1cc
commit bef53749ed

@ -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

@ -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.

@ -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;

@ -57,9 +57,9 @@ namespace mwmp
bool isDisarmed;
bool droppedByPlayer;
bool isSummon;
float summonDuration;
Target master;
bool hasMaster;
bool hasContainer;

@ -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);

Loading…
Cancel
Save