Closed lL1l1 closed 1 week ago
What about:
--- table.copy(t) returns a shallow copy of t.
---@generic T
---@param t T
---@return T
function table.copy(t)
(...)
end
I misunderstood what a shallow copy is. I thought it would only copy 1 deep (which doesn't preserve type) but it just copies old memory references into the new indexes of the new table (which does preserve type, but makes mutating it need more care).
Description of the proposed changes
Fixes in-game blueprint reloading crash caused by #6273 (specific diff) from
blueprints-units.lua:311
due to spawn dummies havingCommandCaps = "0"
. Instead of checking for nil, checks for the value to be a table.The function could use a better annotation if possible.
Testing done on the proposed changes
The game no longer crashes when reloading blueprints during a session.
Checklist
- [ ] Changes are documented in the changelog for the next game versionNot necessary.