Added TES5Edit submodule, modified record filter to work from submodule, and generated records/flags file from submodule.

This commit is contained in:
2022-10-14 16:55:24 +11:00
parent 8e7dd48e06
commit 018fe5a743
7 changed files with 19 additions and 14105 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "reference/TES5Edit"]
path = reference/TES5Edit
url = https://github.com/TES5Edit/TES5Edit.git

1
reference/TES5Edit Submodule

Submodule reference/TES5Edit added at d971eb7112

View File

@@ -1,114 +0,0 @@
import re
import os
import json
from dataclasses import dataclass
class Jsonify:
def encode(self, value=None):
if not value:
value = self.__dict__
return value
@dataclass
class Flag(Jsonify):
bit: int
description: str
@dataclass
class Record(Jsonify):
fourcc: str
name: str
flags: list[Flag]
re_flags = re.compile(".*?(\d+?),.*?'(.*)'")
def find_records(data, re_record, re_first):
found_records = re_record.findall(data)
seen = set()
records = []
for record in found_records:
s = record.split('\n')
[first] = re_first.findall(s[0])
assert len(first) == 2, "Could not parse first line of record:\n{}".format(record)
flags = []
for line in s[2:-1]:
[f] = re_flags.findall(line)
assert len(f) == 2, "Could not parse flag definition: {}".format(line)
desc = f[1].replace("''", "'").replace("', '", "")
flags += [Flag(int(f[0]), desc)]
r = Record(first[0], first[1], flags)
if r.fourcc not in seen:
records += [r]
seen.add(r.fourcc)
return records
def find_wbRecords(data):
re_wbRecord = re.compile("wbRecord\(.*?\n.*?wbFlagsList\(\[\n(?:.*?\n)*?.*?\]")
re_wbRecord_first = re.compile("wbRecord\((\w{4}).*?'(.+?)'.*?")
return find_records(data, re_wbRecord, re_wbRecord_first)
def find_stat(data):
re_stat = re.compile("wbRecord\(STAT,.*?\n.*?\n(?:.*?\n)+?.*?]")
lines = re_stat.findall(data)[0].split('\n')
re_stat_first = re.compile("STAT, '(.*?)'")
[name] = re_stat_first.findall(lines[0])
re_stat_flag = re.compile("'(.*?)'")
flags = []
for i, line in enumerate(lines[2:-1]):
[l] = re_stat_flag.findall(line)
if l:
flags += [Flag(i, l)]
return Record("STAT", name, flags)
def find_concrete_wbRefRecords(data):
re_wbRefRecord = re.compile("wbRefRecord\(\w{4},.*?\n.*?wbFlagsList\(\[.*?\n(?:.*?\n)+?.*?\]")
re_wbRefRecord_first = re.compile("wbRefRecord\((\w{4}).*?'(.+?)'.*?")
return find_records(data, re_wbRefRecord, re_wbRefRecord_first)
def find_ReferenceRecords(data):
re_ReferenceRecordDef = re.compile("wbRefRecord\(aSignature, .*?\n(?:.*?\n)+?.*?]")
re_ReferenceRecordDef_first = re.compile("wbRefRecord\((\w+?), (\w+?),")
[d] = find_records(data, re_ReferenceRecordDef, re_ReferenceRecordDef_first)
re_ReferenceRecord = re.compile("ReferenceRecord\((\w{4}), '(.*?)'\);")
rr = re_ReferenceRecord.findall(data)
records = [Record(r[0], r[1], d.flags) for r in rr]
return records
def find_wbRefRecords(data):
records = find_concrete_wbRefRecords(data)
records = find_ReferenceRecords(data)
return records
fdir = os.path.dirname(__file__)
with open(os.path.join(fdir, "wbDefinitionsTES5.pas"), "r") as f:
inp = f.read()
records = find_wbRecords(inp) + [find_stat(inp)] + find_wbRefRecords(inp)
records.sort(key = lambda x: x.fourcc)
print(len(records))
class Encoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Jsonify):
return obj.encode()
else:
return json.JSONEncoder.default(self, obj)
with open(os.path.join(fdir, "flags.json"), "w") as f:
json.dump(records, f, cls=Encoder, indent=4)

View File

@@ -26,7 +26,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
} }
] ]
}, },
@@ -208,7 +208,7 @@
}, },
{ {
"bit": "19", "bit": "19",
"description": "Can''t Wait" "description": "Can't Wait"
} }
] ]
}, },
@@ -782,7 +782,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
}, },
{ {
"bit": "30", "bit": "30",
@@ -812,7 +812,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
}, },
{ {
"bit": "30", "bit": "30",
@@ -842,7 +842,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
}, },
{ {
"bit": "30", "bit": "30",
@@ -872,7 +872,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
}, },
{ {
"bit": "30", "bit": "30",
@@ -912,7 +912,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
}, },
{ {
"bit": "30", "bit": "30",
@@ -942,7 +942,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
}, },
{ {
"bit": "30", "bit": "30",
@@ -972,7 +972,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
}, },
{ {
"bit": "30", "bit": "30",
@@ -1007,7 +1007,7 @@
}, },
{ {
"bit": "29", "bit": "29",
"description": "Don''t Havok Settle" "description": "Don't Havok Settle"
}, },
{ {
"bit": "30", "bit": "30",
@@ -1324,7 +1324,7 @@
}, },
{ {
"bit": "9", "bit": "9",
"description": "ESL', '" "description": "ESL"
} }
] ]
}, },
@@ -1379,7 +1379,7 @@
"flags": [ "flags": [
{ {
"bit": "19", "bit": "19",
"description": "Can''t Wait" "description": "Can't Wait"
} }
] ]
}, },

View File

@@ -25,7 +25,7 @@ class Record(Jsonify):
# open and read the records from xEdit source # open and read the records from xEdit source
fdir = os.path.dirname(__file__) fdir = os.path.dirname(__file__)
with open(os.path.join(fdir, "wbDefinitionsTES5.pas"), "r") as f: with open(os.path.join(fdir, "TES5Edit/Core/wbDefinitionsTES5.pas"), "r") as f:
inp = f.read() inp = f.read()
# find all wbRecord/wbRefRecord calls # find all wbRecord/wbRefRecord calls
@@ -61,6 +61,8 @@ for string in all:
assert len(flag_lines) > 0 assert len(flag_lines) > 0
for line in flag_lines: for line in flag_lines:
bit, desc = re_flag_line.match(line).groups() bit, desc = re_flag_line.match(line).groups()
# fix '' pascal escape and ESL special case
desc = desc.replace("''", "'").replace("', '", "")
flags += [Flag(bit, desc)] flags += [Flag(bit, desc)]
# handle STAT special case # handle STAT special case
elif sig == "STAT": elif sig == "STAT":

View File

@@ -1,137 +0,0 @@
AACT,Action
ACHR,Placed NPC
ACTI,Activator
ADDN,Addon Node
ALCH,Ingestible
AMMO,Ammunition
ANIO,Animated Object
APPA,Alchemical Apparatus
ARMA,Armor Addon
ARMO,Armor
ARTO,Art Object
ASPC,Acoustic Space
ASTP,Association Type
AVIF,Actor Value Information
BOOK,Book
BPTD,Body Part Data
CAMS,Camera Shot
CELL,Cell
CLAS,Class
CLDC,CLDC
CLFM,Color
CLMT,Climate
COBJ,Constructible Object
COLL,Collision Layer
CONT,Container
CPTH,Camera Path
CSTY,Combat Style
DEBR,Debris
DIAL,Dialog Topic
DLBR,Dialog Branch
DLVW,Dialog View
DOBJ,Default Object Manager
DOOR,Door
DUAL,Dual Cast Data
ECZN,Encounter Zone
EFSH,Effect Shader
ENCH,Object Effect
EQUP,Equip Type
EXPL,Explosion
EYES,Eyes
FACT,Faction
FLOR,Flora
FLST,FormID List
FSTP,Footstep
FSTS,Footstep Set
FURN,Furniture
GLOB,Global
GMST,Game Setting
GRAS,Grass
GRUP,Internal File Structure Group
HAIR,HAIR
HAZD,Hazard
HDPT,Head Part
IDLE,Idle Animation
IDLM,Idle Marker
IMAD,Image Space Adapter
IMGS,Image Space
INFO,Dialog response
INGR,Ingredient
IPCT,Impact
IPDS,Impact Data Set
KEYM,Key
KYWD,Keyword
LAND,Landscape
LCRT,Location Reference Type
LCTN,Location
LENS,Lens Flare
LGTM,Lighting Template
LIGH,Light
LSCR,Load Screen
LTEX,Landscape Texture
LVLI,Leveled Item
LVLN,Leveled NPC
LVSP,Leveled Spell
MATO,Material Object
MATT,Material Type
MESG,Message
MGEF,Magic Effect
MISC,Misc. Item
MOVT,Movement Type
MSTT,Moveable Static
MUSC,Music Type
MUST,Music Track
NAVI,Navigation Mesh Info Map
NAVM,Navigation Mesh
NOTE,NOTE
NPC_,Non-Player Character (Actor)
OTFT,Outfit
PACK,Package
PARW,Placed Arrow
PBAR,Placed Barrier
PBEA,Placed Beam
PCON,Placed Cone/Voice
PERK,Perk
PFLA,Placed Flame
PGRE,Placed Projectile
PHZD,Placed Hazard
PLYR,Player Reference
PMIS,Placed Missile
PROJ,Projectile
PWAT,PWAT
QUST,Quest
RACE,Race
REFR,Placed Object
REGN,Region
RELA,Relationship
REVB,Reverb Parameters
RFCT,Visual Effect
RGDL,RGDL
SCEN,Scene
SCOL,SCOL
SCOL,Static Collection
SCPT,SCPT
SCRL,Scroll
SHOU,Shout
SLGM,Soul Gem
SMBN,Story Manager Branch Node
SMEN,Story Manager Event Node
SMQN,Story Manager Quest Node
SNCT,Sound Category
SNDR,Sound Descriptor
SOPM,Sound Output Model
SOUN,Sound Marker
SPEL,Spell
SPGD,Shader Particle Geometry
STAT,Static
TACT,Talking Activator
TES4,Main File Header
TREE,Tree
TXST,Texture Set
VOLI,Volumetric Lighting
VTYP,Voice Type
WATR,Water
WEAP,Weapon
WOOP,Word of Power
WRLD,Worldspace
WTHR,Weather
1 AACT Action
2 ACHR Placed NPC
3 ACTI Activator
4 ADDN Addon Node
5 ALCH Ingestible
6 AMMO Ammunition
7 ANIO Animated Object
8 APPA Alchemical Apparatus
9 ARMA Armor Addon
10 ARMO Armor
11 ARTO Art Object
12 ASPC Acoustic Space
13 ASTP Association Type
14 AVIF Actor Value Information
15 BOOK Book
16 BPTD Body Part Data
17 CAMS Camera Shot
18 CELL Cell
19 CLAS Class
20 CLDC CLDC
21 CLFM Color
22 CLMT Climate
23 COBJ Constructible Object
24 COLL Collision Layer
25 CONT Container
26 CPTH Camera Path
27 CSTY Combat Style
28 DEBR Debris
29 DIAL Dialog Topic
30 DLBR Dialog Branch
31 DLVW Dialog View
32 DOBJ Default Object Manager
33 DOOR Door
34 DUAL Dual Cast Data
35 ECZN Encounter Zone
36 EFSH Effect Shader
37 ENCH Object Effect
38 EQUP Equip Type
39 EXPL Explosion
40 EYES Eyes
41 FACT Faction
42 FLOR Flora
43 FLST FormID List
44 FSTP Footstep
45 FSTS Footstep Set
46 FURN Furniture
47 GLOB Global
48 GMST Game Setting
49 GRAS Grass
50 GRUP Internal File Structure Group
51 HAIR HAIR
52 HAZD Hazard
53 HDPT Head Part
54 IDLE Idle Animation
55 IDLM Idle Marker
56 IMAD Image Space Adapter
57 IMGS Image Space
58 INFO Dialog response
59 INGR Ingredient
60 IPCT Impact
61 IPDS Impact Data Set
62 KEYM Key
63 KYWD Keyword
64 LAND Landscape
65 LCRT Location Reference Type
66 LCTN Location
67 LENS Lens Flare
68 LGTM Lighting Template
69 LIGH Light
70 LSCR Load Screen
71 LTEX Landscape Texture
72 LVLI Leveled Item
73 LVLN Leveled NPC
74 LVSP Leveled Spell
75 MATO Material Object
76 MATT Material Type
77 MESG Message
78 MGEF Magic Effect
79 MISC Misc. Item
80 MOVT Movement Type
81 MSTT Moveable Static
82 MUSC Music Type
83 MUST Music Track
84 NAVI Navigation Mesh Info Map
85 NAVM Navigation Mesh
86 NOTE NOTE
87 NPC_ Non-Player Character (Actor)
88 OTFT Outfit
89 PACK Package
90 PARW Placed Arrow
91 PBAR Placed Barrier
92 PBEA Placed Beam
93 PCON Placed Cone/Voice
94 PERK Perk
95 PFLA Placed Flame
96 PGRE Placed Projectile
97 PHZD Placed Hazard
98 PLYR Player Reference
99 PMIS Placed Missile
100 PROJ Projectile
101 PWAT PWAT
102 QUST Quest
103 RACE Race
104 REFR Placed Object
105 REGN Region
106 RELA Relationship
107 REVB Reverb Parameters
108 RFCT Visual Effect
109 RGDL RGDL
110 SCEN Scene
111 SCOL SCOL
112 SCOL Static Collection
113 SCPT SCPT
114 SCRL Scroll
115 SHOU Shout
116 SLGM Soul Gem
117 SMBN Story Manager Branch Node
118 SMEN Story Manager Event Node
119 SMQN Story Manager Quest Node
120 SNCT Sound Category
121 SNDR Sound Descriptor
122 SOPM Sound Output Model
123 SOUN Sound Marker
124 SPEL Spell
125 SPGD Shader Particle Geometry
126 STAT Static
127 TACT Talking Activator
128 TES4 Main File Header
129 TREE Tree
130 TXST Texture Set
131 VOLI Volumetric Lighting
132 VTYP Voice Type
133 WATR Water
134 WEAP Weapon
135 WOOP Word of Power
136 WRLD Worldspace
137 WTHR Weather

File diff suppressed because it is too large Load Diff