From 338d83a907d31c9a490fc89a13da078137be1eee Mon Sep 17 00:00:00 2001 From: John Date: Sun, 31 May 2015 14:12:48 +0300 Subject: [PATCH] DANIEL: Friends cleanup --- dependencies/astron/dclass/stride.dc | 7 +- otp/avatar/Avatar.py | 2 +- otp/avatar/DistributedPlayerAI.py | 12 +- otp/distributed/OTPClientRepository.py | 13 +- otp/friends/FriendManagerAI.py | 4 +- otp/otpbase/OTPGlobals.py | 2 - toontown/chat/TTChatInputWhiteList.py | 4 +- .../distributed/ToontownClientRepository.py | 34 +--- toontown/estate/ToonStatueSelectionGUI.py | 8 +- toontown/friends/FriendHandle.py | 2 +- toontown/friends/FriendsListPanel.py | 173 +++++------------- toontown/friends/TTSFriendsManagerUD.py | 40 ++-- toontown/nametag/NametagGlobals.py | 2 +- toontown/parties/PartyPlanner.py | 5 +- toontown/parties/ScrolledFriendList.py | 5 +- toontown/toon/AvatarPanelBase.py | 3 +- toontown/toon/DistributedToon.py | 14 ++ toontown/toon/DistributedToonAI.py | 26 ++- toontown/toon/DistributedToonUD.py | 3 + toontown/town/TownBattleSOSPanel.py | 48 ++--- 20 files changed, 149 insertions(+), 258 deletions(-) diff --git a/dependencies/astron/dclass/stride.dc b/dependencies/astron/dclass/stride.dc index 325c9520..83348f6f 100644 --- a/dependencies/astron/dclass/stride.dc +++ b/dependencies/astron/dclass/stride.dc @@ -150,7 +150,7 @@ dclass DistributedPlayer : DistributedAvatar { setSystemMessage(DoId aboutId, string(0-256) chatString) ownrecv; setSC(uint16 msgIndex) broadcast ownsend airecv; setSCCustom(uint16 msgIndex) broadcast ownsend airecv; - setFriendsList(FriendEntry[] = []) ownrecv required db airecv; + setFriendsList(uint32[] = []) ownrecv required db airecv; setDISLid(uint32 = 0) broadcast ownrecv ram db airecv required; WishName(string = "") db ram; WishNameState(string = "OPEN") db ram; @@ -630,8 +630,8 @@ dclass DistributedToon : DistributedPlayer { takeDamage(uint16) broadcast ownrecv; setBattleId(uint32 = 0) required broadcast ram; setExperience(blob = [0*14]) required broadcast db; - setIgnored(uint32[]) required clsend airecv ownrecv db; - setReported(uint32[]) required ownrecv db; + setIgnored(uint32[] = []) required clsend airecv ownrecv db; + setReported(uint32[] = []) required ownrecv db; setMaxCarry(uint8 = 20) required ownrecv db; setTrackAccess(uint16[] = [0,0,0,0,1,1,0]) required broadcast ownrecv db; setTrackProgress(int8 = -1, uint32 = 0) required ownrecv db; @@ -798,6 +798,7 @@ dclass DistributedToon : DistributedPlayer { setBuffs(uint32[] = []) required ownrecv db; setRedeemedCodes(string [] = []) required ownrecv db; setEmblems(uint32[] = [0, 0]) required ownrecv db; + setTrueFriends(uint32[] = []) required clsend ownrecv db; }; dclass DistributedPartyGate : DistributedObject { diff --git a/otp/avatar/Avatar.py b/otp/avatar/Avatar.py index ea465fe7..a306fb7f 100755 --- a/otp/avatar/Avatar.py +++ b/otp/avatar/Avatar.py @@ -144,7 +144,7 @@ class Avatar(Actor, ShadowCaster): elif self.playerType not in (NametagGlobals.CCNormal, NametagGlobals.CCSpeedChat): self.understandable = 1 self.setPlayerType(NametagGlobals.CCNonPlayer) - elif settings['trueFriends'] and base.cr.getFriendFlags(self.doId) & OTPGlobals.FriendChat: + elif settings['trueFriends'] and base.localAvatar.isTrueFriends(self.doId): self.understandable = 2 self.setPlayerType(NametagGlobals.CCNormal) elif settings['speedchatPlus']: diff --git a/otp/avatar/DistributedPlayerAI.py b/otp/avatar/DistributedPlayerAI.py index 01eaa6e9..237c021b 100755 --- a/otp/avatar/DistributedPlayerAI.py +++ b/otp/avatar/DistributedPlayerAI.py @@ -105,15 +105,11 @@ class DistributedPlayerAI(DistributedAvatarAI.DistributedAvatarAI, PlayerBase.Pl def getAdminAccess(self): return self.adminAccess - def extendFriendsList(self, friendId, friendCode): - for i in xrange(len(self.friendsList)): - friendPair = self.friendsList[i] - if friendPair[0] == friendId: - self.friendsList[i] = (friendId, friendCode) - return - - self.friendsList.append((friendId, friendCode)) + def extendFriendsList(self, friendId): + if friendId in self.friendsList: + return + self.friendsList.append(friendId) @magicWord(category=CATEGORY_SYSTEM_ADMINISTRATOR, types=[str]) def system(message): diff --git a/otp/distributed/OTPClientRepository.py b/otp/distributed/OTPClientRepository.py index 517fec6e..d48267db 100755 --- a/otp/distributed/OTPClientRepository.py +++ b/otp/distributed/OTPClientRepository.py @@ -1252,9 +1252,6 @@ class OTPClientRepository(ClientRepositoryBase): @exceptionLogged(append=False) def handleDatagram(self, di): - if self.notify.getDebug(): - print 'ClientRepository received datagram:' - di.getDatagram().dumpHex(ostream) msgType = self.getMsgType() if msgType == 65535: self.lostConnection() @@ -1266,9 +1263,6 @@ class OTPClientRepository(ClientRepositoryBase): self.considerHeartbeat() return - def askAvatarKnown(self, avId): - return 0 - def queueRequestAvatarInfo(self, avId): pass @@ -1277,11 +1271,8 @@ class OTPClientRepository(ClientRepositoryBase): def identifyAvatar(self, doId): info = self.doId2do.get(doId) - if info: - return info - else: - info = self.identifyFriend(doId) - return info + + return info if info else self.identifyFriend(doId) def sendDisconnect(self): if self.isConnected(): diff --git a/otp/friends/FriendManagerAI.py b/otp/friends/FriendManagerAI.py index 396897db..6d08a8df 100755 --- a/otp/friends/FriendManagerAI.py +++ b/otp/friends/FriendManagerAI.py @@ -95,8 +95,8 @@ class FriendManagerAI(DistributedObjectAI): del self.requests[context] return - requested.extendFriendsList(requester.getDoId(), 0) - requester.extendFriendsList(requested.getDoId(), 0) + requested.extendFriendsList(requester.getDoId()) + requester.extendFriendsList(requested.getDoId()) requested.d_setFriendsList(requested.getFriendsList()) requester.d_setFriendsList(requester.getFriendsList()) diff --git a/otp/otpbase/OTPGlobals.py b/otp/otpbase/OTPGlobals.py index 47d91ab6..a499449b 100755 --- a/otp/otpbase/OTPGlobals.py +++ b/otp/otpbase/OTPGlobals.py @@ -18,8 +18,6 @@ AICollisionPriority = 10 AICollMovePriority = 8 MaxFriends = 200 MaxBackCatalog = 48 -FriendChat = 1 -SuperChat = 2 MaxCustomMessages = 25 SPInvalid = 0 SPHidden = 1 diff --git a/toontown/chat/TTChatInputWhiteList.py b/toontown/chat/TTChatInputWhiteList.py index a52ab904..34775b7b 100755 --- a/toontown/chat/TTChatInputWhiteList.py +++ b/toontown/chat/TTChatInputWhiteList.py @@ -101,8 +101,8 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame): def sendChatByData(self, text): if self.trueFriendChat: - for friendId, flags in base.localAvatar.friendsList: - if flags & ToontownGlobals.FriendChat: + for friendId in base.localAvatar.friendsList: + if base.localAvatar.isTrueFriends(friendId): self.sendWhisperByFriend(friendId, text) elif self.receiverId: base.talkAssistant.sendWhisperTalk(text, self.receiverId) diff --git a/toontown/distributed/ToontownClientRepository.py b/toontown/distributed/ToontownClientRepository.py index 1f1b36ea..080348df 100755 --- a/toontown/distributed/ToontownClientRepository.py +++ b/toontown/distributed/ToontownClientRepository.py @@ -628,25 +628,9 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): return 0 def isFriend(self, doId): - for friendId, flags in base.localAvatar.friendsList: - if friendId == doId: - self.identifyFriend(doId) - return 1 - - return 0 - - def isAvatarFriend(self, doId): - for friendId, flags in base.localAvatar.friendsList: - if friendId == doId: - self.identifyFriend(doId) - return 1 - - return 0 - - def getFriendFlags(self, doId): - for friendId, flags in base.localAvatar.friendsList: - if friendId == doId: - return flags + if doId in base.localAvatar.friendsList: + self.identifyFriend(doId) + return 1 return 0 @@ -694,7 +678,7 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): return self.identifyFriend(doId) def isFriendsMapComplete(self): - for friendId, flags in base.localAvatar.friendsList: + for friendId in base.localAvatar.friendsList: if self.identifyFriend(friendId) == None: return 0 @@ -749,7 +733,6 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): PetDetail.PetDetail(doId, petDetailsCallback) def handleGetFriendsList(self, resp): - print len(resp) for toon in resp: doId = toon[0] name = toon[1] @@ -980,15 +963,6 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): if obj.parentId == localAvatar.defaultShard and obj is not localAvatar: self.deleteObject(doId) - def askAvatarKnown(self, avId): - if not hasattr(base, 'localAvatar'): - return 0 - for friendPair in base.localAvatar.friendsList: - if friendPair[0] == avId: - return 1 - - return 0 - def requestAvatarInfo(self, avId): if avId == 0: return diff --git a/toontown/estate/ToonStatueSelectionGUI.py b/toontown/estate/ToonStatueSelectionGUI.py index 49c6de85..5006a5fe 100755 --- a/toontown/estate/ToonStatueSelectionGUI.py +++ b/toontown/estate/ToonStatueSelectionGUI.py @@ -105,15 +105,11 @@ class ToonStatueSelectionGUI(DirectFrame): newFF = (familyMember.id, familyMember.name, NametagGlobals.CCNonPlayer) self.ffList.append(newFF) - for friendPair in base.localAvatar.friendsList: - friendId, flags = friendPair + for friendId in base.localAvatar.friendsList: handle = base.cr.identifyFriend(friendId) if handle and not self.checkFamily(friendId): if hasattr(handle, 'getName'): - colorCode = NametagGlobals.CCSpeedChat - if flags & ToontownGlobals.FriendChat: - colorCode = NametagGlobals.CCNormal - newFF = (friendPair[0], handle.getName(), colorCode) + newFF = (friendId, handle.getName(), NametagGlobals.getFriendColor(friendId)) self.ffList.append(newFF) else: self.notify.warning('Bad Handle for getName in makeFFlist') diff --git a/toontown/friends/FriendHandle.py b/toontown/friends/FriendHandle.py index 34e17872..64fdbc21 100755 --- a/toontown/friends/FriendHandle.py +++ b/toontown/friends/FriendHandle.py @@ -62,6 +62,6 @@ class FriendHandle: def isUnderstandable(self): if settings['speedchatPlus']: return 1 - elif settings['trueFriends'] and base.cr.getFriendFlags(self.doId) & ToontownGlobals.FriendChat: + elif settings['trueFriends'] and base.localAvatar.isTrueFriends(self.doId): return 1 return 0 diff --git a/toontown/friends/FriendsListPanel.py b/toontown/friends/FriendsListPanel.py index cf8bc5ea..22ed8b41 100755 --- a/toontown/friends/FriendsListPanel.py +++ b/toontown/friends/FriendsListPanel.py @@ -5,19 +5,17 @@ from direct.fsm import StateData from toontown.toon import ToonAvatarPanel from toontown.toonbase import ToontownGlobals from toontown.toonbase import TTLocalizer +from toontown.nametag.NametagGlobals import * from otp.otpbase import OTPGlobals FLPPets = 1 FLPOnline = 2 FLPAll = 3 globalFriendsList = None -def determineFriendName(friendTuple): - if len(friendTuple) < 0: - return None - - handle = base.cr.identifyFriend(friendTuple[0]) - return handle.getName() if handle else None +def determineFriendName(friendId): + handle = base.cr.identifyFriend(friendId) + return handle.getName() if handle else '' def compareFriends(f1, f2): name1 = determineFriendName(f1) @@ -29,7 +27,6 @@ def compareFriends(f1, f2): else: return -1 - def showFriendsList(): global globalFriendsList if globalFriendsList == None: @@ -37,13 +34,11 @@ def showFriendsList(): globalFriendsList.enter() return - def hideFriendsList(): if globalFriendsList != None: globalFriendsList.exit() return - def showFriendsListTutorial(): global globalFriendsList if globalFriendsList == None: @@ -53,7 +48,6 @@ def showFriendsListTutorial(): globalFriendsList.close['command'] = None return - def hideFriendsListTutorial(): if globalFriendsList != None: if hasattr(globalFriendsList, 'closeCommand'): @@ -61,13 +55,11 @@ def hideFriendsListTutorial(): globalFriendsList.exit() return - def isFriendsListShown(): if globalFriendsList != None: return globalFriendsList.isEntered return 0 - def unloadFriendsList(): global globalFriendsList if globalFriendsList != None: @@ -75,7 +67,6 @@ def unloadFriendsList(): globalFriendsList = None return - class FriendsListPanel(DirectFrame, StateData.StateData): def __init__(self): @@ -156,32 +147,14 @@ class FriendsListPanel(DirectFrame, StateData.StateData): DirectFrame.destroy(self) return None - def makeFriendButton(self, friendTuple, colorChoice = None, bold = 0): - avId, flags = friendTuple - command = self.__choseFriend + def makeFriendButton(self, avId, color): handle = base.cr.identifyFriend(avId) - if handle: - toonName = handle.getName() - else: + + if not handle: base.cr.fillUpFriendsMap() return - fg = ToontownGlobals.ColorNoChat - if flags & ToontownGlobals.FriendChat: - fg = ToontownGlobals.ColorAvatar - if colorChoice: - fg = colorChoice - fontChoice = ToontownGlobals.getToonFont() - fontScale = 0.04 - bg = None - if colorChoice and bold: - fontScale = 0.04 - colorS = 0.7 - bg = (colorChoice[0] * colorS, - colorChoice[1] * colorS, - colorChoice[2] * colorS, - colorChoice[3]) - db = DirectButton(relief=None, text=toonName, text_scale=fontScale, text_align=TextNode.ALeft, text_fg=fg, text_shadow=bg, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, text_font=fontChoice, textMayChange=0, command=command, extraArgs=[avId]) - return db + + return DirectButton(relief=None, text=handle.getName(), text_scale=0.04, text_align=TextNode.ALeft, text_fg=color, text_shadow=None, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, text_font=ToontownGlobals.getToonFont(), textMayChange=0, command=self.__choseFriend, extraArgs=[avId]) def enter(self): if self.isEntered == 1: @@ -251,109 +224,47 @@ class FriendsListPanel(DirectFrame, StateData.StateData): if handle != None: messenger.send('clickedNametag', [handle]) + def createButtons(self, avIds, nametag): + avIds.sort(compareFriends) + + for avId in avIds: + if avId not in self.friends: + button = self.makeFriendButton(avId, nametag) + + if button: + self.scrollList.addItem(button, refresh=0) + self.friends[avId] = button + def __updateScrollList(self): - newFriends = [] petFriends = [] - freeChatOneRef = [] - speedChatOneRef = [] - freeChatDouble = [] - speedChatDouble = [] - offlineFriends = [] - if self.panelType == FLPAll: - if True: - for friendPair in base.localAvatar.friendsList: - if base.cr.isFriendOnline(friendPair[0]): - if friendPair[1] & ToontownGlobals.FriendChat: - freeChatOneRef.insert(0, (friendPair[0], - friendPair[1])) - else: - speedChatOneRef.insert(0, (friendPair[0], - friendPair[1])) - elif friendPair[1] & ToontownGlobals.FriendChat: - freeChatOneRef.insert(0, (friendPair[0], - friendPair[1])) - else: - speedChatOneRef.insert(0, (friendPair[0], - friendPair[1])) - - if self.panelType == FLPOnline: - if True: - for friendPair in base.localAvatar.friendsList: - if base.cr.isFriendOnline(friendPair[0]): - offlineFriends.append((friendPair[0], - friendPair[1])) - - if self.panelType == FLPPets: - for objId, obj in base.cr.doId2do.items(): - from toontown.pets import DistributedPet - if isinstance(obj, DistributedPet.DistributedPet): - friendPair = (objId, 0) - petFriends.append(friendPair) + trueFriends = [] + friends = [] if self.panelType == FLPAll or self.panelType == FLPOnline: if base.wantPets and base.localAvatar.hasPet(): - petFriends.insert(0, (base.localAvatar.getPetId(), 0)) - for friendPair in self.friends.keys(): - friendButton = self.friends[friendPair] + petFriends.insert(0, base.localAvatar.getPetId()) + + for friendId in base.localAvatar.friendsList: + if self.panelType != FLPOnline or base.cr.isFriendOnline(friendId): + if base.localAvatar.isTrueFriends(friendId): + trueFriends.insert(0, friendId) + else: + friends.insert(0, friendId) + elif self.panelType == FLPPets and base.wantPets: + for avId, av in base.cr.doId2do.items(): + from toontown.pets import DistributedPet + if isinstance(av, DistributedPet.DistributedPet): + petFriends.append(avId) + + for friendId in self.friends.keys(): + friendButton = self.friends[friendId] self.scrollList.removeItem(friendButton, refresh=0) friendButton.destroy() - del self.friends[friendPair] + del self.friends[friendId] - newFriends.sort(compareFriends) - petFriends.sort(compareFriends) - freeChatOneRef.sort(compareFriends) - speedChatOneRef.sort(compareFriends) - freeChatDouble.sort(compareFriends) - speedChatDouble.sort(compareFriends) - offlineFriends.sort(compareFriends) - for friendPair in newFriends: - if friendPair not in self.friends: - friendButton = self.makeFriendButton(friendPair) - if friendButton: - self.scrollList.addItem(friendButton, refresh=0) - self.friends[friendPair] = friendButton - - for friendPair in petFriends: - if friendPair not in self.friends: - friendButton = self.makeFriendButton(friendPair, ToontownGlobals.ColorNoChat, 0) - if friendButton: - self.scrollList.addItem(friendButton, refresh=0) - self.friends[friendPair] = friendButton - - for friendPair in freeChatDouble: - if friendPair not in self.friends: - friendButton = self.makeFriendButton(friendPair, ToontownGlobals.ColorFreeChat, 1) - if friendButton: - self.scrollList.addItem(friendButton, refresh=0) - self.friends[friendPair] = friendButton - - for friendPair in freeChatOneRef: - if friendPair not in self.friends: - friendButton = self.makeFriendButton(friendPair, ToontownGlobals.ColorFreeChat, 0) - if friendButton: - self.scrollList.addItem(friendButton, refresh=0) - self.friends[friendPair] = friendButton - - for friendPair in speedChatDouble: - if friendPair not in self.friends: - friendButton = self.makeFriendButton(friendPair, ToontownGlobals.ColorSpeedChat, 1) - if friendButton: - self.scrollList.addItem(friendButton, refresh=0) - self.friends[friendPair] = friendButton - - for friendPair in speedChatOneRef: - if friendPair not in self.friends: - friendButton = self.makeFriendButton(friendPair, ToontownGlobals.ColorSpeedChat, 0) - if friendButton: - self.scrollList.addItem(friendButton, refresh=0) - self.friends[friendPair] = friendButton - - for friendPair in offlineFriends: - if friendPair not in self.friends: - friendButton = self.makeFriendButton(friendPair, ToontownGlobals.ColorNoChat, 0) - if friendButton: - self.scrollList.addItem(friendButton, refresh=0) - self.friends[friendPair] = friendButton + self.createButtons(petFriends, NametagColors[CCNonPlayer][0][0]) + self.createButtons(trueFriends, NametagColors[CCNormal][0][0]) + self.createButtons(friends, NametagColors[CCSpeedChat][0][0]) self.scrollList.index = self.listScrollIndex[self.panelType] self.scrollList.refresh() diff --git a/toontown/friends/TTSFriendsManagerUD.py b/toontown/friends/TTSFriendsManagerUD.py index 2342fa93..1736d62c 100755 --- a/toontown/friends/TTSFriendsManagerUD.py +++ b/toontown/friends/TTSFriendsManagerUD.py @@ -57,14 +57,15 @@ class FriendsListOperation(OperationFSM): self.friendIndex = 0 self.realFriendsList = [] - self.air.dbInterface.queryObject(self.air.dbId, self.friendsList[0][0], + self.air.dbInterface.queryObject(self.air.dbId, self.friendsList[0], self.addFriend) def addFriend(self, dclass, fields): if dclass != self.air.dclassesByName['DistributedToonUD']: self.demand('Error', 'Friend was not a Toon') return - friendId = self.friendsList[self.friendIndex][0] + friendId = self.friendsList[self.friendIndex] + self.realFriendsList.append([friendId, fields['setName'][0], fields['setDNAString'][0], fields['setPetId'][0]]) @@ -75,7 +76,7 @@ class FriendsListOperation(OperationFSM): self.friendIndex += 1 self.air.dbInterface.queryObject(self.air.dbId, - self.friendsList[self.friendIndex][0], self.addFriend) + self.friendsList[self.friendIndex], self.addFriend) # -- Remove Friends -- @@ -97,15 +98,11 @@ class RemoveFriendOperation(OperationFSM): self.demand('Retrieved', fields['setFriendsList'][0]) def enterRetrieved(self, friendsList): - newList = [] - for i in xrange(len(friendsList)): - if friendsList[i][0] == self.target: - continue - newList.append(friendsList[i]) + friendsList.remove(self.target) if self.sender in self.mgr.onlineToons: dg = self.air.dclassesByName['DistributedToonUD'].aiFormatUpdate( 'setFriendsList', self.sender, self.sender, - self.air.ourChannel, [newList]) + self.air.ourChannel, [friendsList]) self.air.send(dg) if self.alert: dg = self.air.dclassesByName['DistributedToonUD'].aiFormatUpdate( @@ -117,7 +114,7 @@ class RemoveFriendOperation(OperationFSM): self.air.dbInterface.updateObject(self.air.dbId, self.sender, self.air.dclassesByName['DistributedToonUD'], - {'setFriendsList' : [newList]}) + {'setFriendsList' : [friendsList]}) self.demand('Off') @@ -142,12 +139,10 @@ class FriendDetailsOperation(OperationFSM): def enterRetrieved(self, friendsList): self.currId = 0 for id in self.friendIds: - for friend in friendsList: - if friend[0] == id: - self.currId = id - self.air.dbInterface.queryObject(self.air.dbId, id, - self.handleFriend) - break + if id in friendsList: + self.currId = id + self.air.dbInterface.queryObject(self.air.dbId, id, + self.handleFriend) self.demand('Off') def handleFriend(self, dclass, fields): @@ -177,7 +172,7 @@ class ClearListOperation(OperationFSM): def enterRetrieved(self, friendsList): for friend in friendsList: - newOperation = RemoveFriendOperation(self.mgr, self.air, friend[0], + newOperation = RemoveFriendOperation(self.mgr, self.air, friend, targetAvId=self.sender, alert=True) self.mgr.operations.append(newOperation) newOperation.demand('Start') @@ -274,7 +269,8 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD): # -- Toon Online/Offline -- def toonOnline(self, doId, friendsList): - self.onlineToons.append(doId) + if not doId in self.onlineToons: + self.onlineToons.append(doId) channel = self.GetPuppetConnectionChannel(doId) dgcleanup = self.dclass.aiFormatUpdate('goingOffline', self.doId, self.doId, self.air.ourChannel, [doId]) @@ -284,10 +280,9 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD): self.air.send(dg) for friend in friendsList: - friendId = friend[0] if friend[0] in self.onlineToons: - self.sendUpdateToAvatarId(doId, 'friendOnline', [friendId]) - self.sendUpdateToAvatarId(friendId, 'friendOnline', [doId]) + self.sendUpdateToAvatarId(doId, 'friendOnline', [friend[0]]) + self.sendUpdateToAvatarId(friend[0], 'friendOnline', [doId]) def goingOffline(self, avId): self.toonOffline(avId) @@ -299,8 +294,7 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD): if dclass != self.air.dclassesByName['DistributedToonUD']: return friendsList = fields['setFriendsList'][0] - for friend in friendsList: - friendId = friend[0] + for friendId in friendsList: if friendId in self.onlineToons: self.sendUpdateToAvatarId(friendId, 'friendOffline', [doId]) if doId in self.onlineToons: diff --git a/toontown/nametag/NametagGlobals.py b/toontown/nametag/NametagGlobals.py index a564791d..8f6d3a3c 100755 --- a/toontown/nametag/NametagGlobals.py +++ b/toontown/nametag/NametagGlobals.py @@ -134,7 +134,7 @@ def getModelWidthHeight(model): return (width, height) def getFriendColor(id): - return CCNormal if settings['trueFriends'] and base.cr.getFriendFlags(id) & OTPGlobals.FriendChat else CCNormal + return CCNormal if settings['trueFriends'] and base.localAvatar.isTrueFriends(id) else CCNormal # Foreground, background: NametagColors = { diff --git a/toontown/parties/PartyPlanner.py b/toontown/parties/PartyPlanner.py index f6c666d3..716d2f2f 100755 --- a/toontown/parties/PartyPlanner.py +++ b/toontown/parties/PartyPlanner.py @@ -12,7 +12,6 @@ from pandac.PandaModules import Vec3, Vec4, Point3, TextNode, VBase4 from otp.otpbase import OTPGlobals from otp.otpbase import OTPLocalizer -from toontown.friends.FriendsListPanel import determineFriendName from toontown.nametag.Nametag import Nametag from toontown.nametag.NametagFloat2d import * from toontown.nametag import NametagGlobals @@ -462,8 +461,8 @@ class PartyPlanner(DirectFrame, FSM): self.noFriends = True else: self.noFriends = False - for friendPair in base.localAvatar.friendsList: - self.friendList.addFriend(determineFriendName(friendPair), friendPair[0]) + for friendId in base.localAvatar.friendsList: + self.friendList.addFriend(friendId) self.friendList.scrollTo(0) pos = self.gui.find('**/step_04_partyWillBe_locator').getPos() diff --git a/toontown/parties/ScrolledFriendList.py b/toontown/parties/ScrolledFriendList.py index fd3f9e0a..180504d5 100755 --- a/toontown/parties/ScrolledFriendList.py +++ b/toontown/parties/ScrolledFriendList.py @@ -2,6 +2,7 @@ from direct.gui.DirectGui import DirectFrame, DirectButton, DirectLabel from direct.gui.DirectGui import DirectScrolledList, DirectCheckButton from direct.gui.DirectCheckBox import DirectCheckBox from direct.gui import DirectGuiGlobals +from toontown.friends.FriendsListPanel import determineFriendName from toontown.toonbase import ToontownGlobals from pandac.PandaModules import Vec3, Vec4, PlaneNode, Plane, Point3, TextNode, VBase4, NodePath @@ -22,7 +23,9 @@ class ScrolledFriendList(DirectScrolledList): def scrollButtonPressed(self): pass - def addFriend(self, name, id): + def addFriend(self, id): + name = determineFriendName(id) + if self.makeItemsCheckBoxes: checkedImage = self.gui.find('**/inviteButtonChecked') uncheckedImage = self.gui.find('**/inviteButtonUnchecked') diff --git a/toontown/toon/AvatarPanelBase.py b/toontown/toon/AvatarPanelBase.py index 699fffc5..3dda3b5c 100755 --- a/toontown/toon/AvatarPanelBase.py +++ b/toontown/toon/AvatarPanelBase.py @@ -23,8 +23,7 @@ class AvatarPanelBase(AvatarPanel.AvatarPanel): return (TTLocalizer.AvatarPanelIgnore, self.handleIgnore, IGNORE_SCALE) def handleIgnore(self): - isAvatarFriend = base.cr.isFriend(self.avatar.doId) - if isAvatarFriend: + if base.cr.isFriend(self.avatar.doId): self.dialog = TTDialog.TTGlobalDialog( style=TTDialog.CancelOnly, text=TTLocalizer.IgnorePanelAddFriendAvatar % self.avName, diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index 0a2cc190..7885d0a8 100755 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -182,6 +182,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute self.redeemedCodes = [] self.ignored = [] self.reported = [] + self.trueFriends = [] def disable(self): for soundSequence in self.soundSequenceList: @@ -2519,6 +2520,19 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute def addReport(self, doId): if not self.isReported(doId): self.reported.append(doId) + + def b_setTrueFriends(self, trueFriends): + self.setTrueFriends(trueFriends) + self.d_setTrueFriends(trueFriends) + + def setTrueFriends(self, trueFriends): + self.trueFriends = trueFriends + + def d_setTrueFriends(self, trueFriends): + self.sendUpdate('setTrueFriends', [trueFriends]) + + def isTrueFriends(self, doId): + return doId in self.trueFriends def applyBuffs(self): for id, timestamp in enumerate(self.buffs): diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index 3366d36f..f0aef9d1 100755 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -160,6 +160,8 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo self.redeemedCodes = [] self.ignored = [] self.reported = [] + self.trueFriends = [] + self.fishBingoTutorialDone = False def generate(self): DistributedPlayerAI.DistributedPlayerAI.generate(self) @@ -507,14 +509,11 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo def getFriendsList(self): return self.friendsList - def extendFriendsList(self, friendId, friendCode): - for i in xrange(len(self.friendsList)): - friendPair = self.friendsList[i] - if friendPair[0] == friendId: - self.friendsList[i] = (friendId, friendCode) - return + def extendFriendsList(self, friendId): + if friendId in self.friendsList: + return - self.friendsList.append((friendId, friendCode)) + self.friendsList.append(friendId) self.air.questManager.toonMadeFriend(self) def d_setMaxNPCFriends(self, max): @@ -4075,6 +4074,19 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo if self.isCodeRedeemed(code): self.redeemedCodes.remove(code) self.b_setRedeemedCodes(self.redeemedCodes) + + def setTrueFriends(self, trueFriends): + self.trueFriends = trueFriends + + def d_setTrueFriends(self, trueFriends): + self.sendUpdate('setTrueFriends', [trueFriends]) + + def b_setTrueFriends(self, trueFriends): + self.setTrueFriends(trueFriends) + self.d_setTrueFriends(trueFriends) + + def getTrueFriends(self, trueFriends): + return self.trueFriends @magicWord(category=CATEGORY_PROGRAMMER, types=[str, int, int]) def cheesyEffect(value, hood=0, expire=0): diff --git a/toontown/toon/DistributedToonUD.py b/toontown/toon/DistributedToonUD.py index d1e8c96d..f879be97 100755 --- a/toontown/toon/DistributedToonUD.py +++ b/toontown/toon/DistributedToonUD.py @@ -524,4 +524,7 @@ class DistributedToonUD(DistributedObjectUD): pass def setRedeemedCodes(self, redeemedCodes): + pass + + def setTrueFriends(self, trueFriends): pass \ No newline at end of file diff --git a/toontown/town/TownBattleSOSPanel.py b/toontown/town/TownBattleSOSPanel.py index 6ea76e17..962413f8 100755 --- a/toontown/town/TownBattleSOSPanel.py +++ b/toontown/town/TownBattleSOSPanel.py @@ -76,19 +76,21 @@ class TownBattleSOSPanel(DirectFrame, StateData.StateData): DirectFrame.destroy(self) return None - def makeFriendButton(self, friendPair): - friendId, flags = friendPair + def makeFriendButton(self, friendId): handle = base.cr.identifyFriend(friendId) - if handle == None: + + if not handle: base.cr.fillUpFriendsMap() return + friendName = handle.getName() - fg = Vec4(0.0, 0.0, 0.0, 1.0) + if handle.isPet(): com = self.__chosePet else: com = self.__choseFriend - return DirectButton(relief=None, text=friendName, text_scale=0.04, text_align=TextNode.ALeft, text_fg=fg, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, command=com, extraArgs=[friendId, friendName]) + + return DirectButton(relief=None, text=friendName, text_scale=0.04, text_align=TextNode.ALeft, text_fg=(0.0, 0.0, 0.0, 1.0), text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, command=com, extraArgs=[friendId, friendName]) def makeNPCFriendButton(self, NPCFriendId, numCalls): if NPCFriendId not in TTLocalizer.NPCToonNames: @@ -159,32 +161,30 @@ class TownBattleSOSPanel(DirectFrame, StateData.StateData): self.factoryToonIdList = toonIdList[:] def __updateScrollList(self): - newFriends = [] - battlePets = base.config.GetBool('want-pets-in-battle', 1) - if base.wantPets and battlePets == 1 and base.localAvatar.hasPet(): - newFriends.append((base.localAvatar.getPetId(), 0)) - if not self.bldg or self.factoryToonIdList is not None: - for friendPair in base.localAvatar.friendsList: - if base.cr.isFriendOnline(friendPair[0]): - if self.factoryToonIdList is None or friendPair[0] in self.factoryToonIdList: - newFriends.append(friendPair) + friends = [] - for friendPair in self.friends.keys(): - if friendPair not in newFriends: - friendButton = self.friends[friendPair] + if base.wantPets and config.GetBool('want-pets-in-battle', 1) and base.localAvatar.hasPet(): + friends.append(base.localAvatar.getPetId()) + if not self.bldg or self.factoryToonIdList is not None: + for friendId in base.localAvatar.friendsList: + if base.cr.isFriendOnline(friendId): + if self.factoryToonIdList is None or friendId in self.factoryToonIdList: + friends.append(friendId) + + for friendId in self.friends.keys(): + if friendId not in friends: + friendButton = self.friends[friendId] self.scrollList.removeItem(friendButton) if not friendButton.isEmpty(): friendButton.destroy() - del self.friends[friendPair] + del self.friends[friendId] - for friendPair in newFriends: - if friendPair not in self.friends: - friendButton = self.makeFriendButton(friendPair) + for friendId in friends: + if friendId not in self.friends: + friendButton = self.makeFriendButton(friendId) if friendButton: self.scrollList.addItem(friendButton) - self.friends[friendPair] = friendButton - - return + self.friends[friendId] = friendButton def __updateNPCFriendsPanel(self): self.NPCFriends = {}