#ifndef D2CHAR_H #define D2CHAR_H #include #include "d2strings.h" #define D2S_HEADER_LENGTH 765 #define D2S_SIGNATURE 0xAA55AA55 #define D2S_CHECKSUM_OFFSET 12 #define D2S_CHECKSUM_LENGTH 4 #define D2S_CHARNAME_LENGTH 16 #define D2S_HOTKEYS_LENGTH 64 #define D2S_CHAR_APPEARANCE_LENGTH 32 #define D2S_DIFFICULTY_LENGTH 3 #define D2S_QUESTS_LENGTH 298 #define D2S_WAYPOINTS_LENGTH 81 #define D2S_NPCDATA_LENGTH 51 #define D2S_CHARSTATUS_HARDCORE 0x04 #define D2S_CHARSTATUS_DIED 0x08 #define D2S_CHARSTATUS_EXPANSION 0x20 #define D2S_CHARSTATUS_LADDER 0x40 enum D2Version { VER_106 = 71, VER_107 = 87, VER_108XP = 87, VER_108 = 89, VER_109 = 92, VER_110 = 96 }; enum D2CharClass { D2S_CHARCLASS_AMAZON = 0x00, D2S_CHARCLASS_SORCERESS = 0x01, D2S_CHARCLASS_NECROMANCER = 0x02, D2S_CHARCLASS_PALADIN = 0x03, D2S_CHARCLASS_BARBARIAN = 0x04, D2S_CHARCLASS_DRUID = 0x05, D2S_CHARCLASS_ASSASSIN = 0x06 }; enum D2Acts { D2S_ACT1 = 0, D2S_ACT2 = 1, D2S_ACT3 = 2, D2S_ACT4 = 3, D2S_ACT5 = 4 }; typedef struct __attribute__((packed)){ uint32_t signature; uint32_t versionID; uint32_t fileSize; uint32_t checksum; uint32_t activeWeapon; // TODO char name[D2S_CHARNAME_LENGTH]; uint8_t charStatus; uint8_t charProgress; uint16_t unknown1; // TODO uint8_t charClass; uint16_t unknown2; // TODO uint8_t charLevel; uint32_t unknown3; // TODO uint32_t lastPlayed; uint32_t unknown4; // TODO uint8_t hotkeys[D2S_HOTKEYS_LENGTH]; uint32_t leftAbility; uint32_t rightAbility; uint32_t leftAbilityAlt; uint32_t rightAbilityAlt; uint8_t charAppearance[D2S_CHAR_APPEARANCE_LENGTH]; uint8_t difficulty[D2S_DIFFICULTY_LENGTH]; uint32_t mapID; uint16_t unknown5; uint16_t mercenaryStatus; uint32_t mercenarySeed; uint16_t mercenaryNameID; uint16_t mercenaryType; uint32_t mercenaryExp; uint8_t unknown6[144]; uint8_t questData[D2S_QUESTS_LENGTH]; uint8_t waypointData[D2S_WAYPOINTS_LENGTH]; uint8_t NPCIntroductions[D2S_NPCDATA_LENGTH]; // TODO } D2CharHeader; uint32_t calcChecksum(D2CharHeader* c, void* charData); int checkChecksum(D2CharHeader* c, void* charData); int isHardcore(D2CharHeader* c); int hasDied(D2CharHeader* c); int isExpansion(D2CharHeader* c); int isLadder(D2CharHeader* c); #endif