Revert "Revert "general: Use VFS to resolve paths to resources in dev environments; simplifies dev-prod parity.""

This reverts commit 90cac26612.
This commit is contained in:
Joey Z 2014-05-10 02:57:42 -04:00
parent 9b9933f168
commit 786a97f7db
11 changed files with 29 additions and 34 deletions

View file

@ -10,7 +10,8 @@ want-dev #f
# Resource settings
model-path resources
vfs-mount resources /
model-path /
default-model-extension .bam
# Server settings
@ -43,4 +44,4 @@ show-total-population #f
# Holidays and Events
force-holiday-decorations 6
force-holiday-decorations 6

View file

@ -24,3 +24,12 @@ if not __debug__ and __dev__:
notify = directNotify.newCategory('ShowBaseGlobal')
notify.error("You must set 'want-dev' to false in non-debug mode.")
taskMgr.finalInit()
# The VirtualFileSystem, which has already initialized, doesn't see the mount
# directives in the config(s) yet. We have to force it to load those manually:
from panda3d.core import VirtualFileSystem, ConfigVariableList, Filename
vfs = VirtualFileSystem.getGlobalPtr()
mounts = ConfigVariableList('vfs-mount')
for mount in mounts:
mountfile, mountpoint = (mount.split(' ', 2) + [None, None, None])[:2]
vfs.mount(Filename(mountfile), Filename(mountpoint), 0)

View file

@ -15,6 +15,7 @@ from direct.distributed.PyDatagram import *
from otp.ai.AIZoneData import *
from toontown.dna import DNAParser
from toontown.dna.DNASpawnerAI import DNASpawnerAI
from direct.stdpy.file import open
# Friends!
from otp.friends.FriendManagerAI import FriendManagerAI
@ -210,7 +211,7 @@ class ToontownAIRepository(ToontownInternalRepository):
return 'phase_%s/dna/%s_%s.xml' % (phase, hood, zoneId)
def loadDNA(self, filename):
with open('resources/' + filename) as f:
with open('/' + filename) as f:
tree = DNAParser.parse(f)
return tree

View file

@ -19,16 +19,10 @@ class BattleSounds:
def setupSearchPath(self):
self.sfxSearchPath = DSearchPath()
if __debug__:
self.sfxSearchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('resources/phase_3/audio/sfx')))
self.sfxSearchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('resources/phase_3.5/audio/sfx')))
self.sfxSearchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('resources/phase_4/audio/sfx')))
self.sfxSearchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('resources/phase_5/audio/sfx')))
else:
self.sfxSearchPath.appendDirectory(Filename('/phase_3/audio/sfx'))
self.sfxSearchPath.appendDirectory(Filename('/phase_3.5/audio/sfx'))
self.sfxSearchPath.appendDirectory(Filename('/phase_4/audio/sfx'))
self.sfxSearchPath.appendDirectory(Filename('/phase_5/audio/sfx'))
self.sfxSearchPath.appendDirectory(Filename('/phase_3/audio/sfx'))
self.sfxSearchPath.appendDirectory(Filename('/phase_3.5/audio/sfx'))
self.sfxSearchPath.appendDirectory(Filename('/phase_4/audio/sfx'))
self.sfxSearchPath.appendDirectory(Filename('/phase_5/audio/sfx'))
def clear(self):
if self.isValid:

View file

@ -24,8 +24,6 @@ class TTWhiteList(WhiteList, DistributedObject.DistributedObject):
filename = Filename('twhitelist.dat')
searchPath = DSearchPath()
searchPath.appendDirectory(Filename('/phase_4/etc'))
if __debug__:
searchPath.appendDirectory(Filename('resources/phase_4/etc'))
found = vfs.resolveFilename(filename, searchPath)
if not found:
self.notify.info("Couldn't find whitelist data file!")

View file

@ -38,8 +38,6 @@ class NameGenerator:
self.lastSuffixes = []
self.nameDictionary = {}
searchPath = DSearchPath()
if __debug__:
searchPath.appendDirectory(Filename('resources/phase_3/etc'))
searchPath.appendDirectory(Filename('/phase_3/etc'))
filename = Filename(TTLocalizer.NameShopNameMaster)
found = vfs.resolveFilename(filename, searchPath)

View file

@ -1068,8 +1068,6 @@ class NPCMoviePlayer(DirectObject.DirectObject):
searchPath = DSearchPath()
if __debug__:
searchPath.appendDirectory(Filename('resources/phase_3/etc'))
searchPath.appendDirectory(Filename('/phase_3/etc'))
scriptFile = Filename('QuestScripts.txt')
found = vfs.resolveFilename(scriptFile, searchPath)

View file

@ -16,15 +16,6 @@ from panda3d.core import loadPrcFileData
for i,config in enumerate(_miraidata.CONFIG):
loadPrcFileData('Mirai Packaged Config Page #%d' % i, config)
# The VirtualFileSystem, which has already initialized, doesn't see the mount
# directives in the config(s) yet. We have to force it to load those manually:
from panda3d.core import VirtualFileSystem, ConfigVariableList, Filename
vfs = VirtualFileSystem.getGlobalPtr()
mounts = ConfigVariableList('vfs-mount')
for mount in mounts:
mountfile, mountpoint = (mount.split(' ', 2) + [None, None, None])[:2]
vfs.mount(Filename(mountfile), Filename(mountpoint), 0)
# DC data is a little bit trickier... The stock ConnectionRepository likes to
# read DC from filenames only. DCFile does let us read in istreams, but there's
# really no way to pass the istream off through ConnectionRepository. We can stick

View file

@ -202,8 +202,6 @@ class ToonBase(OTPBase.OTPBase):
vfs = VirtualFileSystem.getGlobalPtr()
searchPath = DSearchPath()
if __debug__:
searchPath.appendDirectory(Filename('resources/phase_3/etc'))
searchPath.appendDirectory(Filename('/phase_3/etc'))
for filename in ['toonmono.cur', 'icon.ico']:

View file

@ -21,10 +21,7 @@ class ToontownLoader(Loader.Loader):
Loader.Loader.destroy(self)
def loadDNA(self, filename):
if __debug__:
filename = 'resources/' + filename
else:
filename = '/' + filename
filename = '/' + filename
with open(filename, 'r') as f:
tree = DNAParser.parse(f)

View file

@ -6,6 +6,16 @@ if __debug__:
# (and it will, in fact, remove entire if __debug__: sections)
loadPrcFile('config/dev.prc')
# The VirtualFileSystem, which has already initialized, doesn't see the mount
# directives in the config(s) yet. We have to force it to load those manually:
from panda3d.core import VirtualFileSystem, ConfigVariableList, Filename
vfs = VirtualFileSystem.getGlobalPtr()
mounts = ConfigVariableList('vfs-mount')
for mount in mounts:
mountfile, mountpoint = (mount.split(' ', 2) + [None, None, None])[:2]
vfs.mount(Filename(mountfile), Filename(mountpoint), 0)
class game:
name = 'toontown'
process = 'client'