Commit 27780d019ce84a8681f92be8113a0680ec84b6d3
1 parent
1e4e1700
WIP
Showing
3 changed files
with
100 additions
and
15 deletions
d2char.c
@@ -35,4 +35,95 @@ int isExpansion(D2CharHeader* c) { | @@ -35,4 +35,95 @@ int isExpansion(D2CharHeader* c) { | ||
35 | 35 | ||
36 | int isLadder(D2CharHeader* c) { | 36 | int isLadder(D2CharHeader* c) { |
37 | return c->charStatus & D2S_CHARSTATUS_LADDER; | 37 | return c->charStatus & D2S_CHARSTATUS_LADDER; |
38 | +} | ||
39 | + | ||
40 | +int getCurrentAct(D2CharHeader* c) { | ||
41 | + if(isExpansion(c)) { | ||
42 | + return c->charProgress % 5; | ||
43 | + } else { | ||
44 | + return c->charProgress % 4; | ||
45 | + } | ||
46 | +} | ||
47 | + | ||
48 | +int isFemale(D2CharHeader* c) { | ||
49 | + return (c->charClass == D2S_CHARCLASS_AMAZON || | ||
50 | + c->charClass == D2S_CHARCLASS_ASSASSIN || | ||
51 | + c->charClass == D2S_CHARCLASS_SORCERESS); | ||
52 | +} | ||
53 | + | ||
54 | +// Returns static string from library memory, no need to free | ||
55 | +const char* getCharacterTitle(D2CharHeader* c) { | ||
56 | + int tier; | ||
57 | + if(isExpansion(c)) { | ||
58 | + // Expansion | ||
59 | + tier = c->charProgress / 5; | ||
60 | + if(isHardcore(c)) { | ||
61 | + // Expansion Hardcore | ||
62 | + switch(tier) { | ||
63 | + case 0: | ||
64 | + return D2S_CHARPROGRESS_TIER0_NAME; | ||
65 | + break; | ||
66 | + case 1: | ||
67 | + return D2S_CHARPROGRESS_EXPANSION_TIER1_NAME_HARDCORE; | ||
68 | + break; | ||
69 | + case 2: | ||
70 | + return D2S_CHARPROGRESS_EXPANSION_TIER2_NAME_HARDCORE; | ||
71 | + break; | ||
72 | + case 3: | ||
73 | + return D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_HARDCORE; | ||
74 | + break; | ||
75 | + } | ||
76 | + } else { | ||
77 | + // Expansion Softcore | ||
78 | + switch(tier) { | ||
79 | + case 0: | ||
80 | + return D2S_CHARPROGRESS_TIER0_NAME; | ||
81 | + break; | ||
82 | + case 1: | ||
83 | + return D2S_CHARPROGRESS_EXPANSION_TIER1_NAME; | ||
84 | + break; | ||
85 | + case 2: | ||
86 | + return D2S_CHARPROGRESS_EXPANSION_TIER2_NAME; | ||
87 | + break; | ||
88 | + case 3: | ||
89 | + return isFemale(c) ? D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_F : D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_M; | ||
90 | + break; | ||
91 | + } | ||
92 | + } | ||
93 | + } else { | ||
94 | + // Classic | ||
95 | + if(isHardcore(c)) { | ||
96 | + // Classic Hardcore | ||
97 | + switch(tier) { | ||
98 | + case 0: | ||
99 | + return D2S_CHARPROGRESS_TIER0_NAME; | ||
100 | + break; | ||
101 | + case 1: | ||
102 | + return isFemale(c) ? D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_HARDCORE_F : D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_HARDCORE_M; | ||
103 | + break; | ||
104 | + case 2: | ||
105 | + return isFemale(c) ? D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_HARDCORE_F : D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_HARDCORE_M; | ||
106 | + break; | ||
107 | + case 3: | ||
108 | + return isFemale(c) ? D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_HARDCORE_F : D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_HARDCORE_M; | ||
109 | + break; | ||
110 | + } | ||
111 | + } else { | ||
112 | + // Classic Softcore | ||
113 | + switch(tier) { | ||
114 | + case 0: | ||
115 | + return D2S_CHARPROGRESS_TIER0_NAME; | ||
116 | + break; | ||
117 | + case 1: | ||
118 | + return isFemale(c) ? D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_F : D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_M; | ||
119 | + break; | ||
120 | + case 2: | ||
121 | + return isFemale(c) ? D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_F : D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_M; | ||
122 | + break; | ||
123 | + case 3: | ||
124 | + return isFemale(c) ? D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_F : D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_M; | ||
125 | + break; | ||
126 | + } | ||
127 | + } | ||
128 | + } | ||
38 | } | 129 | } |
39 | \ No newline at end of file | 130 | \ No newline at end of file |
d2char.h
@@ -21,15 +21,6 @@ | @@ -21,15 +21,6 @@ | ||
21 | #define D2S_CHARSTATUS_EXPANSION 0x20 | 21 | #define D2S_CHARSTATUS_EXPANSION 0x20 |
22 | #define D2S_CHARSTATUS_LADDER 0x40 | 22 | #define D2S_CHARSTATUS_LADDER 0x40 |
23 | 23 | ||
24 | -#define D2S_CHARPROGRESS_CLASSIC_TIER0 3 | ||
25 | -#define D2S_CHARPROGRESS_CLASSIC_TIER1 | ||
26 | -#define D2S_CHARPROGRESS_CLASSIC_TIER2 | ||
27 | -#define D2S_CHARPROGRESS_CLASSIC_TIER3 | ||
28 | -#define D2S_CHARPROGRESS_EXPANSION_TIER0 | ||
29 | -#define D2S_CHARPROGRESS_EXPANSION_TIER1 | ||
30 | -#define D2S_CHARPROGRESS_EXPANSION_TIER2 | ||
31 | -#define D2S_CHARPROGRESS_EXPANSION_TIER3 | ||
32 | - | ||
33 | enum D2Version { | 24 | enum D2Version { |
34 | VER_106 = 71, | 25 | VER_106 = 71, |
35 | VER_107 = 87, | 26 | VER_107 = 87, |
@@ -49,6 +40,14 @@ enum D2CharClass { | @@ -49,6 +40,14 @@ enum D2CharClass { | ||
49 | D2S_CHARCLASS_ASSASSIN = 0x06 | 40 | D2S_CHARCLASS_ASSASSIN = 0x06 |
50 | }; | 41 | }; |
51 | 42 | ||
43 | +enum D2Acts { | ||
44 | + D2S_ACT1 = 0, | ||
45 | + D2S_ACT2 = 1, | ||
46 | + D2S_ACT3 = 2, | ||
47 | + D2S_ACT4 = 3, | ||
48 | + D2S_ACT5 = 4 | ||
49 | +}; | ||
50 | + | ||
52 | typedef struct __attribute__((packed)){ | 51 | typedef struct __attribute__((packed)){ |
53 | uint32_t signature; | 52 | uint32_t signature; |
54 | uint32_t versionID; | 53 | uint32_t versionID; |
d2strings.h
1 | #ifndef D2STRINGS_H | 1 | #ifndef D2STRINGS_H |
2 | #define D2STRINGS_H | 2 | #define D2STRINGS_H |
3 | 3 | ||
4 | -const char* D2S_CHARPROGRESS_CLASSIC_TIER0_NAME_M = ""; | 4 | +const char* D2S_CHARPROGRESS_TIER0_NAME = ""; |
5 | const char* D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_M = "Sir"; | 5 | const char* D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_M = "Sir"; |
6 | const char* D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_M = "Lord"; | 6 | const char* D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_M = "Lord"; |
7 | const char* D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_M = "Baron"; | 7 | const char* D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_M = "Baron"; |
8 | -const char* D2S_CHARPROGRESS_CLASSIC_TIER0_NAME_HARDCORE_M = ""; | ||
9 | const char* D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_HARDCORE_M = "Count"; | 8 | const char* D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_HARDCORE_M = "Count"; |
10 | const char* D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_HARDCORE_M = "Duke"; | 9 | const char* D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_HARDCORE_M = "Duke"; |
11 | const char* D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_HARDCORE_M = "King"; | 10 | const char* D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_HARDCORE_M = "King"; |
12 | -const char* D2S_CHARPROGRESS_CLASSIC_TIER0_NAME_F = ""; | ||
13 | const char* D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_F = "Dame"; | 11 | const char* D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_F = "Dame"; |
14 | const char* D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_F = "Lady"; | 12 | const char* D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_F = "Lady"; |
15 | const char* D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_F = "Baroness"; | 13 | const char* D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_F = "Baroness"; |
16 | -const char* D2S_CHARPROGRESS_CLASSIC_TIER0_NAME_HARDCORE_F = ""; | ||
17 | const char* D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_HARDCORE_F = "Countess"; | 14 | const char* D2S_CHARPROGRESS_CLASSIC_TIER1_NAME_HARDCORE_F = "Countess"; |
18 | const char* D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_HARDCORE_F = "Duchess"; | 15 | const char* D2S_CHARPROGRESS_CLASSIC_TIER2_NAME_HARDCORE_F = "Duchess"; |
19 | const char* D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_HARDCORE_F = "Queen"; | 16 | const char* D2S_CHARPROGRESS_CLASSIC_TIER3_NAME_HARDCORE_F = "Queen"; |
20 | 17 | ||
21 | -const char* D2S_CHARPROGRESS_EXPANSION_TIER0_NAME = ""; | ||
22 | const char* D2S_CHARPROGRESS_EXPANSION_TIER1_NAME = "Slayer"; | 18 | const char* D2S_CHARPROGRESS_EXPANSION_TIER1_NAME = "Slayer"; |
23 | const char* D2S_CHARPROGRESS_EXPANSION_TIER2_NAME = "Champion"; | 19 | const char* D2S_CHARPROGRESS_EXPANSION_TIER2_NAME = "Champion"; |
24 | const char* D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_M = "Patriarch"; | 20 | const char* D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_M = "Patriarch"; |
25 | const char* D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_F = "Matriarch"; | 21 | const char* D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_F = "Matriarch"; |
26 | -const char* D2S_CHARPROGRESS_EXPANSION_TIER0_NAME_HARDCORE = ""; | ||
27 | const char* D2S_CHARPROGRESS_EXPANSION_TIER1_NAME_HARDCORE = "Destroyer"; | 22 | const char* D2S_CHARPROGRESS_EXPANSION_TIER1_NAME_HARDCORE = "Destroyer"; |
28 | const char* D2S_CHARPROGRESS_EXPANSION_TIER2_NAME_HARDCORE = "Conqueror"; | 23 | const char* D2S_CHARPROGRESS_EXPANSION_TIER2_NAME_HARDCORE = "Conqueror"; |
29 | const char* D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_HARDCORE = "Guardian"; | 24 | const char* D2S_CHARPROGRESS_EXPANSION_TIER3_NAME_HARDCORE = "Guardian"; |