Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the ability to read a amiibo's nickname from the VirtualAmiiboFile #217

Merged
merged 3 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct VirtualAmiiboFile
public uint FileVersion { get; set; }
public byte[] TagUuid { get; set; }
public string AmiiboId { get; set; }
public string NickName { get; set; }
public DateTime FirstWriteDate { get; set; }
public DateTime LastWriteDate { get; set; }
public ushort WriteCounter { get; set; }
Expand Down
11 changes: 7 additions & 4 deletions src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ public static CommonInfo GetCommonInfo(string amiiboId)
};
}

public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiiboId, string nickname)
public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiiboId, string userName)
{
VirtualAmiiboFile amiiboFile = LoadAmiiboFile(amiiboId);

string nickname = amiiboFile.NickName ?? "Ryujinx";
UtilityImpl utilityImpl = new(tickSource);
CharInfo charInfo = new();

charInfo.SetFromStoreData(StoreData.BuildDefault(utilityImpl, 0));

charInfo.Nickname = Nickname.FromString(nickname);
// This is the player's name
charInfo.Nickname = Nickname.FromString(userName);

RegisterInfo registerInfo = new()
{
Expand All @@ -85,7 +86,9 @@ public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiibo
Reserved1 = new Array64<byte>(),
Reserved2 = new Array58<byte>(),
};
"Ryujinx"u8.CopyTo(registerInfo.Nickname.AsSpan());
// This is the amiibo's name
byte[] nicknameBytes = System.Text.Encoding.UTF8.GetBytes(nickname);
nicknameBytes.CopyTo(registerInfo.Nickname.AsSpan());

return registerInfo;
}
Expand Down