Browse Source

ai-dev -> want-dev, HQ code uses __dev__

Darren Ranalli 22 years ago
parent
commit
adb24ce408

+ 2 - 2
direct/src/level/BasicEntities.py

@@ -21,7 +21,7 @@ class NodePathEntityBase:
         self.getNodePath().setName('%s-%s' %
                                    (self.__class__.__name__, self.entId))
 
-        if __debug__:
+        if __dev__:
             # for the editor
             self.getNodePath().setTag('entity', '1')
 
@@ -30,7 +30,7 @@ class NodePathEntityBase:
         self.level.requestReparent(self, self.parentEntId)
 
     def destroy(self):
-        if __debug__:
+        if __dev__:
             # for the editor
             self.getNodePath().clearTag('entity')
 

+ 1 - 1
direct/src/level/DistributedEntityAI.py

@@ -31,7 +31,7 @@ class DistributedEntityAI(DistributedObjectAI.DistributedObjectAI,
     def getEntId(self):
         return self.entId
 
-    if __debug__:
+    if __dev__:
         def setParentEntId(self, parentEntId):
             self.parentEntId = parentEntId
             # switch to new zone

+ 4 - 4
direct/src/level/DistributedLevel.py

@@ -136,8 +136,8 @@ class DistributedLevel(DistributedObject.DistributedObject,
     def initializeLevel(self, levelSpec):
         """subclass should call this as soon as it's located its level spec.
         Must be called after obj has been generated."""
-        if __debug__:
-            # if we're in debug, give the server the opportunity to send us
+        if __dev__:
+            # if we're in dev, give the server the opportunity to send us
             # a full spec
             self.candidateSpec = levelSpec
             self.sendUpdate('requestCurrentLevelSpec',
@@ -146,7 +146,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
         else:
             self.privGotSpec(levelSpec)
 
-    if __debug__:
+    if __dev__:
         def setSpecDeny(self, reason):
             DistributedLevel.notify.error(reason)
             
@@ -633,7 +633,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
             self.visChangedThisFrame = 0
         return Task.cont
 
-    if __debug__:
+    if __dev__:
         # level editing stuff
         def setAttribChange(self, entId, attribName, valueStr, username):
             """every time the spec is edited, we get this message

+ 4 - 4
direct/src/level/DistributedLevelAI.py

@@ -30,7 +30,7 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
         self.presentAvIds = list(self.avIdList)
         self.notify.debug("expecting avatars: %s" % str(self.avIdList))
 
-        if __debug__:
+        if __dev__:
             self.modified = 0
 
     def generate(self, levelSpec):
@@ -57,7 +57,7 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
 
     def delete(self):
         self.notify.debug('delete')
-        if __debug__:
+        if __dev__:
             self.removeAutosaveTask()
         self.destroyLevel()
         self.ignoreAll()
@@ -79,7 +79,7 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
 
         Level.Level.initializeLevel(self, self.doId, levelSpec, scenarioIndex)
 
-        if __debug__:
+        if __dev__:
             # listen for requests to save the spec
             self.accept(self.editMgrEntity.getSpecSaveEvent(), self.saveSpec)
 
@@ -125,7 +125,7 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
         if av and (penalty > 0):
             av.takeDamage(penalty)
         
-    if __debug__:
+    if __dev__:
         # level editors should call this func to tweak attributes of level
         # entities
         def setAttribChange(self, entId, attribName, value, username='SYSTEM'):

+ 1 - 1
direct/src/level/EditMgrAI.py

@@ -7,7 +7,7 @@ if __debug__:
 
 class EditMgrAI(EditMgrBase.EditMgrBase):
     """This class handles AI-side editor-specific functionality"""
-    if __debug__:
+    if __dev__:
         def setRequestNewEntity(self, data):
             # pick an unused entId
             spec = self.level.levelSpec

+ 1 - 1
direct/src/level/EditMgrBase.py

@@ -13,7 +13,7 @@ class EditMgrBase(Entity.Entity):
         Entity.Entity.destroy(self)
         self.ignoreAll()
 
-    if __debug__:
+    if __dev__:
         def setInsertEntity(self, data):
             # tell the level who created this entity
             self.level.setEntityCreatorUsername(data['entId'], data['username'])

+ 6 - 5
direct/src/level/Entity.py

@@ -88,6 +88,12 @@ class Entity(DirectObject):
         self.__dict__[attrib] = value
 
     if __debug__:
+        def debugPrint(self, message):
+            """for debugging"""
+            return self.notify.debug(
+                    str(self.__dict__.get('entId', '?'))+' '+message)
+
+    if __dev__:
         # support for level editing
         def handleAttribChange(self, attrib, value):
             # call callback function if it exists
@@ -110,8 +116,3 @@ class Entity(DirectObject):
             in your derived class
             """
             pass
-
-        def debugPrint(self, message):
-            """for debugging"""
-            return self.notify.debug(
-                    str(self.__dict__.get('entId', '?'))+' '+message)

+ 1 - 1
direct/src/level/EntrancePoint.py

@@ -32,7 +32,7 @@ class EntrancePoint(BasicEntities.NodePathEntity):
             if self.level.entranceId2entity.has_key(self.entranceId):
                 del self.level.entranceId2entity[self.entranceId]
 
-    if __debug__:
+    if __dev__:
         def attribChanged(self, *args):
             BasicEntities.NodePathEntity.attribChanged(self, *args)
             self.destroyEntrancePoint()

+ 5 - 6
direct/src/level/Level.py

@@ -44,7 +44,7 @@ class Level:
         self.scenarioIndex = scenarioIndex
 
         self.levelSpec.setScenario(self.scenarioIndex)
-        if __debug__:
+        if __dev__:
             self.levelSpec.setLevel(self)
 
         # create some handy tables
@@ -84,11 +84,10 @@ class Level:
         assert self.entType2ids['levelMgr'][0] == LevelConstants.LevelMgrEntId
         self.levelMgrEntity = self.getEntity(LevelConstants.LevelMgrEntId)
 
+        # there should be one and only one editMgr
+        assert len(self.entType2ids['editMgr']) == 1
+        assert self.entType2ids['editMgr'][0] == LevelConstants.EditMgrEntId
         if __debug__:
-            # there should be one and only one editMgr
-            assert len(self.entType2ids['editMgr']) == 1
-            assert self.entType2ids['editMgr'][0] == \
-                   LevelConstants.EditMgrEntId
             self.editMgrEntity = self.getEntity(LevelConstants.EditMgrEntId)
 
         # there should be one and only one UberZone
@@ -349,7 +348,7 @@ class Level:
         """the zone visibility lists have changed"""
         pass
     
-    if __debug__:
+    if __dev__:
         # the level generates these events when the spec changes
         def getAttribChangeEventName(self):
             return 'attribChange-%s' % self.levelId

+ 6 - 6
direct/src/level/LevelSpec.py

@@ -5,7 +5,7 @@ from PythonUtil import list2dict, uniqueElements
 import string
 import LevelConstants
 import types
-if __debug__:
+if __dev__:
     import os
 
 class LevelSpec:
@@ -19,17 +19,17 @@ class LevelSpec:
         If not passed in, will create a new spec."""
         newSpec = 0
         if type(spec) is types.ModuleType:
-            if __debug__:
+            if __dev__:
                 # reload the spec module to pick up changes
                 reload(spec)
             self.specDict = spec.levelSpec
-            if __debug__:
+            if __dev__:
                 self.setFilename(spec.__file__)
         elif type(spec) is types.DictType:
             # we need this for repr/eval-ing LevelSpecs
             self.specDict = spec
         elif spec is None:
-            if __debug__:
+            if __dev__:
                 newSpec = 1
                 self.specDict = {
                     'globalEntities': {},
@@ -52,7 +52,7 @@ class LevelSpec:
 
         self.setScenario(scenario)
 
-        if __debug__:
+        if __dev__:
             if newSpec:
                 # add required entities
 
@@ -139,7 +139,7 @@ class LevelSpec:
     def privGetScenarioEntityDict(self, scenario):
         return self.specDict['scenarios'][scenario][0]
 
-    if __debug__:
+    if __dev__:
         def setLevel(self, level):
             self.level = level
 

+ 1 - 1
direct/src/level/PropSpinner.py

@@ -47,7 +47,7 @@ class PropSpinner(Entity.Entity):
             self.spinTracks.pause()
             del self.spinTracks
 
-    if __debug__:
+    if __dev__:
         def attribChanged(self, *args):
             self.destroyProps()
             self.initProps()

+ 1 - 1
direct/src/level/VisibilityExtender.py

@@ -46,7 +46,7 @@ class VisibilityExtender(Entity.Entity):
         self.destroyVisExt()
         Entity.Entity.destroy(self)
 
-    if __debug__:
+    if __dev__:
         def setNewZones(self, newZones):
             # we need to call destroyVisExt before accepting the new zone set
             self.destroyVisExt()

+ 1 - 1
direct/src/level/ZoneEntity.py

@@ -40,7 +40,7 @@ class ZoneEntity(ZoneEntityBase.ZoneEntityBase, BasicEntities.NodePathAttribs):
             if self.visibleZoneNums[zoneNum] == 0:
                 del self.visibleZoneNums[zoneNum]
 
-    if __debug__:
+    if __dev__:
         def setVisibility(self, visibility):
             self.decrementRefCounts(self.visibility)
             self.visibility = visibility

+ 1 - 1
direct/src/showbase/ShowBaseGlobal.py

@@ -13,4 +13,4 @@ def inspect(anObject):
     return Inspector.inspect(anObject)
 
 __builtins__["inspect"] = inspect
-
+__builtins__["__dev__"] = base.config.GetBool('want-dev', 0)