mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
fix generation of instance-unique MAC address when using an external firmware
This commit is contained in:
parent
6e26559cd2
commit
968bd26d85
@ -642,7 +642,7 @@ Firmware GenerateFirmware(int type) noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomizeFirmware(firmware);
|
CustomizeFirmware(firmware, true);
|
||||||
|
|
||||||
// If we don't have Wi-fi settings to load,
|
// If we don't have Wi-fi settings to load,
|
||||||
// then the defaults will have already been populated by the constructor.
|
// then the defaults will have already been populated by the constructor.
|
||||||
@ -681,10 +681,7 @@ std::optional<Firmware> LoadFirmware(int type) noexcept
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config::FirmwareOverrideSettings)
|
CustomizeFirmware(firmware, Config::FirmwareOverrideSettings);
|
||||||
{
|
|
||||||
CustomizeFirmware(firmware);
|
|
||||||
}
|
|
||||||
|
|
||||||
return firmware;
|
return firmware;
|
||||||
}
|
}
|
||||||
@ -1120,15 +1117,18 @@ bool ParseMacAddress(void* data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomizeFirmware(Firmware& firmware) noexcept
|
void CustomizeFirmware(Firmware& firmware, bool overridesettings) noexcept
|
||||||
{
|
{
|
||||||
auto& currentData = firmware.GetEffectiveUserData();
|
if (overridesettings)
|
||||||
|
{
|
||||||
|
auto ¤tData = firmware.GetEffectiveUserData();
|
||||||
|
|
||||||
// setting up username
|
// setting up username
|
||||||
std::string orig_username = Config::FirmwareUsername;
|
std::string orig_username = Config::FirmwareUsername;
|
||||||
if (!orig_username.empty())
|
if (!orig_username.empty())
|
||||||
{ // If the frontend defines a username, take it. If not, leave the existing one.
|
{ // If the frontend defines a username, take it. If not, leave the existing one.
|
||||||
std::u16string username = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(orig_username);
|
std::u16string username = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(
|
||||||
|
orig_username);
|
||||||
size_t usernameLength = std::min(username.length(), (size_t) 10);
|
size_t usernameLength = std::min(username.length(), (size_t) 10);
|
||||||
currentData.NameLength = usernameLength;
|
currentData.NameLength = usernameLength;
|
||||||
memcpy(currentData.Nickname, username.data(), usernameLength * sizeof(char16_t));
|
memcpy(currentData.Nickname, username.data(), usernameLength * sizeof(char16_t));
|
||||||
@ -1164,11 +1164,13 @@ void CustomizeFirmware(Firmware& firmware) noexcept
|
|||||||
std::string orig_message = Config::FirmwareMessage;
|
std::string orig_message = Config::FirmwareMessage;
|
||||||
if (!orig_message.empty())
|
if (!orig_message.empty())
|
||||||
{
|
{
|
||||||
std::u16string message = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(orig_message);
|
std::u16string message = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(
|
||||||
|
orig_message);
|
||||||
size_t messageLength = std::min(message.length(), (size_t) 26);
|
size_t messageLength = std::min(message.length(), (size_t) 26);
|
||||||
currentData.MessageLength = messageLength;
|
currentData.MessageLength = messageLength;
|
||||||
memcpy(currentData.Message, message.data(), messageLength * sizeof(char16_t));
|
memcpy(currentData.Message, message.data(), messageLength * sizeof(char16_t));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MacAddress mac;
|
MacAddress mac;
|
||||||
bool rep = false;
|
bool rep = false;
|
||||||
@ -1176,7 +1178,8 @@ void CustomizeFirmware(Firmware& firmware) noexcept
|
|||||||
|
|
||||||
memcpy(&mac, header.MacAddr.data(), sizeof(MacAddress));
|
memcpy(&mac, header.MacAddr.data(), sizeof(MacAddress));
|
||||||
|
|
||||||
|
if (overridesettings)
|
||||||
|
{
|
||||||
MacAddress configuredMac;
|
MacAddress configuredMac;
|
||||||
rep = ParseMacAddress(&configuredMac);
|
rep = ParseMacAddress(&configuredMac);
|
||||||
rep &= (configuredMac != MacAddress());
|
rep &= (configuredMac != MacAddress());
|
||||||
@ -1185,6 +1188,7 @@ void CustomizeFirmware(Firmware& firmware) noexcept
|
|||||||
{
|
{
|
||||||
mac = configuredMac;
|
mac = configuredMac;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int inst = Platform::InstanceID();
|
int inst = Platform::InstanceID();
|
||||||
if (inst > 0)
|
if (inst > 0)
|
||||||
|
@ -67,7 +67,7 @@ std::optional<FATStorageArgs> GetDSiSDCardArgs() noexcept;
|
|||||||
std::optional<FATStorage> LoadDSiSDCard() noexcept;
|
std::optional<FATStorage> LoadDSiSDCard() noexcept;
|
||||||
std::optional<FATStorageArgs> GetDLDISDCardArgs() noexcept;
|
std::optional<FATStorageArgs> GetDLDISDCardArgs() noexcept;
|
||||||
std::optional<FATStorage> LoadDLDISDCard() noexcept;
|
std::optional<FATStorage> LoadDLDISDCard() noexcept;
|
||||||
void CustomizeFirmware(Firmware& firmware) noexcept;
|
void CustomizeFirmware(Firmware& firmware, bool overridesettings) noexcept;
|
||||||
Firmware GenerateFirmware(int type) noexcept;
|
Firmware GenerateFirmware(int type) noexcept;
|
||||||
/// Loads and customizes a firmware image based on the values in Config
|
/// Loads and customizes a firmware image based on the values in Config
|
||||||
std::optional<Firmware> LoadFirmware(int type) noexcept;
|
std::optional<Firmware> LoadFirmware(int type) noexcept;
|
||||||
|
Loading…
Reference in New Issue
Block a user