diff options
author | Treeki <treeki@gmail.com> | 2012-09-19 03:15:21 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-19 03:15:21 +0200 |
commit | 4ac70319733723154537be430c50c2197a271c75 (patch) | |
tree | ffd65de9fa476a269a7d1ff9afa55dc2aa3f0a48 /src | |
parent | d272f3d29ab30f112d412e43e2c4c56f55217a99 (diff) | |
download | koopatlas-4ac70319733723154537be430c50c2197a271c75.tar.gz koopatlas-4ac70319733723154537be430c50c2197a271c75.zip |
somehow the path exit fixes got lost in merges, fixed
Diffstat (limited to 'src')
-rw-r--r-- | src/exporter.py | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/src/exporter.py b/src/exporter.py index 547b6fd..f1afd4b 100644 --- a/src/exporter.py +++ b/src/exporter.py @@ -299,34 +299,35 @@ class KPMapExporter: current = len(data) data += struct.pack('>hhiiiiii', x+12, y+12, 0, 0, 0, 0, 0, 0) - # this varies - if node.isStop(): - # figure out the exits by direction - leftExit, rightExit, upExit, downExit = None, None, None, None - - for exit in node.exits: - start, end = exit._startNodeRef(), exit._endNodeRef() - opposite = end if (start == node) else start - - oX, oY = opposite.position - deltaX, deltaY = oX-x, oY-y - angle = math.degrees(math.atan2(deltaX, deltaY)) % 360 - - # Left = 270, Right = 90, Up = 180, Down = 0 - if angle >= 225 and angle <= 315: - leftExit = exit - elif angle >= 45 and angle <= 135: - rightExit = exit - elif angle > 135 and angle < 225: - upExit = exit - elif angle > 315 or angle < 45: - downExit = exit - - exits = [leftExit, rightExit, upExit, downExit] - - else: - # not a stop, so just dump them in - exits = node.exits + [None,None,None,None] + # figure out the exits by direction + exits = [None, None, None, None] + left, right, up, down = 0, 1, 2, 3 + + for exit in node.exits: + start, end = exit._startNodeRef(), exit._endNodeRef() + opposite = end if (start == node) else start + + oX, oY = opposite.position + deltaX, deltaY = oX-x, oY-y + angle = math.degrees(math.atan2(deltaX, deltaY)) % 360 + print "Here: %d,%d Opposite %d,%d Delta: %d,%d Angle: %d" % (x,y,oX,oY,deltaX,deltaY,angle) + + # Left = 270, Right = 90, Up = 180, Down = 0 + if angle >= 225 and angle <= 315: + direction = left + elif angle >= 45 and angle <= 135: + direction = right + elif angle > 135 and angle < 225: + direction = up + elif angle > 315 or angle < 45: + direction = down + + if exits[direction]: + print "Conflicting directions!" + while exits[direction]: + direction = (direction + 1) % 4 + + exits[direction] = exit requiredFixUps.append((current+4, exits[0])) requiredFixUps.append((current+8, exits[1])) |