Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10053 from lioncash/kdreq
IOS/Network/KD: Minor tidy-up changes
  • Loading branch information
leoetlino committed Aug 30, 2021
2 parents 1fa74ab + 3c0d4b7 commit 95fcede
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 203 deletions.
22 changes: 11 additions & 11 deletions Source/Core/Core/IOS/Network/KD/NWC24Config.cpp
Expand Up @@ -59,8 +59,8 @@ void NWC24Config::ResetConfig()
memset(&m_data, 0, sizeof(m_data));

SetMagic(0x57634366);
SetUnk(8);
SetCreationStage(NWC24_IDCS_INITIAL);
SetVersion(8);
SetCreationStage(NWC24CreationStage::Initial);
SetEnableBooting(0);
SetEmail("@wii.com");

Expand Down Expand Up @@ -110,7 +110,7 @@ s32 NWC24Config::CheckNwc24Config() const
return -14;
}

if (Unk() != 8)
if (Version() != 8)
return -27;

return 0;
Expand All @@ -126,14 +126,14 @@ void NWC24Config::SetMagic(u32 magic)
m_data.magic = Common::swap32(magic);
}

u32 NWC24Config::Unk() const
u32 NWC24Config::Version() const
{
return Common::swap32(m_data.unk_04);
return Common::swap32(m_data.version);
}

void NWC24Config::SetUnk(u32 unk_04)
void NWC24Config::SetVersion(u32 version)
{
m_data.unk_04 = Common::swap32(unk_04);
m_data.version = Common::swap32(version);
}

u32 NWC24Config::IdGen() const
Expand Down Expand Up @@ -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
Expand Down
48 changes: 26 additions & 22 deletions Source/Core/Core/IOS/Network/KD/NWC24Config.h
Expand Up @@ -25,24 +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,
MAX_URL_LENGTH = 0x80,
MAX_EMAIL_LENGTH = 0x40,
MAX_PASSWORD_LENGTH = 0x20,
};

explicit NWC24Config(std::shared_ptr<FS::FileSystem> fs);

void ReadConfig();
Expand All @@ -55,8 +47,8 @@ class NWC24Config final
u32 Magic() const;
void SetMagic(u32 magic);

u32 Unk() const;
void SetUnk(u32 unk_04);
u32 Version() const;
void SetVersion(u32 version);

u32 IdGen() const;
void SetIdGen(u32 id_generation);
Expand All @@ -65,8 +57,12 @@ class NWC24Config final
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);
Expand All @@ -78,14 +74,22 @@ class NWC24Config final
void SetEmail(const char* email);

private:
enum
{
URL_COUNT = 0x05,
MAX_URL_LENGTH = 0x80,
MAX_EMAIL_LENGTH = 0x40,
MAX_PASSWORD_LENGTH = 0x20,
};

#pragma pack(push, 1)
struct ConfigData final
{
u32 magic; // 'WcCf' 0x57634366
u32 unk_04; // must be 8
u32 magic; // 'WcCf' 0x57634366
u32 version; // 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];
Expand Down

0 comments on commit 95fcede

Please sign in to comment.