Convert startbox config to 1-based indexing#5671
Convert startbox config to 1-based indexing#5671MexxPex wants to merge 39 commits intoZeroK-RTS:masterfrom
Conversation
|
Looks like a good starter point but is incomplete, e.g the config for Adansonia v4 has some 0-indexing still. It would also be good if it was split into a bunch of smaller commits because it's difficult to confidently review 300 files at once. |
|
@sprunk does this not need any code changes? As in can the gadget handle both types already? |
|
I could split the commit into multiple commits if I knew how to do it. |
Generally you use
It handles both: Zero-K/LuaRules/Gadgets/Include/startbox_utilities.lua Lines 158 to 174 in 317077d |
|
Is it not a good idea to change that into shifting up now? ie into: if startBoxConfig[0] and not startBoxConfig[1] then
Spring.Echo("0-indexed startbox detected, shifting")
local ret = {}
for boxID, box in pairs(startBoxConfig) do
ret[boxID + 1] = box
end
startBoxConfig = ret
end
return startBoxConfig
end |
|
Yes, but in a separate PR and also keep in mind that the above snippet is not the only place that would need to be changed (also everywhere the resulting table is used). |
Lua tables are naturally 1‑indexed, and explicit 0‑based keys are mistake‑prone.
This aligns the files with the standards described in issue #5137