src = open('original.html').read().split('\n')
head = src[:95]
geo = open('geo.js').read().rstrip('\n').split('\n')
mid1 = src[156:344]
city = open('city.js').read().rstrip('\n').split('\n')
rest = src[796:]
out = '\n'.join(head + geo + mid1 + city + rest)
tex = open('tex.js').read().rstrip('\n')
old = " g.generateTexture('blob', 64, 32); g.clear();\n}"
assert old in out, "anchor missing"
out = out.replace(old, tex, 1)
open('new.html', 'w').write(out)
print("len(out) chars:", len(out), " (objetivo 1399419)")
lines = out.split('\n')
for i, l in enumerate(lines, 1):
    if l.startswith('const WORLD_W') or l.startswith('let S = null') or l.startswith('/* ===================== Ciudad') or l.startswith('function buildCity'):
        print(i, l[:60])
