No more updateCoons.

This commit is contained in:
Loudrob 2015-07-22 18:00:31 -04:00
parent b49683ccd9
commit 1de4367482
3 changed files with 39 additions and 24 deletions

View file

@ -683,15 +683,6 @@ class DistributedEstateAI(DistributedObjectAI):
def rentItem(self, rentType, duration):
self.b_setRentalTimeStamp(time.time() + duration * 60)
self.b_setRentalType(rentType)
def updateToons(self):
self.d_setSlot0ToonId(self.toons[0])
self.d_setSlot1ToonId(self.toons[1])
self.d_setSlot2ToonId(self.toons[2])
self.d_setSlot3ToonId(self.toons[3])
self.d_setSlot4ToonId(self.toons[4])
self.d_setSlot5ToonId(self.toons[5])
self.sendUpdate('setIdList', [self.toons])
def setSlot0ToonId(self, id):
self.toons[0] = id

View file

@ -215,20 +215,34 @@ class LoadEstateFSM(FSM):
if self.state != 'CreateEstate':
return # We must have aborted or something...
self.estateId = estateId
self.demand('StoreEstate')
# Update our account so we can store this new estate object.
def enterStoreEstate(self):
# store the estate in account
# congrats however wrote this for forgetting it!
self.mgr.air.dbInterface.updateObject(
self.mgr.air.dbId,
self.accountId,
self.mgr.air.dclassesByName['AccountAI'],
{ 'ESTATE_ID': estateId }
)
{'ESTATE_ID': self.estateId},
{'ESTATE_ID': 0},
self.__handleStoreEstate)
def __handleStoreEstate(self, fields):
if fields:
self.notify.warning("Failed to associate Estate %d with account %d, loading anyway." % (self.estateId, self.accountId))
self.demand('LoadEstate')
def enterLoadEstate(self):
# Activate the estate:
self.mgr.air.sendActivate(self.estateId, self.mgr.air.districtId, self.zoneId)
fields = {}
for i, toon in enumerate(self.toonIds):
fields['setSlot%dToonId' % i] = (toon,)
self.mgr.air.sendActivate(self.estateId, self.mgr.air.districtId, self.zoneId,
self.mgr.air.dclassesByName['DistributedEstateAI'], fields)
# Now we wait for the estate to show up... We do this by hanging a messenger
# hook which the DistributedEstateAI throws once it spawns.
@ -238,9 +252,6 @@ class LoadEstateFSM(FSM):
self.estate = estate
estate.pets = []
self.estate.toons = self.toonIds
self.estate.updateToons()
# Gotcha! Now we need to load houses:
self.demand('LoadHouses')
@ -312,6 +323,7 @@ class EstateManagerAI(DistributedObjectAI):
self.estate2toons = {}
self.toon2estate = {}
self.estate2timeout = {}
self.zoneId2owner = {}
def getEstateZone(self, avId):
senderId = self.air.getAvatarIdFromSender()
@ -375,11 +387,12 @@ class EstateManagerAI(DistributedObjectAI):
# And I guess we won't need our zoneId anymore...
self.air.deallocateZone(zoneId)
del self.zoneId2owner[zoneId]
toon.loadEstateFSM = None
self.acceptOnce(self.air.getAvatarExitEvent(toon.doId), self._unloadEstate, extraArgs=[toon])
self.zoneId2owner[zoneId] = avId
toon.loadEstateFSM = LoadEstateFSM(self, estateLoaded)
toon.loadEstateFSM.start(accId, zoneId)
@ -443,6 +456,7 @@ class EstateManagerAI(DistributedObjectAI):
# Free estate's zone:
self.air.deallocateZone(estate.zoneId)
del self.zoneId2owner[estate.zoneId]
def _sendToonsToPlayground(self, estate, reason):
for toon in self.estate2toons.get(estate, []):
@ -451,10 +465,12 @@ class EstateManagerAI(DistributedObjectAI):
def _mapToEstate(self, toon, estate):
self._unmapFromEstate(toon)
self.estate2toons.setdefault(estate, []).append(toon)
self.toon2estate[toon] = estate
if hasattr(toon, 'enterEstate'):
toon.enterEstate(estate.owner.doId, estate.zoneId)
def _unmapFromEstate(self, toon):
estate = self.toon2estate.get(toon)
if not estate: return
@ -464,9 +480,19 @@ class EstateManagerAI(DistributedObjectAI):
self.estate2toons[estate].remove(toon)
except (KeyError, ValueError):
pass
if hasattr(toon, 'exitEstate'):
toon.exitEstate()
def _lookupEstate(self, toon):
return self.toon2estate.get(toon)
def getOwnerFromZone(self, avId):
return False
def getOwnerFromZone(self, zoneId):
return self.zoneId2owner.get(zoneId, 0)
def getEstateZones(self, ownerId):
estate = self._lookupEstate(self.air.doId2do.get(ownerId))
if estate:
return [estate.zoneId]
return []

View file

@ -2942,8 +2942,7 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
taskMgr.add(self._moveSphere, self._getMoveSphereTaskName(), priority=OTPGlobals.AICollMovePriority)
self.inEstate = 1
self.estateOwnerId = ownerId
self.estateZones = simbase.air.estateMgr.getEstateZones(ownerId)
self.estateHouseZones = simbase.air.estateMgr.getEstateHouseZones(ownerId)
self.estateZones = [zoneId]
self.enterPetLook()
def _getPetLookerBodyNode(self):
@ -2967,7 +2966,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
self.collNodePath.removeNode()
del self.collNodePath
del self.estateOwnerId
del self.estateHouseZones
del self.inEstate
self._wasInEstate = 1