-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.py
110 lines (90 loc) · 3.4 KB
/
debug.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from . import stream_helper
from . import rat_types
from .utils import (read_sections_chunks, read_ighw_header, query_section)
class Debug:
stream: stream_helper.StreamHelper
header: rat_types.IGHeader
chunks: list[rat_types.IGSectionChunk]
def __init__(self, stream: stream_helper.StreamHelper):
self.stream = stream
stream.seek(0x00)
self.header = read_ighw_header(stream)
self.chunks = list(read_sections_chunks(self.header, stream))
def GetMobysInstancesNames(self):
stream = self.stream
mobysInstNames = query_section(self.chunks, 0x73C0)
stream.seek(mobysInstNames.offset)
for i in range(mobysInstNames.count):
nameinst = read_instance_name(stream)
stream.jump(0x18)
yield nameinst
def GetTiesInstancesNames(self):
stream = self.stream
tiesInstNames = query_section(self.chunks, 0x72C0)
stream.seek(tiesInstNames)
for i in range(tiesInstNames.count):
nameinst = read_instance_name(stream)
stream.jump(0x18)
yield nameinst
def GetMobyPrototypeName(self, index: int):
stream = self.stream
mobysNames = query_section(self.chunks, 0x9480)
stream.seek(mobysNames.offset + index * 0x10)
return read_prototype_name(stream)
def GetTiePrototypeName(self, index: int):
stream = self.stream
tiesnames = query_section(self.chunks, 0x9280)
stream.seek(tiesnames.offset + index * 0x10)
return read_prototype_name(stream)
def GetShaderName(self, index: int):
stream = self.stream
shadernames = query_section(self.chunks, 0x5D00)
stream.seek(shadernames + index * 0x30)
return read_shader_name(stream)
class DebugInstanceName(dict):
"""0x18 Long"""
tuid1: int
tuid2: int
name: str
ukwn: int
class DebugAssetName(dict):
"""0x10 Long"""
tuid: int
name: str
class DebugMaterialName(dict):
"""0x30 Long\nGeneraly called Shader."""
shaderTuid: int
shaderName: str
albedoTuid: int
normalTuid: int
expensiveTuid: int
wthTuid: int
albedoName: str
normalName: str
expensiveName: str
wthName: str
def read_instance_name(stream: stream_helper.StreamHelper) -> DebugInstanceName:
din = DebugInstanceName()
din.tuid1 = stream.readULong(0x00)
din.tuid2 = stream.readULong(0x08)
din.name = stream.readString(stream.readUInt(0x10), False)
din.ukwn = stream.readUInt(0x14)
return din
def read_prototype_name(stream: stream_helper.StreamHelper) -> DebugAssetName:
dan = DebugAssetName()
dan.tuid = stream.readULong(0x00)
dan.name = stream.readString(stream.readUInt(0x08), False)
return dan
def read_shader_name(stream: stream_helper.StreamHelper) -> DebugMaterialName:
dmn = DebugMaterialName()
dmn.shaderTuid = stream.readULong(0x00)
dmn.shaderName = stream.readString(stream.readUInt(0x08), False)
dmn.albedoTuid = stream.readUInt(0x10)
dmn.normalTuid = stream.readUInt(0x14)
dmn.expensiveTuid = stream.readUInt(0x18)
dmn.wthTuid = stream.readUInt(0x1C)
dmn.albedoName = stream.readString(stream.readUInt(0x20), False)
dmn.normalName = stream.readString(stream.readUInt(0x24), False)
dmn.expensiveName = stream.readString(stream.readUInt(0x28), False)
dmn.wthName = stream.readString(stream.readUInt(0x2C), False)
return dmn