summaryrefslogtreecommitdiff
path: root/hercules
diff options
context:
space:
mode:
Diffstat (limited to 'hercules')
-rw-r--r--hercules/code/server/itemdb.py4
-rw-r--r--hercules/code/server/npcs.py28
-rwxr-xr-xhercules/convert_server.py4
3 files changed, 27 insertions, 9 deletions
diff --git a/hercules/code/server/itemdb.py b/hercules/code/server/itemdb.py
index 5bdc53a..b86b848 100644
--- a/hercules/code/server/itemdb.py
+++ b/hercules/code/server/itemdb.py
@@ -15,6 +15,7 @@ def convertItemDb():
constsFile = "newserverdata/db/const.txt"
fieldsSplit = re.compile(",")
scriptsSplit = re.compile("{")
+ items = dict()
with open(srcFile, "r") as r:
with open(dstFile, "w") as w:
with open(constsFile, "a") as c:
@@ -36,6 +37,8 @@ def convertItemDb():
if rows[4] == "2":
rows[4] = "0"
rows[3] = str(int(rows[3]) | 4)
+
+ items[rows[1]] = rows[0]
w.write("{\n")
c.write("{0}\t{1}\n".format(rows[1], rows[0]))
writeIntField(w, "Id", rows[0])
@@ -99,3 +102,4 @@ def convertItemDb():
w.write("},\n")
w.write(")\n")
+ return items
diff --git a/hercules/code/server/npcs.py b/hercules/code/server/npcs.py
index 8d8f8f8..6b59736 100644
--- a/hercules/code/server/npcs.py
+++ b/hercules/code/server/npcs.py
@@ -34,10 +34,10 @@ def createMainScript():
w.write("npc: npc/functions/main.txt\n")
w.write("import: npc/scripts.conf\n")
-def convertNpcs():
- processNpcDir("oldserverdata/npc/", "newserverdata/npc/")
+def convertNpcs(items):
+ processNpcDir("oldserverdata/npc/", "newserverdata/npc/", items)
-def processNpcDir(srcDir, dstDir):
+def processNpcDir(srcDir, dstDir, items):
makeDir(dstDir)
files = os.listdir(srcDir)
for file1 in files:
@@ -46,15 +46,16 @@ def processNpcDir(srcDir, dstDir):
srcPath = os.path.abspath(srcDir + os.path.sep + file1)
dstPath = os.path.abspath(dstDir + os.path.sep + file1)
if not os.path.isfile(srcPath):
- processNpcDir(srcPath, dstPath)
+ processNpcDir(srcPath, dstPath, items)
else:
if file1[-5:] == ".conf" or file1[-4:] == ".txt":
- processNpcFile(srcPath, dstPath)
+ processNpcFile(srcPath, dstPath, items)
-def processNpcFile(srcFile, dstFile):
+def processNpcFile(srcFile, dstFile, items):
# print "file: " + srcFile
tracker = ScriptTracker()
tracker.insideScript = False
+ tracker.items = items
with open(srcFile, "r") as r:
with open(dstFile, "w") as w:
tracker.w = w
@@ -144,6 +145,19 @@ def processScript(tracker):
w.write(",{\n");
+def itemsToShop(tracker, itemsStr):
+ itemsSplit = re.compile(",")
+ itemsSplit2 = re.compile(":")
+ itemsDict = tracker.items
+ outStr = ""
+ items = itemsSplit.split(itemsStr)
+ for str2 in items:
+ parts = itemsSplit2.split(str2)
+ if outStr != "":
+ outStr = outStr + ","
+ outStr = outStr + itemsDict[parts[0].strip()] + ":" + parts[1]
+ return outStr
+
def processShop(tracker):
line = tracker.line
w = tracker.w
@@ -160,7 +174,7 @@ def processShop(tracker):
# m.group("tag"), m.group("name"), m.group("class"), m.group("items"))
writeScript(w, m)
- w.write("," + m.group("items") + "\n")
+ w.write("," + itemsToShop(tracker, m.group("items")) + "\n")
def processMapFlag(tracker):
line = tracker.line
diff --git a/hercules/convert_server.py b/hercules/convert_server.py
index 655e4ad..4cbaa89 100755
--- a/hercules/convert_server.py
+++ b/hercules/convert_server.py
@@ -14,9 +14,9 @@ from code.server.questsdb import *
cleanServerData()
createMainScript()
-convertNpcs()
+items = convertItemDb()
+convertNpcs(items)
convertMobDb()
quests = convertQuestsDb()
convertConsts(quests)
-convertItemDb()
convertMobSkillDb()