-
Notifications
You must be signed in to change notification settings - Fork 3
/
check_names.py
61 lines (51 loc) · 1.53 KB
/
check_names.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
#!/usr/bin/env
import json
import sqlite3
DROP_ACTOR = 1
DROP_TABLE = 2
names = json.load(open("names.json","r"))
missing = {}
with open("missing.csv", "r") as f:
for line in f:
if len(line.strip()) == 0:
continue
if line.strip()[0] == '#':
continue
v = [x.strip() for x in line.split(",")]
key, val = v[0], v[1]
missing[key] = val
con = sqlite3.connect("map.db")
cur = con.cursor()
res = cur.execute('select distinct(unit_config_name) from objs')
for row in res:
if not row[0] in names and not row[0] in missing:
missing[row[0]] = ""
res = cur.execute('select drops from objs')
for row in res:
if row[0] is None or len(row[0]) == 0:
continue
r = json.loads(row[0])
if r[0] == DROP_TABLE:
continue
drop = r[1]
if drop and drop not in names and drop not in missing:
missing[drop] = ""
res = cur.execute('select equip from objs')
for row in res:
if row[0] is None or len(row[0]) == 0:
continue
r = json.loads(row[0])
for val in r:
if not val in names and not val in missing:
missing[val] = ""
print("""# Created make check_names.py to find unit_config_names
# that do not have matching names in names.json
# names.json - Created by make_names_list.py from game data
# Edited by hand to add in missing actors, se
# - $name to reference an existing key
# - raw string to set a value
# Comments are #
""")
for key in sorted(missing.keys()):
val = missing[key]
print(f"{key}, {val}")