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)
|
self._limits.remove(limit)
|
||||||
|
|
||||||
def enforceTelemetryLimits(self):
|
def enforceTelemetryLimits(self):
|
||||||
|
if __astron__ and self.isEmpty():
|
||||||
|
return
|
||||||
|
|
||||||
for limit in self._limits:
|
for limit in self._limits:
|
||||||
limit(self)
|
limit(self)
|
||||||
|
|
|
@ -22,6 +22,11 @@ class TelemetryLimiter(DirectObject):
|
||||||
self._objs[id] = obj
|
self._objs[id] = obj
|
||||||
self.accept(self._getDummyEventName(obj), self._dummyEventHandler)
|
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):
|
def _getDummyEventName(self, obj):
|
||||||
return '%s-%s-%s-%s' % (self.LeakDetectEventName,
|
return '%s-%s-%s-%s' % (self.LeakDetectEventName,
|
||||||
obj.getTelemetryLimiterId(),
|
obj.getTelemetryLimiterId(),
|
||||||
|
@ -80,7 +85,10 @@ class TLGatherAllAvs(DirectObject):
|
||||||
self._handlePlayerArrive(av)
|
self._handlePlayerArrive(av)
|
||||||
|
|
||||||
self.accept(DistributedPlayer.GetPlayerGenerateEvent(), self._handlePlayerArrive)
|
self.accept(DistributedPlayer.GetPlayerGenerateEvent(), self._handlePlayerArrive)
|
||||||
self.accept(DistributedPlayer.GetPlayerNetworkDeleteEvent(), self._handlePlayerLeave)
|
if __astron__:
|
||||||
|
self.accept(DistributedPlayer.GetPlayerDeleteEvent(), self._handlePlayerLeave)
|
||||||
|
else:
|
||||||
|
self.accept(DistributedPlayer.GetPlayerNetworkDeleteEvent(), self._handlePlayerLeave)
|
||||||
|
|
||||||
def _handlePlayerArrive(self, av):
|
def _handlePlayerArrive(self, av):
|
||||||
if av is not localAvatar:
|
if av is not localAvatar:
|
||||||
|
@ -94,14 +102,25 @@ class TLGatherAllAvs(DirectObject):
|
||||||
self._avId2limits[av.doId] = limitList
|
self._avId2limits[av.doId] = limitList
|
||||||
base.cr.telemetryLimiter.addObj(av)
|
base.cr.telemetryLimiter.addObj(av)
|
||||||
|
|
||||||
def _handlePlayerLeave(self, av):
|
if __astron__:
|
||||||
if av is not localAvatar:
|
def _handlePlayerLeave(self, av):
|
||||||
base.cr.telemetryLimiter.removeObj(av)
|
if av is not localAvatar and base.cr.telemetryLimiter.hasObj(av) and av.doId in self._avId2limits:
|
||||||
for limit in self._avId2limits[av.doId]:
|
base.cr.telemetryLimiter.removeObj(av)
|
||||||
av.removeTelemetryLimit(limit)
|
for limit in self._avId2limits[av.doId]:
|
||||||
|
av.removeTelemetryLimit(limit)
|
||||||
|
|
||||||
del self._avId2limits[av.doId]
|
del self._avId2limits[av.doId]
|
||||||
del self._avs[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)
|
||||||
|
for limit in self._avId2limits[av.doId]:
|
||||||
|
av.removeTelemetryLimit(limit)
|
||||||
|
|
||||||
|
del self._avId2limits[av.doId]
|
||||||
|
del self._avs[av.doId]
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
self.ignoreAll()
|
self.ignoreAll()
|
||||||
|
|
Loading…
Reference in a new issue