Last active
May 23, 2018 20:55
-
-
Save darvid/5686293 to your computer and use it in GitHub Desktop.
Generates an indexed table of item entries and icons from WoW DBCs (converted to CSV).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generates SQL to populate a table of item IDs mapped to icon names. | |
* Step 1. Convert `Item.dbc` and `ItemDisplayInfo.dbc` to CSV files, e.g. with | |
`http://www.mediafire.com/?1sydm4aoi9i` | |
* Step 2. Export item quality to CSV with this command: | |
`mysql -utrinity -p world --execute "SELECT entry, quality ` | |
`INTO OUTFILE '/tmp/item_quality.sql' FIELDS TERMINATED BY ','` | |
`OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n'` | |
`FROM item_template"` | |
* Step 3. Run `python generate_item_icons.py > item_icons.sql` and then | |
`mysql -u<username> -p <website db> < item_icons.sql`. | |
* Step 4. ??? | |
* Step 5. Profit! | |
""" | |
import csv | |
def main(): | |
print("""\ | |
DROP TABLE IF EXISTS `item_icons`; | |
CREATE TABLE `item_icons` ( | |
`item` int(11) NOT NULL, | |
`quality` tinyint NOT NULL, | |
`icon` varchar(255) NOT NULL, | |
PRIMARY KEY (`item`) | |
); | |
INSERT INTO `item_icons` VALUES\ | |
""") | |
item_quality = {} | |
item_display_info = {} | |
with open("ItemDisplayInfo.dbc.csv", "rb") as dbc: | |
for row in csv.reader(dbc): | |
item_display_info[int(row[0])] = row[5].lower() | |
with open("item_quality.csv", "rb") as csvfile: | |
for row in csv.reader(csvfile): | |
item_quality[int(row[0])] = int(row[1]) | |
with open("Item.dbc.csv", "rb") as dbc: | |
entries = [] | |
for row in csv.reader(dbc): | |
entry = int(row[0]) | |
if entry not in item_quality: | |
continue | |
entries.append("({0}, {1}, '{2}')".format( | |
row[0], | |
item_quality[entry], | |
item_display_info[int(row[5])]) | |
) | |
print(",\n".join(entries) + ";") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment