Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions common/configs/unit_restrictions_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local function shouldShowWaterUnits()
return false
end

local debugCommands = Spring.GetModOption("debugcommands")
local debugCommands = SpringShared.GetModOption("debugcommands")

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

local _, _, mapMinWater, _ = Spring.GetGroundExtremes()
local _, _, mapMinWater, _ = SpringShared.GetGroundExtremes()

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

return mapMinWater <= -11 -- units.minWaterUnitDepth
Expand All @@ -67,11 +67,11 @@ local function hasGeothermalFeatures()
geoFeatureDefs[defID] = true
end
end
local features = Spring.GetAllFeatures()
local features = SpringShared.GetAllFeatures()
for i = 1, #features do
local featureID = features[i]
if geoFeatureDefs[Spring.GetFeatureDefID(featureID)] then
local _, y, _ = Spring.GetFeaturePosition(featureID)
if geoFeatureDefs[SpringShared.GetFeatureDefID(featureID)] then
local _, y, _ = SpringShared.GetFeaturePosition(featureID)
if y < 0 then
hasSeaGeo = true
else
Expand Down
6 changes: 3 additions & 3 deletions common/holidays.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
if not Spring.GetModOptions then
if not SpringShared.GetModOptions then
return
end

if not Spring.GetModOptions().holiday_events then
if not SpringShared.GetModOptions().holiday_events then
return
end

local modOptions = Spring.GetModOptions()
local modOptions = SpringShared.GetModOptions()
local currentDay = modOptions.date_day
local currentMonth = modOptions.date_month
local currentYear = modOptions.date_year
Expand Down
6 changes: 3 additions & 3 deletions common/lib_startpoint_guesser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local mathSqrt = math.sqrt
local mathFloor = math.floor
local mathMax = math.max
local mathClamp = math.clamp
local spGetGroundHeight = Spring.GetGroundHeight
local spGetGroundHeight = SpringShared.GetGroundHeight

local mtta = mathAcos(1.0 - 0.41221) - 0.02 --http://springrts.com/wiki/Movedefs.lua#How_slope_is_determined & the -0.02 is for safety

Expand Down Expand Up @@ -214,7 +214,7 @@ end

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

Expand Down Expand Up @@ -261,7 +261,7 @@ function GuessTwo(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable) --TOD
end

