From b23c387a29cf234d58417fa171b0907aee18cd0b Mon Sep 17 00:00:00 2001 From: S-Sebb?? Date: Sun, 10 Sep 2023 02:41:04 +0800 Subject: [PATCH] Test --- .../Game/GetGenericMasterController.cs | 32 ++++++++ .../Game/InitialDataCheckController.cs | 75 ++++++++++++++++++- TaikoLocalServer/Program.cs | 11 +++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 TaikoLocalServer/Controllers/Game/GetGenericMasterController.cs diff --git a/TaikoLocalServer/Controllers/Game/GetGenericMasterController.cs b/TaikoLocalServer/Controllers/Game/GetGenericMasterController.cs new file mode 100644 index 0000000..1207a14 --- /dev/null +++ b/TaikoLocalServer/Controllers/Game/GetGenericMasterController.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.Options; +using TaikoLocalServer.Settings; + +namespace TaikoLocalServer.Controllers.Game; + +[ApiController] +[Route("/v12r00_cn/chassis/getgenericmaster.php")] +public class GetGenericMasterController : BaseController +{ + private readonly IGameDataService gameDataService; + + private readonly ServerSettings settings; + + [HttpPost] + [Produces("application/protobuf")] + public IActionResult GetGenericMaster([FromBody] GetGenericMasterRequest request) + { + Logger.LogInformation("GetGenericMasterRequest: {Request}", request.Stringify()); + + var response = new GetGenericMasterResponse() + { + Result = 1, + VerupNo = 2, + // EnableIdBit = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } + EnableIdBit = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} + }; + + + return Ok(response); + } + +} \ No newline at end of file diff --git a/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs b/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs index bdd2cc1..06d468b 100644 --- a/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs +++ b/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs @@ -31,14 +31,87 @@ public class InitialDataCheckController : BaseController(); + var response = new InitialdatacheckResponse { Result = 1, DefaultSongFlg = enabledArray, AchievementSongBit = enabledArray, UraReleaseBit = uraReleaseBit, - SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT) + SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT), + // AryAiEventDatas = + // { + // new InitialdatacheckResponse.AiEventData + // { + // AiEventId = 18, + // TokenId = 4 + // } + // }, + AryVerupNoData1s = + { + + new InitialdatacheckResponse.VerupNoData1 + { + MasterType = 1, + VerupNo = 0 + }, + new InitialdatacheckResponse.VerupNoData1 + { + MasterType = 2, + VerupNo = 0 + }, + new InitialdatacheckResponse.VerupNoData1 + { + MasterType = 3, + VerupNo = 0 + }, + new InitialdatacheckResponse.VerupNoData1 + { + MasterType = 4, + VerupNo = 0 + }, + new InitialdatacheckResponse.VerupNoData1 + { + MasterType = 5, + VerupNo = 0 + } + }, + // AryVerupNoData1s = + // { + // new InitialdatacheckResponse.VerupNoData2 + // { + // MasterType = 3, + // AryInformationDatas = + // { + // new InitialdatacheckResponse.VerupNoData2.InformationData + // { + // InfoId = 1, + // VerupNo = 2 + // } + // } + // } + // } }; + + var danData = new List(); + for (var danId = Constants.MIN_DAN_ID; danId <= Constants.MAX_DAN_ID; danId++) + danData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData + { + InfoId = (uint)danId, + VerupNo = 1 + }); + for (uint i = 0; i < 11; i++) + { + var verUp2 = new InitialdatacheckResponse.VerupNoData2 + { + MasterType = i, + }; + verUp2.AryInformationDatas.AddRange(danData); + response.AryVerupNoData2s.Add(verUp2); + } + response.AryChassisFunctionIds = new uint[] { 3 }; + return Ok(response); } diff --git a/TaikoLocalServer/Program.cs b/TaikoLocalServer/Program.cs index 059505e..beefe30 100644 --- a/TaikoLocalServer/Program.cs +++ b/TaikoLocalServer/Program.cs @@ -125,6 +125,17 @@ try applicationBuilder => applicationBuilder.UseAllNetRequestMiddleware()); app.Run(); + + app.Use(async (context, next) => + { + await next(); + + if (context.Response.StatusCode >= 400) + { + Log.Error("Unknown request from: {RemoteIpAddress} {Method} {Path} {StatusCode}", + context.Connection.RemoteIpAddress, context.Request.Method, context.Request.Path, context.Response.StatusCode); + } + }); } catch (Exception ex) {