CBA_A3 icon indicating copy to clipboard operation
CBA_A3 copied to clipboard

Add function to create UUIDs

Open BaerMitUmlaut opened this issue 4 years ago • 14 comments

When merged this pull request will:

  • Add a simple UUID generator function

BaerMitUmlaut avatar May 23 '21 16:05 BaerMitUmlaut

It's not unique.

commy2 avatar May 23 '21 16:05 commy2

I didn't choose that name.

BaerMitUmlaut avatar May 23 '21 16:05 BaerMitUmlaut

I chose to complain about it.

commy2 avatar May 23 '21 17:05 commy2

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

BaerMitUmlaut avatar May 23 '21 19:05 BaerMitUmlaut

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

commy2 avatar May 23 '21 19:05 commy2

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.

BaerMitUmlaut avatar May 23 '21 20:05 BaerMitUmlaut

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

commy2 avatar May 23 '21 20:05 commy2

Okay, and that helps how exactly?

BaerMitUmlaut avatar May 23 '21 20:05 BaerMitUmlaut

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

commy2 avatar May 23 '21 20:05 commy2

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

BaerMitUmlaut avatar May 23 '21 20:05 BaerMitUmlaut

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

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

commy2 avatar May 23 '21 20:05 commy2

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.

BaerMitUmlaut avatar May 23 '21 20:05 BaerMitUmlaut

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.

commy2 avatar May 24 '21 06:05 commy2

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

BaerMitUmlaut avatar May 24 '21 10:05 BaerMitUmlaut

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

dedmen avatar Jan 17 '23 11:01 dedmen

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.

BaerMitUmlaut avatar Jan 17 '23 11:01 BaerMitUmlaut

Merge it @BaerMitUmlaut!

jonpas avatar Jan 17 '23 11:01 jonpas

I lack the rights to merge.

BaerMitUmlaut avatar Jan 17 '23 12:01 BaerMitUmlaut