summaryrefslogtreecommitdiff
path: root/hercules/code/server/evol/consts.py
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-29 15:16:29 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-29 15:16:29 +0300
commit8621f3e93bad320dc61ea9bea7cfc4767b1c5a8b (patch)
tree98b81fe09d9cd9406d8b65aa82313148eddbdae2 /hercules/code/server/evol/consts.py
parent3e422ea7eb8e83638971bdff4f584db2750ee0a4 (diff)
downloadtools-8621f3e93bad320dc61ea9bea7cfc4767b1c5a8b.tar.gz
tools-8621f3e93bad320dc61ea9bea7cfc4767b1c5a8b.tar.bz2
tools-8621f3e93bad320dc61ea9bea7cfc4767b1c5a8b.tar.xz
tools-8621f3e93bad320dc61ea9bea7cfc4767b1c5a8b.zip
hercules: add support for convert consts.txt from tmw.
Diffstat (limited to 'hercules/code/server/evol/consts.py')
-rw-r--r--hercules/code/server/evol/consts.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/hercules/code/server/evol/consts.py b/hercules/code/server/evol/consts.py
new file mode 100644
index 0000000..d2c5c9b
--- /dev/null
+++ b/hercules/code/server/evol/consts.py
@@ -0,0 +1,52 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import re
+
+from code.fileutils import *
+from code.stringutils import *
+
+def convertConsts(quests):
+ 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]))
+ # build in parameters
+ w.write("ClientVersion\t10000\t1\n");
+
+ 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 quests:
+ rows[1] = str(quests[rows[0]]) + "\n"
+ 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]))