mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
[General] Send summon duration to server in ObjectSpawn packets
This commit is contained in:
parent
9102df7fde
commit
958b220835
9 changed files with 72 additions and 3 deletions
|
@ -113,6 +113,11 @@ int ObjectFunctions::GetObjectLockLevel(unsigned int i) noexcept
|
|||
return readObjectList->baseObjects.at(i).lockLevel;
|
||||
}
|
||||
|
||||
double ObjectFunctions::GetObjectSummonDuration(unsigned int i) noexcept
|
||||
{
|
||||
return readObjectList->baseObjects.at(i).summonDuration;
|
||||
}
|
||||
|
||||
double ObjectFunctions::GetObjectPosX(unsigned int i) noexcept
|
||||
{
|
||||
return readObjectList->baseObjects.at(i).position.pos[0];
|
||||
|
@ -248,6 +253,11 @@ void ObjectFunctions::SetObjectLockLevel(int lockLevel) noexcept
|
|||
tempObject.lockLevel = lockLevel;
|
||||
}
|
||||
|
||||
void ObjectFunctions::SetObjectSummonDuration(float summonDuration) noexcept
|
||||
{
|
||||
tempObject.summonDuration = summonDuration;
|
||||
}
|
||||
|
||||
void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept
|
||||
{
|
||||
tempObject.isDisarmed = disarmState;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
{"GetObjectState", ObjectFunctions::GetObjectState},\
|
||||
{"GetObjectDoorState", ObjectFunctions::GetObjectDoorState},\
|
||||
{"GetObjectLockLevel", ObjectFunctions::GetObjectLockLevel},\
|
||||
{"GetObjectSummonDuration", ObjectFunctions::GetObjectSummonDuration},\
|
||||
{"GetObjectPosX", ObjectFunctions::GetObjectPosX},\
|
||||
{"GetObjectPosY", ObjectFunctions::GetObjectPosY},\
|
||||
{"GetObjectPosZ", ObjectFunctions::GetObjectPosZ},\
|
||||
|
@ -55,6 +56,7 @@
|
|||
{"SetObjectState", ObjectFunctions::SetObjectState},\
|
||||
{"SetObjectLockLevel", ObjectFunctions::SetObjectLockLevel},\
|
||||
{"SetObjectDisarmState", ObjectFunctions::SetObjectDisarmState},\
|
||||
{"SetObjectSummonDuration", ObjectFunctions::SetObjectSummonDuration},\
|
||||
{"SetObjectMasterState", ObjectFunctions::SetObjectMasterState},\
|
||||
{"SetObjectPosition", ObjectFunctions::SetObjectPosition},\
|
||||
{"SetObjectRotation", ObjectFunctions::SetObjectRotation},\
|
||||
|
@ -250,6 +252,17 @@ public:
|
|||
*/
|
||||
static int GetObjectLockLevel(unsigned int i) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the summon duration of the object at a certain index in the read object list's object
|
||||
* changes.
|
||||
*
|
||||
* Note: Returns -1 if indefinite.
|
||||
*
|
||||
* \param i The index of the object.
|
||||
* \return The summon duration.
|
||||
*/
|
||||
static double GetObjectSummonDuration(unsigned int i) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the X position of the object at a certain index in the read object list's object
|
||||
* changes.
|
||||
|
@ -509,6 +522,14 @@ public:
|
|||
*/
|
||||
static void SetObjectLockLevel(int lockLevel) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the summon duration of the temporary object stored on the server.
|
||||
*
|
||||
* \param summonDuration The summon duration.
|
||||
* \return void
|
||||
*/
|
||||
static void SetObjectSummonDuration(float summonDuration) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the disarm state of the temporary object stored on the server.
|
||||
*
|
||||
|
|
|
@ -319,6 +319,26 @@ namespace MWMechanics
|
|||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it easy to get an effect's duration
|
||||
*/
|
||||
float ActiveSpells::getEffectDuration(short effectId)
|
||||
{
|
||||
for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); ++it)
|
||||
{
|
||||
for (std::vector<ActiveEffect>::iterator effectIt = it->second.mEffects.begin();
|
||||
effectIt != it->second.mEffects.end();)
|
||||
{
|
||||
return effectIt->mDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
void ActiveSpells::clear()
|
||||
{
|
||||
mSpells.clear();
|
||||
|
|
|
@ -104,6 +104,16 @@ namespace MWMechanics
|
|||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it easy to get an effect's duration
|
||||
*/
|
||||
float getEffectDuration(short effectId);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/// Remove all spells
|
||||
void clear();
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
Include additional headers for multiplayer purposes
|
||||
*/
|
||||
#include <components/openmw-mp/Log.hpp>
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmp/Main.hpp"
|
||||
#include "../mwmp/Networking.hpp"
|
||||
#include "../mwmp/CellController.hpp"
|
||||
|
@ -107,7 +108,10 @@ namespace MWMechanics
|
|||
{
|
||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||
objectList->reset();
|
||||
objectList->addObjectSpawn(placed, mActor);
|
||||
|
||||
MWMechanics::CreatureStats *actorCreatureStats = &mActor.getClass().getCreatureStats(mActor);
|
||||
|
||||
objectList->addObjectSpawn(placed, mActor, actorCreatureStats->getActiveSpells().getEffectDuration(it->first));
|
||||
objectList->sendObjectSpawn();
|
||||
}
|
||||
|
||||
|
|
|
@ -839,6 +839,7 @@ void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr)
|
|||
baseObject.refId = ptr.getCellRef().getRefId();
|
||||
baseObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
baseObject.mpNum = 0;
|
||||
baseObject.summonDuration = -1;
|
||||
baseObject.hasMaster = false;
|
||||
|
||||
// Make sure we send the RefData position instead of the CellRef one, because that's what
|
||||
|
@ -848,7 +849,7 @@ void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr)
|
|||
addObject(baseObject);
|
||||
}
|
||||
|
||||
void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master)
|
||||
void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, float duration)
|
||||
{
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
|
@ -856,6 +857,7 @@ 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.summonDuration = duration;
|
||||
|
||||
baseObject.hasMaster = true;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace mwmp
|
|||
|
||||
void addObjectPlace(const MWWorld::Ptr& ptr, bool droppedByPlayer = false);
|
||||
void addObjectSpawn(const MWWorld::Ptr& ptr);
|
||||
void addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master);
|
||||
void addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, float spawnDuration);
|
||||
void addObjectDelete(const MWWorld::Ptr& ptr);
|
||||
void addObjectLock(const MWWorld::Ptr& ptr, int lockLevel);
|
||||
void addObjectTrap(const MWWorld::Ptr& ptr, const ESM::Position& pos, bool isDisarmed);
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace mwmp
|
|||
bool isDisarmed;
|
||||
bool droppedByPlayer;
|
||||
|
||||
float summonDuration;
|
||||
Target master;
|
||||
bool hasMaster;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ void PacketObjectSpawn::Object(BaseObject &baseObject, bool send)
|
|||
{
|
||||
ObjectPacket::Object(baseObject, send);
|
||||
RW(baseObject.position, send);
|
||||
RW(baseObject.summonDuration, send);
|
||||
|
||||
RW(baseObject.hasMaster, send);
|
||||
|
||||
|
|
Loading…
Reference in a new issue