1
0
mirror of synced 2025-01-19 08:07:24 +01:00

Make the game not crash by fill in byte arrays

This commit is contained in:
asesidaa 2022-08-17 22:38:42 +08:00
parent 061e0f2c50
commit f94c787985
15 changed files with 28764 additions and 30 deletions

View File

@ -27,7 +27,21 @@ public class BaidController:ControllerBase
RegCountryId = "JPN",
Baid = 1,
MbId = 1,
PlayerType = 2
PlayerType = 2,
AryCostumedata = new BAIDResponse.CostumeData
{
Costume1 = 1,
Costume2 = 1,
Costume3 = 1,
Costume4 = 1,
Costume5 = 1
},
DefaultToneSetting = 0,
AryCrownCounts = new uint[] {0,0,0},
AryScoreRankCounts = new uint[]
{
0,0,0,0,0,0,0
}
};
return Ok(response);

View File

@ -21,8 +21,8 @@ public class CrownsDataController : ControllerBase
var response = new CrownsDataResponse
{
Result = 1,
CrownFlg = GZipBytesUtil.GetEmptyJsonGZipBytes(),
DondafulCrownFlg = GZipBytesUtil.GetEmptyJsonGZipBytes()
CrownFlg = GZipBytesUtil.GetGZipBytes(new byte[1000]),
DondafulCrownFlg = GZipBytesUtil.GetGZipBytes(new byte[1000])
};
return Ok(response);

View File

@ -20,9 +20,9 @@ public class GetScoreRankController : ControllerBase
var response = new GetScoreRankResponse
{
Result = 1,
IkiScoreRankFlg = GZipBytesUtil.GetEmptyJsonGZipBytes(),
KiwamiScoreRankFlg = GZipBytesUtil.GetEmptyJsonGZipBytes(),
MiyabiScoreRankFlg = GZipBytesUtil.GetEmptyJsonGZipBytes()
IkiScoreRankFlg = GZipBytesUtil.GetGZipBytes(new byte[1000]),
KiwamiScoreRankFlg = GZipBytesUtil.GetGZipBytes(new byte[1000]),
MiyabiScoreRankFlg = GZipBytesUtil.GetGZipBytes(new byte[1000])
};
return Ok(response);

View File

@ -21,6 +21,14 @@ public class GetSongIntroductionController : ControllerBase
{
Result = 1
};
response.ArySongIntroductionDatas.Add(new GetSongIntroductionResponse.SongIntroductionData
{
MainSongNo = 1,
SubSongNoes = new uint[] {2,3},
SetId = request.SetIds[0],
VerupNo = 1
});
return Ok(response);
}

View File

@ -21,6 +21,12 @@ public class GetTokenCountController : ControllerBase
{
Result = 1
};
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
{
TokenCount = 0,
TokenId = 1000
});
return Ok(response);
}

View File

