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

Add function to create UUIDs #1459

Merged
merged 1 commit into from
Jan 17, 2023
Merged

Add function to create UUIDs #1459

merged 1 commit into from
Jan 17, 2023

Conversation

BaerMitUmlaut
Copy link
Contributor

When merged this pull request will:

  • Add a simple UUID generator function

@commy2
Copy link
Contributor

commy2 commented May 23, 2021

It's not unique.

@BaerMitUmlaut
Copy link
Contributor Author

BaerMitUmlaut commented May 23, 2021

I didn't choose that name.

@commy2
Copy link
Contributor

commy2 commented May 23, 2021

I chose to complain about it.

Copy link
Contributor

@commy2 commy2 left a comment

Choose a reason for hiding this comment

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

not unique

@BaerMitUmlaut
Copy link
Contributor Author

This is an implementation that meets the RFC spec. If you want to complain about semantics, you'll have to complain to the IETF.

@commy2
Copy link
Contributor

commy2 commented May 23, 2021

Not challenging the spec. But I am saying that this is not suited for anything in Arma.

@BaerMitUmlaut
Copy link
Contributor Author

Arma can only do floats, so in use cases where you can potentially exceed 2^23 IDs, UUIDs would be useful. The chance of a collision is ridiculously low and way less of a risk than running out of numbers.

@commy2
Copy link
Contributor

commy2 commented May 23, 2021

There is no need to do this when everyone already has a unique client id.

@BaerMitUmlaut
Copy link
Contributor Author

Okay, and that helps how exactly?

@commy2
Copy link
Contributor

commy2 commented May 23, 2021

Those are unique and therefore useful. I see no use case for this.

@BaerMitUmlaut
Copy link
Contributor Author

Now you have one unique ID per client. What if I need 2^24 unique IDs per client? Say, for example, PFH IDs?

@commy2
Copy link
Contributor

commy2 commented May 23, 2021

What if I need 2^24 unique IDs per client?

I would use a function that actually provides unique ids, so not this one.

@BaerMitUmlaut
Copy link
Contributor Author

BaerMitUmlaut commented May 23, 2021

Well, then provide a better one. The generated UUIDs are more than good enough, but feel free to prove me wrong. However I'm not willing to wait a hundred years for you to generate a duplicate.

Copy link
Member

@jonpas jonpas left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

This shouldn't be a discussion of its use, it's a standard implementation and CBA as a general library can and should provide those if there is any use for it. It is up to the library consumer to use it or not, there can even be multiple implementations of a "unique ID" generator in CBA.

@commy2
Copy link
Contributor

commy2 commented May 24, 2021

CBA as a general library can and should provide those if there is any use for it

What is the use case? Providing unique ids is not one of them.

@BaerMitUmlaut
Copy link
Contributor Author

Providing an ID that is unique within the next 100 years.

@PabstMirror PabstMirror added this to the 3.15.4 milestone Jun 30, 2021
@PabstMirror PabstMirror modified the milestones: 3.15.4, Ongoing Jun 30, 2021
@dedmen
Copy link
Contributor

dedmen commented Jan 17, 2023

You can use https://community.bistudio.com/wiki/systemTimeUTC to make it mooooooooost likely unique, down to the millisecond.

@BaerMitUmlaut
Copy link
Contributor Author

The OS time is by default not that accurate, but sure, let's say it is.

The chances of a duplicate UUID are far lower than those of a duplicate timestamp. Imagine assigning a unique ID to every player on a server. If that code is executed at the same time for every client, the chances of an overlap are probably higher than 1/1000. Consider that this code might be executed many times, not just per day, but across multiple servers and for every session. You're going to have duplicates.

@jonpas jonpas modified the milestones: Ongoing, 3.15.9 Jan 17, 2023
@jonpas
Copy link
Member

jonpas commented Jan 17, 2023

Merge it @BaerMitUmlaut!

@BaerMitUmlaut
Copy link
Contributor Author

I lack the rights to merge.

@jonpas jonpas merged commit 9db07db into CBATeam:master Jan 17, 2023
@BaerMitUmlaut BaerMitUmlaut deleted the uuid branch January 17, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants