From e7438c6536c35b825cc73c5467009d415edb8a9e Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Tue, 14 Apr 2026 23:52:40 -0600 Subject: [PATCH] refactor(Lua): Spring.X -> SpringBucket.X MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match the split-tables-as-primary Spring API now used by the Recoil engine — route every Spring.X call site to the appropriate SpringSynced / SpringUnsynced / SpringShared bucket per the engine's @context annotations. --- util/LuaRules/Gadgets/ai_chokepoint.lua | 16 ++++----- util/LuaRules/Gadgets/ai_dbg_map.lua | 46 ++++++++++++------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/util/LuaRules/Gadgets/ai_chokepoint.lua b/util/LuaRules/Gadgets/ai_chokepoint.lua index 18e687e43..276207855 100644 --- a/util/LuaRules/Gadgets/ai_chokepoint.lua +++ b/util/LuaRules/Gadgets/ai_chokepoint.lua @@ -46,11 +46,11 @@ local function calcWalkable(p1, p2, maxSlope, minWaterDepth, maxWaterDepth) for j = 0, walkGran - 1 do local x = p1 * granularity + i * 16 local z = p2 * granularity + j * 16 - local _, _, _, slope = Spring.GetGroundNormal(x, z) + local _, _, _, slope = SpringShared.GetGroundNormal(x, z) if slope > maxSlope then return false end - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) if y > -minWaterDepth or y < -maxWaterDepth then return false end @@ -101,7 +101,7 @@ end local function TileToPos(p) local x = p[1] * granularity + granularity / 2 local z = p[2] * granularity + granularity / 2 - return {x, Spring.GetGroundHeight(x, z) + 10, z} + return {x, SpringShared.GetGroundHeight(x, z) + 10, z} end local function GetMiniTile(p) @@ -583,13 +583,13 @@ end local isAnalyzed = false function gadget:Initialize() - Spring.Echo("The generator's gone.") + SpringShared.Echo("The generator's gone.") AnalyzeMap("armcom") - Spring.Echo("Any way we can fix it?") + SpringShared.Echo("Any way we can fix it?") end function gadget:Shutdown() - Spring.Echo("It's GONE, MacReady.") + SpringShared.Echo("It's GONE, MacReady.") end -- WARNING: usage example @@ -603,10 +603,10 @@ function gadget:GameFrame(n) local chokes = GetChokePoints(a, b) for i, cp in ipairs(chokes) do local m = TileToPos(cp.nodes[NODE_MIDDLE]) - Spring.MarkerAddPoint(m[1], m[2], m[3], "choke" .. a .. ":" .. b) + SpringUnsynced.MarkerAddPoint(m[1], m[2], m[3], "choke" .. a .. ":" .. b) local e1 = TileToPos(cp.nodes[NODE_END1]) local e2 = TileToPos(cp.nodes[NODE_END2]) - Spring.MarkerAddLine(e1[1], e1[2], e1[3], e2[1], e2[2], e2[3]) + SpringUnsynced.MarkerAddLine(e1[1], e1[2], e1[3], e2[1], e2[2], e2[3]) end end end diff --git a/util/LuaRules/Gadgets/ai_dbg_map.lua b/util/LuaRules/Gadgets/ai_dbg_map.lua index 65fe09567..d25f44025 100644 --- a/util/LuaRules/Gadgets/ai_dbg_map.lua +++ b/util/LuaRules/Gadgets/ai_dbg_map.lua @@ -18,7 +18,7 @@ local isDraw = false local isPrint = false function gadget:RecvSkirmishAIMessage(teamID, dataStr) --- Spring.Echo("teamID: " .. tostring(teamID) .. " | dataStr: " .. dataStr) +-- SpringShared.Echo("teamID: " .. tostring(teamID) .. " | dataStr: " .. dataStr) local prefix = "ai_" if dataStr:sub(1, #prefix) ~= prefix then return @@ -332,10 +332,10 @@ local function MakeConeGL4(LuaShader, goodbye) end local function InitGL4() - Spring.Echo("Initializing GL4") + SpringShared.Echo("Initializing GL4") local goodbye = function(reason) - Spring.Echo("AI DBG widget exiting with reason: "..reason) + SpringShared.Echo("AI DBG widget exiting with reason: "..reason) gadgetHandler:RemoveGadget() end @@ -364,7 +364,7 @@ local mapWidth = Game.mapSizeX local mapHeight = Game.mapSizeZ local function HandleAiDbgEvent(cmd, teamID, dataStr) --- Spring.Echo("cmd: " .. cmd .. " | teamID: " .. tostring(teamID) .. " | dataStr: '" .. dataStr .. "'") +-- SpringShared.Echo("cmd: " .. cmd .. " | teamID: " .. tostring(teamID) .. " | dataStr: '" .. dataStr .. "'") local cmdThrData = "ai_thr_data:" local cmdBlkData = "ai_blk_data:" local cmdThrSize = "ai_thr_size:" @@ -378,14 +378,14 @@ local function HandleAiDbgEvent(cmd, teamID, dataStr) -- "ai_thr_data:..." local mapStr = dataStr:sub(#cmdThrData + 1) aiData.map = VFS.UnpackF32(mapStr, 1, aiData.width * aiData.height) - aiData.mapChanged = Spring.GetGameFrame() - --Spring.Echo("aiData.mapChanged", Spring.GetGameFrame()) + aiData.mapChanged = SpringShared.GetGameFrame() + --SpringShared.Echo("aiData.mapChanged", SpringShared.GetGameFrame()) elseif dataStr:sub(1, #cmdBlkData) == cmdBlkData then -- "ai_blk_data:..." local mapStr = dataStr:sub(#cmdBlkData + 1) aiData.map = VFS.UnpackU8(mapStr, 1, aiData.width * aiData.height) - aiData.mapChanged = Spring.GetGameFrame() - --Spring.Echo("aiData.mapChanged", Spring.GetGameFrame()) + aiData.mapChanged = SpringShared.GetGameFrame() + --SpringShared.Echo("aiData.mapChanged", SpringShared.GetGameFrame()) elseif dataStr:sub(1, #cmdThrSize) == cmdThrSize then -- "ai_thr_size: " local sb = dataStr:sub(cmdThrSize:len() + 1) @@ -421,7 +421,7 @@ local function HandleAiDbgEvent(cmd, teamID, dataStr) end end -local spGetGroundHeight = Spring.GetGroundHeight +local spGetGroundHeight = SpringShared.GetGroundHeight local lastupdateframe = 0 @@ -461,7 +461,7 @@ local function drawThrOldWay() if aiData.isPrint then local halfSize = size / 2; --- local cx, cy, cz = Spring.GetCameraDirection() +-- local cx, cy, cz = SpringUnsynced.GetCameraDirection() -- local dir = ((math.atan2(cx, cz) / math.pi) + 1) * 180 for x = 1, width do @@ -472,7 +472,7 @@ local function drawThrOldWay() pz = z * size + halfSize local py = spGetGroundHeight(px, pz) - if Spring.IsSphereInView(px, py, pz, size) then + if SpringUnsynced.IsSphereInView(px, py, pz, size) then if py < 0 then py = 0 end gl.PushMatrix() @@ -500,7 +500,7 @@ local function drawMrkOldWay() gl.DrawGroundQuad(v[1] - halfSize, v[2] - halfSize, v[1] + halfSize, v[2] + halfSize) if v[8] then local py = spGetGroundHeight(v[1], v[2]) - if Spring.IsSphereInView(v[1], py, v[2], halfSize) then + if SpringUnsynced.IsSphereInView(v[1], py, v[2], halfSize) then if py < 0 then py = 0 end gl.PushMatrix() gl.Translate(v[1], py, v[2]) @@ -525,8 +525,8 @@ local function drawThrGL4Way() if aiData.isDraw then if aiData.mapChanged > lastupdateframe then - lastupdateframe = Spring.GetGameFrame() --- Spring.Echo("mapChanged updated", lastupdateframe, aiData.mapChanged) + lastupdateframe = SpringShared.GetGameFrame() +-- SpringShared.Echo("mapChanged updated", lastupdateframe, aiData.mapChanged) InstanceVBOTable.clearInstanceTable(circleInstanceVBOthr) -- remove all our previous geometry from buffer for x = 1, width do @@ -565,7 +565,7 @@ local function drawThrGL4Way() gl.DepthTest(false) -- so that it doesnt get hidden under terrain gl.Texture(0, "$heightmap") circleShaderThr:Activate() --- Spring.Echo("Drawing AI DBG circleInstanceVBOthr", circleInstanceVBOthr.usedElements) +-- SpringShared.Echo("Drawing AI DBG circleInstanceVBOthr", circleInstanceVBOthr.usedElements) InstanceVBOTable.drawInstanceVBO(circleInstanceVBOthr) circleShaderThr:Deactivate() gl.Texture(0, false) @@ -574,7 +574,7 @@ local function drawThrGL4Way() if aiData.isPrint then local halfSize = size / 2; --- local cx, cy, cz = Spring.GetCameraDirection() +-- local cx, cy, cz = SpringUnsynced.GetCameraDirection() -- local dir = ((math.atan2(cx, cz) / math.pi) + 1) * 180 for x = 1, width do @@ -585,7 +585,7 @@ local function drawThrGL4Way() pz = z * size + halfSize local py = spGetGroundHeight(px, pz) - if Spring.IsSphereInView(px, py, pz, size) then + if SpringUnsynced.IsSphereInView(px, py, pz, size) then if py < 0 then py = 0 end gl.PushMatrix() @@ -634,7 +634,7 @@ local function drawMrkGL4Way() gl.DepthTest(true) gl.Texture(0, "$heightmap") circleShaderMrk:Activate() --- Spring.Echo("Drawing AI DBG circleInstanceVBOmrk", circleInstanceVBOmrk.usedElements) +-- SpringShared.Echo("Drawing AI DBG circleInstanceVBOmrk", circleInstanceVBOmrk.usedElements) -- gl.Blending("alpha") -- gl.Culling(GL.FRONT) -- InstanceVBOTable.drawInstanceVBO(circleInstanceVBOmrk) @@ -650,7 +650,7 @@ local function drawMrkGL4Way() for k, v in pairs(aiData.marks) do if v[8] then local py = spGetGroundHeight(v[1], v[2]) - if Spring.IsSphereInView(v[1], py, v[2], v[3]) then + if SpringUnsynced.IsSphereInView(v[1], py, v[2], v[3]) then if py < 0 then py = 0 end gl.PushMatrix() gl.Translate(v[1], py, v[2]) @@ -664,8 +664,8 @@ local function drawMrkGL4Way() end function gadget:DrawWorldPreUnit() --- Spring.Echo(aiData.map[0 * width + 1]) --- Spring.Echo(aiData.map[(height - 1) * width + width]) +-- SpringShared.Echo(aiData.map[0 * width + 1]) +-- SpringShared.Echo(aiData.map[(height - 1) * width + width]) if isGL4Way then drawThrGL4Way() @@ -683,13 +683,13 @@ function gadget:DrawWorld() end function gadget:Initialize() - Spring.Echo("Initialize AI DBG") + SpringShared.Echo("Initialize AI DBG") gadgetHandler:AddSyncAction("AiDbgEvent", HandleAiDbgEvent) InitGL4() end function gadget:Shutdown() - Spring.Echo("Shutdown AI DBG") + SpringShared.Echo("Shutdown AI DBG") gadgetHandler:RemoveSyncAction("AiDbgEvent") end