Loc.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. namespace FF8
  2. {
  3. public struct Loc
  4. {
  5. public uint seek;
  6. /// <summary>
  7. /// sometimes there is more than one entry at a location each is 8 bytes
  8. /// </summary>
  9. public uint length;
  10. public uint max => seek + length;
  11. public static bool operator !=(Loc a, Loc b) => a.seek != b.seek && a.length != b.length;
  12. public static bool operator ==(Loc a, Loc b) => a.seek == b.seek && a.length == b.length;
  13. public override bool Equals(object obj)
  14. {
  15. if (!(obj is Loc))
  16. return false;
  17. var loc = (Loc)obj;
  18. return seek == loc.seek &&
  19. length == loc.length;
  20. }
  21. public static implicit operator uint(Loc @in) => @in.seek;
  22. public override int GetHashCode()
  23. {
  24. var hashCode = 202372718;
  25. hashCode = hashCode * -1521134295 + seek.GetHashCode();
  26. hashCode = hashCode * -1521134295 + length.GetHashCode();
  27. return hashCode;
  28. }
  29. }
  30. }