summaryrefslogtreecommitdiff
path: root/hercules/code/server/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/server/maps.py
parent63f135d8af2a81a78626d6229d077e3f91a35288 (diff)
downloadtools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.gz
tools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.bz2
tools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.xz
tools-746192af34a65504cb86a4eca068a8f0fbb361f5.zip
hercules: split implimentation to many files.
Diffstat (limited to 'hercules/code/server/maps.py')
-rw-r--r--hercules/code/server/maps.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/hercules/code/server/maps.py b/hercules/code/server/maps.py
new file mode 100644
index 0000000..2de4bfa
--- /dev/null
+++ b/hercules/code/server/maps.py
@@ -0,0 +1,35 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import zlib
+
+from code.fileutils import *
+
+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)