Skip to content

Commit 3afc93b

Browse files
committed
gen(bar_codemod): rename-aliases, detach-bar-modules, spring-split
1 parent 8c537e4 commit 3afc93b

759 files changed

Lines changed: 11330 additions & 11341 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/configs/unit_restrictions_config.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ local function shouldShowWaterUnits()
4040
return false
4141
end
4242

43-
local debugCommands = Spring.GetModOption("debugcommands")
43+
local debugCommands = SpringShared.GetModOption("debugcommands")
4444

4545
-- terraform, done too late to read w/ get ground, and too hectic to even try and guess
4646
if debugCommands and debugCommands:len() > 1 then
@@ -49,10 +49,10 @@ local function shouldShowWaterUnits()
4949
end
5050
end
5151

52-
local _, _, mapMinWater, _ = Spring.GetGroundExtremes()
52+
local _, _, mapMinWater, _ = SpringShared.GetGroundExtremes()
5353

5454
-- water level shifted, done too late by another gadget for this file to read w/ get ground
55-
local moddedWaterLevel = Spring.GetModOption("map_waterlevel") or 0
55+
local moddedWaterLevel = SpringShared.GetModOption("map_waterlevel") or 0
5656
mapMinWater = mapMinWater - moddedWaterLevel
5757

5858
return mapMinWater <= -11 -- units.minWaterUnitDepth
@@ -67,11 +67,11 @@ local function hasGeothermalFeatures()
6767
geoFeatureDefs[defID] = true
6868
end
6969
end
70-
local features = Spring.GetAllFeatures()
70+
local features = SpringShared.GetAllFeatures()
7171
for i = 1, #features do
7272
local featureID = features[i]
73-
if geoFeatureDefs[Spring.GetFeatureDefID(featureID)] then
74-
local _, y, _ = Spring.GetFeaturePosition(featureID)
73+
if geoFeatureDefs[SpringShared.GetFeatureDefID(featureID)] then
74+
local _, y, _ = SpringShared.GetFeaturePosition(featureID)
7575
if y < 0 then
7676
hasSeaGeo = true
7777
else

common/holidays.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
if not Spring.GetModOptions then
1+
if not SpringShared.GetModOptions then
22
return
33
end
44

5-
if not Spring.GetModOptions().holiday_events then
5+
if not SpringShared.GetModOptions().holiday_events then
66
return
77
end
88

9-
local currentDay = Spring.GetModOptions().date_day
10-
local currentMonth = Spring.GetModOptions().date_month
11-
local currentYear = Spring.GetModOptions().date_year
9+
local currentDay = SpringShared.GetModOptions().date_day
10+
local currentMonth = SpringShared.GetModOptions().date_month
11+
local currentYear = SpringShared.GetModOptions().date_year
1212

1313
-- Meeus's Julian algorithm Function to calculate Easter Sunday for a given year. Magic.
1414
local function EasterDate(year)

common/lib_startpoint_guesser.lua

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ function IsSteep(x, z)
1212
local mtta = math.acos(1.0 - 0.41221) - 0.02 --http://springrts.com/wiki/Movedefs.lua#How_slope_is_determined & the -0.02 is for safety
1313
local a1, a2, a3, a4 = 0, 0, 0, 0
1414
local d = 5
15-
local y = Spring.GetGroundHeight(x, z)
16-
local y1 = Spring.GetGroundHeight(x + d, z)
15+
local y = SpringShared.GetGroundHeight(x, z)
16+
local y1 = SpringShared.GetGroundHeight(x + d, z)
1717
if math.abs(y1 - y) > 0.1 then
1818
a1 = math.atan((y1 - y) / d)
1919
end
20-
local y2 = Spring.GetGroundHeight(x, z + d)
20+
local y2 = SpringShared.GetGroundHeight(x, z + d)
2121
if math.abs(y2 - y) > 0.1 then
2222
a2 = math.atan((y2 - y) / d)
2323
end
24-
local y3 = Spring.GetGroundHeight(x - d, z)
24+
local y3 = SpringShared.GetGroundHeight(x - d, z)
2525
if math.abs(y3 - y) > 0.1 then
2626
a3 = math.atan((y3 - y) / d)
2727
end
28-
local y4 = Spring.GetGroundHeight(x, z + d)
28+
local y4 = SpringShared.GetGroundHeight(x, z + d)
2929
if math.abs(y4 - y) > 0.1 then
3030
a4 = math.atan((y4 - y) / d)
3131
end
@@ -54,14 +54,14 @@ function GuessOne(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable)
5454
for i = 1, #metalSpots do
5555
local spot = metalSpots[i]
5656
local mx, mz = spot.x, spot.z
57-
local my = Spring.GetGroundHeight(mx, mz)
57+
local my = SpringShared.GetGroundHeight(mx, mz)
5858
local isWithinStartBox = (xmin < mx) and (mx < xmax) and (zmin < mz) and (mz < zmax)
5959
local isWithinWalkRadius = (mx >= xmin - walkRadius) and (mx <= xmax + walkRadius) and (mz >= zmin - walkRadius) and (mz <= zmax + walkRadius)
6060

