AI and client check entTypeReg hashes

This commit is contained in:
Darren Ranalli 2003-10-10 22:54:39 +00:00
parent 509110cdc1
commit 0761ade4ae
2 changed files with 19 additions and 2 deletions

View File

@ -112,11 +112,16 @@ class DistributedLevel(DistributedObject.DistributedObject,
# if we're in debug, give the server the opportunity to send us
# a full spec
self.candidateSpec = levelSpec
self.sendUpdate('requestCurrentLevelSpec', [hash(levelSpec)])
self.sendUpdate('requestCurrentLevelSpec',
[hash(levelSpec),
hash(levelSpec.entTypeReg)])
else:
self.privGotSpec(levelSpec)
if __debug__:
def setSpecDeny(self, reason):
DistributedLevel.notify.error(reason)
def setSpecSenderDoId(self, doId):
DistributedLevel.notify.debug('setSpecSenderDoId: %s' % doId)
blobSender = toonbase.tcr.doId2do[doId]

View File

@ -116,8 +116,20 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
self.levelSpec.saveToDisk()
self.modified = 0
def requestCurrentLevelSpec(self, specHash):
def requestCurrentLevelSpec(self, specHash, entTypeRegHash):
senderId = self.air.msgSender
# 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)
if srvHash != entTypeRegHash:
self.sendUpdateToAvatarId(
senderId, 'setSpecDeny',
['EntityTypeRegistry hashes do not match! '
'(server:%s, client:%s' % (srvHash, entTypeRegHash)])
return
spec = None
if hash(self.levelSpec) != specHash:
spec = self.levelSpec