Fix loading

This commit is contained in:
DenialMC 2015-04-04 07:57:23 +03:00
parent acfdd18629
commit 7065e2b06f

View file

@ -12,7 +12,8 @@ from toontown.suit import SuitDNA
from toontown.toon import ToonHeadFrame from toontown.toon import ToonHeadFrame
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownBattleGlobals from toontown.toonbase import ToontownBattleGlobals
import copy, os, re, sys, token, tokenize, QuestScripts, BlinkingArrows from toontown.quest import QuestScripts
import copy, re, tokenize, BlinkingArrows, StringIO
notify = DirectNotifyGlobal.directNotify.newCategory('QuestParser') notify = DirectNotifyGlobal.directNotify.newCategory('QuestParser')
lineDict = {} lineDict = {}
@ -43,11 +44,12 @@ def clear():
def readFile(): def readFile():
global curId global curId
script = StringIO.StringIO(QuestScripts.script)
for line in QuestScripts.script.split('\n'): def readLine():
def readline(): return script.readline().replace('\r', '')
return line
gen = tokenize.generate_tokens(readline) gen = tokenize.generate_tokens(readLine)
line = getLineOfTokens(gen) line = getLineOfTokens(gen)
while line is not None: while line is not None:
@ -57,11 +59,13 @@ def readFile():
if line[0] == 'ID': if line[0] == 'ID':
parseId(line) parseId(line)
elif curId is None: elif curId is None:
notify.error('Every script must begin with an ID') notify.error('A script must begin with an ID')
else: else:
lineDict[curId].append(line) lineDict[curId].append(line)
line = getLineOfTokens(gen) line = getLineOfTokens(gen)
script.close()
def getLineOfTokens(gen): def getLineOfTokens(gen):
tokens = [] tokens = []
nextNeg = 0 nextNeg = 0