diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-02 13:38:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-02 14:37:41 +0300 |
commit | f648ef1a6d5ca562e76362f077cba2b5661cf24c (patch) | |
tree | dca1605fab8e6d3ec3d4981dffcca19b06401ad2 | |
parent | 8dc2b2020ec745d33575c35821f8279d351519f2 (diff) | |
download | evol-tools-f648ef1a6d5ca562e76362f077cba2b5661cf24c.tar.gz evol-tools-f648ef1a6d5ca562e76362f077cba2b5661cf24c.tar.bz2 evol-tools-f648ef1a6d5ca562e76362f077cba2b5661cf24c.tar.xz evol-tools-f648ef1a6d5ca562e76362f077cba2b5661cf24c.zip |
hercules: add const conversion.
-rw-r--r-- | hercules/code/server/consts.py | 48 | ||||
-rwxr-xr-x | hercules/convert_server.py | 2 |
2 files changed, 50 insertions, 0 deletions
diff --git a/hercules/code/server/consts.py b/hercules/code/server/consts.py new file mode 100644 index 0000000..e132581 --- /dev/null +++ b/hercules/code/server/consts.py @@ -0,0 +1,48 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2014 Evol Online +# Author: Andrei Karas (4144) + +import re + +from code.fileutils import * +from code.stringutils import * + +def convertConsts(): + dstFile = "newserverdata/db/const.txt" + fieldsSplit = re.compile("\t+") + fields = dict() + with open(dstFile, "w") as w: + srcFile = "serverdata/db/const.txt" + with open(srcFile, "r") as r: + for line in r: + if len(line) < 2 or line[0:2] == "//": + continue + line = line.replace(" ", "\t") + rows = fieldsSplit.split(line) + sz = len(rows) + if sz < 2 or sz > 3: + continue + + fields[rows[0]] = rows[1][:-1] + if sz == 2: + w.write("{0}\t{1}".format(rows[0], rows[1])) + else: + w.write("{0}\t{1}\t{2}".format(rows[0], rows[1], rows[2])) + + srcFile = "oldserverdata/db/const.txt" + w.write("// evol constants\n") + with open(srcFile, "r") as r: + for line in r: + if len(line) < 2 or line[0:2] == "//": + continue + line = line.replace(" ", "\t") + rows = fieldsSplit.split(line) + if len(rows) != 2: + continue + + if rows[0] in fields: + if fields[rows[0]] != rows[1][:-1]: + print "warning: different const values for {0} ({1}, {2})".format(rows[0], rows[1][:-1], fields[rows[0]]) + else: + w.write("{0}\t{1}".format(rows[0], rows[1])) diff --git a/hercules/convert_server.py b/hercules/convert_server.py index 9968218..563ee70 100755 --- a/hercules/convert_server.py +++ b/hercules/convert_server.py @@ -4,6 +4,7 @@ # Copyright (C) 2014 Evol Online # Author: Andrei Karas (4144) +from code.server.consts import * from code.server.itemdb import * from code.server.mobdb import * from code.server.npcs import * @@ -14,3 +15,4 @@ createMainScript() convertNpcs() convertMobDb() convertItemDb() +convertConsts() |