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

Update openos/lib/uuid.lua to generate valid RFC4122 version 4 UUIDs #2715

Merged
merged 1 commit into from
Jan 11, 2018

Conversation

jobe1986
Copy link
Contributor

@jobe1986 jobe1986 commented Jan 2, 2018

Pull request relating to issue #2713

byte = bit32.bor(bit32.band(byte, 0x3F), 0x80)
end
result = result .. string.format("%02x", byte)
pos = pos + 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can one just use i instead of maintaining a separate counter?

Copy link
Contributor Author

@jobe1986 jobe1986 Jan 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of i is from 1 to the value of 4, 2 or 6 depending on the part of the uuid being generated. Thus you would still need to maintain an index of which section of the uuid you're generating.

For example the 2 options are the method I used, or a method where the option for byte 6 is byte 1 or part 3 and byte 8 is byte 1 of part 4. So you could change "for _,set in ipairs(sets) do" to "for part,set in ipairs(sets) do" and then use "if part == 3 and i == 1 then" and "if part == 4 and i == 1" instead of "if pos == 6 then" and "if pos == 8 then" respectively. The result would then be the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, woops. I evidently failed to read the code properly - sorry.

@payonel payonel merged commit c78cf08 into MightyPirates:master-MC1.7.10 Jan 11, 2018
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

Successfully merging this pull request may close these issues.

3 participants