remove 'options' param from evolved.pack

This commit is contained in:
BlackMATov
2025-08-20 22:23:25 +07:00
parent 008df17ee6
commit 77bc6c298e
4 changed files with 8 additions and 25 deletions

View File

@@ -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`

View File

@@ -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

View File

@@ -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

View File

@@ -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