Blame view

d2stat.h 2.31 KB
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
#ifndef D2STAT_H
#define D2STAT_H

#include <stdint.h>
#include <stdlib.h>

#define D2S_STAT_HEADER "gf"
#define D2S_STAT_HEADER_LENGTH 2
#define D2S_STAT_FOOTER 0x1FF
10
#define D2S_STAT_IDENTIFIER_BIT_LENGTH 9
Imanol-Mikel Barba Sabariego authored
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

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