diff options
author | Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net> | 2011-06-02 17:21:58 +0200 |
---|---|---|
committer | Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net> | 2011-06-02 17:21:58 +0200 |
commit | eeebf632e8d15c7fa7705423657e2012b8525a0c (patch) | |
tree | 2288749b3913315f773b7110b02e7cc3e8533369 /minetestmapper | |
parent | 5df1b218a4833b3ee4eca7134d95eb4db10b7a3b (diff) | |
download | minetest-eeebf632e8d15c7fa7705423657e2012b8525a0c.tar.gz minetest-eeebf632e8d15c7fa7705423657e2012b8525a0c.tar.bz2 minetest-eeebf632e8d15c7fa7705423657e2012b8525a0c.zip |
+ check if sectors/sectors2 directories exist before attempting to read them
Diffstat (limited to 'minetestmapper')
-rwxr-xr-x | minetestmapper/minetestmapper2.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/minetestmapper/minetestmapper2.py b/minetestmapper/minetestmapper2.py index b7264fe34..8dc3de2f4 100755 --- a/minetestmapper/minetestmapper2.py +++ b/minetestmapper/minetestmapper2.py @@ -73,25 +73,28 @@ xlist = [] zlist = []
# List all sectors to memory and calculate the width and heigth of the resulting picture.
-for filename in os.listdir(path + "sectors2"):
- for filename2 in os.listdir(path + "sectors2/" + filename):
- x = hex_to_int(filename)
- z = hex_to_int(filename2)
+if os.path.exists(path + "sectors2"):
+ for filename in os.listdir(path + "sectors2"):
+ for filename2 in os.listdir(path + "sectors2/" + filename):
+ x = hex_to_int(filename)
+ z = hex_to_int(filename2)
+ if x < sector_xmin or x > sector_xmax:
+ continue
+ if z < sector_zmin or z > sector_zmax:
+ continue
+ xlist.append(x)
+ zlist.append(z)
+
+if os.path.exists(path + "sectors"):
+ for filename in os.listdir(path + "sectors"):
+ x = hex4_to_int(filename[:4])
+ z = hex4_to_int(filename[-4:])
if x < sector_xmin or x > sector_xmax:
continue
if z < sector_zmin or z > sector_zmax:
continue
xlist.append(x)
zlist.append(z)
-for filename in os.listdir(path + "sectors"):
- x = hex4_to_int(filename[:4])
- z = hex4_to_int(filename[-4:])
- if x < sector_xmin or x > sector_xmax:
- continue
- if z < sector_zmin or z > sector_zmax:
- continue
- xlist.append(x)
- zlist.append(z)
w = (max(xlist) - min(xlist)) * 16 + 16
h = (max(zlist) - min(zlist)) * 16 + 16
|