Ryujinx/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs
Thog 3b531de670
Implement mii:u and mii:e entirely (#955)
* Implement mii:u and mii:e entirely

Co-authored-by: AcK77 <Acoustik666@gmail.com>

This commit implement the mii service accurately.

This is based on Ac_k work but was polished and updated to 7.x.

Please note that the following calls are partially implemented:

- Convert: Used to convert from old console format (Wii/Wii U/3ds)
- Import and Export: this is shouldn't be accesible in production mode.

* Remove some debug leftovers

* Make it possible to load an arbitrary mii database from a Switch

* Address gdk's comments

* Reduce visibility of all the Mii code

* Address Ac_K's comments

* Remove the StructLayout of DatabaseSessionMetadata

* Add a missing line return in DatabaseSessionMetadata

* Misc fixes and style changes

* Fix some issues from last commit

* Fix database server metadata UpdateCounter in MarkDirty (Thanks Moose for the catch)

* MountCounter should only be incremented when no error is reported

* Fix FixDatabase

Co-authored-by: Alex Barney <thealexbarney@gmail.com>
2020-03-02 09:56:01 +11:00

46 lines
1.1 KiB
C#

using Ryujinx.HLE.Utilities;
using System;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Mii.Types
{
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
struct CreateId : IEquatable<CreateId>
{
public UInt128 Raw;
public bool IsNull => Raw.IsNull;
public bool IsValid => !IsNull && (Raw.High & 0xC0) == 0x80;
public CreateId(byte[] data)
{
Raw = new UInt128(data);
}
public static bool operator ==(CreateId x, CreateId y)
{
return x.Equals(y);
}
public static bool operator !=(CreateId x, CreateId y)
{
return !x.Equals(y);
}
public override bool Equals(object obj)
{
return obj is CreateId createId && Equals(createId);
}
public bool Equals(CreateId cmpObj)
{
// Nintendo additionally check that the CreatorId is valid before doing the actual comparison.
return IsValid && Raw == cmpObj.Raw;
}
public override int GetHashCode()
{
return Raw.GetHashCode();
}
}
}