friends: Handle online friends

This commit is contained in:
John Cote 2021-07-16 22:26:32 -04:00
parent 4587bcd43c
commit b259ead8c8
No known key found for this signature in database
GPG Key ID: E3442FF71E9C1C01
4 changed files with 29 additions and 14 deletions

View File

@ -2856,6 +2856,7 @@ struct Friend {
dclass ToontownFriendsManager : DistributedObject {
getFriendsListRequest() clsend;
getFriendsListResponse(Friend[]);
friendOnline(uint32, uint8, uint8);
};
dclass TTSpeedchatRelay : SpeedchatRelay {

View File

@ -995,20 +995,29 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
if avatarHandleList:
messenger.send('gotExtraFriendHandles', [avatarHandleList])
def handleFriendOnline(self, di):
doId = di.getUint32()
commonChatFlags = 0
whitelistChatFlags = 0
if di.getRemainingSize() > 0:
commonChatFlags = di.getUint8()
if di.getRemainingSize() > 0:
whitelistChatFlags = di.getUint8()
self.notify.debug('Friend %d now online. common=%d whitelist=%d' % (doId, commonChatFlags, whitelistChatFlags))
if doId not in self.friendsOnline:
self.friendsOnline[doId] = self.identifyFriend(doId)
messenger.send('friendOnline', [doId, commonChatFlags, whitelistChatFlags])
if not self.friendsOnline[doId]:
self.friendPendingChatSettings[doId] = (commonChatFlags, whitelistChatFlags)
if __astron__:
def handleFriendOnline(self, doId, commonChatFlags, whitelistChatFlags):
self.notify.debug('Friend %d now online. common=%d whitelist=%d' % (doId, commonChatFlags, whitelistChatFlags))
if doId not in self.friendsOnline:
self.friendsOnline[doId] = self.identifyFriend(doId)
messenger.send('friendOnline', [doId, commonChatFlags, whitelistChatFlags])
if not self.friendsOnline[doId]:
self.friendPendingChatSettings[doId] = (commonChatFlags, whitelistChatFlags)
else:
def handleFriendOnline(self, di):
doId = di.getUint32()
commonChatFlags = 0
whitelistChatFlags = 0
if di.getRemainingSize() > 0:
commonChatFlags = di.getUint8()
if di.getRemainingSize() > 0:
whitelistChatFlags = di.getUint8()
self.notify.debug('Friend %d now online. common=%d whitelist=%d' % (doId, commonChatFlags, whitelistChatFlags))
if doId not in self.friendsOnline:
self.friendsOnline[doId] = self.identifyFriend(doId)
messenger.send('friendOnline', [doId, commonChatFlags, whitelistChatFlags])
if not self.friendsOnline[doId]:
self.friendPendingChatSettings[doId] = (commonChatFlags, whitelistChatFlags)
def handleFriendOffline(self, di):
doId = di.getUint32()

View File

@ -10,3 +10,6 @@ class ToontownFriendsManager(DistributedObjectGlobal):
def getFriendsListResponse(self, friendsList):
self.cr.handleGetFriendsList(friendsList)
def friendOnline(self, doId, commonChatFlags, whitelistChatFlags):
self.cr.handleFriendOnline(doId, commonChatFlags, whitelistChatFlags)

View File

@ -80,6 +80,8 @@ class GetFriendsListOperation(FriendsOperation):
def __sendFriendsList(self):
self.friendsManager.sendUpdateToAvatarId(self.sender, 'getFriendsListResponse', [self.friendsList])
for friendId in self.onlineFriends:
self.friendsManager.sendUpdateToAvatarId(self.sender, 'friendOnline', [friendId, 0, 1])
class ToontownFriendsManagerUD(DistributedObjectGlobalUD):