mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
NWC24Config: Make creation stage an enum class
Makes the enum strongly typed instead of interacting with a raw u32 value. While we're at it, we can add helpers to the NWC24Config to make using code poke at the internals of the class a little bit less and also make the querying a little nicer to read.
This commit is contained in:
parent
82371b89fc
commit
bc939df69c
@ -60,7 +60,7 @@ void NWC24Config::ResetConfig()
|
||||
|
||||
SetMagic(0x57634366);
|
||||
SetUnk(8);
|
||||
SetCreationStage(NWC24_IDCS_INITIAL);
|
||||
SetCreationStage(NWC24CreationStage::Initial);
|
||||
SetEnableBooting(0);
|
||||
SetEmail("@wii.com");
|
||||
|
||||
@ -165,14 +165,14 @@ void NWC24Config::SetChecksum(u32 checksum)
|
||||
m_data.checksum = Common::swap32(checksum);
|
||||
}
|
||||
|
||||
u32 NWC24Config::CreationStage() const
|
||||
NWC24CreationStage NWC24Config::CreationStage() const
|
||||
{
|
||||
return Common::swap32(m_data.creation_stage);
|
||||
return NWC24CreationStage(Common::swap32(u32(m_data.creation_stage)));
|
||||
}
|
||||
|
||||
void NWC24Config::SetCreationStage(u32 creation_stage)
|
||||
void NWC24Config::SetCreationStage(NWC24CreationStage creation_stage)
|
||||
{
|
||||
m_data.creation_stage = Common::swap32(creation_stage);
|
||||
m_data.creation_stage = NWC24CreationStage(Common::swap32(u32(creation_stage)));
|
||||
}
|
||||
|
||||
u32 NWC24Config::EnableBooting() const
|
||||
|
@ -25,16 +25,16 @@ enum ErrorCode : s32
|
||||
WC24_ERR_ID_NOT_REGISTERED = -44,
|
||||
};
|
||||
|
||||
enum class NWC24CreationStage : u32
|
||||
{
|
||||
Initial = 0,
|
||||
Generated = 1,
|
||||
Registered = 2
|
||||
};
|
||||
|
||||
class NWC24Config final
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
NWC24_IDCS_INITIAL = 0,
|
||||
NWC24_IDCS_GENERATED = 1,
|
||||
NWC24_IDCS_REGISTERED = 2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
URL_COUNT = 0x05,
|
||||
@ -65,8 +65,12 @@ public:
|
||||
u32 Checksum() const;
|
||||
void SetChecksum(u32 checksum);
|
||||
|
||||
u32 CreationStage() const;
|
||||
void SetCreationStage(u32 creation_stage);
|
||||
NWC24CreationStage CreationStage() const;
|
||||
void SetCreationStage(NWC24CreationStage creation_stage);
|
||||
|
||||
bool IsCreated() const { return CreationStage() == NWC24CreationStage::Initial; }
|
||||
bool IsGenerated() const { return CreationStage() == NWC24CreationStage::Generated; }
|
||||
bool IsRegistered() const { return CreationStage() == NWC24CreationStage::Registered; }
|
||||
|
||||
u32 EnableBooting() const;
|
||||
void SetEnableBooting(u32 enable_booting);
|
||||
@ -85,7 +89,7 @@ private:
|
||||
u32 unk_04; // must be 8
|
||||
u64 nwc24_id;
|
||||
u32 id_generation;
|
||||
u32 creation_stage; // 0:not_generated; 1:generated; 2:registered
|
||||
NWC24CreationStage creation_stage;
|
||||
char email[MAX_EMAIL_LENGTH];
|
||||
char paswd[MAX_PASSWORD_LENGTH];
|
||||
char mlchkid[0x24];
|
||||
|
@ -228,7 +228,7 @@ std::optional<IPCReply> NetKDRequestDevice::IOCtl(const IOCtlRequest& request)
|
||||
|
||||
case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes)
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
|
||||
if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_INITIAL)
|
||||
if (config.IsCreated())
|
||||
{
|
||||
const std::string settings_file_path =
|
||||
Common::GetTitleDataPath(Titles::SYSTEM_MENU) + "/" WII_SETTING;
|
||||
@ -258,7 +258,7 @@ std::optional<IPCReply> NetKDRequestDevice::IOCtl(const IOCtlRequest& request)
|
||||
const s32 ret = NWC24MakeUserID(&user_id, hollywood_id, id_ctr, hardware_model, area_code);
|
||||
config.SetId(user_id);
|
||||
config.IncrementIdGen();
|
||||
config.SetCreationStage(NWC24::NWC24Config::NWC24_IDCS_GENERATED);
|
||||
config.SetCreationStage(NWC24::NWC24CreationStage::Generated);
|
||||
config.WriteConfig();
|
||||
|
||||
WriteReturnValue(ret, request.buffer_out);
|
||||
@ -268,16 +268,16 @@ std::optional<IPCReply> NetKDRequestDevice::IOCtl(const IOCtlRequest& request)
|
||||
WriteReturnValue(NWC24::WC24_ERR_FATAL, request.buffer_out);
|
||||
}
|
||||
}
|
||||
else if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_GENERATED)
|
||||
else if (config.IsGenerated())
|
||||
{
|
||||
WriteReturnValue(NWC24::WC24_ERR_ID_GENERATED, request.buffer_out);
|
||||
}
|
||||
else if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_REGISTERED)
|
||||
else if (config.IsRegistered())
|
||||
{
|
||||
WriteReturnValue(NWC24::WC24_ERR_ID_REGISTERED, request.buffer_out);
|
||||
}
|
||||
Memory::Write_U64(config.Id(), request.buffer_out + 4);
|
||||
Memory::Write_U32(config.CreationStage(), request.buffer_out + 0xC);
|
||||
Memory::Write_U32(u32(config.CreationStage()), request.buffer_out + 0xC);
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_GET_SCHEDULER_STAT:
|
||||
|
Loading…
Reference in New Issue
Block a user