From 9d43264adc0e6dc9022ad4756f1e9d8bdccb3bc0 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 12 Aug 2015 14:17:43 +0300 Subject: [PATCH] Friends list bug fix --- .../distributed/ToontownClientRepository.py | 13 ++++------ toontown/friends/FriendsListPanel.py | 6 ++--- toontown/friends/TTSFriendsManagerUD.py | 24 ++++++++++--------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/toontown/distributed/ToontownClientRepository.py b/toontown/distributed/ToontownClientRepository.py index 2a5cdbd8..f2aba06a 100755 --- a/toontown/distributed/ToontownClientRepository.py +++ b/toontown/distributed/ToontownClientRepository.py @@ -637,15 +637,13 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): if doId in self.friendsMap: teleportNotify.debug('friend %s in friendsMap' % doId) return self.friendsMap[doId] - avatar = None if doId in self.doId2do: teleportNotify.debug('found friend %s in doId2do' % doId) - avatar = self.doId2do[doId] + return self.doId2do[doId] elif self.cache.contains(doId): teleportNotify.debug('found friend %s in cache' % doId) - avatar = self.cache.dict[doId] + return self.cache.dict[doId] self.notify.warning("Don't know who friend %s is." % doId) - return def identifyAvatar(self, doId): if doId in self.doId2do: @@ -661,6 +659,7 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): if base.wantPets and base.localAvatar.hasPet(): if base.localAvatar.getPetId() not in self.friendsMap: return 0 + return 1 def removeFriend(self, avatarId): @@ -736,16 +735,14 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): def handleFriendOnline(self, doId): self.notify.debug('Friend %d now online.' % doId) if doId not in self.friendsOnline: - self.friendsOnline[doId] = self.identifyFriend(doId) + self.friendsOnline[doId] = self.identifyAvatar(doId) messenger.send('friendOnline', [doId]) def handleFriendOffline(self, doId): self.notify.debug('Friend %d now offline.' % doId) - try: + if doId in self.friendsOnline: del self.friendsOnline[doId] messenger.send('friendOffline', [doId]) - except: - pass def handleGenerateWithRequiredOtherOwner(self, di): # Toontown only makes use of OwnerViews for LocalToon. diff --git a/toontown/friends/FriendsListPanel.py b/toontown/friends/FriendsListPanel.py index af2ff4e6..de38fe38 100755 --- a/toontown/friends/FriendsListPanel.py +++ b/toontown/friends/FriendsListPanel.py @@ -6,6 +6,7 @@ from toontown.friends import ToontownFriendSecret from toontown.toonbase import ToontownGlobals from toontown.toonbase import TTLocalizer from otp.nametag.NametagGroup import * +from otp.nametag.NametagConstants import * from otp.otpbase import OTPGlobals FLPPets = 1 FLPOnline = 2 @@ -241,7 +242,6 @@ class FriendsListPanel(DirectFrame, StateData.StateData): def __updateScrollList(self): petFriends = [] - admins = [] trueFriends = [] friends = [] @@ -257,9 +257,7 @@ class FriendsListPanel(DirectFrame, StateData.StateData): base.cr.fillUpFriendsMap() return - if handle.isAdmin(): - admins.insert(0, friendId) - elif base.localAvatar.isTrueFriends(friendId): + if base.localAvatar.isTrueFriends(friendId): trueFriends.insert(0, friendId) else: friends.insert(0, friendId) diff --git a/toontown/friends/TTSFriendsManagerUD.py b/toontown/friends/TTSFriendsManagerUD.py index 36e1bffc..bd78350c 100755 --- a/toontown/friends/TTSFriendsManagerUD.py +++ b/toontown/friends/TTSFriendsManagerUD.py @@ -65,7 +65,6 @@ class FriendsListOperation(OperationFSM): self.demand('Error', 'Friend was not a Toon') return friendId = self.friendsList[self.friendIndex] - self.realFriendsList.append([friendId, fields['setName'][0], fields['setDNAString'][0], fields['setAdminAccess'][0], fields['setPetId'][0]]) @@ -98,8 +97,10 @@ class RemoveFriendOperation(OperationFSM): self.demand('Retrieved', fields['setFriendsList'][0], fields['setTrueFriends'][0]) def enterRetrieved(self, friendsList, trueFriendsList): - friendsList.remove(self.target) - trueFriendsList.remove(self.target) + if self.target in friendsList: + friendsList.remove(self.target) + if self.target in trueFriendsList: + trueFriendsList.remove(self.target) if self.sender in self.mgr.onlineToons: dg = self.air.dclassesByName['DistributedToonUD'].aiFormatUpdate( 'setFriendsList', self.sender, self.sender, @@ -115,7 +116,7 @@ class RemoveFriendOperation(OperationFSM): self.air.dbInterface.updateObject(self.air.dbId, self.sender, self.air.dclassesByName['DistributedToonUD'], - {'setFriendsList' : [friendsList], 'setTrueFriends' : [trueFriendsList]}) + {'setFriendsList' : [friendsList], 'setTrueFriends': [trueFriendsList]}) self.demand('Off') # -- Clear List -- @@ -201,7 +202,7 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD): self.sendUpdateToAvatarId(senderId, 'friendDetails', [avId, inventory, trackAccess, trophies, hp, maxHp, defaultShard, lastHood, dnaString, experience, trackBonusLevel]) self.air.dbInterface.queryObject(self.air.dbId, avId, handleToon) - + def getPetDetails(self, avId): senderId = self.air.getAvatarIdFromSender() def handlePet(dclass, fields): @@ -235,9 +236,10 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD): self.air.send(dg) for friend in friendsList: - if friend[0] in self.onlineToons: - self.sendUpdateToAvatarId(doId, 'friendOnline', [friend[0]]) - self.sendUpdateToAvatarId(friend[0], 'friendOnline', [doId]) + friendId = friend[0] + if friendId in self.onlineToons: + self.sendUpdateToAvatarId(doId, 'friendOnline', [friendId]) + self.sendUpdateToAvatarId(friendId, 'friendOnline', [doId]) def goingOffline(self, avId): self.toonOffline(avId) @@ -249,9 +251,9 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD): if dclass != self.air.dclassesByName['DistributedToonUD']: return friendsList = fields['setFriendsList'][0] - for friendId in friendsList: - if friendId in self.onlineToons: - self.sendUpdateToAvatarId(friendId, 'friendOffline', [doId]) + for friend in friendsList: + if friend in self.onlineToons: + self.sendUpdateToAvatarId(friend, 'friendOffline', [doId]) if doId in self.onlineToons: self.onlineToons.remove(doId) if doId in self.toon2data: