#pragma once #include #include #include // PORT: supplementary AVA2 pet/rarity state. Classic item packets retain 3 sockets / 7 attributes. #pragma pack(push,1) struct PortItemExtra { int32_t sockets[5]; uint8_t types[8]; int16_t values[8]; char name[25]; }; #pragma pack(pop) static_assert(sizeof(PortItemExtra)==69,"extended item state"); inline std::string PortItemExtraHex(const PortItemExtra& extra) { static const char digits[]="0123456789abcdef"; const auto p=reinterpret_cast(&extra); std::string result(sizeof(extra)*2,'0'); for(unsigned i=0;i>4];result[2*i+1]=digits[p[i]&15];} return result; } inline bool PortItemExtraRead(const char* hex,PortItemExtra& extra) { PortItemExtra decoded = {}; if(!hex)return false; if(!*hex){extra=decoded;return true;} if(std::strlen(hex)!=sizeof(decoded)*2)return false; auto nibble=[](char c){return c>='0' && c<='9'?c-'0':c>='A' && c<='F'?c-'A'+10:c>='a' && c<='f'?c-'a'+10:-1;}; auto p=reinterpret_cast(&decoded); for(unsigned i=0;i((a<<4)|b);} if(decoded.name[24]!=0)return false; extra=decoded;return true; }