diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-18 18:52:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-18 19:03:40 +0300 |
commit | 8baf09493f71df2f6ea81802748a638cbb8f6460 (patch) | |
tree | e82601217ad1c96df67ae8da7fdc47b569a20ffb /hercules/code/server | |
parent | a78224ded6873bbb3078a7f01f123551b34a82fb (diff) | |
download | evol-tools-8baf09493f71df2f6ea81802748a638cbb8f6460.tar.gz evol-tools-8baf09493f71df2f6ea81802748a638cbb8f6460.tar.bz2 evol-tools-8baf09493f71df2f6ea81802748a638cbb8f6460.tar.xz evol-tools-8baf09493f71df2f6ea81802748a638cbb8f6460.zip |
hercules: convert to char.sql
Diffstat (limited to 'hercules/code/server')
-rw-r--r-- | hercules/code/server/db/__init__.py | 0 | ||||
-rw-r--r-- | hercules/code/server/db/char.py | 95 | ||||
-rw-r--r-- | hercules/code/server/dbitem.py | 7 | ||||
-rw-r--r-- | hercules/code/server/dbskill.py | 7 | ||||
-rw-r--r-- | hercules/code/server/dbuser.py | 7 | ||||
-rw-r--r-- | hercules/code/server/evol/athena.py | 207 | ||||
-rw-r--r-- | hercules/code/server/evol/main.py | 4 |
7 files changed, 327 insertions, 0 deletions
diff --git a/hercules/code/server/db/__init__.py b/hercules/code/server/db/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/hercules/code/server/db/__init__.py diff --git a/hercules/code/server/db/char.py b/hercules/code/server/db/char.py new file mode 100644 index 0000000..85e60e8 --- /dev/null +++ b/hercules/code/server/db/char.py @@ -0,0 +1,95 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2015 Evol Online +# Author: Andrei Karas (4144) + +from code.fileutils import * +from code.stringutils import * + +def saveCharTable(users): + dstFile = "newdb/char.sql" + firstLine = True + tpl = readFile("templates/char.sql") + with open(dstFile, "w") as w: + w.write(tpl) + w.write("INSERT INTO `char` VALUES ") + for userId in users: + user = users[userId] + + if firstLine == False: + w.write(",\n") + else: + firstLine = False + + w.write(("({char_id},{account_id},{char_num},'{name}',{CLASS}," + + "{base_level},{job_level},{base_exp},{job_exp},{zeny}," + + "{str},{agi},{vit},{INT},{dex},{luk},{max_hp},{hp},{max_sp}," + + "{sp},{status_point},{skill_point},{option},{karma},{manner}," + + "{party_id},{guild_id},{pet_id},{homun_id},{elemental_id}," + + "{hair},{hair_color},{clothes_color},{weapon},{shield}," + + "{head_top},{head_mid},{head_bottom},{robe}," + + "'{last_map}',{last_x},{last_y},'{save_map}',{save_x},{save_y}," + + "{partner_id},{online},{father},{mother},{child},{fame}," + + "{rename},{delete_date},{slotchange},{char_opt},{font}," + + "{unban_time},{uniqueitem_counter},'{sex}')").format( + char_id = user.char_id, + account_id = user.account_id, + char_num = user.char_num, + name = escapeSqlStr(user.char_name), + CLASS = user.char_class, + base_level = user.base_level, + job_level = user.job_level, + base_exp = user.base_exp, + job_exp = user.job_exp, + zeny = user.zeny, + str = user.stat_str, + agi = user.stat_agi, + vit = user.stat_vit, + INT = user.stat_int, + dex = user.stat_dex, + luk = user.stat_luk, + max_hp = user.max_hp, + hp = user.hp, + max_sp = user.max_sp, + sp = user.sp, + status_point = user.status_point, + skill_point = user.skill_point, + option = user.option, + karma = user.karma, + manner = user.manner, + party_id = user.party_id, + guild_id = user.guild_id, + pet_id = user.pet_id, + homun_id = "0", + elemental_id = "0", + hair = user.hair, + hair_color = user.hair_color, + clothes_color = user.clothes_color, + weapon = user.weapon, + shield = user.shield, + head_top = user.head_top, + head_mid = user.head_mid, + head_bottom = user.head_bottom, + robe = "0", + last_map = escapeSqlStr(user.last_map), + last_x = user.last_x, + last_y = user.last_y, + save_map = escapeSqlStr(user.save_map), + save_x = user.save_x, + save_y = user.save_y, + partner_id = user.partner_id, + online = "0", + father = "0", + mother = "0", + child = "0", + fame = "0", + rename = "0", + delete_date = "0", + slotchange = "0", + char_opt = "0", + font = "0", + unban_time = "0", + uniqueitem_counter = len(user.inventory), + sex = "U" + )) + w.write("\n") diff --git a/hercules/code/server/dbitem.py b/hercules/code/server/dbitem.py new file mode 100644 index 0000000..8534ad4 --- /dev/null +++ b/hercules/code/server/dbitem.py @@ -0,0 +1,7 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2015 Evol Online +# Author: Andrei Karas (4144) + +class Item: + pass diff --git a/hercules/code/server/dbskill.py b/hercules/code/server/dbskill.py new file mode 100644 index 0000000..343f3af --- /dev/null +++ b/hercules/code/server/dbskill.py @@ -0,0 +1,7 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2015 Evol Online +# Author: Andrei Karas (4144) + +class Skill: + pass diff --git a/hercules/code/server/dbuser.py b/hercules/code/server/dbuser.py new file mode 100644 index 0000000..95ad55d --- /dev/null +++ b/hercules/code/server/dbuser.py @@ -0,0 +1,7 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2015 Evol Online +# Author: Andrei Karas (4144) + +class User: + pass diff --git a/hercules/code/server/evol/athena.py b/hercules/code/server/evol/athena.py new file mode 100644 index 0000000..9c03202 --- /dev/null +++ b/hercules/code/server/evol/athena.py @@ -0,0 +1,207 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2015 Evol Online +# Author: Andrei Karas (4144) + +import re + +from code.fileutils import * +from code.stringutils import * +from code.server.dbitem import * +from code.server.dbskill import * +from code.server.dbuser import * + +comaSplit = re.compile(",") +spaceSplit = re.compile(" ") + +def parseInventory(line, data): + items = [] + + if data == "": + return items + + rows = spaceSplit.split(data) + if len(rows) < 1: + return items + + for data2 in rows: + if data2 == "": + continue + + rows2 = comaSplit.split(data2) + + if len(rows2) != 12: + print "wrong inventory in account.txt line: " + stripNewLine(line) + continue + + item = Item() + + item.uknownId = rows2[0] + item.itemId = rows2[1] + item.ammount = rows2[2] + item.equip = rows2[3] + item.color = rows2[4] + item.refine = rows2[5] + item.attribute = rows2[6] + item.card0 = rows2[7] + item.card1 = rows2[8] + item.card2 = rows2[9] + item.card3 = rows2[10] + item.broken = rows2[11] + + items.append(item) + + return items + +def parseSkills(line, data): + skills = [] + + if data == "": + return skills + + rows = spaceSplit.split(data) + if len(rows) < 1: + return skills + + for data2 in rows: + if data2 == "": + continue + + rows2 = comaSplit.split(data2) + + if len(rows2) != 2: + print "wrong skills in account.txt line: " + stripNewLine(line) + continue + + skill = Skill() + skill.skillId = rows2[0] + skill.level = int(rows2[1]) & 0xffff + skill.flags = (int(rows2[1]) * 0xffff) & 0xffff + + skills.append(skill) + + return skills + +def parseVars(line, data): + variables = {} + + if data == "": + return variables + + rows = spaceSplit.split(data) + if len(rows) < 1: + return skills + + for data2 in rows: + if data2 == "": + continue + + rows2 = comaSplit.split(data2) + + if len(rows2) != 2: + print "wrong variables in account.txt line: " + stripNewLine(line) + continue + + variables[rows2[0]] = rows2[1] + + return variables + +def readAthena(): + srcFile = "olddb/athena.txt" + fieldsSplit = re.compile("\t") + + users = {} + with open(srcFile, "r") as r: + for line in r: + if line[:2] == "//": + continue + rows = fieldsSplit.split(line) + if len(rows) == 2: + continue + if len(rows) != 20: + print "wrong account.txt line: " + stripNewLine(line) + continue + + user = User() + + user.char_id = rows[0] + tmp = comaSplit.split(rows[1]) + user.account_id = tmp[0] + user.char_num = tmp[1] + user.char_name = rows[2] + + tmp = comaSplit.split(rows[3]) + user.char_class = tmp[0] + user.base_level = tmp[1] + user.job_level = tmp[2] + + tmp = comaSplit.split(rows[4]) + user.base_exp = tmp[0] + user.job_exp = tmp[1] + user.zeny = tmp[2] + + tmp = comaSplit.split(rows[5]) + user.hp = tmp[0] + user.max_hp = tmp[1] + user.sp = tmp[2] + user.max_sp = tmp[3] + + tmp = comaSplit.split(rows[6]) + user.stat_str = tmp[0] + user.stat_agi = tmp[1] + user.stat_vit = tmp[2] + user.stat_int = tmp[3] + user.stat_dex = tmp[4] + user.stat_luk = tmp[5] + + tmp = comaSplit.split(rows[7]) + user.status_point = tmp[0] + user.skill_point = tmp[1] + + tmp = comaSplit.split(rows[8]) + user.option = tmp[0] + user.karma = tmp[1] + user.manner = tmp[2] + + tmp = comaSplit.split(rows[9]) + user.party_id = tmp[0] + user.guild_id = tmp[1] + user.pet_id = tmp[2] + + tmp = comaSplit.split(rows[10]) + user.hair = tmp[0] + user.hair_color = tmp[1] + user.clothes_color = tmp[2] + + tmp = comaSplit.split(rows[11]) + user.weapon = tmp[0] + user.shield = tmp[1] + user.head_top = tmp[2] + user.head_mid = tmp[3] + user.head_bottom = tmp[4] + + tmp = comaSplit.split(rows[12]) + user.last_map = tmp[0] + user.last_x = tmp[1] + user.last_y = tmp[2] + + tmp = comaSplit.split(rows[13]) + user.save_map = tmp[0] + user.save_x = tmp[1] + user.save_y = tmp[2] + user.partner_id = tmp[3] + user.language_id = tmp[4] + + # skip 14 + + user.inventory = parseInventory(line, rows[15]) + + # skip 16 + + user.skills = parseSkills(line, rows[17]) + + user.variables = parseVars(line, rows[18]) + + users[user.char_id] = user + + return users diff --git a/hercules/code/server/evol/main.py b/hercules/code/server/evol/main.py index 2b8681b..6014e05 100644 --- a/hercules/code/server/evol/main.py +++ b/hercules/code/server/evol/main.py @@ -5,6 +5,8 @@ # Author: Andrei Karas (4144) from code.server.account import * +from code.server.db.char import * +from code.server.evol.athena import * from code.server.evol.consts import * from code.server.evol.itemdb import * from code.server.evol.mobdb import * @@ -26,3 +28,5 @@ def serverEvolMain(): def dbEvolMain(): convertAccount() + users = readAthena(); + saveCharTable(users); |