mirror of
https://github.com/drmext/MonkeyBusiness.git
synced 2024-12-18 02:16:02 +01:00
Fix slow loading DDR records again
This commit is contained in:
parent
d219f9b08d
commit
80c11ccb8c
@ -353,7 +353,7 @@ async def usergamedata_advanced(request: Request):
|
|||||||
mcode = int(n.find("mcode").text)
|
mcode = int(n.find("mcode").text)
|
||||||
if int(n.find("clearkind").text) != 1:
|
if int(n.find("clearkind").text) != 1:
|
||||||
for grade, course_id in enumerate(range(1000, 1011), start=1):
|
for grade, course_id in enumerate(range(1000, 1011), start=1):
|
||||||
if playstyle == 0 and mcode in (course_id, course_id + 11):
|
if playstyle in (0, 2) and mcode in (course_id, course_id + 11):
|
||||||
single_grade = grade
|
single_grade = grade
|
||||||
elif playstyle == 1 and mcode in (
|
elif playstyle == 1 and mcode in (
|
||||||
course_id + 1000,
|
course_id + 1000,
|
||||||
@ -391,24 +391,16 @@ async def usergamedata_advanced(request: Request):
|
|||||||
& (where("ddr_id") != 0)
|
& (where("ddr_id") != 0)
|
||||||
):
|
):
|
||||||
ddr_id = record["ddr_id"]
|
ddr_id = record["ddr_id"]
|
||||||
playstyle = record["playstyle"]
|
|
||||||
mcode = record["mcode"]
|
mcode = record["mcode"]
|
||||||
difficulty = record["difficulty"]
|
difficulty = record["difficulty"]
|
||||||
score = record["score"]
|
score = record["score"]
|
||||||
|
|
||||||
if (
|
if (mcode, difficulty) not in all_scores or score > all_scores[
|
||||||
playstyle,
|
(mcode, difficulty)
|
||||||
mcode,
|
].get("score"):
|
||||||
difficulty,
|
all_scores[mcode, difficulty] = {
|
||||||
) not in all_scores or score > all_scores[
|
|
||||||
(playstyle, mcode, difficulty)
|
|
||||||
].get(
|
|
||||||
"score"
|
|
||||||
):
|
|
||||||
all_scores[playstyle, mcode, difficulty] = {
|
|
||||||
"game_version": game_version,
|
"game_version": game_version,
|
||||||
"ddr_id": ddr_id,
|
"ddr_id": ddr_id,
|
||||||
"playstyle": playstyle,
|
|
||||||
"mcode": mcode,
|
"mcode": mcode,
|
||||||
"difficulty": difficulty,
|
"difficulty": difficulty,
|
||||||
"rank": record["rank"],
|
"rank": record["rank"],
|
||||||
@ -427,24 +419,16 @@ async def usergamedata_advanced(request: Request):
|
|||||||
& (where("ddr_id") != 0)
|
& (where("ddr_id") != 0)
|
||||||
):
|
):
|
||||||
ddr_id = record["ddr_id"]
|
ddr_id = record["ddr_id"]
|
||||||
playstyle = record["playstyle"]
|
|
||||||
mcode = record["mcode"]
|
mcode = record["mcode"]
|
||||||
difficulty = record["difficulty"]
|
difficulty = record["difficulty"]
|
||||||
score = record["score"]
|
score = record["score"]
|
||||||
|
|
||||||
if (
|
if (mcode, difficulty) not in all_scores or score > all_scores[
|
||||||
playstyle,
|
(mcode, difficulty)
|
||||||
mcode,
|
].get("score"):
|
||||||
difficulty,
|
all_scores[mcode, difficulty] = {
|
||||||
) not in all_scores or score > all_scores[
|
|
||||||
(playstyle, mcode, difficulty)
|
|
||||||
].get(
|
|
||||||
"score"
|
|
||||||
):
|
|
||||||
all_scores[playstyle, mcode, difficulty] = {
|
|
||||||
"game_version": game_version,
|
"game_version": game_version,
|
||||||
"ddr_id": ddr_id,
|
"ddr_id": ddr_id,
|
||||||
"playstyle": playstyle,
|
|
||||||
"mcode": mcode,
|
"mcode": mcode,
|
||||||
"difficulty": difficulty,
|
"difficulty": difficulty,
|
||||||
"rank": record["rank"],
|
"rank": record["rank"],
|
||||||
@ -461,24 +445,16 @@ async def usergamedata_advanced(request: Request):
|
|||||||
(where("game_version") == game_version) & (where("ddr_id") != 0)
|
(where("game_version") == game_version) & (where("ddr_id") != 0)
|
||||||
):
|
):
|
||||||
ddr_id = record["ddr_id"]
|
ddr_id = record["ddr_id"]
|
||||||
playstyle = record["playstyle"]
|
|
||||||
mcode = record["mcode"]
|
mcode = record["mcode"]
|
||||||
difficulty = record["difficulty"]
|
difficulty = record["difficulty"]
|
||||||
score = record["score"]
|
score = record["score"]
|
||||||
|
|
||||||
if (
|
if (mcode, difficulty) not in all_scores or score > all_scores[
|
||||||
playstyle,
|
(mcode, difficulty)
|
||||||
mcode,
|
].get("score"):
|
||||||
difficulty,
|
all_scores[mcode, difficulty] = {
|
||||||
) not in all_scores or score > all_scores[
|
|
||||||
(playstyle, mcode, difficulty)
|
|
||||||
].get(
|
|
||||||
"score"
|
|
||||||
):
|
|
||||||
all_scores[playstyle, mcode, difficulty] = {
|
|
||||||
"game_version": game_version,
|
"game_version": game_version,
|
||||||
"ddr_id": ddr_id,
|
"ddr_id": ddr_id,
|
||||||
"playstyle": playstyle,
|
|
||||||
"mcode": mcode,
|
"mcode": mcode,
|
||||||
"difficulty": difficulty,
|
"difficulty": difficulty,
|
||||||
"rank": record["rank"],
|
"rank": record["rank"],
|
||||||
@ -494,6 +470,29 @@ async def usergamedata_advanced(request: Request):
|
|||||||
for s in db.table("ddr_scores_best").search(where("ddr_id") == ddrcode):
|
for s in db.table("ddr_scores_best").search(where("ddr_id") == ddrcode):
|
||||||
scores.append(s)
|
scores.append(s)
|
||||||
|
|
||||||
|
load = []
|
||||||
|
names = {}
|
||||||
|
for r in scores:
|
||||||
|
if r["ddr_id"] not in names:
|
||||||
|
names[r["ddr_id"]] = {}
|
||||||
|
names[r["ddr_id"]]["name"] = get_common(r["ddr_id"], game_version, 27)
|
||||||
|
names[r["ddr_id"]]["area"] = int(
|
||||||
|
str(get_common(r["ddr_id"], game_version, 3)), 16
|
||||||
|
)
|
||||||
|
load.append(
|
||||||
|
{
|
||||||
|
"mcode": r["mcode"],
|
||||||
|
"difficulty": r["difficulty"],
|
||||||
|
"rank": r["rank"],
|
||||||
|
"lamp": r["lamp"],
|
||||||
|
"name": names[r["ddr_id"]]["name"],
|
||||||
|
"area": names[r["ddr_id"]]["area"],
|
||||||
|
"ddr_id": r["ddr_id"],
|
||||||
|
"score": r["score"],
|
||||||
|
"ghostid": r["ghostid"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
response = E.response(
|
response = E.response(
|
||||||
E.playerdata(
|
E.playerdata(
|
||||||
E.result(0, __type="s32"),
|
E.result(0, __type="s32"),
|
||||||
@ -506,18 +505,13 @@ async def usergamedata_advanced(request: Request):
|
|||||||
E.rank(s["rank"], __type="u8"),
|
E.rank(s["rank"], __type="u8"),
|
||||||
E.clearkind(s["lamp"], __type="u8"),
|
E.clearkind(s["lamp"], __type="u8"),
|
||||||
E.flagdata(0, __type="u8"),
|
E.flagdata(0, __type="u8"),
|
||||||
E.name(
|
E.name(s["name"], __type="str"),
|
||||||
get_common(s["ddr_id"], game_version, 27), __type="str"
|
E.area(s["area"], __type="s32"),
|
||||||
),
|
|
||||||
E.area(
|
|
||||||
int(get_common(s["ddr_id"], game_version, 3), 16),
|
|
||||||
__type="s32",
|
|
||||||
),
|
|
||||||
E.code(s["ddr_id"], __type="s32"),
|
E.code(s["ddr_id"], __type="s32"),
|
||||||
E.score(s["score"], __type="s32"),
|
E.score(s["score"], __type="s32"),
|
||||||
E.ghostid(s["ghostid"], __type="s32"),
|
E.ghostid(s["ghostid"], __type="s32"),
|
||||||
)
|
)
|
||||||
for s in scores
|
for s in load
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -353,7 +353,7 @@ async def usergamedata_advanced(request: Request):
|
|||||||
mcode = int(n.find("mcode").text)
|
mcode = int(n.find("mcode").text)
|
||||||
if int(n.find("clearkind").text) != 1:
|
if int(n.find("clearkind").text) != 1:
|
||||||
for grade, course_id in enumerate(range(1000, 1011), start=1):
|
for grade, course_id in enumerate(range(1000, 1011), start=1):
|
||||||
if playstyle == 0 and mcode in (course_id, course_id + 11):
|
if playstyle in (0, 2) and mcode in (course_id, course_id + 11):
|
||||||
single_grade = grade
|
single_grade = grade
|
||||||
elif playstyle == 1 and mcode in (
|
elif playstyle == 1 and mcode in (
|
||||||
course_id + 1000,
|
course_id + 1000,
|
||||||
@ -391,24 +391,16 @@ async def usergamedata_advanced(request: Request):
|
|||||||
& (where("ddr_id") != 0)
|
& (where("ddr_id") != 0)
|
||||||
):
|
):
|
||||||
ddr_id = record["ddr_id"]
|
ddr_id = record["ddr_id"]
|
||||||
playstyle = record["playstyle"]
|
|
||||||
mcode = record["mcode"]
|
mcode = record["mcode"]
|
||||||
difficulty = record["difficulty"]
|
difficulty = record["difficulty"]
|
||||||
score = record["score"]
|
score = record["score"]
|
||||||
|
|
||||||
if (
|
if (mcode, difficulty) not in all_scores or score > all_scores[
|
||||||
playstyle,
|
(mcode, difficulty)
|
||||||
mcode,
|
].get("score"):
|
||||||
difficulty,
|
all_scores[mcode, difficulty] = {
|
||||||
) not in all_scores or score > all_scores[
|
|
||||||
(playstyle, mcode, difficulty)
|
|
||||||
].get(
|
|
||||||
"score"
|
|
||||||
):
|
|
||||||
all_scores[playstyle, mcode, difficulty] = {
|
|
||||||
"game_version": game_version,
|
"game_version": game_version,
|
||||||
"ddr_id": ddr_id,
|
"ddr_id": ddr_id,
|
||||||
"playstyle": playstyle,
|
|
||||||
"mcode": mcode,
|
"mcode": mcode,
|
||||||
"difficulty": difficulty,
|
"difficulty": difficulty,
|
||||||
"rank": record["rank"],
|
"rank": record["rank"],
|
||||||
@ -427,24 +419,16 @@ async def usergamedata_advanced(request: Request):
|
|||||||
& (where("ddr_id") != 0)
|
& (where("ddr_id") != 0)
|
||||||
):
|
):
|
||||||
ddr_id = record["ddr_id"]
|
ddr_id = record["ddr_id"]
|
||||||
playstyle = record["playstyle"]
|
|
||||||
mcode = record["mcode"]
|
mcode = record["mcode"]
|
||||||
difficulty = record["difficulty"]
|
difficulty = record["difficulty"]
|
||||||
score = record["score"]
|
score = record["score"]
|
||||||
|
|
||||||
if (
|
if (mcode, difficulty) not in all_scores or score > all_scores[
|
||||||
playstyle,
|
(mcode, difficulty)
|
||||||
mcode,
|
].get("score"):
|
||||||
difficulty,
|
all_scores[mcode, difficulty] = {
|
||||||
) not in all_scores or score > all_scores[
|
|
||||||
(playstyle, mcode, difficulty)
|
|
||||||
].get(
|
|
||||||
"score"
|
|
||||||
):
|
|
||||||
all_scores[playstyle, mcode, difficulty] = {
|
|
||||||
"game_version": game_version,
|
"game_version": game_version,
|
||||||
"ddr_id": ddr_id,
|
"ddr_id": ddr_id,
|
||||||
"playstyle": playstyle,
|
|
||||||
"mcode": mcode,
|
"mcode": mcode,
|
||||||
"difficulty": difficulty,
|
"difficulty": difficulty,
|
||||||
"rank": record["rank"],
|
"rank": record["rank"],
|
||||||
@ -461,24 +445,16 @@ async def usergamedata_advanced(request: Request):
|
|||||||
(where("game_version") == game_version) & (where("ddr_id") != 0)
|
(where("game_version") == game_version) & (where("ddr_id") != 0)
|
||||||
):
|
):
|
||||||
ddr_id = record["ddr_id"]
|
ddr_id = record["ddr_id"]
|
||||||
playstyle = record["playstyle"]
|
|
||||||
mcode = record["mcode"]
|
mcode = record["mcode"]
|
||||||
difficulty = record["difficulty"]
|
difficulty = record["difficulty"]
|
||||||
score = record["score"]
|
score = record["score"]
|
||||||
|
|
||||||
if (
|
if (mcode, difficulty) not in all_scores or score > all_scores[
|
||||||
playstyle,
|
(mcode, difficulty)
|
||||||
mcode,
|
].get("score"):
|
||||||
difficulty,
|
all_scores[mcode, difficulty] = {
|
||||||
) not in all_scores or score > all_scores[
|
|
||||||
(playstyle, mcode, difficulty)
|
|
||||||
].get(
|
|
||||||
"score"
|
|
||||||
):
|
|
||||||
all_scores[playstyle, mcode, difficulty] = {
|
|
||||||
"game_version": game_version,
|
"game_version": game_version,
|
||||||
"ddr_id": ddr_id,
|
"ddr_id": ddr_id,
|
||||||
"playstyle": playstyle,
|
|
||||||
"mcode": mcode,
|
"mcode": mcode,
|
||||||
"difficulty": difficulty,
|
"difficulty": difficulty,
|
||||||
"rank": record["rank"],
|
"rank": record["rank"],
|
||||||
@ -495,14 +471,21 @@ async def usergamedata_advanced(request: Request):
|
|||||||
scores.append(s)
|
scores.append(s)
|
||||||
|
|
||||||
load = []
|
load = []
|
||||||
|
names = {}
|
||||||
for r in scores:
|
for r in scores:
|
||||||
|
if r["ddr_id"] not in names:
|
||||||
|
names[r["ddr_id"]] = {}
|
||||||
|
names[r["ddr_id"]]["name"] = get_common(r["ddr_id"], game_version, 27)
|
||||||
|
names[r["ddr_id"]]["area"] = int(
|
||||||
|
str(get_common(r["ddr_id"], game_version, 3)), 16
|
||||||
|
)
|
||||||
s = [
|
s = [
|
||||||
r["mcode"],
|
r["mcode"],
|
||||||
r["difficulty"],
|
r["difficulty"],
|
||||||
r["rank"],
|
r["rank"],
|
||||||
r["lamp"],
|
r["lamp"],
|
||||||
get_common(r["ddr_id"], game_version, 27),
|
names[r["ddr_id"]]["name"],
|
||||||
int(get_common(r["ddr_id"], game_version, 3), 16),
|
names[r["ddr_id"]]["area"],
|
||||||
r["ddr_id"],
|
r["ddr_id"],
|
||||||
r["score"],
|
r["score"],
|
||||||
r["ghostid"],
|
r["ghostid"],
|
||||||
|
Loading…
Reference in New Issue
Block a user