-- if it is, add this metal into points
local m = Spring.GetMetalAmount(x, z)
local m = SpringShared.GetMetalAmount(x, z)
if isFree and m > 0.1 then
local y = spGetGroundHeight(x * 16, z * 16)
for _, p in ipairs(points) do
Expand Down
10 changes: 5 additions & 5 deletions common/springFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ local utilities = {
GetRaptorAllyTeamID = team.GetRaptorAllyTeamID,

IsDevMode = function()
local devMode = Spring.GetGameRulesParam("isDevMode")
local devMode = SpringShared.GetGameRulesParam("isDevMode")
return (devMode and devMode > 0) and true or false
end,

ShowDevUI = function()
local devUI = Spring.GetConfigInt("DevUI", 0)
local devUI = SpringUnsynced.GetConfigInt("DevUI", 0)
return (devUI > 0) and true or false
end,

Expand All @@ -40,9 +40,9 @@ local utilities = {
_devModeCache = nil,
_devModeCacheFrame = -1,
IsDevModeCached = function()
local frame = Spring.GetGameFrame()
local frame = SpringShared.GetGameFrame()
if frame ~= utilities._devModeCacheFrame then
local devMode = Spring.GetGameRulesParam("isDevMode")
local devMode = SpringShared.GetGameRulesParam("isDevMode")
utilities._devModeCache = (devMode and devMode > 0) and true or false
utilities._devModeCacheFrame = frame
end
Expand All @@ -60,7 +60,7 @@ local utilities = {
if cached then
return cached
end
local accountInfo = select(11, Spring.GetPlayerInfo(playerID))
local accountInfo = select(11, SpringShared.GetPlayerInfo(playerID))
local accountID = (accountInfo and accountInfo.accountid) and tonumber(accountInfo.accountid) or -1
if accountID ~= -1 then
accountIDCache[playerID] = accountID
Expand Down
12 changes: 6 additions & 6 deletions common/springOverrides.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if Spring.GetModOptions then
local modOptions = Spring.GetModOptions()
if SpringShared.GetModOptions then
local modOptions = SpringShared.GetModOptions()
local modOptionsFile = VFS.Include("modoptions.lua")

for _, modOption in ipairs(modOptionsFile) do
Expand Down Expand Up @@ -31,7 +31,7 @@ if Spring.GetModOptions then
end,
})

Spring.GetModOptions = function()
SpringShared.GetModOptions = function()
return readOnlyModOptions
end

Expand All @@ -42,8 +42,8 @@ if Spring.GetModOptions then
end
end

if Spring.Echo then
local echo = Spring.Echo
if SpringShared.Echo then
local echo = SpringShared.Echo
local printOptions = { pretty = true }

local function multiEcho(...)
Expand Down Expand Up @@ -81,5 +81,5 @@ if Spring.Echo then
end
end

Spring.Echo = multiEcho
SpringShared.Echo = multiEcho
end
16 changes: 8 additions & 8 deletions common/springUtilities/debug.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local function paramsEcho(...)
local called_from = "Called from: " .. tostring(debug.getinfo(2).name) .. " args:"
Spring.Echo(called_from)
SpringShared.Echo(called_from)
local args = { ... }
Spring.Echo(table.toString(args))
SpringShared.Echo(table.toString(args))
return ...
end

Expand Down Expand Up @@ -45,7 +45,7 @@ local function traceEcho(...)
arguments = arguments .. sep .. ((name and tostring(name)) or "name?") .. "=" .. tostring(value)
end
end
Spring.Echo(infostr .. functionstr .. " Args:(" .. arguments .. ")")
SpringShared.Echo(infostr .. functionstr .. " Args:(" .. arguments .. ")")
end

local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
Expand All @@ -56,7 +56,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
-- It will also try to print the source file+line of each function
if debug then
else
Spring.Echo("traceFullEcho needs debug to work, this seems to be missing or overwritten", debug)
SpringShared.Echo("traceFullEcho needs debug to work, this seems to be missing or overwritten", debug)
return
end
local tracedebug = false -- to debug itself
Expand All @@ -72,12 +72,12 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
count = count + 1
if count < maxtableelements then
if tracedebug then
Spring.Echo(count, k)
SpringShared.Echo(count, k)
end
if type(k) == "number" and type(v) == "function" then -- try to get function lists?
local vinfo = debug.getinfo(v)
if tracedebug then
Spring.Echo(k, v, vinfo, vinfo.name)
SpringShared.Echo(k, v, vinfo, vinfo.name)
end --debug.getinfo(v).short_src)?
res = res .. tostring(k) .. ":" .. ((vinfo and vinfo.name) or "<function>") .. ", "
else
Expand Down Expand Up @@ -120,7 +120,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
break
end
if tracedebug then
Spring.Echo(i, j, funcName, name)
SpringShared.Echo(i, j, funcName, name)
end
local sep = ((arguments == "") and "") or "; "
if tostring(name) == "self" then
Expand All @@ -144,7 +144,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...)
break
end
end
Spring.Echo(infostr .. functionstr)
SpringShared.Echo(infostr .. functionstr)
end

