summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-01-20 00:50:15 +0200
committerAndrei Karas <akaras@inbox.ru>2011-01-20 00:50:15 +0200
commita4cd6d374435c629b60a7754c2e8521ae84c389d (patch)
tree2e492aaee0c1d90f923aef4601003083154b4bfd
parent274882231e3996948849ceabd2dbeadc5bca0494 (diff)
downloadevol-tools-a4cd6d374435c629b60a7754c2e8521ae84c389d.tar.gz
evol-tools-a4cd6d374435c629b60a7754c2e8521ae84c389d.tar.bz2
evol-tools-a4cd6d374435c629b60a7754c2e8521ae84c389d.tar.xz
evol-tools-a4cd6d374435c629b60a7754c2e8521ae84c389d.zip
testxml: Add basic validation for npcs.xml
-rwxr-xr-xtestxml/testxml.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/testxml/testxml.py b/testxml/testxml.py
index 8d1804a..dc8a91c 100755
--- a/testxml/testxml.py
+++ b/testxml/testxml.py
@@ -424,7 +424,7 @@ def testSpriteAction(file, name, action, numframes, iserr):
idx = int(frame.attributes["index"].value)
if idx >= numframes or idx < 0:
showMsgSprite(file, "incorrect frame index " + str(idx) + \
- "in action: " + name, iserr)
+ " in action: " + name, iserr)
except:
showMsgSprite(file, "no frame index in action: " + name, iserr)
@@ -443,10 +443,10 @@ def testSpriteAction(file, name, action, numframes, iserr):
i2 = int(sequence.attributes["end"].value)
if i1 >= numframes or i1 < 0:
showMsgSprite(file, "incorrect start sequence index " + str(i1) + \
- "in action: " + name, iserr)
+ " in action: " + name, iserr)
if i2 >= numframes or i2 < 0:
showMsgSprite(file, "incorrect end sequence index " + str(i2) + \
- "in action: " + name, iserr)
+ " in action: " + name, iserr)
except:
showMsgSprite(file, "no sequence start or end index in action: " + name, iserr)
except:
@@ -701,6 +701,29 @@ def testSounds(id, node, type):
testSound(sound.childNodes[0].data)
+def testNpcs(file):
+ global warnings, errors
+ print "Checking npcs.xml"
+ dom = minidom.parse(parentDir + file)
+ idset = set()
+ for node in dom.getElementsByTagName("npc"):
+ try:
+ id = node.attributes["id"].value
+ except:
+ print "error: no id for npc"
+ errors = errors + 1
+ continue
+
+ if id in idset:
+ print "error: duplicate npc id=" + id
+ else:
+ idset.add(id)
+
+ testSprites(id, node, False, True)
+
+
+
+
def haveXml(dir):
if not os.path.isdir(dir) or not os.path.exists(dir):
@@ -732,4 +755,5 @@ enumDirs(parentDir)
loadPaths()
testItems("/items.xml", iconsDir)
testMonsters("/monsters.xml")
+testNpcs("/npcs.xml")
showFooter()