Skip to content

Commit

Permalink
Do mob_groups changes for zoneid
Browse files Browse the repository at this point in the history
The server changed how it queries `mob_groups` to index sequentially by zone, so `zoneid` is now required in the query.

Also allow for specifying path to sql, to make it easier to test during server development.
  • Loading branch information
DiscipleOfEris committed May 24, 2023
1 parent f9710bb commit 99e0400
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions EraMobDrops/parse_db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

import os
import re
import sqlite3

sqlPath = r'./sql'

con = sqlite3.connect('mobs_drops.db')
cur = con.cursor()

Expand Down Expand Up @@ -42,7 +45,7 @@
con.commit()


with open('sql/mob_groups.sql') as file:
with open(os.path.join(sqlPath, r'mob_groups.sql')) as file:
fileContents = file.read()
fileContents = re.sub(r"^CREATE DATABASE[^;]*;", "", fileContents, flags=re.IGNORECASE | re.MULTILINE)
fileContents = re.sub(r"^USE[^;]*;", "", fileContents, flags=re.IGNORECASE | re.MULTILINE)
Expand All @@ -51,7 +54,7 @@
fileContents = re.sub(r"\\'", "''", fileContents)
curTemp.executescript(fileContents)

with open('sql/mob_spawn_points.sql') as file:
with open(os.path.join(sqlPath, r'mob_spawn_points.sql')) as file:
fileContents = file.read()
fileContents = re.sub(r"^CREATE DATABASE[^;]*;", "", fileContents, flags=re.IGNORECASE | re.MULTILINE)
fileContents = re.sub(r"^USE[^;]*;", "", fileContents, flags=re.IGNORECASE | re.MULTILINE)
Expand All @@ -60,7 +63,7 @@
fileContents = re.sub(r"\\'", "''", fileContents)
curTemp.executescript(fileContents)

with open('sql/mob_droplist.sql') as file:
with open(os.path.join(sqlPath, r'mob_droplist.sql')) as file:
fileContents = file.read()
fileContents = re.sub(r"^CREATE DATABASE[^;]*;", "", fileContents, flags=re.IGNORECASE | re.MULTILINE)
fileContents = re.sub(r"^USE[^;]*;", "", fileContents, flags=re.IGNORECASE | re.MULTILINE)
Expand All @@ -74,7 +77,7 @@

def mob_generator():
count = 0
for row in curTemp.execute('SELECT * FROM mob_spawn_points INNER JOIN mob_groups ON mob_spawn_points.groupid = mob_groups.groupid'):
for row in curTemp.execute('SELECT * FROM mob_spawn_points INNER JOIN mob_groups ON mob_spawn_points.groupid = mob_groups.groupid AND mob_groups.zoneid = ((mob_spawn_points.mobid >> 12) & 0xFFF)'):
count += 1

alt_name = row['mobname'].replace('_', ' ')
Expand Down Expand Up @@ -104,4 +107,4 @@ def drop_generator():

cur.executemany('INSERT INTO drops (drop_id, drop_type, group_id, group_rate, item_id, item_rate) VALUES (?, ?, ?, ?, ?, ?)', drop_generator())

con.commit()
con.commit()

0 comments on commit 99e0400

Please sign in to comment.