Poodletooth-iLand/build/data/NiraiStart.py

73 lines
1.6 KiB
Python
Raw Normal View History

2015-06-04 16:30:23 -05:00
from panda3d.core import *
2015-08-22 22:14:12 -05:00
import __builtin__, os, sys
import aes
2015-06-04 16:30:23 -05:00
import niraidata
# Config
prc = niraidata.CONFIG
iv, key, prc = prc[:16], prc[16:32], prc[32:]
prc = aes.decrypt(prc, key, iv)
2015-06-04 16:30:23 -05:00
for line in prc.split('\n'):
line = line.strip()
if line:
loadPrcFileData('nirai config', line)
2015-06-05 00:05:01 -05:00
2015-06-04 16:30:23 -05:00
del prc
del iv
del key
2015-06-05 00:05:01 -05:00
2015-06-04 16:30:23 -05:00
# DC
__builtin__.dcStream = StringStream()
dc = niraidata.DC
iv, key, dc = dc[:16], dc[16:32], dc[32:]
dc = aes.decrypt(dc, key, iv)
2015-06-04 16:30:23 -05:00
dcStream.setData(dc)
del dc
del iv
del key
2015-06-04 16:30:23 -05:00
# Resources
2015-09-03 19:31:08 -05:00
# TO DO: Sign and verify the phases to prevent editing.
vfs = VirtualFileSystem.getGlobalPtr()
mfs = [3, 3.5, 4, 5, 5.5, 6, 7, 8, 9, 10, 11, 12, 13]
2015-06-04 16:30:23 -05:00
abort = False
2015-09-03 19:31:08 -05:00
for mf in mfs:
filename = 'resources/default/phase_%s.mf' % mf
if not os.path.isfile(filename):
print 'Phase %s not found' % filename
abort = True
break
mf = Multifile()
mf.openRead(filename)
if not vfs.mount(mf, '/', 0):
print 'Unable to mount %s' % filename
abort = True
break
2015-06-04 16:30:23 -05:00
# Packs
pack = os.environ.get('TT_STRIDE_CONTENT_PACK')
2015-08-22 22:14:12 -05:00
import glob
2015-06-04 16:30:23 -05:00
if pack and pack != 'default':
print 'Loading content pack', pack
for file in glob.glob('resources/%s/*.mf' % pack):
mf = Multifile()
mf.openReadWrite(Filename(file))
names = mf.getSubfileNames()
for name in names:
ext = os.path.splitext(name)[1]
2015-08-22 22:14:12 -05:00
if ext not in ['.jpg', '.jpeg', '.ogg', '.rgb']:
2015-06-04 16:30:23 -05:00
mf.removeSubfile(name)
2015-08-22 22:14:12 -05:00
vfs.mount(mf, Filename('/'), 0)
2015-06-05 00:05:01 -05:00
2015-06-04 16:30:23 -05:00
if not abort:
# Run
2015-07-08 07:15:51 -05:00
import toontown.toonbase.ToontownStart