@ -1,4 +1,5 @@
using taiko.vsinterface;
using Swan.Extensions;
using TaikoLocalServer.Utils;
namespace TaikoLocalServer.Controllers;
@ -19,19 +20,24 @@ public class InitialDataCheckController:ControllerBase
public IActionResult InitialDataCheck([FromBody] InitialdatacheckRequest request)
{
logger.LogInformation("InitialDataCheck request: {Request}", request.Stringify());
var enabledArray = new byte[1000];
Array.Fill(enabledArray, (byte)1);
var response = new InitialdatacheckResponse
{
Result = 1,
IsDanplay = true,
IsAibattle = true,
IsClose = false
IsDanplay = false,
IsAibattle = false,
IsClose = false,
SongIntroductionEndDatetime = (DateTime.Now + TimeSpan.FromDays(999)).ToUnixTimeMilliseconds().ToString(),
DefaultSongFlg = GZipBytesUtil.GetGZipBytes(enabledArray)
};
/*response.AryMovieInfoes.Add(new InitialdatacheckResponse.MovieData
{
MovieId = 2,
EnableDays = 9999
});*/
response.AryTelopDatas.Add(new InitialdatacheckResponse.InformationData
{
InfoId = 0,

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using TaikoLocalServer.Utils;
namespace TaikoLocalServer.Controllers;

View File

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Http;
using TaikoLocalServer.Models;
using TaikoLocalServer.Utils;
namespace TaikoLocalServer.Controllers;
@ -19,9 +21,27 @@ public class SelfBestController : ControllerBase
var response = new SelfBestResponse
{
Result = 1
Result = 1,
Level = request.Level
};
var manager = MusicAttributeManager.Instance;
foreach (var songNo in request.ArySongNoes)
{
var selfBestData = new SelfBestResponse.SelfBestData
{
SelfBestScore = 0,
SelfBestScoreRate = 0,
SongNo = songNo,
};
response.ArySelfbestScores.Add(selfBestData);
if (manager.MusicHasUra(songNo))
{
selfBestData.UraBestScore = 0;
selfBestData.UraBestScoreRate = 0;
}
}
return Ok(response);
}
}

View File

@ -18,27 +18,20 @@ public class UserDataController : ControllerBase
{
logger.LogInformation("UserData request : {Request}", request.Stringify());
var enabledArray = new byte[1000];
Array.Fill(enabledArray, (byte)1);
var response = new UserDataResponse
{
Result = 1,
ToneFlg = GZipBytesUtil.GetEmptyJsonGZipBytes(),
TitleFlg = GZipBytesUtil.GetEmptyJsonGZipBytes(),
ReleaseSongFlg = GZipBytesUtil.GetEmptyJsonGZipBytes(),
UraReleaseSongFlg = GZipBytesUtil.GetEmptyJsonGZipBytes(),
DefaultOptionSetting = GZipBytesUtil.GetEmptyJsonGZipBytes(),
DispScoreType = 0,
DispLevelChassis = 0,
DispLevelSelf = 0,
IsDispTojiruOn = true,
NotesPosition = 0,
IsVoiceOn = true,
IsChallengecompe = false,
IsSkipOn = true,
DifficultyPlayedCourse = 0,
DifficultyPlayedStar = 0,
TotalCreditCnt = 1,
ToneFlg = GZipBytesUtil.GetGZipBytes(new byte[1000]),
TitleFlg = GZipBytesUtil.GetGZipBytes(new byte[1000]),
ReleaseSongFlg = GZipBytesUtil.GetGZipBytes(enabledArray),
UraReleaseSongFlg = GZipBytesUtil.GetGZipBytes(enabledArray),
DefaultOptionSetting = GZipBytesUtil.GetGZipBytes(new byte[1000]),
SongRecentCnt = 0
};
return Ok(response);
}

View File

@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class MusicAttribute
{
[JsonPropertyName("uniqueId")]
public uint MusicId { get; set; }
[JsonPropertyName("canPlayUra")]
public bool HasUra { get; set; }
}

View File

@ -2,6 +2,7 @@ using System.Security.Authentication;
using Microsoft.AspNetCore.HttpLogging;
using Microsoft.AspNetCore.HttpOverrides;
using TaikoLocalServer.Middlewares;
var builder = WebApplication.CreateBuilder(args);
// Manually enable tls 1.0
builder.WebHost.UseKestrel(kestrelOptions =>

View File

@ -26,4 +26,10 @@
</None>
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\music_attribute.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@ -11,8 +11,20 @@ public static class GZipBytesUtil
using (var stream = new GZipOutputStream(outputStream))
using (var writer = new StreamWriter(stream, Encoding.UTF8))
{
writer.AutoFlush = true;
writer.WriteLine("{}");
/*writer.AutoFlush = true;
writer.WriteLine("{}");*/
stream.Write(Array.Empty<byte>());
}
return outputStream.ToArray();
}
public static byte[] GetGZipBytes(ReadOnlySpan<byte> input)
{
var outputStream = new MemoryStream(1024);
using (var stream = new GZipOutputStream(outputStream))
{
stream.Write(input);
}
return outputStream.ToArray();

View File

@ -0,0 +1,42 @@
using System.Text.Json;
using TaikoLocalServer.Models;
namespace TaikoLocalServer.Utils;
public class MusicAttributeManager
{
private Dictionary<uint,MusicAttribute> musicAttributes;
static MusicAttributeManager()
{
}
private MusicAttributeManager()
{
var path = Environment.ProcessPath;
if (path is null)
{
throw new ApplicationException();
}
var parentPath = Directory.GetParent(path);
if (parentPath is null)
{
throw new ApplicationException();
}
var filePath = Path.Combine(parentPath.ToString(), "wwwroot", "music_attribute.json");
var jsonString = File.ReadAllText(filePath);
var result = JsonSerializer.Deserialize<List<MusicAttribute>>(jsonString);
if (result is null)
{
throw new ApplicationException();
}
musicAttributes = result.ToDictionary(attribute => attribute.MusicId);
}
public static MusicAttributeManager Instance { get; } = new();
public bool MusicHasUra(uint musicId)
{
return musicAttributes[musicId].HasUra;
}
}

File diff suppressed because it is too large Load Diff