From 7b35af2e20b7b6eb7fa6086f5b621e900131a583 Mon Sep 17 00:00:00 2001 From: wushin Date: Mon, 16 Feb 2015 21:32:33 -0600 Subject: Herceles: tmw convertor: fix removing existing files --- hercules/code/server/tmw/itemdb.py | 4 ++++ hercules/code/server/tmw/main.py | 5 ++++- hercules/code/server/tmw/npcs.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hercules/code/server/tmw/itemdb.py b/hercules/code/server/tmw/itemdb.py index 96f5cd0..26b4701 100644 --- a/hercules/code/server/tmw/itemdb.py +++ b/hercules/code/server/tmw/itemdb.py @@ -18,7 +18,11 @@ def getItemDbFile(srcDir): def convertItemDb(): srcDir = "oldserverdata/world/map/db/" dstFile = "newserverdata/db/re/item_db.conf" + if os.path.isfile(dstFile): + os.remove(dstFile) constsFile = "newserverdata/db/const.txt" + if os.path.isfile(constsFile): + os.remove(constsFile) fieldsSplit = re.compile(",") scriptsSplit = re.compile("{") items = dict() diff --git a/hercules/code/server/tmw/main.py b/hercules/code/server/tmw/main.py index 4822199..6cd8f07 100644 --- a/hercules/code/server/tmw/main.py +++ b/hercules/code/server/tmw/main.py @@ -14,7 +14,10 @@ from code.server.questsdb import * from code.serverutils import * def serverTmwMain(): - cleanServerData() + try: + cleanServerData() + except: + print "Updating server" createMainScript() items = convertItemDb() convertNpcs(items) diff --git a/hercules/code/server/tmw/npcs.py b/hercules/code/server/tmw/npcs.py index c7edea2..8f26197 100644 --- a/hercules/code/server/tmw/npcs.py +++ b/hercules/code/server/tmw/npcs.py @@ -9,7 +9,11 @@ from code.fileutils import * from code.stringutils import * mapsConfFile = "newserverdata/conf/maps.conf" +if os.path.isfile(mapsConfFile): + os.remove(mapsConfFile) mapsIndexFile = "newserverdata/db/map_index.txt" +if os.path.isfile(mapsIndexFile): + os.remove(mapsIndexFile) npcMainScript = "newserverdata/npc/re/scripts_main.conf" mapsIndex = 1 scriptRe = re.compile("^(((?P[^/](.+)),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+),([ ]*)(?P[\d]+))|(?Pfunction)|-)" + -- cgit v1.2.3-70-g09d2