2015-06-04 16:30:23 -05:00
|
|
|
from panda3d.core import *
|
|
|
|
import __builtin__, os
|
|
|
|
import rc4
|
|
|
|
|
|
|
|
import niraidata
|
|
|
|
|
|
|
|
# Config
|
|
|
|
prc = niraidata.CONFIG
|
|
|
|
key, prc = prc[:32], prc[32:]
|
|
|
|
rc4.rc4_setkey(key)
|
|
|
|
prc = rc4.rc4(prc)
|
|
|
|
|
|
|
|
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
|
2015-06-05 00:05:01 -05:00
|
|
|
|
2015-06-04 16:30:23 -05:00
|
|
|
# DC
|
|
|
|
__builtin__.dcStream = StringStream()
|
|
|
|
|
|
|
|
dc = niraidata.DC
|
|
|
|
key, dc = dc[:32], dc[32:]
|
|
|
|
rc4.rc4_setkey(key)
|
|
|
|
dc = rc4.rc4(dc)
|
|
|
|
|
|
|
|
dcStream.setData(dc)
|
|
|
|
del dc
|
|
|
|
rc4.rc4_setkey('\0\0\0\0')
|
|
|
|
|
|
|
|
# Resources
|
2015-06-05 22:15:38 -05:00
|
|
|
# TO DO: Sign and verify the phases to prevent editing.
|
2015-06-04 16:30:23 -05:00
|
|
|
|
|
|
|
vfs = VirtualFileSystem.getGlobalPtr()
|
|
|
|
mfs = (3, 3.5, 4, 5, 5.5, 6, 7, 8, 9, 10, 11, 12, 13)
|
|
|
|
abort = False
|
|
|
|
|
|
|
|
for mf in mfs:
|
|
|
|
filename = 'resources/default/phase_%s.mf' % mf
|
|
|
|
if not os.path.isfile(filename):
|
2015-06-05 00:05:01 -05:00
|
|
|
print 'Phase %s not found' % filename
|
2015-06-04 16:30:23 -05:00
|
|
|
abort = True
|
|
|
|
break
|
2015-06-05 00:05:01 -05:00
|
|
|
|
2015-06-04 16:30:23 -05:00
|
|
|
mf = Multifile()
|
|
|
|
mf.openRead(filename)
|
2015-06-05 00:05:01 -05:00
|
|
|
|
2015-06-04 16:30:23 -05:00
|
|
|
if not vfs.mount(mf, '../resources', 0):
|
|
|
|
print 'Unable to mount %s' % filename
|
|
|
|
abort = True
|
|
|
|
break
|
2015-06-05 00:05:01 -05:00
|
|
|
|
2015-06-04 16:30:23 -05:00
|
|
|
# Packs
|
|
|
|
pack = os.environ.get('TT_STRIDE_CONTENT_PACK')
|
|
|
|
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]
|
|
|
|
if ext not in ('.jpg', '.jpeg', '.ogg', '.rgb'):
|
|
|
|
mf.removeSubfile(name)
|
2015-06-05 00:05:01 -05:00
|
|
|
|
2015-06-04 16:30:23 -05:00
|
|
|
mf.flush()
|
2015-06-05 00:05:01 -05:00
|
|
|
|
2015-06-04 16:30:23 -05:00
|
|
|
if not vfs.mount(mf, '../resources', 0):
|
|
|
|
print 'Unable to mount %s' % filename
|
|
|
|
abort = True
|
|
|
|
break
|
2015-06-05 00:05:01 -05:00
|
|
|
|
2015-06-04 16:30:23 -05:00
|
|
|
if not abort:
|
|
|
|
# Run
|
|
|
|
import toontown.toonbase.ClientStart
|