mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
moving doId2do to DoCollectionManager
This commit is contained in:
parent
eb5cb11e3b
commit
cbd8bf2164
@ -5,7 +5,7 @@ from MsgTypes import *
|
||||
from direct.task import Task
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
import CRCache
|
||||
import ConnectionRepository
|
||||
from direct.distributed.ConnectionRepository import ConnectionRepository
|
||||
from direct.showbase import PythonUtil
|
||||
import ParentMgr
|
||||
import RelatedObjectMgr
|
||||
@ -14,7 +14,7 @@ from ClockDelta import *
|
||||
from PyDatagram import PyDatagram
|
||||
from PyDatagramIterator import PyDatagramIterator
|
||||
|
||||
class ClientRepository(ConnectionRepository.ConnectionRepository):
|
||||
class ClientRepository(ConnectionRepository):
|
||||
"""
|
||||
This maintains a client-side connection with a Panda server.
|
||||
It currently supports several different versions of the server:
|
||||
@ -25,7 +25,7 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepository")
|
||||
|
||||
def __init__(self):
|
||||
ConnectionRepository.ConnectionRepository.__init__(self, base.config)
|
||||
ConnectionRepository.__init__(self, base.config)
|
||||
|
||||
self.context=100000
|
||||
self.setClientDatagram(1)
|
||||
@ -36,11 +36,6 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
|
||||
# with set locationa and set interest
|
||||
self.old_setzone_interest_handle = None
|
||||
|
||||
# Dict of {DistributedObject ids : DistributedObjects}
|
||||
self.doId2do = {}
|
||||
if wantOtpServer:
|
||||
# Dict of {parent DistributedObject id : {zoneIds : [child DistributedObject ids]}}
|
||||
self.__doHierarchy = {}
|
||||
self.readDCFile()
|
||||
self.cache=CRCache.CRCache()
|
||||
self.serverDelta = 0
|
||||
@ -917,31 +912,12 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
|
||||
def replaceMethod(self, oldMethod, newFunction):
|
||||
return 0
|
||||
|
||||
def getAllOfType(self, type):
|
||||
# Returns a list of all DistributedObjects in the repository
|
||||
# of a particular type.
|
||||
result = []
|
||||
for obj in self.doId2do.values():
|
||||
if isinstance(obj, type):
|
||||
result.append(obj)
|
||||
return result
|
||||
|
||||
def findAnyOfType(self, type):
|
||||
# Searches the repository for any object of the given type.
|
||||
for obj in self.doId2do.values():
|
||||
if isinstance(obj, type):
|
||||
return obj
|
||||
return None
|
||||
|
||||
def isLocalId(self,id):
|
||||
return ((id >= self.DOIDbase) and (id < self.DOIDlast))
|
||||
|
||||
def haveCreateAuthority(self):
|
||||
return (self.DOIDlast > self.DOIDnext)
|
||||
|
||||
def getDoHierarchy(self):
|
||||
return self.__doHierarchy
|
||||
|
||||
def getWorld(self, doId):
|
||||
# Get the world node for this object
|
||||
obj = self.doId2do[doId]
|
||||
|
@ -2,13 +2,15 @@ from pandac.PandaModules import *
|
||||
from direct.task import Task
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DoInterestManager import DoInterestManager
|
||||
from direct.distributed.DoCollectionManager import DoCollectionManager
|
||||
from PyDatagram import PyDatagram
|
||||
from PyDatagramIterator import PyDatagramIterator
|
||||
|
||||
import types
|
||||
import imp
|
||||
|
||||
class ConnectionRepository(DoInterestManager, CConnectionRepository):
|
||||
class ConnectionRepository(
|
||||
DoInterestManager, DoCollectionManager, CConnectionRepository):
|
||||
"""
|
||||
This is a base class for things that know how to establish a
|
||||
connection (and exchange datagrams) with a gameserver. This
|
||||
@ -20,6 +22,7 @@ class ConnectionRepository(DoInterestManager, CConnectionRepository):
|
||||
def __init__(self, config):
|
||||
assert self.notify.debugCall()
|
||||
DoInterestManager.__init__(self)
|
||||
DoCollectionManager.__init__(self)
|
||||
CConnectionRepository.__init__(self)
|
||||
self.setPythonRepository(self)
|
||||
|
||||
@ -56,20 +59,6 @@ class ConnectionRepository(DoInterestManager, CConnectionRepository):
|
||||
# DC file. The AIRepository will redefine this to 'AI'.
|
||||
self.dcSuffix = ''
|
||||
|
||||
if __debug__:
|
||||
def printObjects(self):
|
||||
format="%10s %10s %10s %30s %20s"
|
||||
title=format%("parentId", "zoneId", "doId", "dclass", "name")
|
||||
print title
|
||||
print '-'*len(title)
|
||||
for distObj in self.doId2do.values():
|
||||
print format%(
|
||||
distObj.__dict__.get("parentId"),
|
||||
distObj.__dict__.get("zoneId"),
|
||||
distObj.__dict__.get("doId"),
|
||||
distObj.dclass.getName(),
|
||||
distObj.__dict__.get("name"))
|
||||
|
||||
def readDCFile(self, dcFileNames = None):
|
||||
"""
|
||||
Reads in the dc files listed in dcFileNames, or if
|
||||
@ -413,21 +402,3 @@ class ConnectionRepository(DoInterestManager, CConnectionRepository):
|
||||
if self.networkPlugPulled():
|
||||
self.notify.info('*** RESTORING SIMULATED PULLED-NETWORK-PLUG ***')
|
||||
self.setSimulatedDisconnect(0)
|
||||
|
||||
def doFind(self, str):
|
||||
"""
|
||||
Returns list of distributed objects with matching str in value.
|
||||
"""
|
||||
for value in self.doId2do.values():
|
||||
if `value`.find(str) >= 0:
|
||||
return value
|
||||
|
||||
def doFindAll(self, str):
|
||||
"""
|
||||
Returns list of distributed objects with matching str in value.
|
||||
"""
|
||||
matches = []
|
||||
for value in self.doId2do.values():
|
||||
if `value`.find(str) >= 0:
|
||||
matches.append(value)
|
||||
return matches
|
||||
|
Loading…
x
Reference in New Issue
Block a user