return {
Expand Down
6 changes: 3 additions & 3 deletions common/springUtilities/image_tga.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local function loadTGA(fileName) -- returns texture | nil, error on failure

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

Expand Down Expand Up @@ -64,7 +64,7 @@ local function loadTGA(fileName) -- returns texture | nil, error on failure
end

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

local file = io.open(fileName, "wb")
if file == nil then
Expand All @@ -87,7 +87,7 @@ local function saveTGA(texture, fileName) --return nil | error on failure
end
end
file:close()
Spring.Echo("Saved", fileName)
SpringShared.Echo("Saved", fileName)
return nil
end

Expand Down
2 changes: 1 addition & 1 deletion common/springUtilities/synced.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- need this because SYNCED.tables are merely proxies, not real tables
local function makeRealTable(proxy, debugTag)
if proxy == nil then
Spring.Log("Table Utilities", LOG.ERROR, "Proxy table is nil: " .. (debugTag or "unknown table"))
SpringShared.Log("Table Utilities", LOG.ERROR, "Proxy table is nil: " .. (debugTag or "unknown table"))
return
end
local proxyLocal = proxy
Expand Down
4 changes: 2 additions & 2 deletions common/springUtilities/tableFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local function customKeyToUsefulTable(dataRaw)
return
end
if not type(dataRaw) == "string" then
Spring.Echo("Customkey data error! type == " .. type(dataRaw))
SpringShared.Echo("Customkey data error! type == " .. type(dataRaw))
else
dataRaw = string.gsub(dataRaw, "_", "=")
dataRaw = string.base64Decode(dataRaw)
Expand All @@ -15,7 +15,7 @@ local function customKeyToUsefulTable(dataRaw)
end
end
if err then
Spring.Echo("Customkey error", err)
SpringShared.Echo("Customkey error", err)
end
end
end
Expand Down
22 changes: 11 additions & 11 deletions common/springUtilities/teamFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ local function getSettings()
local scavTeamID, scavAllyTeamID, raptorTeamID, raptorAllyTeamID
local isHoliday = {}

local gaiaAllyTeamID = select(6, Spring.GetTeamInfo(Spring.GetGaiaTeamID(), false))
local springAllyTeamList = Spring.GetAllyTeamList()
local gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(SpringShared.GetGaiaTeamID(), false))
local springAllyTeamList = SpringShared.GetAllyTeamList()
local allyTeamList = {}
local allyTeamSizes = {}
local entirelyHumanAllyTeams = {}

for _, allyTeamID in ipairs(springAllyTeamList) do
local teamList = Spring.GetTeamList(allyTeamID) or {}
local teamList = SpringShared.GetTeamList(allyTeamID) or {}
local allyteamEntirelyHuman = true

if #teamList > 0 and allyTeamID ~= gaiaAllyTeamID then
local isAllyTeamValid = true

for _, teamID in ipairs(teamList) do
if select(4, Spring.GetTeamInfo(teamID, false)) then
if select(4, SpringShared.GetTeamInfo(teamID, false)) then
allyteamEntirelyHuman = false
else
local teamPlayers = Spring.GetPlayerList(teamID)
local teamPlayers = SpringShared.GetPlayerList(teamID)
for _, playerID in ipairs(teamPlayers) do
playerCount = playerCount + 1
end
end

local luaAI = Spring.GetTeamLuaAI(teamID)
local luaAI = SpringShared.GetTeamLuaAI(teamID)

if luaAI then
if luaAI:find("Raptors") then
Expand Down Expand Up @@ -89,14 +89,14 @@ local function getSettings()
is1v1 = true
end

if #entirelyHumanAllyTeams == 1 and #Spring.GetTeamList(entirelyHumanAllyTeams[1]) > 1 then
if #entirelyHumanAllyTeams == 1 and #SpringShared.GetTeamList(entirelyHumanAllyTeams[1]) > 1 then
isCoop = true
end

if holidaysList and Spring.GetModOptions and Spring.GetModOptions().date_day then
local currentDay = Spring.GetModOptions().date_day
local currentMonth = Spring.GetModOptions().date_month
local currentYear = Spring.GetModOptions().date_year
if holidaysList and SpringShared.GetModOptions and SpringShared.GetModOptions().date_day then
local currentDay = SpringShared.GetModOptions().date_day
local currentMonth = SpringShared.GetModOptions().date_month
local currentYear = SpringShared.GetModOptions().date_year

-- FIXME: This doesn't support events that start and end in different years.
for holiday, dates in pairs(holidaysList) do
Expand Down
Loading
Loading