summaryrefslogtreecommitdiff
path: root/hercules/code/servertoclient/maps.py
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-10-31 01:08:46 +0300
committerAndrei Karas <akaras@inbox.ru>2014-10-31 12:19:12 +0300
commit746192af34a65504cb86a4eca068a8f0fbb361f5 (patch)
tree12d399627720f7fc72e66deb64bac7ef0d9eb71e /hercules/code/servertoclient/maps.py
parent63f135d8af2a81a78626d6229d077e3f91a35288 (diff)
downloadevol-tools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.gz
evol-tools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.bz2
evol-tools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.xz
evol-tools-746192af34a65504cb86a4eca068a8f0fbb361f5.zip
hercules: split implimentation to many files.
Diffstat (limited to 'hercules/code/servertoclient/maps.py')
-rw-r--r--hercules/code/servertoclient/maps.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/hercules/code/servertoclient/maps.py b/hercules/code/servertoclient/maps.py
new file mode 100644
index 0000000..e0a7641
--- /dev/null
+++ b/hercules/code/servertoclient/maps.py
@@ -0,0 +1,48 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import zlib
+
+from code.fileutils import *
+from code.tileutils import *
+
+def covertToTmx(f, mapsCount):
+ destDir = "clientdata/"
+ mapsDir = destDir + "maps/"
+ tilesetsDir = destDir + "graphics/tilesets/"
+ templatesDir = "templates/"
+ makeDir(mapsDir)
+ makeDir(tilesetsDir)
+ copyFile(templatesDir, tilesetsDir, "collision.png")
+ copyFile(templatesDir, tilesetsDir, "tileset.png")
+ tmx = readFile("templates/template.tmx")
+ for i in xrange(0, mapsCount):
+ name = readMapName(f)
+ print "converting map [{0:4}/{1:4}]: {2}".format(i, mapsCount + 1, name)
+ sx = readInt16(f)
+ sy = readInt16(f)
+ sz = readInt32(f)
+ mapData = readData(f, sz)
+ dc = zlib.decompressobj()
+ mapData = dc.decompress(mapData)
+ ground = ""
+ collision = ""
+ fringe = ""
+ for y in xrange(0, sy):
+ for x in xrange(0, sx):
+ tileData = getTileData(mapData, x, y, sx)
+ tile = getTile(tileData)
+ if x + 1 == sx and y + 1 == sy:
+ ground = ground + tile[0]
+ collision = collision + tile[1]
+ fringe = fringe + "0";
+ else:
+ ground = ground + tile[0] + ","
+ collision = collision + tile[1] + ","
+ fringe = fringe + "0,";
+ ground = ground + "\n"
+ collision = collision + "\n"
+ fringe = fringe + "\n"
+ saveFile(mapsDir + name + ".tmx", tmx.format(sx, sy, ground, collision, fringe))