diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-03 16:15:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-03 16:15:51 +0300 |
commit | 8c0b57568736abfe5c1d4410ffa64e845881fe71 (patch) | |
tree | 7c4df7b65b3b286a3b311932393f2aec2e218c02 /hercules/maptool.py | |
parent | 1f87e2efab56ead96c68d66252811c11582aeae3 (diff) | |
download | evol-tools-8c0b57568736abfe5c1d4410ffa64e845881fe71.tar.gz evol-tools-8c0b57568736abfe5c1d4410ffa64e845881fe71.tar.bz2 evol-tools-8c0b57568736abfe5c1d4410ffa64e845881fe71.tar.xz evol-tools-8c0b57568736abfe5c1d4410ffa64e845881fe71.zip |
hercules: add ability to convert quests db into quests.xml
Diffstat (limited to 'hercules/maptool.py')
-rwxr-xr-x | hercules/maptool.py | 41 |
1 files changed, 41 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: |