multiplayer: Fix crashes on Astron clients
This commit is contained in:
parent
092f6611cc
commit
e7936e7045
2 changed files with 30 additions and 8 deletions
|
@ -18,5 +18,8 @@ class TelemetryLimited:
|
|||
self._limits.remove(limit)
|
||||
|
||||
def enforceTelemetryLimits(self):
|
||||
if __astron__ and self.isEmpty():
|
||||
return
|
||||
|
||||
for limit in self._limits:
|
||||
limit(self)
|
||||
|
|
|
@ -22,6 +22,11 @@ class TelemetryLimiter(DirectObject):
|
|||
self._objs[id] = obj
|
||||
self.accept(self._getDummyEventName(obj), self._dummyEventHandler)
|
||||
|
||||
if __astron__:
|
||||
def hasObj(self, obj):
|
||||
id = obj.getTelemetryLimiterId()
|
||||
return id in self._objs
|
||||
|
||||
def _getDummyEventName(self, obj):
|
||||
return '%s-%s-%s-%s' % (self.LeakDetectEventName,
|
||||
obj.getTelemetryLimiterId(),
|
||||
|
@ -80,6 +85,9 @@ class TLGatherAllAvs(DirectObject):
|
|||
self._handlePlayerArrive(av)
|
||||
|
||||
self.accept(DistributedPlayer.GetPlayerGenerateEvent(), self._handlePlayerArrive)
|
||||
if __astron__:
|
||||
self.accept(DistributedPlayer.GetPlayerDeleteEvent(), self._handlePlayerLeave)
|
||||
else:
|
||||
self.accept(DistributedPlayer.GetPlayerNetworkDeleteEvent(), self._handlePlayerLeave)
|
||||
|
||||
def _handlePlayerArrive(self, av):
|
||||
|
@ -94,6 +102,17 @@ class TLGatherAllAvs(DirectObject):
|
|||
self._avId2limits[av.doId] = limitList
|
||||
base.cr.telemetryLimiter.addObj(av)
|
||||
|
||||
if __astron__:
|
||||
def _handlePlayerLeave(self, av):
|
||||
if av is not localAvatar and base.cr.telemetryLimiter.hasObj(av) and av.doId in self._avId2limits:
|
||||
base.cr.telemetryLimiter.removeObj(av)
|
||||
for limit in self._avId2limits[av.doId]:
|
||||
av.removeTelemetryLimit(limit)
|
||||
|
||||
del self._avId2limits[av.doId]
|
||||
if av.doId in self._avs:
|
||||
del self._avs[av.doId]
|
||||
else:
|
||||
def _handlePlayerLeave(self, av):
|
||||
if av is not localAvatar:
|
||||
base.cr.telemetryLimiter.removeObj(av)
|
||||
|
|
Loading…
Reference in a new issue