6161
local isFree = true
6262
for _, startpoint in pairs(startPointTable) do -- we avoid enemy startpoints too, to prevent unnecessary explosions and to deal with the case of having no startboxes
6363
local sx, sz = startpoint[1], startpoint[2]
64-
local sy = Spring.GetGroundHeight(sx, sz)
64+
local sy = SpringShared.GetGroundHeight(sx, sz)
6565
local isWithinClaimRadius = ((sx - mx) * (sx - mx) + (sz - mz) * (sz - mz) <= claimRadius * claimRadius)
6666
local isWithinClaimHeight = (math.abs(my - sy) <= claimHeight)
6767
if isWithinClaimRadius and isWithinClaimHeight then
@@ -116,8 +116,8 @@ function GuessOne(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable)
116116
local jx, jz = freeMetalSpots[j][1], freeMetalSpots[j][2]
117117
if ix ~= jx or iz ~= jz then
118118
local r = math.sqrt((ix - jx) ^ 2 + (iz - jz) ^ 2)
119-
local iy = Spring.GetGroundHeight(ix, iz)
120-
local jy = Spring.GetGroundHeight(jx, jz)
119+
local iy = SpringShared.GetGroundHeight(ix, iz)
120+
local jy = SpringShared.GetGroundHeight(jx, jz)
121121
local isWithinClaimRadius = (r <= claimRadius)
122122
local isWithinClaimHeight = (math.abs(iy - jy) <= claimHeight)
123123
local score -- Magic formula. Assumes all metal spots are of equal production value, TODO...
@@ -134,8 +134,8 @@ function GuessOne(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable)
134134
local jx, jz = walkableMetalSpots[j][1], walkableMetalSpots[j][2]
135135
if ix ~= jx or iz ~= jz then
136136
local r = math.sqrt((ix - jx) ^ 2 + (iz - jz) ^ 2)
137-
local iy = Spring.GetGroundHeight(ix, iz)
138-
local jy = Spring.GetGroundHeight(jx, jz)
137+
local iy = SpringShared.GetGroundHeight(ix, iz)
138+
local jy = SpringShared.GetGroundHeight(jx, jz)
139139
local isWithinClaimRadius = (r <= claimRadius)
140140
local isWithinClaimHeight = (math.abs(iy - jy) <= claimHeight)
141141
local score -- Magic formula. Assumes all metal spots are of equal production value, TODO...
@@ -199,15 +199,15 @@ end
199199

200200
function GuessTwo(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable) --TODO: make this more efficient, atm it akes 1-2 sec to run
201201
-- search over metal map and find a point with a reasonable amount of non-claimed metal near to it
202-
local mmapx, mmapz = Spring.GetMetalMapSize() -- metal map cords * 16 = world coords
202+
local mmapx, mmapz = SpringShared.GetMetalMapSize() -- metal map cords * 16 = world coords
203203
local xres = math.max(1, math.floor(mmapx / 16))
204204
local zres = math.max(1, math.floor(mmapz / 16))
205205

