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

Output hex and other formats for objects #50

Open
dd84ai opened this issue Nov 2, 2024 · 1 comment
Open

Output hex and other formats for objects #50

dd84ai opened this issue Nov 2, 2024 · 1 comment

Comments

@dd84ai
Copy link
Member

dd84ai commented Nov 2, 2024

(in hex, decimal signed, decimal unsigned variants if possible :])

@dd84ai dd84ai changed the title Output hex and other Output hex and other formats for objects Nov 2, 2024
@dd84ai
Copy link
Member Author

dd84ai commented Nov 14, 2024

public static uint CreateId(string nickname)
    {
      if (StringUtils.createIDTable == null)
      {
        StringUtils.createIDTable = new uint[256];
        for (uint index1 = 0; index1 < 256U; ++index1)
        {
          uint num = index1;
          for (uint index2 = 0; index2 < 8U; ++index2)
            num = ((int) num & 1) == 1 ? num >> 1 ^ 671105024U : num >> 1;
          StringUtils.createIDTable[(int) index1] = num;
        }
      }
      byte[] bytes = Encoding.ASCII.GetBytes(nickname.ToLowerInvariant());
      uint num1 = 0;
      for (int index = 0; index < bytes.Length; ++index)
        num1 = num1 >> 8 ^ StringUtils.createIDTable[(int) (byte) num1 ^ (int) bytes[index]];
      return (uint) (((int) (num1 >> 24) | (int) (num1 >> 8) & 65280 | (int) num1 << 8 & 16711680 | (int) num1 << 24) >>> 2 | int.MinValue);
    }

    public static uint CreateFactionId(string nickname)
    {
      if (StringUtils.createFactionIDTable == null)
      {
        StringUtils.createFactionIDTable = new uint[256];
        for (uint index1 = 0; index1 < 256U; ++index1)
        {
          uint num = index1 << 8;
          for (uint index2 = 0; index2 < 8U; ++index2)
            num = (((int) num & 32768) == 32768 ? (uint) ((int) num << 1 ^ 4129) : num << 1) & (uint) ushort.MaxValue;
          StringUtils.createFactionIDTable[(int) index1] = num;
        }
      }
      byte[] bytes = Encoding.ASCII.GetBytes(nickname.ToLowerInvariant());
      uint factionId = (uint) ushort.MaxValue;
      for (uint index = 0; (long) index < (long) bytes.Length; ++index)
        factionId = (factionId & 65280U) >> 8 ^ StringUtils.createFactionIDTable[(int) factionId & (int) byte.MaxValue ^ (int) bytes[(int) index]];
      return factionId;
    }

Write faction hashing too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant