1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 08:49:55 +00:00
openmw-tes3mp/apps/openmw/mwworld/actiontake.cpp

51 lines
1.9 KiB
C++
Raw Normal View History

2010-08-07 18:25:17 +00:00
#include "actiontake.hpp"
#include <components/openmw-mp/Log.hpp>
#include "../mwmp/Main.hpp"
2016-12-16 08:59:15 +00:00
#include "../mwmp/Networking.hpp"
#include "../mwmp/WorldEvent.hpp"
2016-12-16 08:59:15 +00:00
#include "../mwmp/LocalPlayer.hpp"
2016-10-23 10:30:32 +00:00
#include "../mwworld/cellstore.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
2014-01-07 18:49:16 +00:00
#include "../mwbase/mechanicsmanager.hpp"
2010-08-07 18:25:17 +00:00
#include "class.hpp"
#include "containerstore.hpp"
2010-08-07 18:25:17 +00:00
namespace MWWorld
{
2012-09-04 18:56:28 +00:00
ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {}
2010-08-07 18:25:17 +00:00
void ActionTake::executeImp (const Ptr& actor)
2010-08-07 18:25:17 +00:00
{
2014-01-07 18:49:16 +00:00
MWBase::Environment::get().getMechanicsManager()->itemTaken(
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
// Added by tes3mp
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *getTarget().getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = getTarget().getCellRef().getRefId();
worldObject.refNumIndex = getTarget().getCellRef().getRefNum().mIndex;
worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_DELETE about\n- cellRef: %s, %i\n- cell: %s",
worldObject.refId.c_str(),
worldObject.refNumIndex,
worldEvent->cell.getDescription().c_str());
// LocalPlayer's inventory has changed, so send a packet with it
mwmp::Main::get().getLocalPlayer()->sendInventory();
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
setTarget(newitem);
2010-08-07 18:25:17 +00:00
}
}