-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaobj.imhex
69 lines (47 loc) · 1.1 KB
/
aobj.imhex
1
2
3
4
5
6
7
8
9
10
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
#include <std/string.pat>
#include <std/io.pat>
#include <std/mem.pat>
fn is_zero(u32 count) {
u32 offset = 0;
for (u32 i = 0, i < count, i += 1) {
u8 read_byte = std::mem::read_unsigned($ + offset, 1);
if (read_byte != 0) {
return false;
}
offset += 1;
}
return true;
};
struct SkipZero<auto Count, auto error_on_not_zero, auto print_on_not_zero> {
bool is_zero = is_zero(Count);
padding[Count];
if (!is_zero) {
if (error_on_not_zero) {
std::error("Value was not zero!");
} else {
if (print_on_not_zero) {
std::print("Value was not zero!");
}
}
}
} [[sealed, hidden, no_unique_address]];
struct Object {
u8 type;
char name[32];
u32 name_length = std::string::length(name);
u8 level;
u32 time;
u16 data1[4];
u16 data2[4];
u16 magic;
u16 price;
SkipZero<2, true, true>;
u16 magic2;
SkipZero<2, true, true>;
u8 magic3;
};
struct AObj {
Object objects[732];
//Object objects[117];
};
AObj aobj @ $;