-
Notifications
You must be signed in to change notification settings - Fork 9
/
build_lookup.ps1
86 lines (76 loc) · 2.43 KB
/
build_lookup.ps1
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
param(
$LookupFile = "$((Get-Item $PSScriptRoot).Parent.Fullname)/lookup/lookup.txt",
$LookupFileStruct = "$((Get-Item $PSScriptRoot).Parent.Fullname)/lookup/lookup_structs.txt",
$LookupFileStructBig = "$((Get-Item $PSScriptRoot).Parent.Fullname)/lookup/lookup_structs_big.txt"
)
$LookupFileData = Get-Content $LookupFile
$prevPwd = $PWD
try {
$base = (Get-Item $PSScriptRoot).Parent
Set-Location ($base.Fullname)
Set-Location scripts\core_common
@"
// this file was created using the build_lookup.ps1 script, do no write in it!!!
// a basic lookup function, not all the hashes are here, but enough to give information
hash_lookup(hash_value) {
#ifdef ATIAN_COD_TOOL
return ACTSLookup(hash_value);
#else
if (isdefined(level.hash_lookup_big)) {
// checking big version (is described)
res = [[ level.hash_lookup_big ]](hash_value);
if (isdefined(res)) {
return res;
}
}
if (!isdefined(hash_value)) {
return undefined;
}
switch (hash_value) {
$(($LookupFileData | Sort-Object | ForEach-Object {
$line = $_
" case #`"$line`": return `"$line`";"
}) -join "`n")
default: return hash_value;
}
#endif
}
"@ | Out-File -Encoding utf8 lookup.gcsc
}
finally {
$prevPwd | Set-Location
}
$LookupFileData = Get-Content $LookupFileStruct
$LookupFileDataBig = Get-Content $LookupFileStructBig
try {
$base = (Get-Item $PSScriptRoot).Parent
Set-Location ($base.Fullname)
Set-Location scripts\core_common\dev
@"
// this file was created using the build_lookup.ps1 script, do no write in it!!!
// a basic struct lookup function, not all the canon. ids are here, but enough to give information
// search the elements of a struct (please help me if you know how to do it without injecting a custom function in the vm)
get_struct_explorer_values(obj) {
elements = [];
#ifdef ATIAN_MENU_LOOKUP_BIG
$(($LookupFileDataBig | Sort-Object | ForEach-Object {
$line = $_
if ($line.Length -ne 0) {
" elements = add_struct_explorer_value(elements, `"$line`", obj.$line);"
}
}) -join "`n")
#else
$(($LookupFileData | Sort-Object | ForEach-Object {
$line = $_
if ($line.Length -ne 0) {
" elements = add_struct_explorer_value(elements, `"$line`", obj.$line);"
}
}) -join "`n")
#endif
return elements;
}
"@ | Out-File -Encoding utf8 lookup_structs.gsc
}
finally {
$prevPwd | Set-Location
}