summaryrefslogtreecommitdiff
path: root/testxml/testxml.py
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-01-25 17:50:37 +0200
committerAndrei Karas <akaras@inbox.ru>2011-01-25 17:50:37 +0200
commit77a4432581baed14124d0efe11cf0baf49ed487e (patch)
treec819f81fed65ffa6f8e3526186aa38735e450309 /testxml/testxml.py
parente7edef63b1f9d35d3504b9bcbd59d6331fe716b8 (diff)
downloadtools-77a4432581baed14124d0efe11cf0baf49ed487e.tar.gz
tools-77a4432581baed14124d0efe11cf0baf49ed487e.tar.bz2
tools-77a4432581baed14124d0efe11cf0baf49ed487e.tar.xz
tools-77a4432581baed14124d0efe11cf0baf49ed487e.zip
testxml: add border check in collision layer.
Diffstat (limited to 'testxml/testxml.py')
-rwxr-xr-xtestxml/testxml.py46
1 files changed, 42 insertions, 4 deletions
diff --git a/testxml/testxml.py b/testxml/testxml.py
index df4f30a..3a9c793 100755
--- a/testxml/testxml.py
+++ b/testxml/testxml.py
@@ -27,6 +27,7 @@ errors = 0
warnings = 0
errDict = set()
safeDye = False
+borderSize = 20
class Tileset:
None
@@ -912,10 +913,10 @@ def testMap(file, path):
if mapWidth == 0 or mapHeight == 0 or mapTileWidth == 0 or mapTileHeight == 0:
return
- if mapWidth < 16:
- showMsgFile(file, "map width to small", False)
- if mapHeight < 16:
- showMsgFile(file, "map height to small", False)
+ if mapWidth < borderSize * 2 + 1:
+ showMsgFile(file, "map width to small: " + str(mapWidth), False)
+ if mapHeight < borderSize * 2 + 1:
+ showMsgFile(file, "map height to small: " + str(mapHeight), False)
tilesMap = dict()
@@ -1067,6 +1068,11 @@ def testMap(file, path):
showMsgFile(file, "missing fringe layer", True)
if collision == None:
showMsgFile(file, "missing collision layer", True)
+ else:
+ ids =testCollisionLayer(file, collision)
+ if ids != None and len(ids) > 0:
+ showLayerErrors(file, ids, "empty tiles in collision border", False)
+
if len(lowLayers) < 1:
showMsgFile(file, "missing low layers", False)
if len(overLayers) < 1:
@@ -1091,6 +1097,38 @@ def testMap(file, path):
showLayerErrors(file, err1, "empty tile in all layers", True)
+def testCollisionLayer(file, layer):
+ haveTiles = False
+ tileset = set()
+ arr = layer.arr
+ x1 = borderSize
+ y1 = borderSize
+ x2 = layer.width - 20
+ y2 = layer.width - 20
+ if x2 < 0:
+ x2 = 0
+ if y2 < 0:
+ y2 = 0
+
+ for x in range(0, layer.width):
+ if haveTiles == True:
+ break
+ for y in range(0, layer.height):
+ idx = ((y * layer.width) + x) * 4
+ val = getLDV(arr, idx)
+ if val != 0:
+ haveTiles = True
+ if val == 0 and (x < x1 or x > x2 or y < y1 or y > y2):
+ tileset.add((x, y))
+
+
+ if haveTiles == False:
+ showMsgFile(file, "empty collision layer", False)
+
+ return tileset
+
+
+
def showLayerErrors(file, points, msg, iserr):
txt = ""
cnt = 0