diff --git a/README.md b/README.md index feb43e1..e67b685 100644 --- a/README.md +++ b/README.md @@ -150,10 +150,9 @@ Sometimes (for debugging purposes, for example), it is necessary to extract the ```lua ---@param primary integer ---@param secondary integer ----@param options? integer ---@return evolved.id id ---@nodiscard -function evolved.pack(primary, secondary, options) end +function evolved.pack(primary, secondary) end ---@param id evolved.id ---@return integer primary @@ -1105,7 +1104,7 @@ DESTRUCTION_POLICY_REMOVE_FRAGMENT :: id id :: integer? -> id... name :: id... -> string... -pack :: integer, integer, integer? -> id +pack :: integer, integer -> id unpack :: id -> integer, integer, integer defer :: boolean @@ -1330,10 +1329,9 @@ function evolved.name(...) end ```lua ---@param primary integer ---@param secondary integer ----@param options? integer ---@return evolved.id id ---@nodiscard -function evolved.pack(primary, secondary, options) end +function evolved.pack(primary, secondary) end ``` ### `evolved.unpack` diff --git a/develop/fuzzing/pack_unpack_fuzz.lua b/develop/fuzzing/pack_unpack_fuzz.lua index bd01310..32c1997 100644 --- a/develop/fuzzing/pack_unpack_fuzz.lua +++ b/develop/fuzzing/pack_unpack_fuzz.lua @@ -20,28 +20,14 @@ for _ = 1, 1000 do assert(0 == unpacked_options) end -for _ = 1, 1000 do - local initial_primary = math.random(1, 2 ^ 20 - 1) - local initial_secondary = math.random(1, 2 ^ 20 - 1) - local initial_options = math.random(1, 2 ^ 12 - 1) - - local packed_id = evo.pack(initial_primary, initial_secondary, initial_options) - local unpacked_primary, unpacked_secondary, unpacked_options = evo.unpack(packed_id) - - assert(initial_primary == unpacked_primary) - assert(initial_secondary == unpacked_secondary) - assert(initial_options == unpacked_options) -end - for _ = 1, 1000 do local initial_primary = math.random(1, 2 ^ 31 - 1) local initial_secondary = math.random(1, 2 ^ 31 - 1) - local initial_options = math.random(1, 2 ^ 31 - 1) - local packed_id = evo.pack(initial_primary, initial_secondary, initial_options) + local packed_id = evo.pack(initial_primary, initial_secondary) local unpacked_primary, unpacked_secondary, unpacked_options = evo.unpack(packed_id) assert(initial_primary % 2 ^ 20 == unpacked_primary) assert(initial_secondary % 2 ^ 20 == unpacked_secondary) - assert(initial_options % 2 ^ 12 == unpacked_options) + assert(0 == unpacked_options) end diff --git a/develop/testing/pairs_tests.lua b/develop/testing/pairs_tests.lua index 72289bb..e5982bd 100644 --- a/develop/testing/pairs_tests.lua +++ b/develop/testing/pairs_tests.lua @@ -1604,3 +1604,4 @@ end -- builder:has/has_all/has_any should work with wildcards / remove too? -- should we provide wildcard support for get operations? -- prevent setting pairs with dead secondary fragments +-- process evo.ANY as single wildcard diff --git a/evolved.lua b/evolved.lua index 7832824..a1fb6fe 100644 --- a/evolved.lua +++ b/evolved.lua @@ -4674,13 +4674,11 @@ end ---@param primary integer ---@param secondary integer ----@param options? integer ---@return evolved.id id ---@nodiscard -function __evolved_pack(primary, secondary, options) +function __evolved_pack(primary, secondary) return primary % 2 ^ 20 - + secondary % 2 ^ 20 * 2 ^ 20 - + (options or 0) % 2 ^ 12 * 2 ^ 40 --[[@as evolved.id]] + + secondary % 2 ^ 20 * 2 ^ 20 --[[@as evolved.id]] end ---@param id evolved.id