From 9e469b04f1a26a5b5ca0ba4511a9808d49f22d4f Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Wed, 26 Oct 2022 15:10:07 +0200 Subject: [PATCH] add Util.GenerateUUID lua api This api generates a pseudorandom RFC 4122 compliant UUID (https://www.ietf.org/rfc/rfc4122.txt). It's pseudorandom, so it is *unlikely* to have collisions. --- CMakeLists.txt | 3 +-- Changelog.md | 1 + src/TLuaEngine.cpp | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10f576e..991a80d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ set(BeamMP_Sources include/TPluginMonitor.h src/TPluginMonitor.cpp include/Environment.h include/BoostAliases.h + include/Uuid.h src/Uuid.cpp ) set(BeamMP_Includes @@ -161,8 +162,6 @@ if (UNIX) -Werror=missing-field-initializers -Werror=write-strings -Werror=ctor-dtor-privacy - -Wswitch-enum - -Wswitch-default -Werror=old-style-cast -Werror=overloaded-virtual -Werror=overloaded-virtual diff --git a/Changelog.md b/Changelog.md index 27445c0..daca0a6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ # v3.2.0 - ADDED `settings` command, which lets you `get`, `list`, and `set` config options from the console +- ADDED `Util.GenerateUUID()`, which generates an RFC4122 UUID (universally unique identifier) # v3.1.1 diff --git a/src/TLuaEngine.cpp b/src/TLuaEngine.cpp index f2034ae..78a3a6c 100644 --- a/src/TLuaEngine.cpp +++ b/src/TLuaEngine.cpp @@ -4,6 +4,7 @@ #include "Http.h" #include "LuaAPI.h" #include "TLuaPlugin.h" +#include "Uuid.h" #include "sol/object.hpp" #include @@ -818,6 +819,7 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, TLuaStateI UtilTable.set_function("JsonUnflatten", &LuaAPI::MP::JsonUnflatten); UtilTable.set_function("JsonPrettify", &LuaAPI::MP::JsonPrettify); UtilTable.set_function("JsonMinify", &LuaAPI::MP::JsonMinify); + UtilTable.set_function("GenerateUUID", &uuid::GenerateUuid); UtilTable.set_function("Random", [this] { return mUniformRealDistribution01(mMersenneTwister); });