1
0
mirror of synced 2024-11-23 22:41:01 +01:00

Add support for more songs, but disabled by default as that causes issues with the game

This commit is contained in:
asesidaa 2022-09-21 21:42:53 +08:00
parent 55ed7a8df8
commit 3ae6528922
10 changed files with 67 additions and 36 deletions

View File

@ -4,17 +4,9 @@ public static class Constants
{
public const string DATE_TIME_FORMAT = "yyyyMMddHHmmss";
public const int MUSIC_ID_MAX = 9000;
public const int MUSIC_ID_MAX = 1599;
public const int CROWN_FLAG_ARRAY_SIZE = MUSIC_ID_MAX + 1;
public const int DONDAFUL_CROWN_FLAG_ARRAY_SIZE = MUSIC_ID_MAX + 1;
public const int KIWAMI_SCORE_RANK_ARRAY_SIZE = MUSIC_ID_MAX + 1;
public const int IKI_CORE_RANK_ARRAY_SIZE = MUSIC_ID_MAX + 1;
public const int MIYABI_CORE_RANK_ARRAY_SIZE = MUSIC_ID_MAX + 1;
public const int MUSIC_ID_MAX_EXPANDED = 9000;
public const string DEFAULT_DB_NAME = "taiko.db3";

View File

@ -7,9 +7,9 @@ namespace TaikoLocalServer.Controllers.AmAuth;
[Route("/sys/servlet/PowerOn")]
public class PowerOnController : BaseController<PowerOnController>
{
private readonly UrlSettings settings;
private readonly ServerSettings settings;
public PowerOnController(IOptions<UrlSettings> settings)
public PowerOnController(IOptions<ServerSettings> settings)
{
this.settings = settings.Value;
}

View File

@ -5,9 +5,9 @@ namespace TaikoLocalServer.Controllers.AmUpdater;
public class MuchaController : BaseController<MuchaController>
{
private readonly UrlSettings settings;
private readonly ServerSettings settings;
public MuchaController(IOptions<UrlSettings> settings)
public MuchaController(IOptions<ServerSettings> settings)
{
this.settings = settings.Value;
}

View File

@ -1,4 +1,8 @@
namespace TaikoLocalServer.Controllers.Game;
using System.Runtime.InteropServices;
using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/crownsdata.php")]
[ApiController]
@ -6,9 +10,12 @@ public class CrownsDataController : BaseController<CrownsDataController>
{
private readonly ISongBestDatumService songBestDatumService;
public CrownsDataController(ISongBestDatumService songBestDatumService)
private readonly ServerSettings settings;
public CrownsDataController(ISongBestDatumService songBestDatumService, IOptions<ServerSettings> settings)
{
this.songBestDatumService = songBestDatumService;
this.settings = settings.Value;
}
[HttpPost]
@ -19,10 +26,11 @@ public class CrownsDataController : BaseController<CrownsDataController>
var songBestData = await songBestDatumService.GetAllSongBestData(request.Baid);
var crown = new ushort[Constants.CROWN_FLAG_ARRAY_SIZE];
var dondafulCrown = new byte[Constants.DONDAFUL_CROWN_FLAG_ARRAY_SIZE];
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var crown = new ushort[songIdMax + 1];
var dondafulCrown = new byte[songIdMax + 1];
for (var songId = 0; songId < Constants.MUSIC_ID_MAX; songId++)
for (var songId = 0; songId < songIdMax; songId++)
{
var id = songId;
dondafulCrown[songId] = songBestData
@ -39,7 +47,7 @@ public class CrownsDataController : BaseController<CrownsDataController>
// Calculate flag according to difficulty
.Aggregate((ushort)0, (flag, datum) => FlagCalculator.ComputeCrownFlag(flag, datum.BestCrown, datum.Difficulty));
}
var response = new CrownsDataResponse
{
Result = 1,

View File

@ -1,14 +1,20 @@
namespace TaikoLocalServer.Controllers.Game;
using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getscorerank.php")]
[ApiController]
public class GetScoreRankController : BaseController<GetScoreRankController>
{
private readonly ISongBestDatumService songBestDatumService;
private readonly ServerSettings settings;
public GetScoreRankController(ISongBestDatumService songBestDatumService)
public GetScoreRankController(ISongBestDatumService songBestDatumService, IOptions<ServerSettings> settings)
{
this.songBestDatumService = songBestDatumService;
this.settings = settings.Value;
}
[HttpPost]
@ -16,12 +22,13 @@ public class GetScoreRankController : BaseController<GetScoreRankController>
public async Task<IActionResult> GetScoreRank([FromBody] GetScoreRankRequest request)
{
Logger.LogInformation("GetScoreRank request : {Request}", request.Stringify());
var kiwamiScores = new byte[Constants.KIWAMI_SCORE_RANK_ARRAY_SIZE];
var miyabiScores = new ushort[Constants.MIYABI_CORE_RANK_ARRAY_SIZE];
var ikiScores = new ushort[Constants.IKI_CORE_RANK_ARRAY_SIZE];
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var kiwamiScores = new byte[songIdMax + 1];
var miyabiScores = new ushort[songIdMax + 1];
var ikiScores = new ushort[songIdMax + 1];
var songBestData = await songBestDatumService.GetAllSongBestData(request.Baid);
for (var songId = 0; songId < Constants.MUSIC_ID_MAX; songId++)
for (var songId = 0; songId < songIdMax; songId++)
{
var id = songId;
kiwamiScores[songId] = songBestData

View File

@ -1,4 +1,7 @@
namespace TaikoLocalServer.Controllers.Game;
using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r03/chassis/initialdatacheck.php")]
@ -6,9 +9,12 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
{
private readonly IGameDataService gameDataService;
public InitialDataCheckController(IGameDataService gameDataService)
private readonly ServerSettings settings;
public InitialDataCheckController(IGameDataService gameDataService, IOptions<ServerSettings> settings)
{
this.gameDataService = gameDataService;
this.settings = settings.Value;
}
[HttpPost]
@ -17,8 +23,9 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
{
Logger.LogInformation("Initial data check request: {Request}", request.Stringify());
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var enabledArray =
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicList(), Constants.MUSIC_ID_MAX, Logger);
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicList(), songIdMax, Logger);
var danData = new List<InitialdatacheckResponse.InformationData>();
for (var danId = Constants.MIN_DAN_ID; danId <= Constants.MAX_DAN_ID; danId++)

View File

@ -1,5 +1,7 @@
using System.Buffers.Binary;
using System.Text.Json;
using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings;
using Throw;
namespace TaikoLocalServer.Controllers.Game;
@ -13,12 +15,16 @@ public class UserDataController : BaseController<UserDataController>
private readonly ISongPlayDatumService songPlayDatumService;
private readonly IGameDataService gameDataService;
private readonly ServerSettings settings;
public UserDataController(IUserDatumService userDatumService, ISongPlayDatumService songPlayDatumService, IGameDataService gameDataService)
public UserDataController(IUserDatumService userDatumService, ISongPlayDatumService songPlayDatumService,
IGameDataService gameDataService, IOptions<ServerSettings> settings)
{
this.userDatumService = userDatumService;
this.songPlayDatumService = songPlayDatumService;
this.gameDataService = gameDataService;
this.settings = settings.Value;
}
[HttpPost]
@ -27,11 +33,12 @@ public class UserDataController : BaseController<UserDataController>
{
Logger.LogInformation("UserData request : {Request}", request.Stringify());
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var releaseSongArray =
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicList(), Constants.MUSIC_ID_MAX, Logger);
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicList(), songIdMax, Logger);
var uraSongArray =
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicWithUraList(), Constants.MUSIC_ID_MAX, Logger);
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicWithUraList(), songIdMax, Logger);
var userData = await userDatumService.GetFirstUserDatumOrDefault(request.Baid);

View File

@ -35,10 +35,17 @@ try
configuration.WriteTo.Console().ReadFrom.Configuration(context.Configuration);
});
if (builder.Configuration.GetValue<bool>("ServerSettings:EnableMoreSongs"))
{
Log.Warning("Song limit expanded! Currently the game has issue loading crown/score rank and " +
"probably more server related data for songs with id > 1599. " +
"Also, the game can have random crashes because of that! Use at your own risk!");
}
// Add services to the container.
builder.Services.AddOptions();
builder.Services.AddSingleton<IGameDataService, GameDataService>();
builder.Services.Configure<UrlSettings>(builder.Configuration.GetSection(nameof(UrlSettings)));
builder.Services.Configure<ServerSettings>(builder.Configuration.GetSection(nameof(ServerSettings)));
builder.Services.AddControllers().AddProtoBufNet();
builder.Services.AddDbContext<TaikoDbContext>(option =>
{

View File

@ -1,8 +1,10 @@
namespace TaikoLocalServer.Settings;
public class UrlSettings
public class ServerSettings
{
public string MuchaUrl { get; set; } = string.Empty;
public string GameUrl { get; set; } = string.Empty;
public bool EnableMoreSongs { get; set; }
}

View File

@ -1,7 +1,8 @@
{
"UrlSettings": {
"ServerSettings": {
"MuchaUrl": "https://v402-front.mucha-prd.nbgi-amnet.jp:10122",
"GameUrl": "vsapi.taiko-p.jp"
"GameUrl": "vsapi.taiko-p.jp",
"EnableMoreSongs": false
},
"DbFileName" : "taiko.db3",