Add and implement ID_WORLD_OBJECT_LOCK

coverity_scan^2
David Cernat 8 years ago
parent 3a5a5e73a1
commit 3fd93896f2

@ -410,6 +410,23 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
break;
}
case ID_WORLD_OBJECT_LOCK:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_WORLD_OBJECT_LOCK from %s",
player->Npc()->mName.c_str());
myPacket->Read(event);
LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s",
event->cellRef.mRefID.c_str(),
event->cellRef.mRefNum.mIndex,
event->cell.getDescription().c_str());
myPacket->Send(event, true);
break;
}
case ID_WORLD_OBJECT_UNLOCK:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_WORLD_OBJECT_UNLOCK from %s",

@ -686,13 +686,9 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
MWWorld::CellStore *ptrCellStore;
if (event->cell.isExterior())
{
ptrCellStore = MWBase::Environment::get().getWorld()->getExterior(event->cell.mData.mX, event->cell.mData.mY);
}
else
{
ptrCellStore = MWBase::Environment::get().getWorld()->getInterior(event->cell.mName);
}
switch (packet->data[0])
{
@ -725,6 +721,27 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
break;
}
case ID_WORLD_OBJECT_LOCK:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_WORLD_OBJECT_LOCK");
LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s",
event->cellRef.mRefID.c_str(),
event->cellRef.mRefNum.mIndex,
event->cell.getDescription().c_str());
MWWorld::Ptr ptrFound = ptrCellStore->searchByRefNum(event->cellRef.mRefNum);
if (ptrFound)
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Found %s, %i",
ptrFound.getCellRef().getRefId().c_str(),
ptrFound.getCellRef().getRefNum());
ptrFound.getClass().lock(ptrFound, event->lockLevel);
}
break;
}
case ID_WORLD_OBJECT_UNLOCK:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_WORLD_OBJECT_UNLOCK");

@ -157,7 +157,8 @@ add_component_dir (openmw-mp
Packets/Player/PacketHandshake Packets/Player/PacketGUIBoxes Packets/Player/PacketClass
Packets/Player/PacketTime Packets/Player/PacketInventory
Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectUnlock)
Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectLock
Packets/World/PacketObjectUnlock)
add_component_dir (fallback
fallback validate

@ -25,6 +25,7 @@ namespace mwmp
ESM::Cell cell;
ESM::CellRef cellRef;
int lockLevel;
};
}

@ -4,6 +4,7 @@
#include "../Packets/World/PacketObjectDelete.hpp"
#include "../Packets/World/PacketObjectPlace.hpp"
#include "../Packets/World/PacketObjectLock.hpp"
#include "../Packets/World/PacketObjectUnlock.hpp"
#include "WorldPacketController.hpp"
@ -20,6 +21,7 @@ mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *pee
{
AddPacket<PacketObjectDelete>(&packets, peer);
AddPacket<PacketObjectPlace>(&packets, peer);
AddPacket<PacketObjectLock>(&packets, peer);
AddPacket<PacketObjectUnlock>(&packets, peer);
}

@ -35,6 +35,7 @@ enum GameMessages
ID_WORLD_OBJECT_PLACE,
ID_WORLD_OBJECT_DELETE,
ID_WORLD_OBJECT_LOCK,
ID_WORLD_OBJECT_UNLOCK
};

@ -0,0 +1,24 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketObjectLock.hpp"
using namespace mwmp;
PacketObjectLock::PacketObjectLock(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
{
packetID = ID_WORLD_OBJECT_LOCK;
}
void PacketObjectLock::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
{
WorldPacket::Packet(bs, event, send);
RW(event->cellRef.mRefID, send);
RW(event->cellRef.mRefNum.mIndex, send);
RW(event->cell.mData.mFlags, send);
RW(event->cell.mData.mX, send);
RW(event->cell.mData.mY, send);
RW(event->cell.mName, send);
RW(event->lockLevel, send);
}

@ -0,0 +1,17 @@
#ifndef OPENMW_PACKETOBJECTLOCK_HPP
#define OPENMW_PACKETOBJECTLOCK_HPP
#include <components/openmw-mp/Packets/World/WorldPacket.hpp>
namespace mwmp
{
class PacketObjectLock : public WorldPacket
{
public:
PacketObjectLock(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send);
};
}
#endif //OPENMW_PACKETOBJECTLOCK_HPP
Loading…
Cancel
Save