#ifndef D2STAT_H #define D2STAT_H #include #include #define D2S_STAT_HEADER "gf" #define D2S_STAT_HEADER_LENGTH 2 #define D2S_STAT_FOOTER 0x1FF #define D2S_STAT_IDENTIFIER_BIT_LENGTH 9 typedef enum D2S_STAT { D2S_STAT_STRENGTH = 0x00, D2S_STAT_ENERGY = 0x01, D2S_STAT_DEXTERITY = 0x02, D2S_STAT_VITALITY = 0x03, D2S_STAT_STATPTS = 0x04, D2S_STAT_SKILLPTS = 0x05, D2S_STAT_LIFE = 0x06, D2S_STAT_MAXLIFE = 0x07, D2S_STAT_MANA = 0x08, D2S_STAT_MAXMANA = 0x09, D2S_STAT_STAMINA = 0x0a, D2S_STAT_MAXSTAMINA = 0x0b, D2S_STAT_LEVEL = 0x0c, D2S_STAT_EXPERIENCE = 0x0d, D2S_STAT_GOLD = 0x0e, D2S_STAT_GOLDSTASH = 0x0f, } D2S_STAT; // Internal use. Length of each stat in bits const int statCost[] = { 10, //D2S_STAT_STRENGTH 10, //D2S_STAT_ENERGY 10, //D2S_STAT_DEXTERITY 10, //D2S_STAT_VITALITY 10, //D2S_STAT_STATPTS 8, //D2S_STAT_SKILLPTS 21, //D2S_STAT_LIFE 21, //D2S_STAT_MAXLIFE 21, //D2S_STAT_MANA 21, //D2S_STAT_MAXMANA 21, //D2S_STAT_STAMINA 21, //D2S_STAT_MAXSTAMINA 7, //D2S_STAT_LEVEL 32, //D2S_STAT_EXPERIENCE 25, //D2S_STAT_GOLD 25 //D2S_STAT_GOLDSTASH }; // Internal use. Mask to apply to the bit offset (when properly shifted) to get the stat value const uint64_t statCostMask[] = { 0x00000000000003FF, //D2S_STAT_STRENGTH (10 bits) 0x00000000000003FF, //D2S_STAT_ENERGY (10 bits) 0x00000000000003FF, //D2S_STAT_DEXTERITY (10 bits) 0x00000000000003FF, //D2S_STAT_VITALITY (10 bits) 0x00000000000003FF, //D2S_STAT_STATPTS (10 bits) 0x00000000000000FF, //D2S_STAT_SKILLPTS (8 bits) 0x00000000001FFFFF, //D2S_STAT_LIFE (21 bits) 0x00000000001FFFFF, //D2S_STAT_MAXLIFE (21 bits) 0x00000000001FFFFF, //D2S_STAT_MANA (21 bits) 0x00000000001FFFFF, //D2S_STAT_MAXMANA (21 bits) 0x00000000001FFFFF, //D2S_STAT_STAMINA (21 bits) 0x00000000001FFFFF, //D2S_STAT_MAXSTAMINA (21 bits) 0x000000000000007F, //D2S_STAT_LEVEL (7 bits) 0x00000000FFFFFFFF, //D2S_STAT_EXPERIENCE (32 bits) 0x0000000001FFFFFF, //D2S_STAT_GOLD (25 bits) 0x0000000001FFFFFF //D2S_STAT_GOLDSTASH (25 bits) }; int getStat(D2S_STAT stat, unsigned int* value, void* charData, size_t dataLen); int setStat(D2S_STAT stat, unsigned int value, void* charData, size_t dataLen); #endif