summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hercules/code/server/tmw/itemdb.py54
-rw-r--r--hercules/code/server/tmw/main.py4
-rw-r--r--hercules/code/server/tmw/npcs.py18
-rwxr-xr-xhercules/convert_server.py20
4 files changed, 68 insertions, 28 deletions
diff --git a/hercules/code/server/tmw/itemdb.py b/hercules/code/server/tmw/itemdb.py
index a4cca70..ecd69ca 100644
--- a/hercules/code/server/tmw/itemdb.py
+++ b/hercules/code/server/tmw/itemdb.py
@@ -135,7 +135,7 @@ def replaceStr(line):
line = line.replace(val[0], val[1]);
return line
-def convertItemDb():
+def convertItemDb(isNew):
srcDir = "oldserverdata/world/map/db/"
dstFile = "newserverdata/db/re/item_db.conf"
if os.path.isfile(dstFile):
@@ -177,34 +177,42 @@ def convertItemDb():
c.write("{0}\t{1}\n".format(rows[1], rows[0]))
writeIntField(w, "Id", rows[0])
writeStrField(w, "AegisName", rows[1])
- writeStrField(w, "Name", rows[2])
- if rows[3] == "0":
+ if isNew == True:
+ offset = -1
+ else:
+ offset = 0
+ writeStrField(w, "Name", rows[offset + 2])
+ if rows[offset + 3] == "0":
writeIntField(w, "Type", "2")
else:
- writeIntField(w, "Type", rows[3])
- writeIntField(w, "Buy", rows[4])
- if int(rows[4])*.75 <= int(rows[5])*1.24:
- writeIntField(w, "Sell", str(int(rows[4])*.75))
+ writeIntField(w, "Type", rows[offset + 3])
+ writeIntField(w, "Buy", rows[offset + 4])
+ if int(rows[offset + 4])*.75 <= int(rows[offset + 5])*1.24:
+ writeIntField(w, "Sell", str(int(rows[offset + 4])*.75))
else:
- writeIntField(w, "Sell", rows[5])
- writeIntField(w, "Weight", rows[6])
- writeIntField(w, "Atk", rows[7])
+ writeIntField(w, "Sell", rows[offset + 5])
+ writeIntField(w, "Weight", rows[offset + 6])
+ writeIntField(w, "Atk", rows[offset + 7])
writeIntField(w, "Matk", "0")
- writeIntField(w, "Def", rows[8])
- writeIntField(w, "Range", rows[9])
+ writeIntField(w, "Def", rows[offset + 8])
+ writeIntField(w, "Range", rows[offset + 9])
writeIntField(w, "Slots", "0")
writeIntField(w, "Job", "0xFFFFFFFF")
writeIntField(w, "Upper", "0x3F")
- writeIntField(w, "Gender", rows[12])
- writeIntField(w, "Loc", rows[13])
- writeIntField(w, "WeaponLv", rows[14])
- writeIntField(w, "EquipLv", rows[15])
+ writeIntField(w, "Gender", rows[offset + 12])
+ writeIntField(w, "Loc", rows[offset + 13])
+ writeIntField(w, "WeaponLv", rows[offset + 14])
+ writeIntField(w, "EquipLv", rows[offset + 15])
writeIntField(w, "Refine", "false")
- if rows[13] == "2":
+ if isNew == True:
+ offset = 2
+ else:
+ offset = 0
+ if rows[offset + 13] == "2":
writeIntField(w, "View", "1")
- elif rows[13] == "34":
+ elif rows[offset + 13] == "34":
writeIntField(w, "View", "11")
- elif rows[13] == "32768":
+ elif rows[offset + 13] == "32768":
writeIntField(w, "View", "1")
else:
writeIntField(w, "View", rows[0])
@@ -218,8 +226,12 @@ def convertItemDb():
scripts = scripts + ", " + rows[f]
rows = scriptsSplit.split(scripts)
# Needs .split(';') and \n each
- UseScript = scriptsTextColon.sub(';',scriptsTextComma.sub('', scriptsTextClean.sub('', rows[0]))).strip().split(';')
- EquipScript = scriptsTextColon.sub(';',scriptsTextComma.sub('', scriptsTextClean.sub('', rows[1]))).strip().split(';')
+ if len(rows) > 1:
+ UseScript = scriptsTextColon.sub(';',scriptsTextComma.sub('', scriptsTextClean.sub('', rows[0]))).strip().split(';')
+ EquipScript = scriptsTextColon.sub(';',scriptsTextComma.sub('', scriptsTextClean.sub('', rows[1]))).strip().split(';')
+ else:
+ UseScript = ""
+ EquipScript = ""
# move to for stmt
if len(UseScript) > 1:
writeStartScript(w, "Script")
diff --git a/hercules/code/server/tmw/main.py b/hercules/code/server/tmw/main.py
index 7a872b4..330c860 100644
--- a/hercules/code/server/tmw/main.py
+++ b/hercules/code/server/tmw/main.py
@@ -22,13 +22,13 @@ from code.server.utils import *
from code.server.questsdb import *
from code.serverutils import *
-def serverTmwMain():
+def serverTmwMain(isNew):
try:
cleanServerData()
except:
print "Updating server"
createMainScript()
- items = convertItemDb()
+ items = convertItemDb(isNew)
npcIds = Set()
convertNpcs(items, npcIds)
convertMobDb()
diff --git a/hercules/code/server/tmw/npcs.py b/hercules/code/server/tmw/npcs.py
index e1e9544..2d8abdb 100644
--- a/hercules/code/server/tmw/npcs.py
+++ b/hercules/code/server/tmw/npcs.py
@@ -40,9 +40,10 @@ mapFlagRe2 = re.compile("^(?P<map>[^/](.+))[.]gat" +
warpRe = re.compile("^(?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+)[|]"
"(?P<tag>warp)[|](?P<name>[^|]+)[|](?P<xs>[\d-]+),(?P<ys>[\d-]+),(?P<targetmap>[^/](.+)),([ ]*)(?P<targetx>[\d]+),([ ]*)(?P<targety>[\d]+)$")
-
warpRe2 = re.compile("^(?P<map>[^/](.+))[.]gat,([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+)([\t]+)"
"(?P<tag>warp)[\t](?P<name>[^\t]+)([\t]+)(?P<xs>[\d-]+),(?P<ys>[\d-]+),(?P<targetmap>[^/](.+))[.]gat,([ ]*)(?P<targetx>[\d]+),([ ]*)(?P<targety>[\d]+)$")
+warpRe3 = re.compile("^(?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+)[|]"
+ "(?P<tag>warp)[|](?P<xs>[\d-]+),(?P<ys>[\d-]+),(?P<targetmap>[^/](.+)),([ ]*)(?P<targetx>[\d]+),([ ]*)(?P<targety>[\d]+)$")
monsterRe = re.compile("^(?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+),([ ]*)(?P<xs>[\d-]+),(?P<ys>[\d-]+)[|]"
"(?P<tag>monster)[|](?P<name>[\w#' ]+)[|]"
@@ -177,6 +178,8 @@ def writeScript(w, m, npcIds):
class_ = m.group("class")
if class_ == "0": # hidden npc
class_ = 32767
+ elif class_ == None:
+ class_ = -1;
else:
class_ = int(class_)
# if class_ > 125 and class_ <= 400:
@@ -293,17 +296,26 @@ def processWarp(tracker):
line = tracker.line
w = tracker.w
m = warpRe.search(line)
+ noName = False
if m == None:
m = warpRe2.search(line)
if m == None:
+ m = warpRe3.search(line)
+ noName = True
+ if m == None:
print "error in parsing: " + line
w.write("!!!error parsing line")
w.write(line)
return
+ if noName == True:
+ warpName = "{0}_{1}_{2}".format(m.group("map"), m.group("x"), m.group("y"))
+ else:
+ warpName = m.group("name")
+
# print "source=" + line[:-1]
# print "map={0} xy={1},{2} tag={3} name={4} xs={5} ys={6} target: map={7} xy={8},{9}".format(
-# m.group("map"), m.group("x"), m.group("y"), m.group("tag"), m.group("name"), m.group("xs"), m.group("ys"), m.group("targetmap"), m.group("targetx"), m.group("targety"))
+# m.group("map"), m.group("x"), m.group("y"), m.group("tag"), warpName, m.group("xs"), m.group("ys"), m.group("targetmap"), m.group("targetx"), m.group("targety"))
xs = int(m.group("xs"))
ys = int(m.group("ys"))
@@ -312,7 +324,7 @@ def processWarp(tracker):
if ys < 0:
ys = 0
w.write("{0},{1},{2},{3}\t{4}\t{5}\t{6},{7},{8},{9},{10}\n".format(
- m.group("map"), m.group("x"), m.group("y"), "0", m.group("tag"), m.group("name"),
+ m.group("map"), m.group("x"), m.group("y"), "0", m.group("tag"), warpName,
xs, ys, m.group("targetmap"), m.group("targetx"), m.group("targety")))
diff --git a/hercules/convert_server.py b/hercules/convert_server.py
index f323b4e..6f0f5ba 100755
--- a/hercules/convert_server.py
+++ b/hercules/convert_server.py
@@ -4,12 +4,28 @@
# Copyright (C) 2014 Evol Online
# Author: Andrei Karas (4144)
+import sys
+
from code.serverutils import *
from code.server.evol.main import *
from code.server.tmw.main import *
-serverType = detectServerType()
+def showHelp():
+ print "Usage: ./convert_server.py evol"
+ print " ./convert_server.py tmwold"
+ print " ./convert_server.py tmwnew"
+ exit(1)
+
+if len(sys.argv) != 2:
+ showHelp()
+ exit(1)
+
+serverType = sys.argv[1]
if serverType == "evol":
serverEvolMain();
+elif serverType == "tmwold":
+ serverTmwMain(False);
+elif serverType == "tmwnew":
+ serverTmwMain(True);
else:
- serverTmwMain();
+ print "Wrong parameter" \ No newline at end of file