diff options
-rw-r--r-- | src/exporter.py | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/exporter.py b/src/exporter.py index b90cc49..0e2ab1e 100644 --- a/src/exporter.py +++ b/src/exporter.py @@ -296,35 +296,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 - 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: - 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])) |