From b221108f07e876a02804b55228de7c521c56afe4 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 14 Oct 2018 20:05:58 +0100 Subject: [PATCH] Change to uuid system --- modules/ExpGamingCore/Server/control.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/ExpGamingCore/Server/control.lua b/modules/ExpGamingCore/Server/control.lua index 2d2a673f..0001e545 100644 --- a/modules/ExpGamingCore/Server/control.lua +++ b/modules/ExpGamingCore/Server/control.lua @@ -21,6 +21,7 @@ local module_verbose = false --true|false -- @field named a name index for thread uuids -- @field print_to contains players that event details will be printed to -- @field uuid contains the random number generator for the uuid system +local pre_load_uuid = 0 local global = global{ all={_n=0}, queue={}, @@ -38,12 +39,20 @@ local global = global{ -- @treturn string the new uuid Server.uuid = add_metatable({},function() -- when it is called as a function - global.uuid=global.uuid+1 - verbose('UUID Created: '..global.uuid) - return global.uuid + local uuid = 0 + if game then + global.uuid=global.uuid+1 + uuid=global.uuid+pre_load_uuid + verbose('Game UUID Increased: '..uuid) + else + pre_load_uuid=pre_load_uuid+1 + uuid=pre_load_uuid + verbose('Load UUID Increased: '..uuid) + end + return add_metatable({uuid},nil,function(tbl) return string.to_hex(tostring(tbl[1])) end) end,function() -- when it is treated as a string - return string.to_hex(tostring(Server.uuid())) + return tostring(Server.uuid()) end) --- Redirect to the thread index