friends: Work around race condition
This commit is contained in:
parent
77d35d7875
commit
5592dc8a34
|
|
@ -2853,7 +2853,7 @@ dclass ToontownFriendsManager : DistributedObject {
|
||||||
getAvatarDetailsRequest(uint32) clsend;
|
getAvatarDetailsRequest(uint32) clsend;
|
||||||
getAvatarDetailsResponse(blob);
|
getAvatarDetailsResponse(blob);
|
||||||
makeFriends(uint32, uint32, uint8, uint32);
|
makeFriends(uint32, uint32, uint8, uint32);
|
||||||
makeFriendsResponse(uint8, uint32) airecv;
|
makeFriendsResponse(uint32, uint32, uint8, uint32) airecv;
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass TTSpeedchatRelay : SpeedchatRelay {
|
dclass TTSpeedchatRelay : SpeedchatRelay {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,18 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed.DistributedObjectGlobalAI import DistributedObjectGlobalAI
|
from direct.distributed.DistributedObjectGlobalAI import DistributedObjectGlobalAI
|
||||||
|
from direct.distributed.PyDatagram import *
|
||||||
|
|
||||||
|
|
||||||
class ToontownFriendsManagerAI(DistributedObjectGlobalAI):
|
class ToontownFriendsManagerAI(DistributedObjectGlobalAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('ToontownFriendsManagerAI')
|
notify = DirectNotifyGlobal.directNotify.newCategory('ToontownFriendsManagerAI')
|
||||||
|
|
||||||
|
def sendFriendOnline(self, avId, friendId, commonChatFlags, whitelistChatFlags):
|
||||||
|
datagram = PyDatagram()
|
||||||
|
datagram.addUint32(friendId) # doId
|
||||||
|
datagram.addUint8(commonChatFlags) # commonChatFlags
|
||||||
|
datagram.addUint8(whitelistChatFlags) # whitelistChatFlags
|
||||||
|
self.sendUpdateToAvatarId(avId, 'friendOnline', [datagram.getMessage()])
|
||||||
|
|
||||||
def makeFriends(self, avatarAId, avatarBId, flags, context):
|
def makeFriends(self, avatarAId, avatarBId, flags, context):
|
||||||
"""
|
"""
|
||||||
Requests to make a friendship between avatarA and avatarB with
|
Requests to make a friendship between avatarA and avatarB with
|
||||||
|
|
@ -16,5 +24,9 @@ class ToontownFriendsManagerAI(DistributedObjectGlobalAI):
|
||||||
"""
|
"""
|
||||||
self.sendUpdate('makeFriends', [avatarAId, avatarBId, flags, context])
|
self.sendUpdate('makeFriends', [avatarAId, avatarBId, flags, context])
|
||||||
|
|
||||||
def makeFriendsResponse(self, result, context):
|
def makeFriendsResponse(self, avatarAId, avatarBId, result, context):
|
||||||
|
if result == 1:
|
||||||
|
self.sendFriendOnline(avatarAId, avatarBId, 0, 1)
|
||||||
|
self.sendFriendOnline(avatarBId, avatarAId, 0, 1)
|
||||||
|
|
||||||
messenger.send("makeFriendsReply", [result, context])
|
messenger.send("makeFriendsReply", [result, context])
|
||||||
|
|
|
||||||
|
|
@ -218,8 +218,6 @@ class MakeFriendsOperation(FriendsOperation):
|
||||||
{'setFriendsList': [friendsList]})
|
{'setFriendsList': [friendsList]})
|
||||||
if avId in self.onlineToons:
|
if avId in self.onlineToons:
|
||||||
self.friendsManager.sendUpdateToAvatar(avId, 'setFriendsList', [friendsList])
|
self.friendsManager.sendUpdateToAvatar(avId, 'setFriendsList', [friendsList])
|
||||||
if friendId in self.onlineToons:
|
|
||||||
self.friendsManager.sendFriendOnline(avId, friendId, 0, 1)
|
|
||||||
|
|
||||||
def __handleAvatarARetrieved(self, dclass, fields):
|
def __handleAvatarARetrieved(self, dclass, fields):
|
||||||
self.__handleMakeFriends(dclass, fields, self.avatarAId, self.avatarBId)
|
self.__handleMakeFriends(dclass, fields, self.avatarAId, self.avatarBId)
|
||||||
|
|
@ -237,12 +235,12 @@ class MakeFriendsOperation(FriendsOperation):
|
||||||
|
|
||||||
def _handleDone(self):
|
def _handleDone(self):
|
||||||
self.resultCode = 1
|
self.resultCode = 1
|
||||||
self.friendsManager.sendMakeFriendsResponse(self.resultCode, self.context)
|
self.friendsManager.sendMakeFriendsResponse(self.avatarAId, self.avatarBId, self.resultCode, self.context)
|
||||||
FriendsOperation._handleDone(self)
|
FriendsOperation._handleDone(self)
|
||||||
|
|
||||||
def _handleError(self, error):
|
def _handleError(self, error):
|
||||||
self.resultCode = 0
|
self.resultCode = 0
|
||||||
self.friendsManager.sendMakeFriendsResponse(self.resultCode, self.context)
|
self.friendsManager.sendMakeFriendsResponse(self.avatarAId, self.avatarBId, self.resultCode, self.context)
|
||||||
FriendsOperation._handleError(self, error)
|
FriendsOperation._handleError(self, error)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -253,8 +251,8 @@ class ToontownFriendsManagerUD(DistributedObjectGlobalUD):
|
||||||
DistributedObjectGlobalUD.__init__(self, air)
|
DistributedObjectGlobalUD.__init__(self, air)
|
||||||
self.operations = []
|
self.operations = []
|
||||||
|
|
||||||
def sendMakeFriendsResponse(self, result, context):
|
def sendMakeFriendsResponse(self, avatarAId, avatarBId, result, context):
|
||||||
self.sendUpdate('makeFriendsResponse', [result, context])
|
self.sendUpdate('makeFriendsResponse', [avatarAId, avatarBId, result, context])
|
||||||
|
|
||||||
def sendFriendOnline(self, avId, friendId, commonChatFlags, whitelistChatFlags):
|
def sendFriendOnline(self, avId, friendId, commonChatFlags, whitelistChatFlags):
|
||||||
datagram = PyDatagram()
|
datagram = PyDatagram()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue