mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
FriendManagerAI cleanup
This commit is contained in:
parent
6377cec192
commit
4f9190418c
1 changed files with 26 additions and 6 deletions
|
@ -13,58 +13,74 @@ class FriendManagerAI(DistributedObjectAI):
|
||||||
|
|
||||||
def friendQuery(self, requested):
|
def friendQuery(self, requested):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
avId = self.air.getAvatarIdFromSender()
|
||||||
if not requested in self.air.doId2do:
|
av = self.air.doId2do.get(avId)
|
||||||
|
|
||||||
|
if not av:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to friend a player that does not exist!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to friend a player that does not exist!')
|
||||||
return
|
return
|
||||||
|
|
||||||
context = self.currentContext
|
context = self.currentContext
|
||||||
self.requests[context] = [ [ avId, requested ], 'friendQuery']
|
self.requests[context] = [ [ avId, requested ], 'friendQuery']
|
||||||
self.currentContext += 1
|
self.currentContext += 1
|
||||||
self.sendUpdateToAvatarId(requested, 'inviteeFriendQuery', [avId, self.air.doId2do[avId].getName(), self.air.doId2do[avId].getDNAString(), context])
|
self.sendUpdateToAvatarId(requested, 'inviteeFriendQuery', [avId, av.getName(), av.getDNAString(), context])
|
||||||
|
|
||||||
def cancelFriendQuery(self, context):
|
def cancelFriendQuery(self, context):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
|
||||||
if not context in self.requests:
|
if not context in self.requests:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to cancel a request that doesn\'t exist!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to cancel a request that doesn\'t exist!')
|
||||||
return
|
return
|
||||||
|
|
||||||
if avId != self.requests[context][0][0]:
|
if avId != self.requests[context][0][0]:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to cancel someone elses request!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to cancel someone elses request!')
|
||||||
return
|
return
|
||||||
|
|
||||||
self.requests[context][1] = 'cancelled'
|
self.requests[context][1] = 'cancelled'
|
||||||
self.sendUpdateToAvatarId(self.requests[context][0][1], 'inviteeCancelFriendQuery', [context])
|
self.sendUpdateToAvatarId(self.requests[context][0][1], 'inviteeCancelFriendQuery', [context])
|
||||||
|
|
||||||
def inviteeFriendConsidering(self, yesNo, context):
|
def inviteeFriendConsidering(self, yesNo, context):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
|
||||||
if not context in self.requests:
|
if not context in self.requests:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to consider a friend request that doesn\'t exist!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to consider a friend request that doesn\'t exist!')
|
||||||
return
|
return
|
||||||
|
|
||||||
if avId != self.requests[context][0][1]:
|
if avId != self.requests[context][0][1]:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to consider for someone else!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to consider for someone else!')
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.requests[context][1] != 'friendQuery':
|
if self.requests[context][1] != 'friendQuery':
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to reconsider friend request!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to reconsider friend request!')
|
||||||
return
|
return
|
||||||
|
|
||||||
if yesNo != 1:
|
if yesNo != 1:
|
||||||
self.sendUpdateToAvatarId(self.requests[context][0][0], 'friendConsidering', [yesNo, context])
|
self.sendUpdateToAvatarId(self.requests[context][0][0], 'friendConsidering', [yesNo, context])
|
||||||
del self.requests[context]
|
del self.requests[context]
|
||||||
return
|
return
|
||||||
|
|
||||||
self.requests[context][1] = 'friendConsidering'
|
self.requests[context][1] = 'friendConsidering'
|
||||||
self.sendUpdateToAvatarId(self.requests[context][0][0], 'friendConsidering', [yesNo, context])
|
self.sendUpdateToAvatarId(self.requests[context][0][0], 'friendConsidering', [yesNo, context])
|
||||||
|
|
||||||
def inviteeFriendResponse(self, response, context):
|
def inviteeFriendResponse(self, response, context):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
|
||||||
if not context in self.requests:
|
if not context in self.requests:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to respond to a friend request that doesn\'t exist!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to respond to a friend request that doesn\'t exist!')
|
||||||
return
|
return
|
||||||
|
|
||||||
if avId != self.requests[context][0][1]:
|
if avId != self.requests[context][0][1]:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to respond to someone else\'s request!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to respond to someone else\'s request!')
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.requests[context][1] == 'cancelled':
|
if self.requests[context][1] == 'cancelled':
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to respond to non-active friend request!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to respond to non-active friend request!')
|
||||||
return
|
return
|
||||||
self.sendUpdateToAvatarId(self.requests[context][0][0], 'friendResponse', [response, context])
|
|
||||||
if response == 1:
|
|
||||||
|
|
||||||
|
self.sendUpdateToAvatarId(self.requests[context][0][0], 'friendResponse', [response, context])
|
||||||
|
|
||||||
|
if response == 1:
|
||||||
requested = self.requests[context][0][1]
|
requested = self.requests[context][0][1]
|
||||||
|
|
||||||
if requested in self.air.doId2do:
|
if requested in self.air.doId2do:
|
||||||
requested = self.air.doId2do[requested]
|
requested = self.air.doId2do[requested]
|
||||||
else:
|
else:
|
||||||
|
@ -72,6 +88,7 @@ class FriendManagerAI(DistributedObjectAI):
|
||||||
return
|
return
|
||||||
|
|
||||||
requester = self.requests[context][0][0]
|
requester = self.requests[context][0][0]
|
||||||
|
|
||||||
if requester in self.air.doId2do:
|
if requester in self.air.doId2do:
|
||||||
requester = self.air.doId2do[requester]
|
requester = self.air.doId2do[requester]
|
||||||
else:
|
else:
|
||||||
|
@ -83,22 +100,25 @@ class FriendManagerAI(DistributedObjectAI):
|
||||||
|
|
||||||
requested.d_setFriendsList(requested.getFriendsList())
|
requested.d_setFriendsList(requested.getFriendsList())
|
||||||
requester.d_setFriendsList(requester.getFriendsList())
|
requester.d_setFriendsList(requester.getFriendsList())
|
||||||
del self.requests[context]
|
|
||||||
|
|
||||||
|
del self.requests[context]
|
||||||
|
|
||||||
def inviteeAcknowledgeCancel(self, context):
|
def inviteeAcknowledgeCancel(self, context):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
|
||||||
if not context in self.requests:
|
if not context in self.requests:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to acknowledge the cancel of a friend request that doesn\'t exist!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to acknowledge the cancel of a friend request that doesn\'t exist!')
|
||||||
return
|
return
|
||||||
|
|
||||||
if avId != self.requests[context][0][1]:
|
if avId != self.requests[context][0][1]:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to acknowledge someone else\'s cancel!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to acknowledge someone else\'s cancel!')
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.requests[context][1] != 'cancelled':
|
if self.requests[context][1] != 'cancelled':
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Player tried to cancel non-cancelled request!')
|
self.air.writeServerEvent('suspicious', avId, 'Player tried to cancel non-cancelled request!')
|
||||||
return
|
return
|
||||||
del self.requests[context]
|
|
||||||
|
|
||||||
|
del self.requests[context]
|
||||||
|
|
||||||
def friendConsidering(self, todo0, todo1):
|
def friendConsidering(self, todo0, todo1):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue