forked from teamnwah/openmw-tes3coop
[Client] Send level creatures in ObjectPlace reply to ActorList request
This commit is contained in:
parent
9eef867928
commit
bdc8b7f863
5 changed files with 46 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwmechanics/combat.hpp"
|
#include "../mwmechanics/combat.hpp"
|
||||||
|
#include "../mwmechanics/levelledlist.hpp"
|
||||||
#include "../mwmechanics/spellcasting.hpp"
|
#include "../mwmechanics/spellcasting.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
@ -14,9 +15,11 @@
|
||||||
|
|
||||||
#include "MechanicsHelper.hpp"
|
#include "MechanicsHelper.hpp"
|
||||||
#include "Main.hpp"
|
#include "Main.hpp"
|
||||||
|
#include "Networking.hpp"
|
||||||
#include "LocalPlayer.hpp"
|
#include "LocalPlayer.hpp"
|
||||||
#include "DedicatedPlayer.hpp"
|
#include "DedicatedPlayer.hpp"
|
||||||
#include "PlayerList.hpp"
|
#include "PlayerList.hpp"
|
||||||
|
#include "WorldEvent.hpp"
|
||||||
#include "CellController.hpp"
|
#include "CellController.hpp"
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
@ -38,6 +41,34 @@ osg::Vec3f MechanicsHelper::getLinearInterpolation(osg::Vec3f start, osg::Vec3f
|
||||||
return (start + osg::componentMultiply(position, (end - start)));
|
return (start + osg::componentMultiply(position, (end - start)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inspired by similar code in mwclass\creaturelevlist.cpp
|
||||||
|
void MechanicsHelper::spawnLeveledCreatures(MWWorld::CellStore* cellStore)
|
||||||
|
{
|
||||||
|
MWWorld::CellRefList<ESM::CreatureLevList> *creatureLevList = cellStore->getCreatureLists();
|
||||||
|
|
||||||
|
for (typename MWWorld::CellRefList<ESM::CreatureLevList>::List::iterator listIter(creatureLevList->mList.begin());
|
||||||
|
listIter != creatureLevList->mList.end(); ++listIter)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr(&*listIter, cellStore);
|
||||||
|
|
||||||
|
MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = ptr.get<ESM::CreatureLevList>();
|
||||||
|
|
||||||
|
std::string id = MWMechanics::getLevelledItem(ref->mBase, true);
|
||||||
|
|
||||||
|
if (!id.empty())
|
||||||
|
{
|
||||||
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
MWWorld::ManualRef manualRef(store, id);
|
||||||
|
manualRef.getPtr().getCellRef().setPosition(ptr.getCellRef().getPosition());
|
||||||
|
MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->placeObject(manualRef.getPtr(), ptr.getCell(), ptr.getCellRef().getPosition());
|
||||||
|
|
||||||
|
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||||
|
worldEvent->sendObjectPlace(placed);
|
||||||
|
MWBase::Environment::get().getWorld()->deleteObject(placed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Attack *MechanicsHelper::getLocalAttack(const MWWorld::Ptr& ptr)
|
Attack *MechanicsHelper::getLocalAttack(const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace mwmp
|
||||||
|
|
||||||
osg::Vec3f getLinearInterpolation(osg::Vec3f start, osg::Vec3f end, float percent);
|
osg::Vec3f getLinearInterpolation(osg::Vec3f start, osg::Vec3f end, float percent);
|
||||||
|
|
||||||
|
void spawnLeveledCreatures(MWWorld::CellStore* cellStore);
|
||||||
|
|
||||||
Attack *getLocalAttack(const MWWorld::Ptr& ptr);
|
Attack *getLocalAttack(const MWWorld::Ptr& ptr);
|
||||||
Attack *getDedicatedAttack(const MWWorld::Ptr& ptr);
|
Attack *getDedicatedAttack(const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "apps/openmw/mwmp/ActorProcessor.hpp"
|
#include "apps/openmw/mwmp/ActorProcessor.hpp"
|
||||||
#include "apps/openmw/mwmp/Main.hpp"
|
#include "apps/openmw/mwmp/Main.hpp"
|
||||||
#include "apps/openmw/mwmp/CellController.hpp"
|
#include "apps/openmw/mwmp/CellController.hpp"
|
||||||
|
#include "apps/openmw/mwmp/MechanicsHelper.hpp"
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
|
@ -30,7 +31,10 @@ namespace mwmp
|
||||||
|
|
||||||
// If we've received a request for information, comply with it
|
// If we've received a request for information, comply with it
|
||||||
if (actorList.action == mwmp::BaseActorList::REQUEST)
|
if (actorList.action == mwmp::BaseActorList::REQUEST)
|
||||||
|
{
|
||||||
|
mwmp::Main::get().getMechanicsHelper()->spawnLeveledCreatures(ptrCellStore);
|
||||||
actorList.sendActorsInCell(ptrCellStore);
|
actorList.sendActorsInCell(ptrCellStore);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,6 +526,12 @@ namespace MWWorld
|
||||||
return &mCreatures;
|
return &mCreatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Added by tes3mp and used to get all the creatures in the cell
|
||||||
|
CellRefList<ESM::CreatureLevList> *CellStore::getCreatureLists()
|
||||||
|
{
|
||||||
|
return &mCreatureLists;
|
||||||
|
}
|
||||||
|
|
||||||
// Added by tes3mp and used to get all the containers in the cell
|
// Added by tes3mp and used to get all the containers in the cell
|
||||||
CellRefList<ESM::Container> *CellStore::getContainers()
|
CellRefList<ESM::Container> *CellStore::getContainers()
|
||||||
{
|
{
|
||||||
|
|
|
@ -243,6 +243,9 @@ namespace MWWorld
|
||||||
CellRefList<ESM::Creature> *getCreatures();
|
CellRefList<ESM::Creature> *getCreatures();
|
||||||
// Added by tes3mp and used to get all the creatures in the cell
|
// Added by tes3mp and used to get all the creatures in the cell
|
||||||
|
|
||||||
|
CellRefList<ESM::CreatureLevList> *getCreatureLists();
|
||||||
|
// Added by tes3mp and used to get all the leveled creature lists in the cell
|
||||||
|
|
||||||
CellRefList<ESM::Container> *getContainers();
|
CellRefList<ESM::Container> *getContainers();
|
||||||
// Added by tes3mp and used to get all the containers in the cell
|
// Added by tes3mp and used to get all the containers in the cell
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue