Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4KB

  1. using System;
  2. using System.IO;
  3. using System.Runtime.CompilerServices;
  4. using NetworkFramework.Shared;
  5. namespace CLre_server.API.Synergy.Tweaks
  6. {
  7. public struct SerializedCLreTerrainModifyRejection: ISerializedNetData
  8. {
  9. public RejectionFlag Flags;
  10. public uint Cell;
  11. public byte[] Serialize()
  12. {
  13. using (MemoryStream stream = new MemoryStream())
  14. {
  15. using (BinaryWriter writer = new BinaryWriter(stream))
  16. {
  17. writer.Write((byte)Flags);
  18. writer.Write(Cell);
  19. return stream.ToArray();
  20. }
  21. }
  22. }
  23. public void Deserialize(byte[] data)
  24. {
  25. using (MemoryStream stream = new MemoryStream(data))
  26. {
  27. using (BinaryReader reader = new BinaryReader(stream))
  28. {
  29. Flags = (RejectionFlag)reader.ReadByte();
  30. Cell = reader.ReadUInt32();
  31. }
  32. }
  33. }
  34. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  35. public bool Ok()
  36. {
  37. return (Flags & RejectionFlag.Rejection) == RejectionFlag.None;
  38. }
  39. }
  40. [Flags]
  41. public enum RejectionFlag : byte
  42. {
  43. None = 0,
  44. Rejection = 1,
  45. Proximity = 1 << 1,
  46. Permission = 1 << 2,
  47. AccountNotFound = 1 << 3,
  48. InitError = 1 << 4,
  49. }
  50. }