#ifndef ITEM_H_ #define ITEM_H_ #include #include #ifdef WIN32 #define STDEXT stdext #endif using namespace STDEXT; #define LOC_IS_BACKPACK 0 #define LOC_IN_BACKPACK 1 #define LOC_IN_STORAGE 2 #define LOC_IN_EQUIPPED 3 #define EXT_HEAD 4 #define EXT_CHEST 2 #define EXT_ARMS 6 #define EXT_LEGS 3 #define EXT_FEET 5 #define INT_HEAD 0 #define INT_CHEST 1 #define INT_ARMS 2 #define INT_LEGS 3 #define INT_FEET 4 using namespace std; //Data required by the GW packet struct GWITEM { //In the GW item packet unsigned short gwId; unsigned short graphicalOptions; unsigned char upgradeComponent; unsigned char color[3]; unsigned char unknownBlock1; unsigned char unknownBlock2; unsigned char unknownBlock3; unsigned char uniqueness; unsigned char unknownBlock4; unsigned char rarity; unsigned char unknownBlock5; unsigned char unknownBlock6; unsigned char unknownBlock7; unsigned char unknownBlock8; unsigned char unknownBlock9; unsigned char unknownBlock10; unsigned char unknownBlock11; unsigned char unknownBlock12; unsigned char unknownBlock13; unsigned long quantity; short itemNameLength; char itemName[25];//I've only seen max 10 unsigned char numMods; long mod[30]; //END GW item packet char customized[20]; int profession; }; struct ITEM_ID { unsigned char id[12]; }; class Item { public: Item(); int ToItemPacket(unsigned char* pDestBuffer); int ToCustomizationPacket(unsigned char* pDestBuffer); void SetColorWithDye(int color); void GenerateId(int accountId, int characterId, vector* pItemList); void GenerateIdHm(int accountId, int characterId, hash_map* pItemList); void SetItemStorageLocation(int type); void SetItemStoragePosition(int pos); bool Save(); char* GetId(); bool Delete();//Removes the item by ID from the database static bool Delete(char* pItemId); GWITEM* GetRawItemData(); int GetItemStorageLocation(); bool Customize(char* pCharacterName); bool IsCustomized(); char GetItemStoragePosition(); int CreateItemPacket(short GENERAL_ITEM, short IT_LOCATION, short IT_OWNER_NAME, short IT_PROFFESSION, long *pIsa, short *pPage, short *pStreamId, char* pDestBuf); void SetIsa(long id);//Item Stream Agent long GetIsa(); long GetExternalIsa(); void SetExternalIsa(long eisa); static unsigned long Load(ITEM_ID* pItems, unsigned long numItems); static unsigned long Load(unsigned long accountId, unsigned long characterId); static Item* ConvertResultSet(void* pResult, long* pNumItems); static int ConvertToExternal(int ref); static void SetDatabase(void* pDatabase); private: bool CheckForDuplicateIds(vector* pItemList); bool CheckForDuplicateIdsHM(hash_map* pItemList); char mId[12]; //ID that the item is referenced by bool mExistsInDb; int mLocation; //1st byte=place of storage //2-3 byte=page number? //4th byte=slot number? GWITEM mData; //Contains all the data needed by the GW client long mIsa; long mExternalIsa; friend class ItemDefManager; }; #endif