diff options
Diffstat (limited to 'mapcache')
-rw-r--r-- | mapcache/.gitignore | 3 | ||||
l--------- | mapcache/cachetotmx.py | 1 | ||||
l--------- | mapcache/extract.py | 1 | ||||
l--------- | mapcache/list.py | 1 | ||||
-rwxr-xr-x | mapcache/maptool.py | 172 | ||||
-rw-r--r-- | mapcache/templates/collision.png | bin | 275 -> 0 bytes | |||
-rw-r--r-- | mapcache/templates/example.tmx | 38 | ||||
-rw-r--r-- | mapcache/templates/template.tmx | 25 | ||||
-rw-r--r-- | mapcache/templates/tileset.png | bin | 1132 -> 0 bytes |
9 files changed, 0 insertions, 241 deletions
diff --git a/mapcache/.gitignore b/mapcache/.gitignore deleted file mode 100644 index 9092a2d..0000000 --- a/mapcache/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -clientdata -maps -serverdata diff --git a/mapcache/cachetotmx.py b/mapcache/cachetotmx.py deleted file mode 120000 index df2b3e6..0000000 --- a/mapcache/cachetotmx.py +++ /dev/null @@ -1 +0,0 @@ -maptool.py
\ No newline at end of file diff --git a/mapcache/extract.py b/mapcache/extract.py deleted file mode 120000 index df2b3e6..0000000 --- a/mapcache/extract.py +++ /dev/null @@ -1 +0,0 @@ -maptool.py
\ No newline at end of file diff --git a/mapcache/list.py b/mapcache/list.py deleted file mode 120000 index df2b3e6..0000000 --- a/mapcache/list.py +++ /dev/null @@ -1 +0,0 @@ -maptool.py
\ No newline at end of file diff --git a/mapcache/maptool.py b/mapcache/maptool.py deleted file mode 100755 index 375a25d..0000000 --- a/mapcache/maptool.py +++ /dev/null @@ -1,172 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf8 -*- -# -# Copyright (C) 2014 Evol Online -# Author: Andrei Karas (4144) - -import array -import base64 -import gzip -import os -import re -import datetime -import xml -import csv -import ogg.vorbis -import StringIO -import sys -import zlib -import struct -import shutil - -def detectCommand(): - if sys.argv[0][-8:] == "/list.py": - return "list" - elif sys.argv[0][-11:] == "/extract.py": - return "extract" - elif sys.argv[0][-14:] == "/cachetotmx.py": - return "cachetotmx" - return "help" - -def makeDir(path): - if not os.path.exists(path): - os.makedirs(path) - -def readInt32(f): - data = f.read(4) - arr = array.array("I") - arr.fromstring(data) - return arr[0] - -def readInt16(f): - data = f.read(2) - arr = array.array("H") - arr.fromstring(data) - return arr[0] - -def readMapName(f): - data = f.read(12) - data = str(data) - while data[-1] == '\x00': - data = data[:-1] - return data - -def readData(f, sz): - return f.read(sz) - -def readFile(path): - with open(path, "r") as f: - return f.read() - -def getTile(mapData, x, y, sx): - data = mapData[y * sx + x] - arr = array.array("B") - arr.fromstring(data) - return arr[0] - -def getGroundTile(flag): - return str(flag + 1) - -def getCollisionTile(flag): - if flag == 0: - return "0" - return "4" - -def copyFile(src, dst, name): - shutil.copyfile(src + name, dst + name) - -def saveFile(fileName, data): - with open(fileName, "w") as w: - w.write(data) - -def printHelp(): - print "Unknown options selected." - print "" - print "Use list.py for list maps in cache" - print "Use extract.py to extract maps from cache" - exit(0) - -def listMapCache(f, mapsCount): - print "Known maps:" - print "{0:12} {1:<4}x {2:<4} {3:<10}".format("Map name", "sx", "sy", "compressed size") - for i in xrange(0, mapsCount): - name = readMapName(f) - sx = readInt16(f) - sy = readInt16(f) - sz = readInt32(f) - print "{0:12} {1:<4}x {2:<4} {3:<10}".format(name, sx, sy, sz) - f.seek(sz, 1) - -def extractMaps(f, mapsCount): - destDir = "maps/" - makeDir(destDir) - for i in xrange(0, mapsCount): - name = readMapName(f) - sx = readInt16(f) - sy = readInt16(f) - sz = readInt32(f) - data = readData(f, sz) - dc = zlib.decompressobj() - data = dc.decompress(data) - with open(destDir + name, "wb") as w: - w.write(struct.pack("H", sx)) - w.write(struct.pack("H", sy)) - w.write(data) - -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): - tile = getTile(mapData, x, y, sx) - if x + 1 == sx and y + 1 == sy: - ground = ground + getGroundTile(tile) - collision = collision + getCollisionTile(tile) - fringe = fringe + "0"; - else: - ground = ground + getGroundTile(tile) + "," - collision = collision + getCollisionTile(tile) + "," - fringe = fringe + "0,"; - ground = ground + "\n" - collision = collision + "\n" - saveFile(mapsDir + name + ".tmx", tmx.format(sx, sy, ground, collision, fringe)) - -def readMapCache(path, cmd): - if cmd == "help": - printHelp() - with open(path, "rb") as f: - size = readInt32(f) - if os.path.getsize(path) != size: - print "Map cache corrupted, wrong file size." - exit(1) - mapsCount = readInt16(f) - print "Maps count: " + str(mapsCount) - readInt16(f) # padding - if cmd == "list": - listMapCache(f, mapsCount) - elif cmd == "extract": - extractMaps(f, mapsCount) - elif cmd == "cachetotmx": - covertToTmx(f, mapsCount) - - -readMapCache("serverdata/db/re/map_cache.dat", detectCommand()) diff --git a/mapcache/templates/collision.png b/mapcache/templates/collision.png Binary files differdeleted file mode 100644 index f360c63..0000000 --- a/mapcache/templates/collision.png +++ /dev/null diff --git a/mapcache/templates/example.tmx b/mapcache/templates/example.tmx deleted file mode 100644 index 1d14957..0000000 --- a/mapcache/templates/example.tmx +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd"> -<map version="1.0" orientation="orthogonal" width="10" height="10" tilewidth="32" tileheight="32"> - <tileset firstgid="1" name="tiles" tilewidth="32" tileheight="32"> - <image source="tileset.png" width="64" height="32"/> - </tileset> - <tileset firstgid="3" name="Collision" tilewidth="32" tileheight="32"> - <image source="collision.png" width="64" height="32"/> - </tileset> - <layer name="ground" width="10" height="10"> - <data encoding="csv"> -1,2,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0 -</data> - </layer> - <layer name="Collision" width="10" height="10"> - <data encoding="csv"> -4,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0 -</data> - </layer> -</map> diff --git a/mapcache/templates/template.tmx b/mapcache/templates/template.tmx deleted file mode 100644 index 40d8d14..0000000 --- a/mapcache/templates/template.tmx +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd"> -<map version="1.0" orientation="orthogonal" width="{0}" height="{1}" tilewidth="32" tileheight="32"> - <tileset firstgid="1" name="tiles" tilewidth="32" tileheight="32"> - <image source="../graphics/tilesets/tileset.png" width="64" height="32"/> - </tileset> - <tileset firstgid="3" name="Collision" tilewidth="32" tileheight="32"> - <image source="../graphics/tilesets/collision.png" width="64" height="32"/> - </tileset> - <layer name="ground" width="{0}" height="{1}"> - <data encoding="csv"> -{2} -</data> - </layer> - <layer name="Fringe" width="{0}" height="{1}"> - <data encoding="csv"> -{4} -</data> - </layer> - <layer name="Collision" width="{0}" height="{1}"> - <data encoding="csv"> -{3} -</data> - </layer> -</map> diff --git a/mapcache/templates/tileset.png b/mapcache/templates/tileset.png Binary files differdeleted file mode 100644 index cee4071..0000000 --- a/mapcache/templates/tileset.png +++ /dev/null |