mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
better entTypeReg hash
This commit is contained in:
parent
8c9b7b114b
commit
8a061a7f81
@ -136,7 +136,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
self.candidateSpec = levelSpec
|
self.candidateSpec = levelSpec
|
||||||
self.sendUpdate('requestCurrentLevelSpec',
|
self.sendUpdate('requestCurrentLevelSpec',
|
||||||
[hash(levelSpec),
|
[hash(levelSpec),
|
||||||
hash(levelSpec.entTypeReg)])
|
levelSpec.entTypeReg.getHashStr()])
|
||||||
else:
|
else:
|
||||||
self.privGotSpec(levelSpec)
|
self.privGotSpec(levelSpec)
|
||||||
|
|
||||||
|
@ -180,10 +180,14 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
|
|||||||
def requestCurrentLevelSpec(self, specHash, entTypeRegHash):
|
def requestCurrentLevelSpec(self, specHash, entTypeRegHash):
|
||||||
senderId = self.air.msgSender
|
senderId = self.air.msgSender
|
||||||
|
|
||||||
|
self.notify.info('av %s: specHash %s, entTypeRegHash %s' %
|
||||||
|
(senderId, specHash, entTypeRegHash))
|
||||||
|
|
||||||
# first check the typeReg hash -- if it doesn't match, the
|
# first check the typeReg hash -- if it doesn't match, the
|
||||||
# client should not be connecting. Their entityTypeRegistry
|
# client should not be connecting. Their entityTypeRegistry
|
||||||
# is different from ours.
|
# is different from ours.
|
||||||
srvHash = hash(self.levelSpec.entTypeReg)
|
srvHash = self.levelSpec.entTypeReg.getHashStr()
|
||||||
|
self.notify.info('srv entTypeRegHash %s' % srvHash)
|
||||||
if srvHash != entTypeRegHash:
|
if srvHash != entTypeRegHash:
|
||||||
self.sendUpdateToAvatarId(
|
self.sendUpdateToAvatarId(
|
||||||
senderId, 'setSpecDeny',
|
senderId, 'setSpecDeny',
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""EntityTypeRegistry module: contains the EntityTypeRegistry class"""
|
"""EntityTypeRegistry module: contains the EntityTypeRegistry class"""
|
||||||
|
|
||||||
|
from PandaModules import *
|
||||||
import DirectNotifyGlobal
|
import DirectNotifyGlobal
|
||||||
import types
|
import types
|
||||||
import AttribDesc
|
import AttribDesc
|
||||||
@ -12,6 +13,19 @@ class EntityTypeRegistry:
|
|||||||
def __init__(self, entityTypeModule):
|
def __init__(self, entityTypeModule):
|
||||||
"""pass in a module that contains EntityTypeDesc classes"""
|
"""pass in a module that contains EntityTypeDesc classes"""
|
||||||
self.entTypeModule = entityTypeModule
|
self.entTypeModule = entityTypeModule
|
||||||
|
|
||||||
|
# compute the hash of the source modules as of the time of creation
|
||||||
|
hv = HashVal()
|
||||||
|
import EntityTypes
|
||||||
|
reload(EntityTypes)
|
||||||
|
reload(self.entTypeModule)
|
||||||
|
hv.hashFile(Filename.fromOsSpecific(EntityTypes.__file__))
|
||||||
|
s = str(hv.asHex())
|
||||||
|
s += '.'
|
||||||
|
hv.hashFile(Filename.fromOsSpecific(self.entTypeModule.__file__))
|
||||||
|
s += str(hv.asHex())
|
||||||
|
self.hashStr = s
|
||||||
|
|
||||||
# get a list of the EntityTypeDesc classes in the type module
|
# get a list of the EntityTypeDesc classes in the type module
|
||||||
classes = []
|
classes = []
|
||||||
for key, value in entityTypeModule.__dict__.items():
|
for key, value in entityTypeModule.__dict__.items():
|
||||||
@ -92,7 +106,12 @@ class EntityTypeRegistry:
|
|||||||
def getPermanentTypeNames(self):
|
def getPermanentTypeNames(self):
|
||||||
return self.permanentTypeNames
|
return self.permanentTypeNames
|
||||||
|
|
||||||
|
def getHashStr(self):
|
||||||
|
return self.hashStr
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
|
# THIS IS NOT GUARANTEED TO PRODUCE THE SAME VALUE ACROSS DIFFERENT
|
||||||
|
# MACHINES; use getHashStr instead
|
||||||
return hash(repr(self))
|
return hash(repr(self))
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
# this is used to produce a hash value
|
# this is used to produce a hash value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user