[Client] Implement sending and reading of ObjectTrap packets

0.6.1
David Cernat 8 years ago
parent 4082cddde5
commit 7ac115b359

@ -207,6 +207,28 @@ void WorldEvent::lockObjects(MWWorld::CellStore* cellStore)
}
}
void WorldEvent::triggerTrapObjects(MWWorld::CellStore* cellStore)
{
WorldObject worldObject;
for (unsigned int i = 0; i < worldObjectCount; i++)
{
worldObject = worldObjects.at(i);
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
LOG_APPEND(Log::LOG_VERBOSE, "-- Found %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(),
ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
ptrFound.getCellRef().setTrap("");
}
}
}
void WorldEvent::scaleObjects(MWWorld::CellStore* cellStore)
{
WorldObject worldObject;
@ -490,6 +512,17 @@ void WorldEvent::addObjectLock(const MWWorld::Ptr& ptr, int lockLevel)
addObject(worldObject);
}
void WorldEvent::addObjectTrap(const MWWorld::Ptr& ptr)
{
cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId();
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
worldObject.mpNum = ptr.getCellRef().getMpNum();
addObject(worldObject);
}
void WorldEvent::addObjectScale(const MWWorld::Ptr& ptr, float scale)
{
cell = *ptr.getCell()->getCell();
@ -613,6 +646,12 @@ void WorldEvent::sendObjectLock()
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send();
}
void WorldEvent::sendObjectTrap()
{
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_TRAP)->setEvent(this);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_TRAP)->Send();
}
void WorldEvent::sendObjectScale()
{
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->setEvent(this);

@ -23,6 +23,7 @@ namespace mwmp
void placeObjects(MWWorld::CellStore* cellStore);
void deleteObjects(MWWorld::CellStore* cellStore);
void lockObjects(MWWorld::CellStore* cellStore);
void triggerTrapObjects(MWWorld::CellStore* cellStore);
void scaleObjects(MWWorld::CellStore* cellStore);
void moveObjects(MWWorld::CellStore* cellStore);
void rotateObjects(MWWorld::CellStore* cellStore);
@ -40,6 +41,7 @@ namespace mwmp
void addObjectPlace(const MWWorld::Ptr& ptr);
void addObjectDelete(const MWWorld::Ptr& ptr);
void addObjectLock(const MWWorld::Ptr& ptr, int lockLevel);
void addObjectTrap(const MWWorld::Ptr& ptr);
void addObjectScale(const MWWorld::Ptr& ptr, float scale);
void addObjectAnimPlay(const MWWorld::Ptr& ptr, std::string group, int mode);
void addDoorState(const MWWorld::Ptr& ptr, int state);
@ -53,6 +55,7 @@ namespace mwmp
void sendObjectPlace();
void sendObjectDelete();
void sendObjectLock();
void sendObjectTrap();
void sendObjectScale();
void sendObjectAnimPlay();
void sendDoorState();

@ -18,7 +18,7 @@ namespace mwmp
{
BaseObjectProcessor::Do(packet, event);
//event.setObjectTraps(ptrCellStore);
event.triggerTrapObjects(ptrCellStore);
}
};
}

@ -5,12 +5,10 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Log.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
#include "../mwmp/WorldEvent.hpp"
#include "../mwmp/LocalPlayer.hpp"
#include "../mwworld/cellstore.hpp"
/*
End of tes3mp addition
*/

@ -1,5 +1,17 @@
#include "actiontrap.hpp"
/*
Start of tes3mp addition
Include additional headers for multiplayer purposes
*/
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
#include "../mwmp/WorldEvent.hpp"
/*
End of tes3mp addition
*/
#include "../mwmechanics/spellcasting.hpp"
#include "../mwbase/environment.hpp"
@ -30,5 +42,19 @@ namespace MWWorld
cast.cast(mSpellId);
}
mTrapSource.getCellRef().setTrap("");
/*
Start of tes3mp addition
Send an ID_OBJECT_TRAP packet every time an item is taken from the world
by the player outside of the inventory screen
*/
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
worldEvent->reset();
worldEvent->addObjectTrap(mTrapSource);
worldEvent->sendObjectTrap();
/*
End of tes3mp addition
*/
}
}

Loading…
Cancel
Save