206206
local points = {} --possible startpoints point[id] = {x,z,metal}, grid over metalmap of sidelength res
207207
local x = xres
208208
local z = zres
209209
while true do --i hate lua
210-
local y = Spring.GetGroundHeight(x * 16, z * 16)
210+
local y = SpringShared.GetGroundHeight(x * 16, z * 16)
211211
local isWithinStartBox = (xmin < 16 * x) and (16 * x < xmax) and (zmin < 16 * z) and (16 * z < zmax)
212212
if isWithinStartBox then
213213
points[#points + 1] = { x = x, y = y, z = z, m = 0 }
@@ -231,8 +231,8 @@ function GuessTwo(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable) --TOD
231231
local isFree = true
232232
for _, startpoint in pairs(startPointTable) do -- we avoid enemy startpoints too, to prevent unnecessary explosions and to deal with the case of having no startboxes
233233
local sx, sz = startpoint[1], startpoint[2]
234-
local sy = Spring.GetGroundHeight(sx, sz)
235-
local y = Spring.GetGroundHeight(x * 16, z * 16)
234+
local sy = SpringShared.GetGroundHeight(sx, sz)
235+
local y = SpringShared.GetGroundHeight(x * 16, z * 16)
236236
local isWithinClaimRadius = ((sx - x * 16) * (sx - x * 16) + (sz - z * 16) * (sz - z * 16) <= claimRadius2 * claimRadius2)
237237
local isWithinClaimHeight = (math.abs(sy - y) <= claimHeight)
238238
if isWithinClaimRadius and isWithinClaimHeight then
@@ -242,9 +242,9 @@ function GuessTwo(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable) --TOD
242242
end
243243

244244
-- if it is, add this metal into points
245-
local m = Spring.GetMetalAmount(x, z)
245+
local m = SpringShared.GetMetalAmount(x, z)
246246
if isFree and m > 0.1 then
247-
local y = Spring.GetGroundHeight(x * 16, z * 16)
247+
local y = SpringShared.GetGroundHeight(x * 16, z * 16)
248248
for _, p in ipairs(points) do
249249
if m and (p.x - x) * (p.x - x) + (p.z - z) * (p.z - z) <= (claimRadius2 / 16) * (claimRadius2 / 16) and math.abs(p.y - y) <= claimHeight then
250250
p.m = p.m + m

common/springFunctions.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ local utilities = {
2626
GetRaptorAllyTeamID = team.GetRaptorAllyTeamID,
2727

2828
IsDevMode = function()
29-
local devMode = Spring.GetGameRulesParam("isDevMode")
29+
local devMode = SpringShared.GetGameRulesParam("isDevMode")
3030
return (devMode and devMode > 0) and true or false
3131
end,
3232

3333
ShowDevUI = function()
34-
local devUI = Spring.GetConfigInt("DevUI", 0)
34+
local devUI = SpringUnsynced.GetConfigInt("DevUI", 0)
3535
return (devUI > 0) and true or false
3636
end,
3737

@@ -40,9 +40,9 @@ local utilities = {
4040
_devModeCache = nil,
4141
_devModeCacheFrame = -1,
4242
IsDevModeCached = function()
43-
local frame = Spring.GetGameFrame()
43+
local frame = SpringShared.GetGameFrame()
4444
if frame ~= utilities._devModeCacheFrame then
45-
local devMode = Spring.GetGameRulesParam("isDevMode")
45+
local devMode = SpringShared.GetGameRulesParam("isDevMode")
4646
utilities._devModeCache = (devMode and devMode > 0) and true or false
4747
utilities._devModeCacheFrame = frame
4848
end
@@ -59,7 +59,7 @@ local utilities = {
5959
if cached then
6060
return cached
6161
end
62-
local accountInfo = select(11, Spring.GetPlayerInfo(playerID))
62+
local accountInfo = select(11, SpringShared.GetPlayerInfo(playerID))
6363
local accountID = (accountInfo and accountInfo.accountid) and tonumber(accountInfo.accountid) or -1
6464
if accountID ~= -1 then
6565
accountIDCache[playerID] = accountID

common/springOverrides.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
if Spring.GetModOptions then
2-
local modOptions = Spring.GetModOptions()
1+
if SpringShared.GetModOptions then
2+
local modOptions = SpringShared.GetModOptions()
33
local modOptionsFile = VFS.Include("modoptions.lua")
44

55
for _, modOption in ipairs(modOptionsFile) do
@@ -31,19 +31,19 @@ if Spring.GetModOptions then
3131
end,
3232
})
3333

34-
Spring.GetModOptions = function()
34+
SpringShared.GetModOptions = function()
3535
return readOnlyModOptions
3636
end
3737

3838
-- Returns a copy of the modOptions table. Slower, but allows iterating over
3939
-- the returned table using pairs/ipairs.
40-
Spring.GetModOptionsCopy = function()
40+
GetModOptionsCopy = function()
4141
return table.copy(modOptions)
4242
end
4343
end
4444

45-
if Spring.Echo then
46-
local echo = Spring.Echo
45+
if SpringShared.Echo then
46+
local echo = SpringShared.Echo
4747
local printOptions = { pretty = true }
4848

4949
local function multiEcho(...)
@@ -71,5 +71,5 @@ if Spring.Echo then
7171
end
7272
end
7373

74-
Spring.Echo = multiEcho
74+
SpringShared.Echo = multiEcho
7575
end

common/springUtilities/debug.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
local function paramsEcho(...)
22
local called_from = "Called from: " .. tostring(debug.getinfo(2).name) .. " args:"
3-
Spring.Echo(called_from)
3+
SpringShared.Echo(called_from)
44
local args = { ... }
5-
Spring.Echo(table.toString(args))
5+
SpringShared.Echo(table.toString(args))
66
return ...
77
end
88

@@ -41,7 +41,7 @@ local function traceEcho(...)
4141
arguments = arguments .. sep .. ((name and tostring(name)) or "name?") .. "=" .. tostring(value)
4242
end
4343
end
44-
Spring.Echo(infostr .. functionstr .. " Args:(" .. arguments .. ")")
44+
SpringShared.Echo(infostr .. functionstr .. " Args:(" .. arguments .. ")")
4545
end
4646

4747
local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
@@ -52,7 +52,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
5252
-- It will also try to print the source file+line of each function
5353
if debug then
5454
else
55-
Spring.Echo("traceFullEcho needs debug to work, this seems to be missing or overwritten", debug)
55+
SpringShared.Echo("traceFullEcho needs debug to work, this seems to be missing or overwritten", debug)
5656
return
5757
end
5858
local tracedebug = false -- to debug itself
@@ -68,11 +68,11 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
6868
count = count + 1
6969
if count < maxtableelements then
7070
if tracedebug then
71-
Spring.Echo(count, k)
71+
SpringShared.Echo(count, k)
7272
end
7373
if type(k) == "number" and type(v) == "function" then -- try to get function lists?
7474
if tracedebug then
75-
Spring.Echo(k, v, debug.getinfo(v), debug.getinfo(v).name)
75+
SpringShared.Echo(k, v, debug.getinfo(v), debug.getinfo(v).name)
7676
end --debug.getinfo(v).short_src)?
7777
res = res .. tostring(k) .. ":" .. ((debug.getinfo(v) and debug.getinfo(v).name) or "<function>") .. ", "
7878
else
@@ -115,7 +115,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
115115
break
116116
end
117117
if tracedebug then
118-
Spring.Echo(i, j, funcName, name)
118+
SpringShared.Echo(i, j, funcName, name)
119119
end
120120
local sep = ((arguments == "") and "") or "; "
121121
if tostring(name) == "self" then
@@ -139,7 +139,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
139139
break
140140
end
141141
end
142-
Spring.Echo(infostr .. functionstr)
142+
SpringShared.Echo(infostr .. functionstr)
143143
end
144144

145145
return {

common/springUtilities/image_tga.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ local function loadTGA(fileName) -- returns texture | nil, error on failure
3434

3535
local data = string.sub(file, 19, texture.width * texture.height * texture.channels + 18)
3636
if string.len(data) ~= texture.width * texture.height * texture.channels then --WHY +1?????
37-
Spring.Echo("Failed to load", fileName, string.len(data), texture.width, texture.height, texture.channels)
37+
SpringShared.Echo("Failed to load", fileName, string.len(data), texture.width, texture.height, texture.channels)
3838
return nil, "Error loading file, size mismatch"
3939
end
4040

@@ -62,7 +62,7 @@ local function loadTGA(fileName) -- returns texture | nil, error on failure
6262
end
6363

6464
local function saveTGA(texture, fileName) --return nil | error on failure
65-
Spring.Echo("Saving", fileName)
65+
SpringShared.Echo("Saving", fileName)
6666

6767
local file = io.open(fileName, "wb")
6868
if file == nil then
@@ -85,7 +85,7 @@ local function saveTGA(texture, fileName) --return nil | error on failure
8585
end
8686
end
8787
file:close()
88-
Spring.Echo("Saved", fileName)
88+
SpringShared.Echo("Saved", fileName)
8989
return nil
9090
end
9191

common/springUtilities/synced.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- need this because SYNCED.tables are merely proxies, not real tables
22
local function makeRealTable(proxy, debugTag)
33
if proxy == nil then
4-
Spring.Log("Table Utilities", LOG.ERROR, "Proxy table is nil: " .. (debugTag or "unknown table"))
4+
SpringShared.Log("Table Utilities", LOG.ERROR, "Proxy table is nil: " .. (debugTag or "unknown table"))
55
return
66
end
77
local proxyLocal = proxy

common/springUtilities/tableFunctions.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local function customKeyToUsefulTable(dataRaw)
33
return
44
end
55
if not type(dataRaw) == "string" then
6-
Spring.Echo("Customkey data error! type == " .. type(dataRaw))
6+
SpringShared.Echo("Customkey data error! type == " .. type(dataRaw))
77
else
88
dataRaw = string.gsub(dataRaw, "_", "=")
99
dataRaw = string.base64Decode(dataRaw)
@@ -18,7 +18,7 @@ local function customKeyToUsefulTable(dataRaw)
1818
end
1919
end
2020
if err then
21-
Spring.Echo("Customkey error", err)
21+
SpringShared.Echo("Customkey error", err)
2222
end
2323
end
2424
if collectgarbage then

0 commit comments

Comments
 (0)