Skip to content

Commit

Permalink
[+] New APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Oct 25, 2024
1 parent f3bebc6 commit 80536ef
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
23 changes: 23 additions & 0 deletions AquaMai/Helpers/Shim.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using HarmonyLib;
using MAI2.Util;
using Manager;
using Manager.UserDatas;
using Net.Packet;
using Net.Packet.Mai2;

Expand Down Expand Up @@ -64,4 +67,24 @@ public static class Shim
throw new MissingMethodException("No matching PacketUpsertUserAll constructor found");
}
})();

public static IEnumerable<UserScore>[] GetUserScoreList(UserData userData)
{
var tUserData = Traverse.Create(userData);

var tScoreList = tUserData.Property("ScoreList");
if (tScoreList.PropertyExists())
{
return tScoreList.GetValue<List<UserScore>[]>();
}

var tScoreDic = tUserData.Property("ScoreDic");
if (tScoreDic.PropertyExists())
{
var scoreDic = tScoreDic.GetValue<Dictionary<int, UserScore>[]>();
return scoreDic.Select(dic => dic.Values).ToArray();
}

throw new MissingFieldException("No matching UserData.ScoreList/ScoreDic found");
}
}
6 changes: 1 addition & 5 deletions AquaMai/UX/ImmediateSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.Linq;
using AquaMai.Helpers;
using AquaMai.Resources;
using AquaMai.Utils;
using CriAtomDebugDetail;
using DB;
using HarmonyLib;
using MAI2.Util;
Expand All @@ -16,7 +14,6 @@
using Monitor.Entry.Parts.Screens;
using Net.Packet;
using Net.Packet.Helper;
using Net.Packet.Mai2;
using Process;
using Process.UserDataNet.State.UserDataULState;
using UnityEngine;
Expand Down Expand Up @@ -109,7 +106,6 @@ void CheckSaveDone()
private static void SaveDataFix(UserData userData)
{
UserDetail detail = userData.Detail;
_ = userData.ScoreList;
detail.EventWatchedDate = TimeManager.GetDateString(TimeManager.PlayBaseTime);
userData.CalcTotalValue();
float num = 0f;
Expand Down Expand Up @@ -147,7 +143,7 @@ private static void SaveDataFix(UserData userData)

List<UserRate> list = new List<UserRate>();
List<UserRate> list2 = new List<UserRate>();
List<UserScore>[] scoreList = userData.ScoreList;
IEnumerable<UserScore>[] scoreList = Shim.GetUserScoreList(userData);
List<UserRate> ratingList = userData.RatingList.RatingList;
List<UserRate> newRatingList = userData.RatingList.NewRatingList;
int achive = RatingTableID.Rate_22.GetAchive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ class Maimai2ServletController(
val getGameNgMusicId = BaseHandler { mapOf("length" to 0, "musicIdList" to empty) }
val getGameRanking = BaseHandler { mapOf("type" to it["type"].toString(), "gameRankingList" to empty) }
val getGameTournamentInfo = BaseHandler { mapOf("length" to 0, "gameTournamentInfoList" to empty) }
val getGameKaleidxScope = BaseHandler { mapOf("gameKaleidxScopeList" to empty) }
val getUserKaleidxScope = UserReqHandler { _, uid -> mapOf("userId" to uid, "userKaleidxScopeList" to empty) }
val getUserNewItem = UserReqHandler { _, uid -> mapOf("userId" to uid, "itemKind" to 0, "itemId" to 0) }
val getUserNewItemList = UserReqHandler { _, uid -> mapOf("userId" to uid, "userItemList" to empty) }

val getGameSetting = BaseHandler {
// The client-side implementation for reboot time is extremely cursed.
Expand Down Expand Up @@ -289,6 +293,15 @@ class Maimai2ServletController(
"userMissionDataList" to empty
) }

val getGameMusicScore = BaseHandler { mapOf(
"gameMusicScore" to mapOf(
"musicId" to 0,
"level" to 0,
"type" to 0,
"scoreData" to ""
)
) }

val endpointList = setOf("GetGameEventApi", "GetGameRankingApi", "GetGameSettingApi", "GetGameTournamentInfoApi", "GetGameWeeklyDataApi",
"GetTransferFriendApi", "GetUserActivityApi", "GetUserCardApi", "GetUserCharacterApi", "GetUserDataApi",
"GetUserExtendApi", "GetUserFavoriteApi", "GetUserGhostApi", "GetUserItemApi", "GetUserLoginBonusApi",
Expand All @@ -303,7 +316,8 @@ class Maimai2ServletController(
"CMUpsertUserPrintlogApi", "GetUserFavoriteItemApi", "GetUserRivalDataApi", "GetUserRivalMusicApi",
"GetUserScoreRankingApi", "UpsertClientBookkeepingApi", "UpsertClientSettingApi",
"UpsertClientTestmodeApi", "UpsertClientUploadApi", "Ping", "RemoveTokenApi", "CMLoginApi", "CMLogoutApi",
"CMUpsertBuyCardApi", "GetGameSettingApi").toMutableList()
"CMUpsertBuyCardApi", "GetGameSettingApi", "GetGameKaleidxScopeApi", "GetGameMusicScoreApi",
"GetUserKaleidxScopeApi", "GetUserNewItemApi", "GetUserNewItemListApi").toMutableList()

val noopEndpoint = endpointList.popAll("GetUserScoreRankingApi", "UpsertClientBookkeepingApi",
"UpsertClientSettingApi", "UpsertClientTestmodeApi", "UpsertClientUploadApi", "Ping", "RemoveTokenApi",
Expand Down

0 comments on commit 80536ef

Please sign in to comment.