mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
[General] Simplify WorldPackets
This commit is contained in:
parent
556bf18535
commit
fd8e833d6a
35 changed files with 148 additions and 681 deletions
|
@ -7,49 +7,29 @@ using namespace mwmp;
|
||||||
PacketContainer::PacketContainer(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketContainer::PacketContainer(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_CONTAINER;
|
packetID = ID_CONTAINER;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
|
void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
if(!PacketHeader(bs, send))
|
||||||
|
return;
|
||||||
|
|
||||||
RW(event->action, send);
|
RW(event->action, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
WorldObject worldObject;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
||||||
{
|
{
|
||||||
if (send)
|
if (send)
|
||||||
{
|
{
|
||||||
worldObject = event->worldObjects.at(i);
|
worldObject = event->worldObjects.at(i);
|
||||||
worldObject.containerItemCount = (unsigned int)(worldObject.containerItems.size());
|
worldObject.containerItemCount = (unsigned int) (worldObject.containerItems.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
worldObject.containerItems.clear();
|
worldObject.containerItems.clear();
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
Object(worldObject, send);
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.containerItemCount, send);
|
RW(worldObject.containerItemCount, send);
|
||||||
|
|
||||||
if (worldObject.containerItemCount > maxObjects || worldObject.refId.empty() || (worldObject.refNumIndex != 0 && worldObject.mpNum != 0))
|
if (worldObject.containerItemCount > maxObjects || worldObject.refId.empty() || (worldObject.refNumIndex != 0 && worldObject.mpNum != 0))
|
||||||
|
@ -63,9 +43,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
|
||||||
for (unsigned int j = 0; j < worldObject.containerItemCount; j++)
|
for (unsigned int j = 0; j < worldObject.containerItemCount; j++)
|
||||||
{
|
{
|
||||||
if (send)
|
if (send)
|
||||||
{
|
|
||||||
containerItem = worldObject.containerItems.at(j);
|
containerItem = worldObject.containerItems.at(j);
|
||||||
}
|
|
||||||
|
|
||||||
RW(containerItem.refId, send);
|
RW(containerItem.refId, send);
|
||||||
RW(containerItem.count, send);
|
RW(containerItem.count, send);
|
||||||
|
@ -73,14 +51,9 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
|
||||||
RW(containerItem.actionCount, send);
|
RW(containerItem.actionCount, send);
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
{
|
|
||||||
worldObject.containerItems.push_back(containerItem);
|
worldObject.containerItems.push_back(containerItem);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
event->worldObjects.push_back(worldObject);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,47 +6,11 @@ using namespace mwmp;
|
||||||
PacketDoorState::PacketDoorState(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketDoorState::PacketDoorState(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_DOOR_STATE;
|
packetID = ID_DOOR_STATE;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketDoorState::Packet(RakNet::BitStream *bs, bool send)
|
void PacketDoorState::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.doorState, send);
|
RW(worldObject.doorState, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketDoorState(RakNet::RakPeerInterface *peer);
|
PacketDoorState(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,37 +8,7 @@ PacketMusicPlay::PacketMusicPlay(RakNet::RakPeerInterface *peer) : WorldPacket(p
|
||||||
packetID = ID_MUSIC_PLAY;
|
packetID = ID_MUSIC_PLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketMusicPlay::Packet(RakNet::BitStream *bs, bool send)
|
void PacketMusicPlay::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.filename, send);
|
RW(worldObject.filename, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketMusicPlay(RakNet::RakPeerInterface *peer);
|
PacketMusicPlay(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,48 +6,12 @@ using namespace mwmp;
|
||||||
PacketObjectAnimPlay::PacketObjectAnimPlay(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketObjectAnimPlay::PacketObjectAnimPlay(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_ANIM_PLAY;
|
packetID = ID_OBJECT_ANIM_PLAY;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectAnimPlay::Packet(RakNet::BitStream *bs, bool send)
|
void PacketObjectAnimPlay::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.animGroup, send);
|
RW(worldObject.animGroup, send);
|
||||||
RW(worldObject.animMode, send);
|
RW(worldObject.animMode, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketObjectAnimPlay(RakNet::RakPeerInterface *peer);
|
PacketObjectAnimPlay(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,46 +6,5 @@ using namespace mwmp;
|
||||||
PacketObjectDelete::PacketObjectDelete(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketObjectDelete::PacketObjectDelete(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_DELETE;
|
packetID = ID_OBJECT_DELETE;
|
||||||
}
|
hasCellData = true;
|
||||||
|
|
||||||
void PacketObjectDelete::Packet(RakNet::BitStream *bs, bool send)
|
|
||||||
{
|
|
||||||
WorldPacket::Packet(bs, send);
|
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PacketObjectDelete(RakNet::RakPeerInterface *peer);
|
PacketObjectDelete(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,45 +8,8 @@ PacketObjectLock::PacketObjectLock(RakNet::RakPeerInterface *peer) : WorldPacket
|
||||||
packetID = ID_OBJECT_LOCK;
|
packetID = ID_OBJECT_LOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectLock::Packet(RakNet::BitStream *bs, bool send)
|
void PacketObjectLock::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.lockLevel, send);
|
RW(worldObject.lockLevel, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketObjectLock(RakNet::RakPeerInterface *peer);
|
PacketObjectLock(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,49 +6,11 @@ using namespace mwmp;
|
||||||
PacketObjectMove::PacketObjectMove(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketObjectMove::PacketObjectMove(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_MOVE;
|
packetID = ID_OBJECT_MOVE;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectMove::Packet(RakNet::BitStream *bs, bool send)
|
void PacketObjectMove::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
RW(worldObject.position.pos, send);
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.position.pos[0], send);
|
|
||||||
RW(worldObject.position.pos[1], send);
|
|
||||||
RW(worldObject.position.pos[2], send);
|
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketObjectMove(RakNet::RakPeerInterface *peer);
|
PacketObjectMove(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,50 +6,14 @@ using namespace mwmp;
|
||||||
PacketObjectPlace::PacketObjectPlace(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketObjectPlace::PacketObjectPlace(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_PLACE;
|
packetID = ID_OBJECT_PLACE;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectPlace::Packet(RakNet::BitStream *bs, bool send)
|
void PacketObjectPlace::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.count, send);
|
RW(worldObject.count, send);
|
||||||
RW(worldObject.charge, send);
|
RW(worldObject.charge, send);
|
||||||
RW(worldObject.goldValue, send);
|
RW(worldObject.goldValue, send);
|
||||||
RW(worldObject.position, send);
|
RW(worldObject.position, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketObjectPlace(RakNet::RakPeerInterface *peer);
|
PacketObjectPlace(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,49 +6,13 @@ using namespace mwmp;
|
||||||
PacketObjectRotate::PacketObjectRotate(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketObjectRotate::PacketObjectRotate(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_ROTATE;
|
packetID = ID_OBJECT_ROTATE;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectRotate::Packet(RakNet::BitStream *bs, bool send)
|
void PacketObjectRotate::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.position.rot[0], send);
|
RW(worldObject.position.rot[0], send);
|
||||||
RW(worldObject.position.rot[1], send);
|
RW(worldObject.position.rot[1], send);
|
||||||
RW(worldObject.position.rot[2], send);
|
RW(worldObject.position.rot[2], send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketObjectRotate(RakNet::RakPeerInterface *peer);
|
PacketObjectRotate(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,47 +6,11 @@ using namespace mwmp;
|
||||||
PacketObjectScale::PacketObjectScale(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketObjectScale::PacketObjectScale(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_SCALE;
|
packetID = ID_OBJECT_SCALE;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectScale::Packet(RakNet::BitStream *bs, bool send)
|
void PacketObjectScale::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.scale, send);
|
RW(worldObject.scale, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketObjectScale(RakNet::RakPeerInterface *peer);
|
PacketObjectScale(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,42 +6,12 @@ using namespace mwmp;
|
||||||
PacketObjectSpawn::PacketObjectSpawn(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketObjectSpawn::PacketObjectSpawn(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_SPAWN;
|
packetID = ID_OBJECT_SPAWN;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectSpawn::Packet(RakNet::BitStream *bs, bool send)
|
void PacketObjectSpawn::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.position, send);
|
RW(worldObject.position, send);
|
||||||
|
|
||||||
RW(worldObject.hasMaster, send);
|
RW(worldObject.hasMaster, send);
|
||||||
|
@ -52,10 +22,4 @@ void PacketObjectSpawn::Packet(RakNet::BitStream *bs, bool send)
|
||||||
RW(worldObject.master.mpNum, send);
|
RW(worldObject.master.mpNum, send);
|
||||||
RW(worldObject.master.guid, send);
|
RW(worldObject.master.guid, send);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketObjectSpawn(RakNet::RakPeerInterface *peer);
|
PacketObjectSpawn(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,50 +6,14 @@ using namespace mwmp;
|
||||||
PacketObjectTrap::PacketObjectTrap(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketObjectTrap::PacketObjectTrap(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_TRAP;
|
packetID = ID_OBJECT_TRAP;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectTrap::Packet(RakNet::BitStream *bs, bool send)
|
void PacketObjectTrap::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.isDisarmed, send);
|
RW(worldObject.isDisarmed, send);
|
||||||
|
|
||||||
if (!worldObject.isDisarmed)
|
if (!worldObject.isDisarmed)
|
||||||
RW(worldObject.position, send);
|
RW(worldObject.position, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketObjectTrap(RakNet::RakPeerInterface *peer);
|
PacketObjectTrap(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,38 +8,8 @@ PacketScriptGlobalShort::PacketScriptGlobalShort(RakNet::RakPeerInterface *peer)
|
||||||
packetID = ID_SCRIPT_GLOBAL_SHORT;
|
packetID = ID_SCRIPT_GLOBAL_SHORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketScriptGlobalShort::Packet(RakNet::BitStream *bs, bool send)
|
void PacketScriptGlobalShort::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.varName, send);
|
RW(worldObject.varName, send);
|
||||||
RW(worldObject.shortVal, send);
|
RW(worldObject.shortVal, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketScriptGlobalShort(RakNet::RakPeerInterface *peer);
|
PacketScriptGlobalShort(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,48 +6,12 @@ using namespace mwmp;
|
||||||
PacketScriptLocalFloat::PacketScriptLocalFloat(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketScriptLocalFloat::PacketScriptLocalFloat(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_SCRIPT_LOCAL_FLOAT;
|
packetID = ID_SCRIPT_LOCAL_FLOAT;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketScriptLocalFloat::Packet(RakNet::BitStream *bs, bool send)
|
void PacketScriptLocalFloat::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.index, send);
|
RW(worldObject.index, send);
|
||||||
RW(worldObject.floatVal, send);
|
RW(worldObject.floatVal, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketScriptLocalFloat(RakNet::RakPeerInterface *peer);
|
PacketScriptLocalFloat(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,48 +6,12 @@ using namespace mwmp;
|
||||||
PacketScriptLocalShort::PacketScriptLocalShort(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
PacketScriptLocalShort::PacketScriptLocalShort(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_SCRIPT_LOCAL_SHORT;
|
packetID = ID_SCRIPT_LOCAL_SHORT;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketScriptLocalShort::Packet(RakNet::BitStream *bs, bool send)
|
void PacketScriptLocalShort::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
WorldPacket::Object(worldObject, send);
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(event->cell.mData.mFlags, send);
|
|
||||||
RW(event->cell.mData.mX, send);
|
|
||||||
RW(event->cell.mData.mY, send);
|
|
||||||
RW(event->cell.mName, send);
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
|
||||||
RW(worldObject.refNumIndex, send);
|
|
||||||
RW(worldObject.mpNum, send);
|
|
||||||
RW(worldObject.index, send);
|
RW(worldObject.index, send);
|
||||||
RW(worldObject.shortVal, send);
|
RW(worldObject.shortVal, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketScriptLocalShort(RakNet::RakPeerInterface *peer);
|
PacketScriptLocalShort(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &obj, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,39 +8,9 @@ PacketScriptMemberShort::PacketScriptMemberShort(RakNet::RakPeerInterface *peer)
|
||||||
packetID = ID_SCRIPT_MEMBER_SHORT;
|
packetID = ID_SCRIPT_MEMBER_SHORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketScriptMemberShort::Packet(RakNet::BitStream *bs, bool send)
|
void PacketScriptMemberShort::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.refId, send);
|
RW(worldObject.refId, send);
|
||||||
RW(worldObject.index, send);
|
RW(worldObject.index, send);
|
||||||
RW(worldObject.shortVal, send);
|
RW(worldObject.shortVal, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketScriptMemberShort(RakNet::RakPeerInterface *peer);
|
PacketScriptMemberShort(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &obj, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,38 +8,8 @@ PacketVideoPlay::PacketVideoPlay(RakNet::RakPeerInterface *peer) : WorldPacket(p
|
||||||
packetID = ID_VIDEO_PLAY;
|
packetID = ID_VIDEO_PLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketVideoPlay::Packet(RakNet::BitStream *bs, bool send)
|
void PacketVideoPlay::Object(WorldObject &worldObject, bool send)
|
||||||
{
|
{
|
||||||
WorldPacket::Packet(bs, send);
|
|
||||||
|
|
||||||
if (send)
|
|
||||||
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
|
||||||
else
|
|
||||||
event->worldObjects.clear();
|
|
||||||
|
|
||||||
RW(event->worldObjectCount, send);
|
|
||||||
|
|
||||||
if (event->worldObjectCount > maxObjects)
|
|
||||||
{
|
|
||||||
event->isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldObject worldObject;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
|
||||||
{
|
|
||||||
if (send)
|
|
||||||
{
|
|
||||||
worldObject = event->worldObjects.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
RW(worldObject.filename, send);
|
RW(worldObject.filename, send);
|
||||||
RW(worldObject.allowSkipping, send);
|
RW(worldObject.allowSkipping, send);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
{
|
|
||||||
event->worldObjects.push_back(worldObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace mwmp
|
||||||
public:
|
public:
|
||||||
PacketVideoPlay(RakNet::RakPeerInterface *peer);
|
PacketVideoPlay(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Object(WorldObject &obj, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ using namespace mwmp;
|
||||||
|
|
||||||
WorldPacket::WorldPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
WorldPacket::WorldPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
||||||
{
|
{
|
||||||
|
hasCellData = false;
|
||||||
packetID = 0;
|
packetID = 0;
|
||||||
priority = HIGH_PRIORITY;
|
priority = HIGH_PRIORITY;
|
||||||
reliability = RELIABLE_ORDERED;
|
reliability = RELIABLE_ORDERED;
|
||||||
|
@ -24,3 +25,53 @@ void WorldPacket::setEvent(BaseEvent *event)
|
||||||
this->event = event;
|
this->event = event;
|
||||||
guid = event->guid;
|
guid = event->guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldPacket::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
{
|
||||||
|
if(!PacketHeader(bs, send))
|
||||||
|
return;
|
||||||
|
|
||||||
|
WorldObject worldObject;
|
||||||
|
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
||||||
|
{
|
||||||
|
if (send)
|
||||||
|
worldObject = event->worldObjects.at(i);
|
||||||
|
|
||||||
|
Object(worldObject, send);
|
||||||
|
|
||||||
|
if (!send)
|
||||||
|
event->worldObjects.push_back(worldObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorldPacket::PacketHeader(RakNet::BitStream *bs, bool send)
|
||||||
|
{
|
||||||
|
BasePacket::Packet(bs, send);
|
||||||
|
|
||||||
|
if (send)
|
||||||
|
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
||||||
|
else
|
||||||
|
event->worldObjects.clear();
|
||||||
|
|
||||||
|
RW(event->worldObjectCount, send);
|
||||||
|
|
||||||
|
if (event->worldObjectCount > maxObjects)
|
||||||
|
{
|
||||||
|
event->isValid = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasCellData)
|
||||||
|
{
|
||||||
|
RW(event->cell.mData, send, 1);
|
||||||
|
RW(event->cell.mName, send, 1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldPacket::Object(WorldObject &worldObject, bool send)
|
||||||
|
{
|
||||||
|
RW(worldObject.refId, send);
|
||||||
|
RW(worldObject.refNumIndex, send);
|
||||||
|
RW(worldObject.mpNum, send);
|
||||||
|
}
|
||||||
|
|
|
@ -21,9 +21,14 @@ namespace mwmp
|
||||||
|
|
||||||
void setEvent(BaseEvent *event);
|
void setEvent(BaseEvent *event);
|
||||||
|
|
||||||
|
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void Object(WorldObject &worldObject, bool send);
|
||||||
|
bool PacketHeader(RakNet::BitStream *bs, bool send);
|
||||||
BaseEvent *event;
|
BaseEvent *event;
|
||||||
static const int maxObjects = 3000;
|
static const int maxObjects = 3000;
|
||||||
|
bool hasCellData;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue