[General] Add action types to WorldEvent's ContainerChanges

pull/163/head
David Cernat 8 years ago
parent a07e616878
commit 9f8bed9be1

@ -66,7 +66,7 @@ namespace mwmp
{
ESM::Cell cell;
enum CELl_STATE_ACTION
enum CELL_STATE_ACTION
{
LOAD = 0,
UNLOAD = 1
@ -91,7 +91,7 @@ namespace mwmp
ADD,
REMOVE
};
int action; //0 - Clear and set in entirety, 1 - Add item, 2 - Remove item
int action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item
};
struct SpellbookChanges
@ -104,7 +104,7 @@ namespace mwmp
ADD,
REMOVE
};
int action; //0 - Clear and set in entirety, 1 - Add spell, 2 - Remove spell
int action; // 0 - Clear and set in entirety, 1 - Add spell, 2 - Remove spell
};
struct CellStateChanges

@ -36,12 +36,34 @@ namespace mwmp
std::string refId;
int count;
int health;
inline bool operator==(const ContainerItem& rhs)
{
return refId == rhs.refId && count == rhs.count && health == rhs.health;
}
};
struct ObjectChanges
{
std::vector<WorldObject> objects;
unsigned int count;
};
struct ContainerChanges
{
std::vector<ContainerItem> items;
unsigned int count;
enum CONTAINER_ACTION
{
SET = 0,
ADD = 1,
REMOVE = 2
};
int action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item
};
class WorldEvent
{
public:
@ -56,18 +78,6 @@ namespace mwmp
}
struct ObjectChanges
{
std::vector<WorldObject> objects;
unsigned int count;
};
struct ContainerChanges
{
std::vector<ContainerItem> items;
unsigned int count;
};
RakNet::RakNetGUID guid;
ObjectChanges objectChanges;
ContainerChanges containerChanges;

@ -12,8 +12,13 @@ void PacketContainer::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send
{
WorldPacket::Packet(bs, event, send);
RW(event->containerChanges.action, send);
if (!send)
{
event->objectChanges.objects.clear();
event->containerChanges.items.clear();
}
else
{
event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size());

Loading…
Cancel
Save