国設定ファイルがない場合はリージョンに合わせたデフォルト国で動作するように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@46 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-02-10 10:27:07 +00:00
parent eaa3853461
commit 27290b0227
3 changed files with 78 additions and 15 deletions

View File

@ -45,6 +45,7 @@
#include "Aes_define.h"
#include "configLoader.h"
#include "PlayHistoryManager.h"
#include "FileChecker.h"
#include <string>
#include <cstring>
@ -323,26 +324,81 @@ void ImportCountryLanguageData()
{
nn::Result result;
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
if (buf != NULL)
if (common::ExistsCountryLanguageFile())
{
common::SdReaderWriter sdReader;
size_t readSize;
result = sdReader.ReadBuf(common::COUNTRY_SETTING_PATHNAME, buf, bufSize, &readSize);
if(result.IsSuccess())
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
if (buf != NULL)
{
// SDから読み出し成功
SetCountry(reinterpret_cast<common::CfgCountryLanguage*>(buf)->country);
common::SdReaderWriter sdReader;
SetLanguage(reinterpret_cast<common::CfgCountryLanguage*>(buf)->language);
size_t readSize;
result = sdReader.ReadBuf(common::COUNTRY_SETTING_PATHNAME, buf, bufSize, &readSize);
if (result.IsSuccess())
{
// SDから読み出し成功
SetCountry(reinterpret_cast<common::CfgCountryLanguage*> (buf)->country);
SetLanguage(reinterpret_cast<common::CfgCountryLanguage*> (buf)->language);
}
else
{
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
}
common::HeapManager::GetHeap()->Free(buf);
}
else
}
else
{
// リージョンから適当な国を指定する
nn::cfg::CTR::CfgRegionCode region;
region = nn::cfg::CTR::GetRegion();
NN_LOG("Country Setting does not exist. Use Default Setting\n");
switch(region)
{
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
case nn::cfg::CTR::CFG_REGION_JAPAN:
{
SetCountry(nn::cfg::CTR::CFG_COUNTRY_JAPAN);
}
break;
case nn::cfg::CTR::CFG_REGION_AMERICA:
{
SetCountry(nn::cfg::CTR::CFG_COUNTRY_UNITED_STATES);
}
break;
case nn::cfg::CTR::CFG_REGION_EUROPE:
{
SetCountry(nn::cfg::CTR::CFG_COUNTRY_FRANCE);
}
break;
case nn::cfg::CTR::CFG_REGION_AUSTRALIA:
{
SetCountry(nn::cfg::CTR::CFG_COUNTRY_AUSTRALIA);
}
break;
case nn::cfg::CTR::CFG_REGION_CHINA:
{
SetCountry(nn::cfg::CTR::CFG_COUNTRY_CHINA);
}
break;
case nn::cfg::CTR::CFG_REGION_KOREA:
{
SetCountry(nn::cfg::CTR::CFG_COUNTRY_SOUTH_KOREA);
}
break;
case nn::cfg::CTR::CFG_REGION_TAIWAN:
{
SetCountry(nn::cfg::CTR::CFG_COUNTRY_TAIWAN);
}
break;
}
common::HeapManager::GetHeap()->Free(buf);
}
}

View File

@ -100,6 +100,10 @@ bool ExistsRtcSyncFinishedFile()
return ExistsFile(EXISTS_RTC_SYNC_FINISHED);
}
bool ExistsCountryLanguageFile()
{
return ExistsFile(EXISTS_COUNTRY_LANGUAGE);
}
void InitializeFileCheck()
{

View File

@ -30,6 +30,7 @@ typedef enum FILE_EXISTS_CHECK
EXISTS_WRITE_FINISHED,
EXISTS_AP_SETTING,
EXISTS_RTC_SYNC_FINISHED,
EXISTS_COUNTRY_LANGUAGE,
EXISTS_MAX
} FileExistsCheck;
@ -41,7 +42,8 @@ const wchar_t* const FILENAME_TABLE[EXISTS_MAX] =
common::INITIALIZED_CHECK_PATHNAME,
common::WRITE_FINISHED_CHECK_PATHNAME,
common::AP_SETTING_PATHNAME,
common::RTC_SYNC_CHECK_PATHNAME
common::RTC_SYNC_CHECK_PATHNAME,
common::COUNTRY_SETTING_PATHNAME
};
@ -52,6 +54,7 @@ bool ExistsConsoleInitializedFile();
bool ExistsWriteFinishedFile();
bool ExistsAPSetting();
bool ExistsRtcSyncFinishedFile();
bool ExistsCountryLanguageFile();
void InitializeFileCheck();