summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-03 16:15:51 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-03 16:15:51 +0300
commit8c0b57568736abfe5c1d4410ffa64e845881fe71 (patch)
tree7c4df7b65b3b286a3b311932393f2aec2e218c02
parent1f87e2efab56ead96c68d66252811c11582aeae3 (diff)
downloadtools-8c0b57568736abfe5c1d4410ffa64e845881fe71.tar.gz
tools-8c0b57568736abfe5c1d4410ffa64e845881fe71.tar.bz2
tools-8c0b57568736abfe5c1d4410ffa64e845881fe71.tar.xz
tools-8c0b57568736abfe5c1d4410ffa64e845881fe71.zip
hercules: add ability to convert quests db into quests.xml
-rwxr-xr-xhercules/maptool.py41
l---------hercules/queststoxml.py1
-rw-r--r--hercules/templates/quest.tpl5
-rw-r--r--hercules/templates/quests.xml6
4 files changed, 53 insertions, 0 deletions
diff --git a/hercules/maptool.py b/hercules/maptool.py
index 51ff750..ef7fec3 100755
--- a/hercules/maptool.py
+++ b/hercules/maptool.py
@@ -26,6 +26,8 @@ def detectCommand():
return "extractmaps"
elif sys.argv[0][-13:] == "/mapstotmx.py":
return "mapstotmx"
+ elif sys.argv[0][-15:] == "/queststoxml.py":
+ return "queststoxml"
return "help"
def makeDir(path):
@@ -79,6 +81,13 @@ def saveFile(fileName, data):
with open(fileName, "w") as w:
w.write(data)
+def stripQuotes(data):
+ if data[-1] == "\"":
+ data = data[:-1]
+ if data[0] == "\"":
+ data = data[1:]
+ return data
+
def printHelp():
print "Unknown options selected."
print ""
@@ -150,9 +159,41 @@ def covertToTmx(f, mapsCount):
collision = collision + "\n"
saveFile(mapsDir + name + ".tmx", tmx.format(sx, sy, ground, collision, fringe))
+def covertQuests():
+ destDir = "clientdata/"
+ templatesDir = "templates/"
+ questsDbFile = "serverdata/db/quest_db.txt"
+ fieldsSplit = re.compile(",")
+ makeDir(destDir)
+ tpl = readFile(templatesDir + "quest.tpl")
+ quests = readFile(templatesDir + "quests.xml")
+ data = ""
+ with open(questsDbFile, "r") as f:
+ for line in f:
+ if line == "" or line[0:2] == "//":
+ continue
+ rows = fieldsSplit.split(line)
+ if len(rows) < 9:
+ continue
+ questId = rows[0]
+ text = rows[8]
+ if text[-1] == "\n":
+ text = text[:-1]
+ text = stripQuotes(text)
+ name = text
+ if len(name) > 20:
+ name = name[:19]
+
+ data = data + tpl.format(questId, name, text + ": " + str(questId))
+ saveFile(destDir + "quests.xml", quests.format(data))
+
def readMapCache(path, cmd):
if cmd == "help":
printHelp()
+ if cmd == "queststoxml":
+ covertQuests()
+ return
+
with open(path, "rb") as f:
size = readInt32(f)
if os.path.getsize(path) != size:
diff --git a/hercules/queststoxml.py b/hercules/queststoxml.py
new file mode 120000
index 0000000..df2b3e6
--- /dev/null
+++ b/hercules/queststoxml.py
@@ -0,0 +1 @@
+maptool.py \ No newline at end of file
diff --git a/hercules/templates/quest.tpl b/hercules/templates/quest.tpl
new file mode 100644
index 0000000..25615f9
--- /dev/null
+++ b/hercules/templates/quest.tpl
@@ -0,0 +1,5 @@
+ <var id="{0}">
+ <quest name="{1}" group="hercules" incomplete="1" complete="2">
+ <name>{2}</name>
+ </quest>
+ </var>
diff --git a/hercules/templates/quests.xml b/hercules/templates/quests.xml
new file mode 100644
index 0000000..c2828f9
--- /dev/null
+++ b/hercules/templates/quests.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Authors: 4144
+Copyright (C) 2014 Evol Online -->
+<quests>
+{0}
+</quests>