forked from teamnwah/openmw-tes3coop
[General] Add ContainerItem and ContainerChanges structs to WorldEvent
This commit is contained in:
parent
6328ffb9aa
commit
a07e616878
4 changed files with 77 additions and 0 deletions
|
@ -37,6 +37,11 @@ void LocalEvent::addObject(WorldObject worldObject)
|
|||
objectChanges.objects.push_back(worldObject);
|
||||
}
|
||||
|
||||
void LocalEvent::addContainerItem(ContainerItem containerItem)
|
||||
{
|
||||
containerChanges.items.push_back(containerItem);
|
||||
}
|
||||
|
||||
void LocalEvent::placeObjects(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
WorldObject worldObject;
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace mwmp
|
|||
virtual ~LocalEvent();
|
||||
|
||||
void addObject(WorldObject worldObject);
|
||||
void addContainerItem(ContainerItem containerItem);
|
||||
|
||||
void placeObjects(MWWorld::CellStore* cellStore);
|
||||
void deleteObjects(MWWorld::CellStore* cellStore);
|
||||
|
|
|
@ -31,6 +31,17 @@ namespace mwmp
|
|||
std::string varName;
|
||||
};
|
||||
|
||||
struct ContainerItem
|
||||
{
|
||||
std::string refId;
|
||||
int count;
|
||||
int health;
|
||||
inline bool operator==(const ContainerItem& rhs)
|
||||
{
|
||||
return refId == rhs.refId && count == rhs.count && health == rhs.health;
|
||||
}
|
||||
};
|
||||
|
||||
class WorldEvent
|
||||
{
|
||||
public:
|
||||
|
@ -51,8 +62,15 @@ namespace mwmp
|
|||
unsigned int count;
|
||||
};
|
||||
|
||||
struct ContainerChanges
|
||||
{
|
||||
std::vector<ContainerItem> items;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
RakNet::RakNetGUID guid;
|
||||
ObjectChanges objectChanges;
|
||||
ContainerChanges containerChanges;
|
||||
|
||||
ESM::Cell cell;
|
||||
};
|
||||
|
|
|
@ -11,4 +11,57 @@ PacketContainer::PacketContainer(RakNet::RakPeerInterface *peer) : WorldPacket(p
|
|||
void PacketContainer::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
|
||||
{
|
||||
WorldPacket::Packet(bs, event, send);
|
||||
|
||||
if (!send)
|
||||
event->objectChanges.objects.clear();
|
||||
else
|
||||
{
|
||||
event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size());
|
||||
event->containerChanges.count = (unsigned int)(event->containerChanges.items.size());
|
||||
}
|
||||
|
||||
RW(event->objectChanges.count, send);
|
||||
RW(event->containerChanges.count, send);
|
||||
|
||||
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->objectChanges.count; i++)
|
||||
{
|
||||
if (send)
|
||||
{
|
||||
worldObject = event->objectChanges.objects[i];
|
||||
}
|
||||
|
||||
RW(worldObject.refId, send);
|
||||
RW(worldObject.refNumIndex, send);
|
||||
|
||||
if (!send)
|
||||
{
|
||||
event->objectChanges.objects.push_back(worldObject);
|
||||
}
|
||||
}
|
||||
|
||||
ContainerItem containerItem;
|
||||
|
||||
for (unsigned int i = 0; i < event->containerChanges.count; i++)
|
||||
{
|
||||
if (send)
|
||||
{
|
||||
containerItem = event->containerChanges.items[i];
|
||||
}
|
||||
|
||||
RW(containerItem.refId, send);
|
||||
RW(containerItem.count, send);
|
||||
|
||||
if (!send)
|
||||
{
|
||||
event->containerChanges.items.push_back(containerItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue