mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
erpt: identify flags in autogen
This commit is contained in:
parent
823a1f3ea3
commit
50ea19e7a2
2 changed files with 631 additions and 616 deletions
File diff suppressed because it is too large
Load diff
|
@ -238,6 +238,11 @@ FIELD_TYPES = {
|
||||||
15 : 'FieldType_I8Array',
|
15 : 'FieldType_I8Array',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FIELD_FLAGS = {
|
||||||
|
0 : 'FieldFlag_None',
|
||||||
|
1 : 'FieldFlag_Encrypt',
|
||||||
|
}
|
||||||
|
|
||||||
def get_full(nxo):
|
def get_full(nxo):
|
||||||
full = nxo.text[0]
|
full = nxo.text[0]
|
||||||
if nxo.ro[2] >= len(full):
|
if nxo.ro[2] >= len(full):
|
||||||
|
@ -352,12 +357,20 @@ def find_types(full, num_fields):
|
||||||
ind = full.index(''.join(pk('<I', i) for i in KNOWN))
|
ind = full.index(''.join(pk('<I', i) for i in KNOWN))
|
||||||
return list(up('<'+'I'*num_fields, full[ind:ind+4*num_fields]))
|
return list(up('<'+'I'*num_fields, full[ind:ind+4*num_fields]))
|
||||||
|
|
||||||
|
def find_flags(full, num_fields):
|
||||||
|
KNOWN = '\x00' + ('\x01'*6) + '\x00\x01\x01\x00'
|
||||||
|
ind = full.index(KNOWN) - 443
|
||||||
|
return list(up('<'+'B'*num_fields, full[ind:ind+num_fields]))
|
||||||
|
|
||||||
def cat_to_string(c):
|
def cat_to_string(c):
|
||||||
return CATEGORIES[c] if c in CATEGORIES else 'Category_Unknown%d' % c
|
return CATEGORIES[c] if c in CATEGORIES else 'Category_Unknown%d' % c
|
||||||
|
|
||||||
def typ_to_string(t):
|
def typ_to_string(t):
|
||||||
return FIELD_TYPES[t] if t in FIELD_TYPES else 'FieldType_Unknown%d' % t
|
return FIELD_TYPES[t] if t in FIELD_TYPES else 'FieldType_Unknown%d' % t
|
||||||
|
|
||||||
|
def flg_to_string(f):
|
||||||
|
return FIELD_FLAGS[f] if f in FIELD_FLAGS else 'FieldFlag_Unknown%d' % f
|
||||||
|
|
||||||
def main(argc, argv):
|
def main(argc, argv):
|
||||||
if argc != 2:
|
if argc != 2:
|
||||||
print 'Usage: %s erpt_nso' % argv[0]
|
print 'Usage: %s erpt_nso' % argv[0]
|
||||||
|
@ -370,14 +383,16 @@ def main(argc, argv):
|
||||||
NUM_FIELDS = len(fields)
|
NUM_FIELDS = len(fields)
|
||||||
cats = find_categories(full, NUM_FIELDS)
|
cats = find_categories(full, NUM_FIELDS)
|
||||||
types = find_types(full, NUM_FIELDS)
|
types = find_types(full, NUM_FIELDS)
|
||||||
|
flags = find_flags(full, NUM_FIELDS)
|
||||||
print 'Identified %d fields.' % NUM_FIELDS
|
print 'Identified %d fields.' % NUM_FIELDS
|
||||||
mf = max(len(s) for s in fields)
|
mf = max(len(s) for s in fields)
|
||||||
mc = max(len(cat_to_string(c)) for c in cats)
|
mc = max(len(cat_to_string(c)) for c in cats)
|
||||||
mt = max(len(typ_to_string(t)) for t in types)
|
mt = max(len(typ_to_string(t)) for t in types)
|
||||||
format_string = '- %%-%ds %%-%ds %%-%ds' % (mf+1, mc+1, mt)
|
ml = max(len(flg_to_string(f)) for f in flags)
|
||||||
|
format_string = '- %%-%ds %%-%ds %%-%ds %%-%ds' % (mf+1, mc+1, mt+1, ml)
|
||||||
for i in xrange(NUM_FIELDS):
|
for i in xrange(NUM_FIELDS):
|
||||||
f, c, t = fields[i], cat_to_string(cats[i]), typ_to_string(types[i])
|
f, c, t, l = fields[i], cat_to_string(cats[i]), typ_to_string(types[i]), flg_to_string(flags[i])
|
||||||
print format_string % (f+',', c+',', t)
|
print format_string % (f+',', c+',', t+',', l)
|
||||||
with open(argv[1]+'.hpp', 'w') as out:
|
with open(argv[1]+'.hpp', 'w') as out:
|
||||||
out.write(HEADER)
|
out.write(HEADER)
|
||||||
out.write('#define AMS_ERPT_FOREACH_FIELD_TYPE(HANDLER) \\\n')
|
out.write('#define AMS_ERPT_FOREACH_FIELD_TYPE(HANDLER) \\\n')
|
||||||
|
@ -390,8 +405,8 @@ def main(argc, argv):
|
||||||
out.write('\n')
|
out.write('\n')
|
||||||
out.write('#define AMS_ERPT_FOREACH_FIELD(HANDLER) \\\n')
|
out.write('#define AMS_ERPT_FOREACH_FIELD(HANDLER) \\\n')
|
||||||
for i in xrange(NUM_FIELDS):
|
for i in xrange(NUM_FIELDS):
|
||||||
f, c, t = fields[i], cats[i], types[i]
|
f, c, t, l = fields[i], cats[i], types[i], flags[i]
|
||||||
out.write((' HANDLER(%%-%ds %%-4s %%-%ds %%-%ds) \\\n' % (mf+1, mc+1, mt)) % (f+',', '%d,'%i, cat_to_string(c)+',', typ_to_string(t)))
|
out.write((' HANDLER(%%-%ds %%-4s %%-%ds %%-%ds %%-%ds) \\\n' % (mf+1, mc+1, mt+1, ml)) % (f+',', '%d,'%i, cat_to_string(c)+',', typ_to_string(t)+',', flg_to_string(l)))
|
||||||
out.write('\n')
|
out.write('\n')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue