summaryrefslogtreecommitdiff
path: root/hercules
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-19 00:02:49 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-19 00:02:49 +0300
commit3c410c7ab75a2f730ef41ca8d0c55fe1fc23ac13 (patch)
tree254962c8e383822ca6da391d40ef4d9c97aadd4f /hercules
parent3a4c2dc2c190be9c0ecd3407183ccf0b01ced722 (diff)
downloadevol-tools-3c410c7ab75a2f730ef41ca8d0c55fe1fc23ac13.tar.gz
evol-tools-3c410c7ab75a2f730ef41ca8d0c55fe1fc23ac13.tar.bz2
evol-tools-3c410c7ab75a2f730ef41ca8d0c55fe1fc23ac13.tar.xz
evol-tools-3c410c7ab75a2f730ef41ca8d0c55fe1fc23ac13.zip
hercules: convert to acc_reg_num_db.sql
Diffstat (limited to 'hercules')
-rw-r--r--hercules/code/server/accreg.py53
-rw-r--r--hercules/code/server/evol/main.py2
-rw-r--r--hercules/code/server/tmw/main.py2
-rw-r--r--hercules/templates/acc_reg_num_db.sql9
4 files changed, 66 insertions, 0 deletions
diff --git a/hercules/code/server/accreg.py b/hercules/code/server/accreg.py
new file mode 100644
index 0000000..98b0934
--- /dev/null
+++ b/hercules/code/server/accreg.py
@@ -0,0 +1,53 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import re
+
+from code.fileutils import *
+from code.stringutils import *
+from code.server.dbitem import *
+
+def convertAccReg():
+ srcFile = "olddb/accreg.txt"
+ dstFile = "newdb/acc_reg_num_db.sql"
+ fieldsSplit = re.compile("\t")
+ comaSplit = re.compile(",")
+ spaceSplit = re.compile(" ")
+ tpl = readFile("templates/acc_reg_num_db.sql")
+ firstLine = True
+ with open(dstFile, "w") as w:
+ w.write(tpl)
+ w.write("INSERT INTO `acc_reg_num_db` VALUES ")
+ with open(srcFile, "r") as r:
+ for line in r:
+ if line[:2] == "//":
+ continue
+ line = stripNewLine(line)
+ rows = fieldsSplit.split(line)
+ if len(rows) != 2:
+ print "wrong accreg.txt line: " + line
+ continue
+
+ accountId = rows[0]
+
+ data = spaceSplit.split(rows[1])
+ for varStr in data:
+ if varStr == "":
+ continue
+
+ tmp = comaSplit.split(varStr)
+
+ if firstLine == False:
+ w.write(",\n")
+ else:
+ firstLine = False
+
+ w.write(("({account_id},'{key}',{index},{value})").format(
+ account_id = accountId,
+ key = tmp[0],
+ index = "0",
+ value = tmp[1]
+ ))
+ w.write("\n")
diff --git a/hercules/code/server/evol/main.py b/hercules/code/server/evol/main.py
index f00192b..8d62d17 100644
--- a/hercules/code/server/evol/main.py
+++ b/hercules/code/server/evol/main.py
@@ -5,6 +5,7 @@
# Author: Andrei Karas (4144)
from code.server.account import *
+from code.server.accreg import *
from code.server.storage import *
from code.server.db.char import *
from code.server.db.charregnumdb import *
@@ -38,3 +39,4 @@ def dbEvolMain():
saveSkillTable(users)
saveInventoryTable(users)
convertStorage()
+ convertAccReg()
diff --git a/hercules/code/server/tmw/main.py b/hercules/code/server/tmw/main.py
index 8e2e9e3..da8951c 100644
--- a/hercules/code/server/tmw/main.py
+++ b/hercules/code/server/tmw/main.py
@@ -5,6 +5,7 @@
# Author: Andrei Karas (4144)
from code.server.account import *
+from code.server.accreg import *
from code.server.storage import *
from code.server.db.char import *
from code.server.db.charregnumdb import *
@@ -41,3 +42,4 @@ def dbTmwMain():
saveSkillTable(users)
saveInventoryTable(users)
convertStorage()
+ convertAccReg()
diff --git a/hercules/templates/acc_reg_num_db.sql b/hercules/templates/acc_reg_num_db.sql
new file mode 100644
index 0000000..71552c2
--- /dev/null
+++ b/hercules/templates/acc_reg_num_db.sql
@@ -0,0 +1,9 @@
+CREATE TABLE IF NOT EXISTS `acc_reg_num_db` (
+ `account_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `key` VARCHAR(32) BINARY NOT NULL DEFAULT '',
+ `index` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `value` INT(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`account_id`,`key`,`index`),
+ KEY `account_id` (`account_id`)
+) ENGINE=InnoDB;
+