From 7cb50fc828e1ba77c7036ae218994ef5137b7590 Mon Sep 17 00:00:00 2001 From: Loudrob Date: Sat, 18 Jul 2015 12:57:36 -0400 Subject: [PATCH] Mongo --- toontown/distributed/ToontownInternalRepository.py | 9 +++++++++ toontown/pets/PetManagerAI.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/toontown/distributed/ToontownInternalRepository.py b/toontown/distributed/ToontownInternalRepository.py index 3bf1b399..8a083f4b 100755 --- a/toontown/distributed/ToontownInternalRepository.py +++ b/toontown/distributed/ToontownInternalRepository.py @@ -17,6 +17,15 @@ class ToontownInternalRepository(AstronInternalRepository): def handleConnected(self): self.__messenger = ToontownNetMessengerAI(self) + if config.GetBool('want-mongo', False): + import pymongo + self.dbConn = pymongo.MongoClient(config.GetString('mongodb-url', 'localhost')) + self.dbGlobalCursor = self.dbConn.toontownstride + self.dbCursor = self.dbGlobalCursor['air-%d' % self.ourChannel] + else: + self.dbConn = None + self.dbGlobalCursor = None + self.dbCursor = None def sendNetEvent(self, message, sentArgs=[]): self.__messenger.send(message, sentArgs) diff --git a/toontown/pets/PetManagerAI.py b/toontown/pets/PetManagerAI.py index 1e1f081f..a7128304 100755 --- a/toontown/pets/PetManagerAI.py +++ b/toontown/pets/PetManagerAI.py @@ -28,11 +28,11 @@ class PetManagerAI: self.seeds['day'] = getDayId() - def getAvailablePets(self, seed, safezoneId): + def getAvailablePets(self, safezoneId): if self.seeds.get('day', -1) != getDayId(): self.generateSeeds() - return list(set(self.seeds.get(safezoneId, [seed]))) + return list(set(self.seeds.get(safezoneId, [random.randint(0, 255)]))) def createNewPetFromSeed(self, avId, seed, nameIndex, gender, safeZoneId): av = self.air.doId2do[avId]