summaryrefslogtreecommitdiff
path: root/merge-server.py
blob: 04441efabb144a6ed057273132c1304af681a0f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/python3
# This consolidates server databases
import os, traceback

MYSELF="serverdata/"
EVOLVED="../pre-renewal/server-data/"
MOUBOO="../server-data/"
REVOLT="../evol/server-data/"

# Rewrite db/re/item_db.conf
# Pets? Can't be carried over :< Homunculus? Same :<
# Skills? Eugh.

os.chdir("..")
item_db=[]

## Moubootaur Legends is a raw copy
with open("%s/db/re/item_db.conf" % MOUBOO, "r") as f:
    for l in f:
        #l=l.replace("    ", "\t")
        ## Add headers
        if "== License ==" in l:
            item_db.append("//=========================================================================\n")
            item_db.append("// This file is generated automatically.\n")
            item_db.append("// Please do not edit it directly.\n")
        ## Save the line
        item_db.append(l)
    while not ")" in item_db[-1]:
        item_db=item_db[:-1]
item_db=item_db[:-1]
print("\033[32;1mMoubootaur Legends OK\033[0m")

## Legacy/Evolved has an offset of 10k
with open("%s/db/pre-re/item_db.conf" % EVOLVED, "r") as f:
    for l in f:
        l=l.replace("    ", "\t")
        if "item_db:" in l:
            continue

        if "\tId:" in l:
            tmp=l.split("Id:")
            try:
                tmp[1]=str(int(tmp[1]) + 10000)
            except:
                traceback.print_exc()
                tmp[1]="19999"
            l="Id:".join(tmp)
            l+="\n"

        if "\tAegisName:" in l:
            tmp=l.split("\"")
            tmp[1]="L_%s" % tmp[1]
            l="\"".join(tmp)

        if "\tName:" in l:
            tmp=l.split("\"")
            tmp[1]="L %s" % tmp[1]
            l="\"".join(tmp)

        item_db.append(l)
    while not ")" in item_db[-1]:
        item_db=item_db[:-1]
item_db=item_db[:-1]
print("\033[32;1mLegacy/Evolved OK\033[0m")

## rEvolt has an offset of 20k
with open("%s/db/re/item_db.conf" % REVOLT, "r") as f:
    for l in f:
        l=l.replace("    ", "\t")
        if "item_db:" in l:
            continue

        if "\tId:" in l:
            tmp=l.split("Id:")
            try:
                tmp[1]=str(int(tmp[1]) + 20000)
            except:
                traceback.print_exc()
                tmp[1]="29999"
            l="Id:".join(tmp)
            l+="\n"

        if "\tAegisName:" in l:
            tmp=l.split("\"")
            tmp[1]="R_%s" % tmp[1]
            l="\"".join(tmp)

        if "\tName:" in l:
            tmp=l.split("\"")
            tmp[1]="R %s" % tmp[1]
            l="\"".join(tmp)

        item_db.append(l)
    while not ")" in item_db[-1]:
        item_db=item_db[:-1]
#item_db=item_db[:-1]
print("\033[32;1mrEvolt OK\033[0m")


## Save the final item database
with open(MYSELF+"db/re/item_db.conf", "w") as f:
    for l in item_db:
        f.write(l)

print("\033[33;1mSaved! Databases merged!\033[0m")