From 071d59f4d08f85d16370161cc18b132bfd93a7f0 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 18 Jul 2015 11:21:53 +0300 Subject: [PATCH] Leaderboard fix + ~race finish magic word --- toontown/racing/DistributedRace.py | 14 +++++++++----- toontown/racing/LeaderboardMgrAI.py | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/toontown/racing/DistributedRace.py b/toontown/racing/DistributedRace.py index 000069d5..7293057e 100755 --- a/toontown/racing/DistributedRace.py +++ b/toontown/racing/DistributedRace.py @@ -74,6 +74,7 @@ class DistributedRace(DistributedObject.DistributedObject): self.bananaSound = base.loadSfx('phase_6/audio/sfx/KART_tossBanana.ogg') self.anvilFall = base.loadSfx('phase_6/audio/sfx/KART_Gag_Hit_Anvil.ogg') self.accept('leaveRace', self.leaveRace) + self.accept('finishRace', self.finishRace) self.toonsToLink = [] self.curveTs = [] self.curvePoints = [] @@ -569,11 +570,7 @@ class DistributedRace(DistributedObject.DistributedObject): now = globalClock.getFrameTime() timestamp = globalClockDelta.localToNetworkTime(now) if self.laps == self.lapCount: - self.sendUpdate('heresMyT', [localAvatar.doId, - self.laps, - self.currLapT, - timestamp]) - self.fsm.request('finished') + self.finishRace() if self.laps > self.maxLap: self.maxLap = self.laps self.sendUpdate('heresMyT', [localAvatar.doId, @@ -1088,6 +1085,10 @@ class DistributedRace(DistributedObject.DistributedObject): def leaveRace(self): self.fsm.request('leave') + + def finishRace(self): + self.sendUpdate('heresMyT', [localAvatar.doId, self.lapCount, self.currLapT, globalClockDelta.localToNetworkTime(globalClock.getFrameTime())]) + self.fsm.request('finished') def racerLeft(self, avId): if avId != localAvatar.doId: @@ -1243,4 +1244,7 @@ def race(command): if command == 'leave': messenger.send('leaveRace') return 'You left the race!' + elif command == 'finish': + messenger.send('finishRace') + return 'You finished the race!' return 'Invalid command!' diff --git a/toontown/racing/LeaderboardMgrAI.py b/toontown/racing/LeaderboardMgrAI.py index aebbd059..682dac40 100644 --- a/toontown/racing/LeaderboardMgrAI.py +++ b/toontown/racing/LeaderboardMgrAI.py @@ -31,14 +31,14 @@ class LeaderboardMgrAI: originalRace = self.database[race][1] newRace = list(originalRace) - newRace.append((name, timestamp)) + newRace.append([name, timestamp]) sortedRace = self.trimList(sorted(newRace, key=operator.itemgetter(1))) if originalRace != sortedRace: self.database[race][1] = sortedRace self.saveDatabase() else: - self.database[race] = (time.time(), [(name, timestamp)]) + self.database[race] = [time.time(), [(name, timestamp)]] self.saveDatabase() @magicWord(category=CATEGORY_PROGRAMMER, types=[str, int, int, str, int])