From a5b83b03d6fc567c51abded0736659b7513d91e7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 2 Feb 2016 14:45:44 +0300 Subject: hercules: Fix parsing npc scripts from old tmw server. --- hercules/code/server/evol/npcs.py | 3 +-- hercules/code/server/tmw/npcs.py | 52 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/hercules/code/server/evol/npcs.py b/hercules/code/server/evol/npcs.py index 2082b23..2d198c1 100644 --- a/hercules/code/server/evol/npcs.py +++ b/hercules/code/server/evol/npcs.py @@ -66,7 +66,7 @@ def processNpcFile(srcFile, dstFile, items): with open(dstFile, "w") as w: tracker.w = w for line in r: - tracker.line = line + tracker.line = stripWindows(line) res = convertTextLine(tracker) if res: w.write(tracker.line) @@ -258,7 +258,6 @@ def processStrReplace(tracker): w = tracker.w line = line.replace("setskill ", "addtoskill ") line = line.replace("zeny", "Zeny") - line = line.replace("countitem(", "countitemcolor(") line = line.replace("getclientversion(\"\")", "ClientVersion") line = line.replace("getclientversion()", "ClientVersion") line = line.replace("setlang @", "Lang = @") diff --git a/hercules/code/server/tmw/npcs.py b/hercules/code/server/tmw/npcs.py index dae9b00..525de7c 100644 --- a/hercules/code/server/tmw/npcs.py +++ b/hercules/code/server/tmw/npcs.py @@ -20,20 +20,38 @@ scriptRe = re.compile("^(((?P[^/](.+)),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+ "[|](?Pscript)[|](?P[^|]+)([|]" "(?P[\d-]+)((,((?P[\d]+),(?P[\d]+)))|)|)$") +scriptRe2 = re.compile("^(((?P[^/](.+))[.]gat,([ ]*)(?P[\d]+),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+))|(?Pfunction)|-)" + + "[\t](?Pscript)[\t](?P[\w#'\\[\\]_ äü.-]+)[\t]" + "(((?P[\d-]+)((,((?P[\d-]+),(?P[\d-]+)))|)(|,)(|[ \t]))|){(|[ ])$") + shopRe = re.compile("^(?P[^/](.+)),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+)(|,(?P[\d]+))" + "[|](?Pshop)[|](?P[\w#' ]+)[|]" "(?P[\d]+),(?P(.+))$") +shopRe2 = re.compile("^(?P[^/](.+))[.]gat,([ ]*)(?P[\d]+),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+)" + + "[\t](?Pshop)[\t](?P[\w#'\\[\\] ]+)[\t]" + "(?P[\d]+),(?P(.+))$") + mapFlagRe = re.compile("^(?P[^/](.+))" + "[|](?Pmapflag)[|](?P[\w#']+)(|[|](?P.*))$") +mapFlagRe2 = re.compile("^(?P[^/](.+))[.]gat" + + "[ ](?Pmapflag)[ ](?P[\w#']+)(|[ ](?P.*))$") + warpRe = re.compile("^(?P[^/](.+)),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+)[|]" "(?Pwarp)[|](?P[^|]+)[|](?P[\d-]+),(?P[\d-]+),(?P[^/](.+)),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+)$") +warpRe2 = re.compile("^(?P[^/](.+))[.]gat,([ ]*)(?P[\d]+),([ ]*)(?P[\d]+)([\t]+)" + "(?Pwarp)[\t](?P[^\t]+)([\t]+)(?P[\d-]+),(?P[\d-]+),(?P[^/](.+))[.]gat,([ ]*)(?P[\d]+),([ ]*)(?P[\d]+)$") + monsterRe = re.compile("^(?P[^/](.+)),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+),([ ]*)(?P[\d-]+),(?P[\d-]+)[|]" "(?Pmonster)[|](?P[\w#' ]+)[|]" "(?P[\d]+),(?P[\d]+),(?P[\d]+)ms,(?P[\d]+)ms(|,(?P