From 746192af34a65504cb86a4eca068a8f0fbb361f5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 31 Oct 2014 01:08:46 +0300 Subject: hercules: split implimentation to many files. --- hercules/code/servertoclient/maps.py | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 hercules/code/servertoclient/maps.py (limited to 'hercules/code/servertoclient/maps.py') 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)) -- cgit v1.2.3-70-g09d2