From 1b06da4e737ed3f9036ec3ff18bc0a776df7e0aa Mon Sep 17 00:00:00 2001 From: Ryan Rector Date: Mon, 11 Jul 2011 10:44:55 -0600 Subject: [PATCH] Rotate region coords based on configured north --- world.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/world.py b/world.py index a53b823..b5ce5a0 100644 --- a/world.py +++ b/world.py @@ -189,7 +189,6 @@ class World(object): def unconvert_coords(self, col, row): """Undoes what convert_coords does. Returns (chunkx, chunky).""" - return ((col - row) / 2, (row + col) / 2) def findTrueSpawn(self): @@ -285,6 +284,7 @@ class World(object): world. Returns (regionx, regiony, filename)""" + join = os.path.join if regionlist is not None: for path in regionlist: @@ -293,7 +293,20 @@ class World(object): if f.startswith("r.") and f.endswith(".mcr"): p = f.split(".") logging.debug("Using path %s from regionlist", f) - yield (int(p[1]), int(p[2]), join(self.worlddir, 'region', f)) + x = int(p[1]) + y = int(p[2]) + if self.north_direction == 'upper-right': + x = -x + y = -y + elif self.north_direction == 'upper-left': + temp = x + x = -y + y = temp + elif self.north_direction == 'lower-right': + temp = x + x = y + y = -temp + yield (x, y, join(self.worlddir, 'region', f)) else: logging.warning("Ignore path '%s' in regionlist", f) @@ -301,7 +314,20 @@ class World(object): for path in glob(os.path.join(self.worlddir, 'region') + "/r.*.*.mcr"): dirpath, f = os.path.split(path) p = f.split(".") - yield (int(p[1]), int(p[2]), join(dirpath, f)) + x = int(p[1]) + y = int(p[2]) + if self.north_direction == 'upper-right': + x = -x + y = -y + elif self.north_direction == 'upper-left': + temp = x + x = -y + y = temp + elif self.north_direction == 'lower-right': + temp = x + x = y + y = -temp + yield (x, y, join(dirpath, f)) def get_save_dir(): """Returns the path to the local saves directory