From 7b8e48df784ed2769f9a9e34f53a5d20346aa3f5 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 31 May 2015 14:27:24 +0300 Subject: [PATCH] We don't need a ClsendTracker --- otp/avatar/DistributedPlayerAI.py | 6 +--- otp/distributed/ClsendTracker.py | 58 ------------------------------- 2 files changed, 1 insertion(+), 63 deletions(-) delete mode 100755 otp/distributed/ClsendTracker.py diff --git a/otp/avatar/DistributedPlayerAI.py b/otp/avatar/DistributedPlayerAI.py index 237c021b..3d04d921 100755 --- a/otp/avatar/DistributedPlayerAI.py +++ b/otp/avatar/DistributedPlayerAI.py @@ -6,22 +6,19 @@ from otp.ai.MagicWordGlobal import * from otp.avatar import DistributedAvatarAI from otp.avatar import PlayerBase from otp.distributed import OtpDoGlobals -from otp.distributed.ClsendTracker import ClsendTracker from otp.otpbase import OTPLocalizer -class DistributedPlayerAI(DistributedAvatarAI.DistributedAvatarAI, PlayerBase.PlayerBase, ClsendTracker): +class DistributedPlayerAI(DistributedAvatarAI.DistributedAvatarAI, PlayerBase.PlayerBase): def __init__(self, air): DistributedAvatarAI.DistributedAvatarAI.__init__(self, air) PlayerBase.PlayerBase.__init__(self) - ClsendTracker.__init__(self) self.friendsList = [] self.DISLid = 0 self.adminAccess = 0 def announceGenerate(self): DistributedAvatarAI.DistributedAvatarAI.announceGenerate(self) - ClsendTracker.announceGenerate(self) self._doPlayerEnter() def _announceArrival(self): @@ -35,7 +32,6 @@ class DistributedPlayerAI(DistributedAvatarAI.DistributedAvatarAI, PlayerBase.Pl def delete(self): self._doPlayerExit() - ClsendTracker.destroy(self) DistributedAvatarAI.DistributedAvatarAI.delete(self) def isPlayerControlled(self): diff --git a/otp/distributed/ClsendTracker.py b/otp/distributed/ClsendTracker.py deleted file mode 100755 index 65b221fe..00000000 --- a/otp/distributed/ClsendTracker.py +++ /dev/null @@ -1,58 +0,0 @@ -from pandac.PandaModules import StringStream -from direct.distributed.PyDatagram import PyDatagram -import random - -class ClsendTracker: - clsendNotify = directNotify.newCategory('clsend') - NumTrackersLoggingOverflow = 0 - MaxTrackersLoggingOverflow = config.GetInt('max-clsend-loggers', 5) - - def __init__(self): - self._logClsendOverflow = False - if self.isPlayerControlled(): - if simbase.air.getTrackClsends(): - if ClsendTracker.NumTrackersLoggingOverflow < ClsendTracker.MaxTrackersLoggingOverflow: - self._logClsendOverflow = random.random() < 1.0 / config.GetFloat('clsend-log-one-av-in-every', choice(0, 4, 50)) - if self._logClsendOverflow: - ClsendTracker.NumTrackersLoggingOverflow += 1 - self._clsendMsgs = [] - self._clsendBufLimit = 100 - self._clsendFlushNum = 20 - self._clsendCounter = 0 - - def announceGenerate(self): - if self._logClsendOverflow: - self.clsendNotify.info('logging all clsends for %s' % self.doId) - - def destroy(self): - if self._logClsendOverflow: - ClsendTracker.NumTrackersLoggingOverflow -= 1 - - def trackClientSendMsg(self, dataStr): - self._clsendMsgs.append((self.air.getAvatarIdFromSender(), dataStr)) - if len(self._clsendMsgs) >= self._clsendBufLimit: - self._trimClsend() - - def _trimClsend(self): - for i in xrange(self._clsendFlushNum): - if self._logClsendOverflow: - self._logClsend(*self._clsendMsgs[0]) - self._clsendMsgs = self._clsendMsgs[1:] - self._clsendCounter += 1 - - def _logClsend(self, senderId, dataStr): - msgStream = StringStream() - simbase.air.describeMessage(msgStream, '', dataStr) - readableStr = msgStream.getData() - sstream = StringStream() - PyDatagram(dataStr).dumpHex(sstream) - hexDump = sstream.getData() - self.clsendNotify.info('%s [%s]: %s%s' % (self.doId, - self._clsendCounter, - readableStr, - hexDump)) - - def dumpClientSentMsgs(self): - for msg in self._clsendMsgs: - self._logClsend(*msg) - self._clsendCounter += 1