微修正

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@268 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2205 2011-05-24 06:03:28 +00:00
parent d246b688b8
commit 0f0a440c55

View File

@ -45,6 +45,7 @@ namespace {
const char* const NAND_TWL_ARCHIVE_NAME = "twln:";
const char* const NAND_TWL_KENJ_DIR_PATHNAME = "twln:/title/00030004/4b454e4a";
const char* const NAND_TWL_KENJ_SAVE_DATA_PATHNAME = "twln:/title/00030004/4b454e4a/data/Public.sav";
const nn::ProgramId NAND_TWL_KENJ_PROGRAM_ID = 0x000480044b454e4aULL;
// 乱数生成クラス
// 線形合同法を用いて乱数を生成する。
@ -133,14 +134,12 @@ namespace {
// セーブデータファイルのサイズを読む
result = file.TryGetSize( &file_size );
NN_LOG("save data size : %d\n", file_size);
if( result.IsFailure() )
{
file.Finalize();
return result;
}
nn::fnd::TimeSpan ts;
nn::fnd::DateTime tm;
nn::os::Tick tick;
Random rand;
@ -152,11 +151,10 @@ namespace {
NN_TPANIC_IF_NULL_( buf );
// 乱数のシードを設定
// [TODO]シードをちゃんと決める
seed = (u64)(ts.GetMilliSeconds() ^ tick.GetSystemCurrent());
// NN_LOG("Time Span MilliSec : %x\n", ts.GetMilliSeconds());
// NN_LOG("Get System Current Tick : %x\n", tick.GetSystemCurrent());
NN_LOG("seed : %d\n", seed);
nn::fnd::DateTimeParameters param = tm.GetNow().GetParameters();
seed = tm.DateToDays( param.year, param.month, param.day );
seed = (u64)(seed * 86400 + param.hour * 3600 + param.minute * 60 + param.second);
seed = (u64)(seed ^ tick.GetSystemCurrent());
rand.SetSeed( seed );
// バッファを乱数で埋める
@ -165,17 +163,9 @@ namespace {
{
p[loopSizeFile] = (u8)rand.Get32(0xff);
}
// 書き込み
result = file.TryWrite( &sizeResult, buf, file_size);
if( file_size != sizeResult )
{
NN_LOG("Write Failed...\n");
NN_LOG("File Size : %d\n", file_size);
NN_LOG("Write Size : %d\n", sizeResult);
}
NN_LOG("Save Data Fill Success!\n");
result = file.TryWrite(&sizeResult, buf, file_size);
file.Finalize();
@ -211,9 +201,14 @@ namespace {
// ほぼ日健康手帳のセーブデータを乱数で埋める
result = FillRandamDataToKENJSaveData();
if( result.IsFailure() )
{
nn::fs::Unmount( "twln:" );
return result;
}
// ほぼ日健康手帳を消す
result = nn::am::DeleteProgram(nn::fs::MEDIA_TYPE_NAND, 0x000480044b454e4aULL);
result = nn::am::DeleteProgram(nn::fs::MEDIA_TYPE_NAND, NAND_TWL_KENJ_PROGRAM_ID);
UTIL_RETURN_IF_NOT_AM_NOT_FOUND(result);
}