diff --git a/.gitignore b/.gitignore index 37321f8..bbd3cb3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ whitelist/ *.jpg .idea *.buildings +*.trackRecords diff --git a/toontown/racing/DistributedLeaderBoardAI.py b/toontown/racing/DistributedLeaderBoardAI.py index 206c2bc..b17e9f5 100644 --- a/toontown/racing/DistributedLeaderBoardAI.py +++ b/toontown/racing/DistributedLeaderBoardAI.py @@ -35,7 +35,11 @@ class DistributedLeaderBoardAI(DistributedObjectAI): self.subscriptions.append(subscription) def handleUpdateRaceRecord(self, record): - self.notify.info('handleUpdateRaceRecord TODO') + trackId, period = record + if trackId not in self.records: + return + + self.records[trackId][period] = [(x[0], x[3]) for x in self.air.raceMgr.getRecords(trackId, period)] def updateDisplay(self): self.currentIndex += 1 diff --git a/toontown/racing/RaceManagerAI.py b/toontown/racing/RaceManagerAI.py index 46b30c6..3626432 100644 --- a/toontown/racing/RaceManagerAI.py +++ b/toontown/racing/RaceManagerAI.py @@ -323,7 +323,7 @@ class RaceManagerAI(DirectObject.DirectObject): self.notify.debug('trophies %s' % trophies) self.notify.debug('GrandTouring: already has grand touring %s' % trophies[RaceGlobals.GrandTouring]) for i in range(1, RaceGlobals.NumTrophies // RaceGlobals.TrophiesPerCup + 1): - cupNum = (trophies[:RaceGlobals.NumTrophies].count(1) + addTrophyCount) / (i * RaceGlobals.TrophiesPerCup) + cupNum = (trophies[:RaceGlobals.NumTrophies].count(1) + addTrophyCount) // (i * RaceGlobals.TrophiesPerCup) self.notify.debug('cupNum: %s' % cupNum) trophyIndex = RaceGlobals.TrophyCups[i - 1] if cupNum and not trophies[trophyIndex]: @@ -545,8 +545,8 @@ class RaceManagerAI(DirectObject.DirectObject): newTrophies.append(totalTrophyIndex) self.air.writeServerEvent('kartingTrophy', avId, '%s' % totalTrophyIndex) self.notify.debug('trophy: ' + TTLocalizer.KartTrophyDescriptions[totalTrophyIndex]) - for i in range(1, RaceGlobals.NumTrophies / RaceGlobals.TrophiesPerCup + 1): - cupNum = trophies[:RaceGlobals.NumTrophies].count(1) / (i * RaceGlobals.TrophiesPerCup) + for i in range(1, RaceGlobals.NumTrophies // RaceGlobals.TrophiesPerCup + 1): + cupNum = trophies[:RaceGlobals.NumTrophies].count(1) // (i * RaceGlobals.TrophiesPerCup) self.notify.debug('cupNum: %s' % cupNum) trophyIndex = RaceGlobals.TrophyCups[i - 1] if cupNum and not trophies[trophyIndex]: @@ -610,7 +610,7 @@ class RaceManagerAI(DirectObject.DirectObject): backup = self.filename + '.bu' if os.path.exists(self.filename): os.rename(self.filename, backup) - file = open(self.filename, 'w') + file = open(self.filename, 'wb') file.seek(0) pickle.dump(self.trackRecords, file) file.close() @@ -624,12 +624,12 @@ class RaceManagerAI(DirectObject.DirectObject): def loadRecords(self): try: - file = open(self.filename + '.bu', 'r') + file = open(self.filename + '.bu', 'rb') if os.path.exists(self.filename): os.remove(self.filename) except IOError: try: - file = open(self.filename, 'r') + file = open(self.filename, 'rb') except IOError: return self.getRecordTimes()