Magic word crash prevention

This commit is contained in:
John 2015-08-13 23:06:19 +03:00
parent ecc33e1c3d
commit 5f9592cdd7

View file

@ -1,12 +1,9 @@
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from direct.distributed import DistributedObject from direct.distributed import DistributedObject
from otp.ai.MagicWordGlobal import * from otp.ai.MagicWordGlobal import *
lastClickedNametag = None lastClickedNametag = None
class MagicWordManager(DistributedObject.DistributedObject): class MagicWordManager(DistributedObject.DistributedObject):
notify = DirectNotifyGlobal.directNotify.newCategory('MagicWordManager') notify = DirectNotifyGlobal.directNotify.newCategory('MagicWordManager')
neverDisable = 1 neverDisable = 1
@ -20,6 +17,9 @@ class MagicWordManager(DistributedObject.DistributedObject):
DistributedObject.DistributedObject.disable(self) DistributedObject.DistributedObject.disable(self)
def handleMagicWord(self, magicWord): def handleMagicWord(self, magicWord):
if not base.localAvatar.isAdmin():
return
if magicWord.startswith('~~'): if magicWord.startswith('~~'):
if lastClickedNametag == None: if lastClickedNametag == None:
target = base.localAvatar target = base.localAvatar
@ -32,6 +32,7 @@ class MagicWordManager(DistributedObject.DistributedObject):
targetId = target.doId targetId = target.doId
self.sendUpdate('sendMagicWord', [magicWord, targetId]) self.sendUpdate('sendMagicWord', [magicWord, targetId])
if target == base.localAvatar: if target == base.localAvatar:
response = spellbook.process(base.localAvatar, target, magicWord) response = spellbook.process(base.localAvatar, target, magicWord)
if response: if response: