[General] Add packetOrigin and originClientScript to ObjectList packets

Additionally, add script functions for getting the packetOrigin and originClientScript of received ObjectList packets.
pull/471/head
David Cernat 7 years ago
parent b891acd46e
commit 3dc2d1b214

@ -28,6 +28,7 @@ void ObjectFunctions::ClearObjectList() noexcept
{
writeObjectList.cell.blank();
writeObjectList.baseObjects.clear();
writeObjectList.packetOrigin = mwmp::PACKET_ORIGIN::SERVER_SCRIPT;
}
void ObjectFunctions::SetObjectListPid(unsigned short pid) noexcept
@ -48,6 +49,16 @@ unsigned int ObjectFunctions::GetObjectListSize() noexcept
return readObjectList->baseObjectCount;
}
unsigned char ObjectFunctions::GetObjectListOrigin() noexcept
{
return readObjectList->packetOrigin;
}
const char *ObjectFunctions::GetObjectListClientScript() noexcept
{
return readObjectList->originClientScript.c_str();
}
unsigned char ObjectFunctions::GetObjectListAction() noexcept
{
return readObjectList->action;

@ -10,6 +10,8 @@
{"CopyReceivedObjectListToStore", ObjectFunctions::CopyReceivedObjectListToStore},\
\
{"GetObjectListSize", ObjectFunctions::GetObjectListSize},\
{"GetObjectListOrigin", ObjectFunctions::GetObjectListOrigin},\
{"GetObjectListClientScript", ObjectFunctions::GetObjectListClientScript},\
{"GetObjectListAction", ObjectFunctions::GetObjectListAction},\
{"GetObjectListContainerSubAction", ObjectFunctions::GetObjectListContainerSubAction},\
\
@ -170,6 +172,20 @@ public:
*/
static unsigned int GetObjectListSize() noexcept;
/**
* \brief Get the origin of the read object list.
*
* \return The origin (0 for GAMEPLAY, 1 for CONSOLE, 2 for CLIENT_SCRIPT).
*/
static unsigned char GetObjectListOrigin() noexcept;
/**
* \brief Get the client script that the read object list originated from.
*
* \return The ID of the client script.
*/
static const char *GetObjectListClientScript() noexcept;
/**
* \brief Get the action type used in the read object list.
*

@ -113,6 +113,9 @@ namespace mwmp
ESM::Cell cell;
std::string consoleCommand;
unsigned char packetOrigin; // 0 - Gameplay, 1 - Console, 2 - Client script, 3 - Server script
std::string originClientScript;
unsigned char action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item, 3 - Request items
unsigned char containerSubAction; // 0 - None, 1 - Drag, 2 - Drop, 3 - Take all, 4 - Reply to request

@ -9,6 +9,14 @@
namespace mwmp
{
enum PACKET_ORIGIN
{
GAMEPLAY = 0,
CONSOLE = 1,
CLIENT_SCRIPT = 2,
SERVER_SCRIPT = 3
};
struct Item
{
std::string refId;

@ -48,6 +48,11 @@ bool ObjectPacket::PacketHeader(RakNet::BitStream *bs, bool send)
{
BasePacket::Packet(bs, send);
RW(objectList->packetOrigin, send);
if (objectList->packetOrigin == mwmp::CLIENT_SCRIPT)
RW(objectList->originClientScript, true);
if (send)
objectList->baseObjectCount = (unsigned int)(objectList->baseObjects.size());
else

Loading…
Cancel
Save