Simplified GetAreaCode() and GetHardwareModel() to simply use a map in comparisons.

This commit is contained in:
Lioncash 2014-02-05 19:59:13 -05:00
parent 9a24ba343b
commit 78356ce184
2 changed files with 30 additions and 35 deletions

View File

@ -148,9 +148,9 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
} }
if (_GotSettings) if (_GotSettings)
{ {
u8 area_code = GetAreaCode(area.c_str()); u8 area_code = GetAreaCode(area);
u8 id_ctr = config.IdGen(); u8 id_ctr = config.IdGen();
u8 hardware_model = GetHardwareModel(model.c_str()); u8 hardware_model = GetHardwareModel(model);
EcWii &ec = EcWii::GetInstance(); EcWii &ec = EcWii::GetInstance();
u32 HollywoodID = ec.getNgId(); u32 HollywoodID = ec.getNgId();
@ -205,42 +205,37 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
} }
u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode( const char * area ) u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode(const std::string& area)
{ {
u32 i; std::map<std::string, u8> regions = {
u8 regions_[] = {0,1,2,2,1,3,3,4,5,5,1,2,6,7}; { "JPN", 0 }, { "USA", 1 }, { "EUR", 2 },
const char* regions[] = {"JPN", "USA", "EUR", "AUS", "BRA", "TWN", "ROC", "KOR", "HKG", "ASI", "LTN", "SAF", "CHN", ""}; { "AUS", 2 }, { "BRA", 1 }, { "TWN", 3 },
for (i=0; i<sizeof(regions)/sizeof(*regions); i++) { "ROC", 3 }, { "KOR", 4 }, { "HKG", 5 },
{ { "ASI", 5 }, { "LTN", 1 }, { "SAF", 2 },
if (!strncmp(regions[i], area, 4)) { "CHN", 6 },
{ };
return regions_[i];
}
}
return 7; auto entryPos = regions.find(area);
if (entryPos != regions.end())
return entryPos->second;
else
return 7; // Unknown
} }
u8 CWII_IPC_HLE_Device_net_kd_request::GetHardwareModel(const char * model) u8 CWII_IPC_HLE_Device_net_kd_request::GetHardwareModel(const std::string& model)
{ {
u8 mdl; std::map<std::string, u8> models = {
if (!strncmp(model, "RVL", 4)) { "RVL", MODEL_RVL },
{ { "RVT", MODEL_RVT },
mdl = MODEL_RVL; { "RVV", MODEL_RVV },
}else if (!strncmp(model, "RVT", 4)) { "RVD", MODEL_RVD },
{ };
mdl = MODEL_RVT;
}else if (!strncmp(model, "RVV", 4)) auto entryPos = models.find(model);
{ if (entryPos != models.end())
mdl = MODEL_RVV; return entryPos->second;
}else if (!strncmp(model, "RVD", 4)) else
{ return MODEL_ELSE;
mdl = MODEL_RVD;
}else
{
mdl = MODEL_ELSE;
}
return mdl;
} }
static inline u8 u64_get_byte(u64 value, u8 shift) static inline u8 u64_get_byte(u64 value, u8 shift)

View File

@ -433,8 +433,8 @@ private:
MODEL_ELSE = 7 MODEL_ELSE = 7
}; };
u8 GetAreaCode(const char * area); u8 GetAreaCode(const std::string& area);
u8 GetHardwareModel(const char * model); u8 GetHardwareModel(const std::string& model);
s32 NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, u8 hardware_model, u8 area_code); s32 NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, u8 hardware_model, u8 area_code);