mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -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.sendUpdate('requestCurrentLevelSpec',
|
||||
[hash(levelSpec),
|
||||
hash(levelSpec.entTypeReg)])
|
||||
levelSpec.entTypeReg.getHashStr()])
|
||||
else:
|
||||
self.privGotSpec(levelSpec)
|
||||
|
||||
|
@ -180,10 +180,14 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
|
||||
def requestCurrentLevelSpec(self, specHash, entTypeRegHash):
|
||||
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
|
||||
# client should not be connecting. Their entityTypeRegistry
|
||||
# is different from ours.
|
||||
srvHash = hash(self.levelSpec.entTypeReg)
|
||||
srvHash = self.levelSpec.entTypeReg.getHashStr()
|
||||
self.notify.info('srv entTypeRegHash %s' % srvHash)
|
||||
if srvHash != entTypeRegHash:
|
||||
self.sendUpdateToAvatarId(
|
||||
senderId, 'setSpecDeny',
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""EntityTypeRegistry module: contains the EntityTypeRegistry class"""
|
||||
|
||||
from PandaModules import *
|
||||
import DirectNotifyGlobal
|
||||
import types
|
||||
import AttribDesc
|
||||
@ -12,6 +13,19 @@ class EntityTypeRegistry:
|
||||
def __init__(self, entityTypeModule):
|
||||
"""pass in a module that contains EntityTypeDesc classes"""
|
||||
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
|
||||
classes = []
|
||||
for key, value in entityTypeModule.__dict__.items():
|
||||
@ -92,7 +106,12 @@ class EntityTypeRegistry:
|
||||
def getPermanentTypeNames(self):
|
||||
return self.permanentTypeNames
|
||||
|
||||
def getHashStr(self):
|
||||
return self.hashStr
|
||||
|
||||
def __hash__(self):
|
||||
# THIS IS NOT GUARANTEED TO PRODUCE THE SAME VALUE ACROSS DIFFERENT
|
||||
# MACHINES; use getHashStr instead
|
||||
return hash(repr(self))
|
||||
def __repr__(self):
|
||||
# this is used to produce a hash value
|
||||
|
Loading…
x
Reference in New Issue
Block a user