2010-08-07 18:25:17 +00:00
|
|
|
#include "actiontake.hpp"
|
|
|
|
|
2017-04-24 16:46:12 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Include additional headers for multiplayer purposes
|
|
|
|
*/
|
2016-10-22 14:10:57 +00:00
|
|
|
#include "../mwmp/Main.hpp"
|
2016-12-16 08:59:15 +00:00
|
|
|
#include "../mwmp/Networking.hpp"
|
2018-05-12 21:42:24 +00:00
|
|
|
#include "../mwmp/ObjectList.hpp"
|
2017-04-24 16:46:12 +00:00
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
2016-10-22 14:10:57 +00:00
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
2012-08-12 16:11:09 +00:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2014-01-07 18:49:16 +00:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2012-04-23 13:27:03 +00:00
|
|
|
|
2018-09-10 11:18:07 +00:00
|
|
|
#include "../mwgui/inventorywindow.hpp"
|
|
|
|
|
2010-08-07 18:25:17 +00:00
|
|
|
#include "class.hpp"
|
2012-02-23 11:38:25 +00:00
|
|
|
#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
|
|
|
|
2013-02-17 14:56:22 +00:00
|
|
|
void ActionTake::executeImp (const Ptr& actor)
|
2010-08-07 18:25:17 +00:00
|
|
|
{
|
2018-09-10 11:18:07 +00:00
|
|
|
// When in GUI mode, we should use drag and drop
|
|
|
|
if (actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
|
|
|
{
|
|
|
|
MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
|
|
|
|
if (mode == MWGui::GM_Inventory || mode == MWGui::GM_Container)
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->pickUpObject(getTarget());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-07 18:49:16 +00:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->itemTaken(
|
2015-02-03 22:43:56 +00:00
|
|
|
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
|
2017-01-18 20:57:50 +00:00
|
|
|
MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
|
2016-10-22 14:10:57 +00:00
|
|
|
|
2017-02-26 14:59:53 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Send an ID_OBJECT_DELETE packet every time an item is taken from the world
|
|
|
|
by the player outside of the inventory screen
|
|
|
|
*/
|
2018-05-12 21:42:24 +00:00
|
|
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
|
|
|
objectList->reset();
|
2018-07-22 22:39:43 +00:00
|
|
|
objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY;
|
2020-01-23 07:03:40 +00:00
|
|
|
objectList->addObjectGeneric(getTarget());
|
2018-05-12 21:42:24 +00:00
|
|
|
objectList->sendObjectDelete();
|
2017-02-26 14:59:53 +00:00
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
2016-11-17 18:51:07 +00:00
|
|
|
|
2012-09-04 13:34:44 +00:00
|
|
|
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
2017-01-18 20:57:50 +00:00
|
|
|
setTarget(newitem);
|
2010-08-07 18:25:17 +00:00
|
|
|
}
|
|
|
|
}
|