出力ファイルチェッカ:ROMチェックを追加。オールベリファイ処理が未実装。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@166 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
nishikawa_takeshi 2009-02-19 10:36:38 +00:00
parent 4e4127c020
commit 36d3312c57
11 changed files with 447 additions and 249 deletions

View File

@ -79,11 +79,11 @@
<rRP><J></J><E></E></rRP>
</BBFC>
<UN>
<r00><J></J><E></E></r00>
<J></J><E></E>
</UN>
<Undefined>
<DISABLE>
<J>不可</J>
<E></E>
</Undefined>
</DISABLE>
</Rating>
</Config>

View File

@ -9,13 +9,17 @@ int main(array<System::String ^> ^args)
{
try
{
setDebugPrint( true );
//FilenameItem ^fItem = gcnew FilenameItem;
//fItem->parseFilename( args[0] );
//SheetItem ^sItem = gcnew SheetItem;
//sItem->readSheet( args[0] );
//checkSheet( fItem, sItem );
FilenameItem ^fItem = gcnew FilenameItem;
fItem->parseFilename( args[0] );
SheetItem ^sItem = gcnew SheetItem;
sItem->readSheet( args[0] );
checkSheet( fItem, sItem );
checkRom( fItem, args[0] );
}
catch( System::Exception ^ex )
{

View File

@ -1,8 +1,54 @@
#include "stdafx.h"
#include "check.h"
#include <common.h>
#include <twl/types.h>
#include <twl/os/common/format_rom.h>
#include <twl/os/common/ownerInfoEx.h>
using namespace System;
// ------------------------------------------------------------------
// デバッグ表示
// ------------------------------------------------------------------
static System::Boolean gbDebugPrint = false;
void setDebugPrint( System::Boolean b )
{
gbDebugPrint = b;
}
void DebugPrint( System::String ^str )
{
if( gbDebugPrint )
{
Console::WriteLine( str );
}
}
void DebugPrint( System::String ^fmt, System::Object ^arg0 )
{
if( gbDebugPrint )
{
Console::WriteLine( fmt, arg0 );
}
}
void DebugPrint( System::String ^fmt, System::Object ^arg0, System::Object ^arg1 )
{
if( gbDebugPrint )
{
Console::WriteLine( fmt, arg0, arg1 );
}
}
void DebugPrint( System::String ^fmt, System::Object ^arg0, System::Object ^arg1, System::Object ^arg2 )
{
if( gbDebugPrint )
{
Console::WriteLine( fmt, arg0, arg1, arg2 );
}
}
// ------------------------------------------------------------------
// ファイル名の解析
// ------------------------------------------------------------------
@ -17,10 +63,156 @@ System::Void FilenameItem::parseFilename( System::String ^filepath )
this->rating = System::String::Copy(list[2]);
this->lang = System::String::Copy(list[3]);
Console::WriteLine( "[In Filename]" );
Console::WriteLine( "Region: " + this->region );
Console::WriteLine( "Ogn: " + this->ogn );
Console::WriteLine( "Rating: " + this->rating );
Console::WriteLine( "Lang: " + this->lang );
DebugPrint( "--------------------------------------------------------" );
DebugPrint( "{0,-10} {1,-20}", "Filename",filename );
DebugPrint( "{0,-10} {1,-20}", "Region", this->region );
DebugPrint( "{0,-10} {1,-20}", "Ogn", this->ogn );
DebugPrint( "{0,-10} {1,-20}", "Rating", this->rating );
DebugPrint( "{0,-10} {1,-20}", "Language",this->lang );
DebugPrint( "--------------------------------------------------------" );
return;
}
// -----------------------------------------------------------------
// ファイル名の文字列をROMヘッダ中の値に変換
// -----------------------------------------------------------------
u32 FilenameItem::getRegionBitmap()
{
u32 bitmap = 0;
if( this->region == "JP" )
{
bitmap = METWL_MASK_REGION_JAPAN;
}
else if( this->region == "US" )
{
bitmap = METWL_MASK_REGION_AMERICA;
}
else if( this->region == "EU" )
{
bitmap = METWL_MASK_REGION_EUROPE;
}
else if( this->region == "AU" )
{
bitmap = METWL_MASK_REGION_AUSTRALIA;
}
else if( this->region == "EUAU" )
{
bitmap = (METWL_MASK_REGION_EUROPE | METWL_MASK_REGION_AUSTRALIA);
}
else if( this->region == "USAU" )
{
bitmap = (METWL_MASK_REGION_AMERICA | METWL_MASK_REGION_AUSTRALIA);
}
else if( this->region == "USEUAU" )
{
bitmap = (METWL_MASK_REGION_AMERICA | METWL_MASK_REGION_EUROPE | METWL_MASK_REGION_AUSTRALIA);
}
else if( this->region == "CN" )
{
bitmap = (METWL_MASK_REGION_CHINA);
}
else if( this->region == "KR" )
{
bitmap = (METWL_MASK_REGION_KOREA);
}
else if( this->region == "ALL" )
{
bitmap = METWL_MASK_REGION_ALL;
}
return bitmap;
}
int FilenameItem::getOgnNumber()
{
int num = -1;
if( this->ogn == "CERO" )
{
num = OS_TWL_PCTL_OGN_CERO;
}
else if( this->ogn == "ESRB" )
{
num = OS_TWL_PCTL_OGN_ESRB;
}
else if( this->ogn == "USK" )
{
num = OS_TWL_PCTL_OGN_USK;
}
else if( this->ogn == "PEGI" )
{
num = OS_TWL_PCTL_OGN_PEGI_GEN;
}
else if( this->ogn == "PRT" )
{
num = OS_TWL_PCTL_OGN_PEGI_PRT;
}
else if( this->ogn == "BBFC" )
{
num = OS_TWL_PCTL_OGN_PEGI_BBFC;
}
else if( this->ogn == "OFLC" )
{
num = OS_TWL_PCTL_OGN_OFLC;
}
//else if( this->ogn == "GRB" )
//{
// num = OS_TWL_PCTL_OGN_GRB;
//}
return num;
}
System::String ^FilenameItem::getOgnString(int ogn)
{
System::String ^str = nullptr;
if( ogn == OS_TWL_PCTL_OGN_CERO )
{
str = "CERO";
}
else if( ogn == OS_TWL_PCTL_OGN_ESRB )
{
str = "ESRB";
}
else if( ogn == OS_TWL_PCTL_OGN_USK )
{
str = "USK";
}
else if( ogn == OS_TWL_PCTL_OGN_PEGI_GEN )
{
str = "PEGI";
}
else if( ogn == OS_TWL_PCTL_OGN_PEGI_PRT )
{
str = "PRT";
}
else if( ogn == OS_TWL_PCTL_OGN_PEGI_BBFC )
{
str = "BBFC";
}
else if( ogn == OS_TWL_PCTL_OGN_OFLC )
{
str = "OFLC";
}
//else if( ogn == OS_TWL_PCTL_OGN_GRB )
//{
// str = "GRB";
//}
else if( ogn < 0 )
{
str = "UN";
}
return str;
}
u8 FilenameItem::getRatingValue()
{
u8 val = 0;
if( this->rating == "RP" )
{
val = OS_TWL_PCTL_OGNINFO_ENABLE_MASK | OS_TWL_PCTL_OGNINFO_ALWAYS_MASK;
}
else
{
val = OS_TWL_PCTL_OGNINFO_ENABLE_MASK | (System::Byte::Parse(this->rating));
}
return val;
}

View File

@ -1,7 +1,9 @@
#pragma once
#include <twl/types.h>
//
// ファイル名から抽出されるファイル情報の構造体
// ファイル名から抽出される真値の構造体
//
ref class FilenameItem
{
@ -14,6 +16,12 @@ public:
FilenameItem(){}
public:
System::Void parseFilename( System::String ^filepath );
public:
// 各メンバをROMヘッダの値に変換
u32 getRegionBitmap();
int getOgnNumber();
System::String ^getOgnString(int ogn);
u8 getRatingValue();
};
//
@ -23,13 +31,7 @@ ref class SheetItem
{
public:
property System::String ^region;
property System::String ^CERO;
property System::String ^ESRB;
property System::String ^USK;
property System::String ^PEGI;
property System::String ^PEGIPRT;
property System::String ^PEGIBBFC;
property System::String ^OFLC;
property cli::array<System::String^> ^ratings;
property System::Boolean IsUnnecessaryRating;
public:
SheetItem(){}
@ -37,5 +39,15 @@ public:
System::Void readSheet( System::String ^sheetfile );
};
// ROMヘッダの値と真値(ファイル名)を比較
System::Void checkRom( FilenameItem ^fItem, System::String ^srlpath );
// 提出確認書の文字列と真値を比較
System::Void checkSheet( FilenameItem ^fItem, SheetItem ^sItem );
// デバッグ表示
void setDebugPrint( System::Boolean b );
void DebugPrint( System::String ^str );
void DebugPrint( System::String ^fmt, System::Object ^arg0 );
void DebugPrint( System::String ^fmt, System::Object ^arg0, System::Object ^arg1 );
void DebugPrint( System::String ^fmt, System::Object ^arg0, System::Object ^arg1, System::Object ^arg2 );

View File

@ -1,118 +1,22 @@
#include "stdafx.h"
#include "check.h"
#include <apptype.h>
#include <keys.h>
#include <common.h>
#include <utility.h>
#include <twl/types.h>
#include <twl/os/common/format_rom.h>
#include <twl/os/common/ownerInfoEx.h>
#include <acsign/include/acsign.h>
#include <cstring>
#include <cstdio>
//
// ファイル名の文字列とリージョン/レーティングの値の対応づけ
//
System::Void checkRomHeaderSign( ROM_Header *prh );
u32 getRegionBitmap( System::String ^region )
{
u32 bitmap = 0;
if( region == "JP" )
{
bitmap = METWL_MASK_REGION_JAPAN;
}
else if( region == "US" )
{
bitmap = METWL_MASK_REGION_AMERICA;
}
else if( region == "EU" )
{
bitmap = METWL_MASK_REGION_EUROPE;
}
else if( region == "AU" )
{
bitmap = METWL_MASK_REGION_AUSTRALIA;
}
else if( region == "EUAU" )
{
bitmap = (METWL_MASK_REGION_EUROPE | METWL_MASK_REGION_AUSTRALIA);
}
else if( region == "USAU" )
{
bitmap = (METWL_MASK_REGION_AMERICA | METWL_MASK_REGION_AUSTRALIA);
}
else if( region == "USEUAU" )
{
bitmap = (METWL_MASK_REGION_AMERICA | METWL_MASK_REGION_EUROPE | METWL_MASK_REGION_AUSTRALIA);
}
else if( region == "CN" )
{
bitmap = (METWL_MASK_REGION_CHINA);
}
else if( region == "KR" )
{
bitmap = (METWL_MASK_REGION_KOREA);
}
else if( region == "ALL" )
{
bitmap = METWL_MASK_REGION_ALL;
}
return bitmap;
}
int getOgnNumber( System::String ^ogn )
{
int num = -1;
if( ogn == "CERO" )
{
num = OS_TWL_PCTL_OGN_CERO;
}
if( ogn == "ESRB" )
{
num = OS_TWL_PCTL_OGN_ESRB;
}
if( ogn == "USK" )
{
num = OS_TWL_PCTL_OGN_USK;
}
if( ogn == "PEGI_GEN" )
{
num = OS_TWL_PCTL_OGN_PEGI_GEN;
}
if( ogn == "PEGI_PRT" )
{
num = OS_TWL_PCTL_OGN_PEGI_PRT;
}
if( ogn == "PEGI_BBFC" )
{
num = OS_TWL_PCTL_OGN_PEGI_BBFC;
}
if( ogn == "OFLC" )
{
num = OS_TWL_PCTL_OGN_OFLC;
}
if( ogn == "GRB" )
{
num = OS_TWL_PCTL_OGN_GRB;
}
return num;
}
u8 getRatingValue( System::String ^rating )
{
u8 val = 0;
if( rating == "RP" )
{
val = OS_TWL_PCTL_OGNINFO_ENABLE_MASK | OS_TWL_PCTL_OGNINFO_ALWAYS_MASK;
}
else
{
val = OS_TWL_PCTL_OGNINFO_ENABLE_MASK | (System::Byte::Parse(rating));
}
return val;
}
//
// -------------------------------------------------------------------
// 出力SRLのチェック
//
// -------------------------------------------------------------------
System::Void checkRom( FilenameItem ^fItem, System::String ^srlpath )
{
const char *chpath =
@ -136,8 +40,17 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^srlpath )
}
fclose(fp);
// 署名のチェック
checkRomHeaderSign( &rh );
DebugPrint( "--------------------------------------------------------" );
DebugPrint( "{0,-10} {1,-20}", nullptr, "RomHeader" );
DebugPrint( "--" );
// リージョンのチェック
u32 region = getRegionBitmap( fItem->region );
u32 region = fItem->getRegionBitmap(); // ファイル名に対応する真値を取得
DebugPrint( "{0,-10} {1,-20:X04}", "Region", rh.s.card_region_bitmap );
DebugPrint( "--" );
if( rh.s.card_region_bitmap != region )
{
throw (gcnew System::Exception("Illegal Region in ROM Header."));
@ -156,8 +69,8 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^srlpath )
}
// 設定したレーティングが正しいかどうかをチェック
int ogn = getOgnNumber( fItem->ogn ); // ファイル名から団体とレーティング値の真値を決定
u8 rating = getRatingValue( fItem->rating );
int ogn = fItem->getOgnNumber(); // ファイル名に対応する真値を取得
u8 rating = fItem->getRatingValue();
if( rh.s.parental_control_rating_info[ ogn ] != rating )
{
throw (gcnew System::Exception("Mismatch Rating Ogn " + ogn.ToString() + ". "
@ -166,6 +79,22 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^srlpath )
return;
}
// 表示
System::Collections::Generic::List<int> ^alllist = gcnew System::Collections::Generic::List<int>();
alllist->Clear();
alllist->Add( OS_TWL_PCTL_OGN_CERO );
alllist->Add( OS_TWL_PCTL_OGN_ESRB );
alllist->Add( OS_TWL_PCTL_OGN_USK );
alllist->Add( OS_TWL_PCTL_OGN_PEGI_GEN );
alllist->Add( OS_TWL_PCTL_OGN_PEGI_PRT );
alllist->Add( OS_TWL_PCTL_OGN_PEGI_BBFC );
alllist->Add( OS_TWL_PCTL_OGN_OFLC );
//alllist->Add( OS_TWL_PCTL_OGN_GRB );
for each ( int ogn in alllist )
{
DebugPrint( "{0,-10} {1,-20:X02}", fItem->getOgnString(ogn), rh.s.parental_control_rating_info[ogn] );
}
// リージョンに含まれない団体のレーティングがクリアされているかチェック
int i;
for( i=0; i < PARENTAL_CONTROL_INFO_SIZE; i++ )
@ -176,4 +105,66 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^srlpath )
return;
}
}
DebugPrint( "--------------------------------------------------------" );
}
// -------------------------------------------------------------------
// ROMヘッダの署名を外す
// -------------------------------------------------------------------
System::Void checkRomHeaderSign( ROM_Header *prh )
{
u8 original[ RSA_KEY_LENGTH ]; // 署名外した後のデータ格納先
s32 pos = 0; // ブロックの先頭アドレス
u8 digest[ DIGEST_SIZE_SHA1 ]; // ROMヘッダのダイジェスト
u8 *publicKey = (u8*)MasterEditorTWL::g_devPubKey_DER;
// <データの流れ>
// (1) 公開鍵で復号した結果(ブロック)をローカル変数(original)に格納
// (2) ブロックから余分な部分を取り除いて引数(pDst)にコピー
u8 *idL = prh->s.titleID_Lo;
u32 idH = prh->s.titleID_Hi;
if( (idL[3]=='H') && (idL[2]=='N') && (idL[1]=='A') ) // ランチャアプリかどうかはTitleID_Loの値で決定
{
publicKey = (u8*)MasterEditorTWL::g_devPubKey_DER_launcher;
}
else if( idH & TITLE_ID_HI_SECURE_FLAG_MASK ) // 各ビットは排他的とは限らないのでelse ifにはならない
{
publicKey = (u8*)MasterEditorTWL::g_devPubKey_DER_secure;
}
else if( (idH & TITLE_ID_HI_APP_TYPE_MASK) == 1 )
{
publicKey = (u8*)MasterEditorTWL::g_devPubKey_DER_system;
}
else if( (idH & TITLE_ID_HI_APP_TYPE_MASK) == 0 )
{
publicKey = (u8*)MasterEditorTWL::g_devPubKey_DER;
}
// 署名の解除 = 公開鍵で復号
if( !ACSign_Decrypto( original, publicKey, prh->signature, RSA_KEY_LENGTH ) )
{
throw (gcnew System::Exception("Fail to decrypt sign."));
return;
}
// 署名前データを復号後ブロックからゲット
for( pos=0; pos < (RSA_KEY_LENGTH-2); pos++ ) // 本来ブロックの先頭は0x00だが復号化の内部処理によって消える仕様
{
// 暗号ブロック形式 = 0x00, BlockType, Padding, 0x00, 実データ
if( original[pos] == 0x00 ) // 実データの直前の0x00をサーチ
{
break;
}
}
// ベリファイ
// ROMヘッダのダイジェストを算出(先頭から証明書領域の直前までが対象)
ROM_Header tmprh; // マネージヒープ上にある場合実アドレスを取得できないのでサイズ計算用のROMヘッダを用意
ACSign_DigestUnit( digest, prh, (u32)&(tmprh.certificate) - (u32)&(tmprh) );
if( memcmp( &(original[pos+1]), digest, DIGEST_SIZE_SHA1 ) != 0 )
{
throw (gcnew System::Exception("Fail to verify sign."));
return;
}
return;
}

View File

@ -5,16 +5,21 @@
#include "stdafx.h"
#include "check.h"
#include <utility.h>
#include <twl/types.h>
#include <twl/os/common/ownerInfoEx.h>
#include <twl/os/common/format_rom.h>
using namespace System;
// ------------------------------------------------------------------
// 提出確認書の読み込み
// ------------------------------------------------------------------
System::Void SheetItem::readSheet( System::String ^sheetfile )
{
// メンバの初期化
this->ratings = gcnew cli::array<System::String^>(PARENTAL_CONTROL_INFO_SIZE);
// XSLによってXML変換
System::String ^tmpfile = ".\\temp" + System::DateTime::Now.ToString("yyyyMMddHHmmss") + ".xml";
System::Xml::Xsl::XslCompiledTransform ^xslt = gcnew System::Xml::Xsl::XslCompiledTransform;
@ -33,13 +38,14 @@ System::Void SheetItem::readSheet( System::String ^sheetfile )
System::Xml::XmlElement ^root = doc->DocumentElement;
{
this->region = MasterEditorTWL::getXPathText( root, "/Sheet/Region" );
this->CERO = MasterEditorTWL::getXPathText( root, "/Sheet/RatingCERO" );
this->ESRB = MasterEditorTWL::getXPathText( root, "/Sheet/RatingESRB" );
this->USK = MasterEditorTWL::getXPathText( root, "/Sheet/RatingUSK" );
this->PEGI = MasterEditorTWL::getXPathText( root, "/Sheet/RatingPEGI" );
this->PEGIPRT = MasterEditorTWL::getXPathText( root, "/Sheet/RatingPEGIPRT" );
this->PEGIBBFC = MasterEditorTWL::getXPathText( root, "/Sheet/RatingPEGIBBFC" );
this->OFLC = MasterEditorTWL::getXPathText( root, "/Sheet/RatingOFLC" );
this->ratings[ OS_TWL_PCTL_OGN_CERO ] = MasterEditorTWL::getXPathText( root, "/Sheet/RatingCERO" );
this->ratings[ OS_TWL_PCTL_OGN_ESRB ] = MasterEditorTWL::getXPathText( root, "/Sheet/RatingESRB" );
this->ratings[ OS_TWL_PCTL_OGN_USK ] = MasterEditorTWL::getXPathText( root, "/Sheet/RatingUSK" );
this->ratings[ OS_TWL_PCTL_OGN_PEGI_GEN ] = MasterEditorTWL::getXPathText( root, "/Sheet/RatingPEGI" );
this->ratings[ OS_TWL_PCTL_OGN_PEGI_PRT ] = MasterEditorTWL::getXPathText( root, "/Sheet/RatingPEGIPRT" );
this->ratings[ OS_TWL_PCTL_OGN_PEGI_BBFC ] = MasterEditorTWL::getXPathText( root, "/Sheet/RatingPEGIBBFC" );
this->ratings[ OS_TWL_PCTL_OGN_OFLC ] = MasterEditorTWL::getXPathText( root, "/Sheet/RatingOFLC" );
//this->ratings[ OS_TWL_PCTL_OGN_GRB ] = MasterEditorTWL::getXPathText( root, "/Sheet/RatingGRB" );
System::String ^text = MasterEditorTWL::getXPathText( root, "/Sheet/IsUnnecessaryRating" );
if( !System::String::IsNullOrEmpty( text ) && text->Equals( "" ) )
@ -51,16 +57,18 @@ System::Void SheetItem::readSheet( System::String ^sheetfile )
this->IsUnnecessaryRating = false;
}
Console::WriteLine( "[In Sheet]" );
Console::WriteLine( "Region: " + this->region );
Console::WriteLine( "CERO: " + this->CERO );
Console::WriteLine( "ESRB: " + this->ESRB );
Console::WriteLine( "USK: " + this->USK );
Console::WriteLine( "PEGI: " + this->PEGI );
Console::WriteLine( "PEGIPRT: " + this->PEGIPRT );
Console::WriteLine( "PEGIBBFC: " + this->PEGIBBFC );
Console::WriteLine( "OFLC: " + this->OFLC );
Console::WriteLine( "Unnecessary: " + this->IsUnnecessaryRating.ToString() );
//Console::WriteLine( "[In Sheet]" );
//Console::WriteLine( "Region: " + this->region );
//Console::WriteLine( "Region: {0,-20} {1,-20}", this->region, this->region );
//Console::WriteLine( "CERO: " + this->ratings[ OS_TWL_PCTL_OGN_CERO ] );
//Console::WriteLine( "ESRB: " + this->ratings[ OS_TWL_PCTL_OGN_ESRB ] );
//Console::WriteLine( "USK: " + this->ratings[ OS_TWL_PCTL_OGN_USK ] );
//Console::WriteLine( "PEGI: " + this->ratings[ OS_TWL_PCTL_OGN_PEGI_GEN ] );
//Console::WriteLine( "PEGIPRT: " + this->ratings[ OS_TWL_PCTL_OGN_PEGI_PRT ] );
//Console::WriteLine( "PEGIBBFC: " + this->ratings[ OS_TWL_PCTL_OGN_PEGI_BBFC ] );
//Console::WriteLine( "OFLC: " + this->ratings[ OS_TWL_PCTL_OGN_OFLC ] );
////Console::WriteLine( "GRB: " + this->ratings[ OS_TWL_PCTL_OGN_GRB ] );
//Console::WriteLine( "Unnecessary: " + this->IsUnnecessaryRating.ToString() );
}
// 中間ファイルを削除
@ -87,126 +95,117 @@ System::Void checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
// XMLからデータを抽出
System::Xml::XmlElement ^root = doc->DocumentElement;
DebugPrint( "--------------------------------------------------------" );
DebugPrint( "{0,-10} {1,-20} {2,-20}", nullptr, "Config", "Sheet" );
DebugPrint( "--" );
// 設定ファイル中の真値と提出確認書の記述を比較
// (設定ファイルにはファイル名と対応させたタグ名で真値が記述されている)
System::String ^region = MasterEditorTWL::getXPathText( root, "/Config/Region/" + fItem->region + "/" + fItem->lang );
System::String ^undef = MasterEditorTWL::getXPathText( root, "/Config/Rating/Undefined/" + fItem->lang );
System::String ^rating = MasterEditorTWL::getXPathText( root, "/Config/Rating/" + fItem->ogn + "/r" + fItem->rating + "/" + fItem->lang );
Console::WriteLine( "[In Config file]" );
Console::WriteLine( "Region: " + region );
Console::WriteLine( "Rating: " + rating );
Console::WriteLine( "Undefined: " + undef );
System::String ^errmsg = nullptr;
// リージョンの文字列をチェック
System::String ^region = MasterEditorTWL::getXPathText( root, "/Config/Region/" + fItem->region + "/" + fItem->lang );
DebugPrint( "{0,-10} {1,-20} {2,-20}", "Region", region, sItem->region );
DebugPrint( "--" );
if( sItem->region != region )
{
throw (gcnew System::Exception("In Sheet, region is illegal string."));
throw (gcnew System::Exception("In Sheet, region is an Illegal String."));
return;
}
// レーティングの文字列をチェック
if( fItem->region == "JP" )
// レーティングの文字列のチェック
System::Collections::Generic::List<int> ^ognlist = MasterEditorTWL::getOgnListInRegion( fItem->getRegionBitmap() );
if( fItem->ogn != fItem->getOgnString(-1) )
{
if( sItem->CERO != rating )
// 「レーティング表示不要」でないとき
// 対象のレーティングの文字列を真値と比較
System::String ^rating = MasterEditorTWL::getXPathText( root, "/Config/Rating/" + fItem->ogn + "/r" + fItem->rating + "/" + fItem->lang );
DebugPrint( "{0,-10} {1,-20} {2,-20}", fItem->ogn, rating, sItem->ratings[fItem->getOgnNumber()] );
if( sItem->ratings[fItem->getOgnNumber()] != rating )
{
errmsg = "In Sheet, CERO is illegal string.";
throw (gcnew System::Exception("In Sheet, " + fItem->ogn + " is an Illegal String."));
return;
}
if( (sItem->ESRB != undef) ||
(sItem->USK != undef) ||
(sItem->PEGI != undef) ||
(sItem->PEGIPRT != undef) ||
(sItem->PEGIBBFC != undef) ||
(sItem->OFLC != undef) )
// その他のリージョンに含まれる団体が「全年齢」になっているかチェック
for each ( int ogn in ognlist )
{
errmsg = "In Sheet, Other Ogn is illegal string.";
if( ogn != fItem->getOgnNumber() )
{
// 設定ファイルから 00 (全年齢)のときの文字列を抜き出す
System::String ^str = fItem->getOgnString( ogn );
System::String ^other = MasterEditorTWL::getXPathText( root, "/Config/Rating/" + str + "/r00/" + fItem->lang );
DebugPrint( "{0,-10} {1,-20} {2,-20}", str, other, sItem->ratings[ogn] );
// 提出確認書の文字列をチェック
if( sItem->ratings[ogn] != other )
{
throw (gcnew System::Exception("In Sheet, " + str + " is not a String for \"All ages\""));
return;
}
}
}
}
else if( fItem->region == "US" )
else
{
if( sItem->ESRB != rating )
// 「レーティング表示不要」のとき
// リージョンに含まれるすべての団体が「レーティング不要」になっているかチェック
for each ( int ogn in ognlist )
{
errmsg = "In Sheet, ESRB is illegal string.";
// 設定ファイルから「レーティング表示不要」のときの文字列を抜き出す
System::String ^str = fItem->getOgnString(-1);
System::String ^unnecessary = MasterEditorTWL::getXPathText( root, "/Config/Rating/" + str + "/" + fItem->lang );
DebugPrint( "{0,-10} {1,-20} {2,-20}", fItem->getOgnString(ogn), unnecessary, sItem->ratings[ogn] );
// 提出確認書の文字列をチェック
if( sItem->ratings[ogn] != unnecessary )
{
throw (gcnew System::Exception("In Sheet, " + str + " is not a String for \"Unnecessary\""));
return;
}
}
if( (sItem->CERO != undef) ||
(sItem->USK != undef) ||
(sItem->PEGI != undef) ||
(sItem->PEGIPRT != undef) ||
(sItem->PEGIBBFC != undef) ||
(sItem->OFLC != undef) )
// フラグをチェック
if( !sItem->IsUnnecessaryRating )
{
errmsg = "In Sheet, Other Ogn is illegal string.";
throw (gcnew System::Exception("In Sheet, \"Unnecessary\" Flag is Negated."));
return;
}
}
else if( fItem->region == "EU" )
// リージョン設定可能な団体(Reservedでない団体)をリストアップ(ここに含まれない団体はチェックしなくてよい)
System::Collections::Generic::List<int> ^alllist = gcnew System::Collections::Generic::List<int>();
alllist->Clear();
alllist->Add( OS_TWL_PCTL_OGN_CERO );
alllist->Add( OS_TWL_PCTL_OGN_ESRB );
alllist->Add( OS_TWL_PCTL_OGN_USK );
alllist->Add( OS_TWL_PCTL_OGN_PEGI_GEN );
alllist->Add( OS_TWL_PCTL_OGN_PEGI_PRT );
alllist->Add( OS_TWL_PCTL_OGN_PEGI_BBFC );
alllist->Add( OS_TWL_PCTL_OGN_OFLC );
//alllist->Add( OS_TWL_PCTL_OGN_GRB );
// リージョンに含まれない団体が「不可」になっているかチェック
System::String ^disable = MasterEditorTWL::getXPathText( root, "/Config/Rating/DISABLE/" + fItem->lang );
int i;
for( i=0; i < PARENTAL_CONTROL_INFO_SIZE; i++ )
{
if( sItem->USK != rating )
// Reserved の団体は調べない
if( (alllist->IndexOf(i) >=0 ) && (ognlist->IndexOf(i) < 0) )
{
errmsg = "In Sheet, USK is illegal string.";
}
if( sItem->PEGI != rating )
{
errmsg = "In Sheet, PEGI is illegal string.";
}
if( sItem->PEGIPRT != rating )
{
errmsg = "In Sheet, PEGIPRT is illegal string.";
}
if( sItem->PEGIBBFC != rating )
{
errmsg = "In Sheet, PEGIBBFC is illegal string.";
}
if( (sItem->CERO != undef) ||
(sItem->ESRB != undef) ||
(sItem->OFLC != undef) )
{
errmsg = "In Sheet, Other Ogn is illegal string.";
DebugPrint( "{0,-10} {1,-20} {2,-20}", fItem->getOgnString(i), disable, sItem->ratings[i] );
if( sItem->ratings[i] != disable )
{
throw (gcnew System::Exception("In Sheet, " + fItem->getOgnString(i) + " is not a String for \"Disable\""));
return;
}
}
}
else if( fItem->region == "AU" )
{
if( sItem->OFLC != rating )
{
errmsg = "In Sheet, OFLC is illegal string.";
}
if( (sItem->CERO != undef) ||
(sItem->ESRB != undef) ||
(sItem->USK != undef) ||
(sItem->PEGI != undef) ||
(sItem->PEGIPRT != undef) ||
(sItem->PEGIBBFC != undef) )
{
errmsg = "In Sheet, Other Ogn is illegal string.";
}
}
else if( fItem->region == "EUAU" )
{
if( sItem->USK != rating )
{
errmsg = "In Sheet, USK is illegal string.";
}
if( sItem->PEGI != rating )
{
errmsg = "In Sheet, PEGI is illegal string.";
}
if( sItem->PEGIPRT != rating )
{
errmsg = "In Sheet, PEGIPRT is illegal string.";
}
if( sItem->PEGIBBFC != rating )
{
errmsg = "In Sheet, PEGIBBFC is illegal string.";
}
if( sItem->OFLC != rating )
{
errmsg = "In Sheet, OFLC is illegal string.";
}
if( (sItem->CERO != undef) ||
(sItem->ESRB != undef) )
{
errmsg = "In Sheet, Other Ogn is illegal string.";
}
}
if( errmsg != nullptr )
{
throw (gcnew System::Exception(errmsg));
}
DebugPrint( "--------------------------------------------------------" );
return;
}

View File

@ -79,11 +79,11 @@
<rRP><J></J><E></E></rRP>
</BBFC>
<UN>
<r00><J></J><E></E></r00>
<J></J><E></E>
</UN>
<Undefined>
<DISABLE>
<J>不可</J>
<E></E>
</Undefined>
</DISABLE>
</Rating>
</Config>

View File

@ -79,11 +79,11 @@
<rRP><J></J><E></E></rRP>
</BBFC>
<UN>
<r00><J></J><E></E></r00>
<J></J><E></E>
</UN>
<Undefined>
<DISABLE>
<J>不可</J>
<E></E>
</Undefined>
</DISABLE>
</Rating>
</Config>