Skip to content

Commit

Permalink
Merge branch 'beyond-all-reason:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSilverHornet authored Mar 26, 2024
2 parents 0a08615 + f40a24f commit 35c3c7a
Show file tree
Hide file tree
Showing 68 changed files with 749 additions and 412 deletions.
1 change: 1 addition & 0 deletions .github/workflows/quick_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
if: github.repository == 'beyond-all-reason/Beyond-All-Reason'
permissions:
id-token: write
steps:
Expand Down
60 changes: 2 additions & 58 deletions common/numberfunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,6 @@ if not math.cross_product then
end
end

local abs = math.abs
local strFormat = string.format

if not ToSI then
function ToSI(num, displaySign)
if type(num) ~= 'number' then
num = tonumber(num)
end
if num == 0 then
return "0"
else
local absNum = abs(num)
if absNum < 0.001 then
return displaySign and strFormat("%+.1fu", 1000000 * num) or strFormat("%.1fu", 1000000 * num)
elseif absNum < 1 then
return displaySign and strFormat("%+.1f", num) or strFormat("%.1f", num)
elseif absNum < 1000 then
return displaySign and strFormat("%+.0f", num) or strFormat("%.0f", num)
elseif absNum < 1000000 then
return displaySign and strFormat("%+.1fk", 0.001 * num) or strFormat("%.1fk", 0.001 * num)
else
return displaySign and strFormat("%+.1fM", 0.000001 * num) or strFormat("%.1fM", 0.000001 * num)
end
end
end
end

if not ToSIPrec then
function ToSIPrec(num)
-- more precise
if type(num) ~= 'number' then
num = tonumber(num)
end

if num == 0 then
return "0"
else
local absNum = abs(num)
if absNum < 0.001 then
return strFormat("%.2fu", 1000000 * num)
elseif absNum < 1 then
return strFormat("%.2f", num)
elseif absNum < 10 then
return strFormat("%.2f", num)

elseif absNum < 1000 then
return strFormat("%.0f", num)
elseif absNum < 1000000 then
return strFormat("%.1fk", 0.001 * num)
else
return strFormat("%.1fM", 0.000001 * num)
end
end
end
end

if not math.triangulate then
-- accepts an array of polygons (where a polygon is an array of {x, z} vertices), and returns an array of counterclockwise triangles
function math.triangulate(polies)
Expand Down Expand Up @@ -228,7 +172,7 @@ if not math.HSLtoRGB then
end
end

if not math.distance3d then
if not math.distance3dSquared then
function math.distance3dSquared(x1, y1, z1, x2, y2, z2)
local x = x1 - x2
local y = y1 - y2
Expand All @@ -237,7 +181,7 @@ if not math.HSLtoRGB then
end
end

if not math.distance3dSquared then
if not math.distance3d then
function math.distance3d(x1, y1, z1, x2, y2, z2)
return math.diag(x1 - x2, y1 - y2, z1 - z2)
end
Expand Down
85 changes: 81 additions & 4 deletions common/stringFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ if not string.lines then
end

-- Returns python style tuple string.partition()
if not string.partition then
if not string.partition then
function string:partition(sep)
local seppos = self:find(sep, nil, true)
if seppos == nil then
return self, nil, nil
if seppos == nil then
return self, nil, nil
else
if seppos == 1 then
if seppos == 1 then
return nil, sep, self:sub(sep:len()+1)
else
return self:sub(1, seppos -1), sep, self:sub(seppos + sep:len())
Expand Down Expand Up @@ -78,4 +78,81 @@ end
-- print(string.partition("blaksjdfsaldkj","ldkj"))
-- print(string.partition("blaksjdfsaldkj","aks"))

if not string.formatSI then
local mathFloor = math.floor
local mathLog10 = math.log10
local mathPow = math.pow
local stringFormat = string.format

local SI_PREFIXES_LOG1K = {
[10] = "Q",
[9] = "R",
[8] = "Y",
[7] = "Z",
[6] = "E",
[5] = "P",
[4] = "T",
[3] = "G",
[2] = "M",
[1] = "k",
[0] = "",
[-1] = "m",
[-2] = "u",
[-3] = "n",
[-4] = "p",
[-5] = "f",
[-6] = "a",
[-7] = "z",
[-8] = "y",
[-9] = "r",
[-10] = "q",
}

local DIVIDE_LOG1K = {}
for i = -10, 10 do
DIVIDE_LOG1K[i] = 1 / mathPow(1000, i)
end

--- Formats a number with an SI prefix, and at most 3 significant figures
---@param number number
---@param options table Optional parameters for formatting
---@param options.leaveTrailingZeros boolean Whether to leave any trailing zeros (default: false)
---@param options.showSign boolean Whether to show a "+" for positive numbers (default: false)
---@return string
function string.formatSI(number, options)
if number == nil then
return nil
end

if number == 0 then
return "0"
end

local sign = 1
if number < 0 then
number = number * -1
sign = -1
end

local numberLog10 = mathLog10(number)
local numberLog1k = mathFloor(numberLog10 / 3 + 1e-4)
local siPrefix = SI_PREFIXES_LOG1K[numberLog1k]
if siPrefix == nil then
return nil
end

local precision = 2 - mathFloor(numberLog10 - 3 * numberLog1k)

local str = stringFormat("%." .. precision .. "f", sign * number * DIVIDE_LOG1K[numberLog1k])

if precision > 0 and not (options and options.leaveTrailingZeros) then
str = str:gsub("%.?0+$", "")
end

if sign == 1 and options and options.showSign then
str = "+" .. str
end

return str .. siPrefix
end
end
2 changes: 1 addition & 1 deletion features/raptor_egg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ for _, size in pairs(sizes) do
def.customparams = {
model_author = "KDR11k, Beherith",
normalmaps = "yes",
normaltex = "unittextures/raptor_s_normals.png",
normaltex = "unittextures/chicken_s_normals.png",
treeshader = "yes",
i18nfrom = 'raptor_egg'
}
Expand Down
2 changes: 1 addition & 1 deletion gamedata/alldefs_post.lua
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function UnitDef_Post(name, uDef)
local numBuildoptions = #uDef.buildoptions
uDef.buildoptions[numBuildoptions+1] = "corapt3"
uDef.buildoptions[numBuildoptions+2] = "legministarfall"
uDef.buildoptions[numBuildoptions+3] = "corwint2"
uDef.buildoptions[numBuildoptions+3] = "corwint2" --Rename to "legwint2" once energy production issue is solved on legwint2. (See "legwint2.lua" "energymultiplier" parameter)
uDef.buildoptions[numBuildoptions+4] = "corhllllt"
uDef.buildoptions[numBuildoptions+6] = "cordoomt3"
uDef.buildoptions[numBuildoptions+7] = "cornanotct2"
Expand Down
4 changes: 4 additions & 0 deletions gamedata/icontypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,10 @@ local icontypes = {
bitmap = "icons/wind.png",
size = 1.04999995
},
legwint2 = {
bitmap = "icons/wind.png",
size = 1.67999995
},
lootboxbronze = {
bitmap = "icons/lootbox.png",
size = 1.04999995
Expand Down
6 changes: 3 additions & 3 deletions language/de/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@
"Low traj": "Direktes Feuer",
"High traj": "Indirektes Feuer",
"trajectory_tooltip": "Setzt den Feuermodus im Artilleriezustand (Flache/Steile Flugbahn)",
"hound_weapon_plasma": "Schwere Plasmakanonea",
"hound_weapon_gauss": "Gauß-Kanone",
"hound_weapon_toggle_tooltip": "Wechselt zwischen Gauss-Kanone und schwerer Plasmakanone",

"customOnOff": {
"lowTrajectory": "Direktes Feuer",
"highTrajectory": "Indirektes Feuer",
"trajectory_tooltip": "Schaltet den Artillerie-Abschusswinkel zwischen flacher und steiler Flugbahn um",
"gaussCannon": "Gauß-Kanone",
"heavyPlasma": "Schwere Plasmakanone",
"gauss_tooltip": "Wechselt zwischen Gauss-Kanone und schwerer Plasmakanone"
}
},
"idleBuilders": {
Expand Down
6 changes: 3 additions & 3 deletions language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,17 @@
"Low traj": "High Traj",
"High traj": "High Traj",
"trajectory_tooltip": "Sets fire mode in artillery state (firing upwards instead of forwards)",
"hound_weapon_plasma": "Heavy Plasma",
"hound_weapon_gauss": "Gauss Cannon",
"hound_weapon_toggle_tooltip": "Sets weapon to a slow plasma projectile with a large aoe, or a fast projectile gauss weapon",

"customOnOff": {
"lowTrajectory": "Low Trajectory",
"highTrajectory": "High Trajectory",
"trajectory_tooltip": "Switch artillery firing angle between low and high trajectory",
"gaussCannon": "Gauss Cannon",
"heavyPlasma": "Heavy Plasma",
"siegeMode": "Spread Fire",
"suppressiveFire": "Focused Fire",
"siege_tooltip": "Switches between Focused Fire and longer ranged Spread Fire",
"gauss_tooltip": "Switches between Gauss Cannon and Heavy Plasma Cannon"
}
},
"idleBuilders": {
Expand Down
46 changes: 24 additions & 22 deletions language/en/units.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
"armdl": "Anemone",
"armdrag": "Dragon's Teeth",
"armdrone": "Attack Drone",
"armdronecarry": "Drone Carrier",
"armdronecarryland": "Crawling Drone Carrier",
"armdronecarry": "Nexus",
"armdronecarryland": "Nexus Terra",
"armdroneold": "Attack Drone",
"armemp": "Paralyzer",
"armepoch": "Epoch",
Expand Down Expand Up @@ -140,7 +140,7 @@
"armliche": "Liche",
"armlichet4": "Epic Liche",
"armllt": "Sentry",
"armlship": "Lightning Ship",
"armlship": "Maelstrom",
"armlun": "Lunkhead",
"armlunchbox": "Lunchbox",
"armmakr": "Energy Converter",
Expand Down Expand Up @@ -418,8 +418,8 @@
"cordoomt3": "Epic Bulwark",
"cordrag": "Dragon's Teeth",
"cordrone": "Attack Drone",
"cordronecarry": "Drone Carrier",
"cordronecarryair": "Flying Drone Carrier",
"cordronecarry": "Disperser",
"cordronecarryair": "Disperser Omni",
"cordroneold": "Attack Drone",
"cords": "Disgruntler",
"corenaa": "Naval Birdshot",
Expand Down Expand Up @@ -449,7 +449,7 @@
"corfrad": "Naval Radar / Sonar Tower",
"corfrock": "Janitor",
"corfrt": "Slingshot",
"corfship": "Flamethrower Ship",
"corfship": "Brimstone",
"corftiger": "Heat Tiger",
"corfus": "Fusion Reactor",
"corgant": "Experimental Gantry",
Expand Down Expand Up @@ -626,7 +626,7 @@
"legbart": "Belcher",
"legbastion": "Bastion",
"legca": "Legion Construction Aircraft",
"legcib": "Counterintelligence Bomber",
"legcib": "Blindfold",
"legck": "Legion Construction Bot",
"legcv": "Legion Construction Vehicle",
"legcen": "Centaur",
Expand All @@ -643,24 +643,24 @@
"legdrag": "Dragon's Teeth",
"legdtf": "Dragon's Maw",
"legdtl": "Dragon's Claw",
"legdtm": "Missile Wall",
"legdtm": "Dragon's Tail",
"legforti": "Fortification Wall",
"legdefcarryt1": "Drone Defense",
"legdefcarryt1": "Hive",
"legdrone": "Light Combat Drone",
"legfig": "Fighter / Scout Drone",
"legfig": "Noctua",
"legflak": "Ravager",
"legfloat": "Triton",
"legfort": "Legion Flying Fortress",
"legfort": "Tyrannus",
"leggant": "Experimental Gantry",
"leggat": "Gatling",
"leggat": "Decurion",
"leggob": "Goblin",
"leghades": "Hades",
"leghades": "Alaris",
"leghelios": "Helios",
"leginc": "Incinerator",
"leginf": "Inferno",
"leginfestor": "Infestor",
"legionnaire": "Legionnaire",
"legkam": "Kamikaze Drone",
"legkam": "Martyr",
"legkark": "Karkinos",
"legkeres": "Keres",
"leglab": "Legion Bot Lab",
Expand All @@ -670,27 +670,28 @@
"legmext15": "Overcharged Metal Extractor",
"legmext2": "Advanced Metal Extractor",
"legmg": "Cacophony",
"legmineb": "Minelayer Bomber",
"legmineb": "Harbinger",
"legministarfall": "Mini Starfall",
"legmos": "Mosquito",
"legmrv": "Quickshot",
"legnap": "Napalm Bomber",
"legnap": "Wildfire",
"legpede": "Mukade",
"legphoenix": "Phoenix",
"legrail": "Railgun",
"legrail": "Lance",
"legsolar": "Solar Collector",
"legsco": "Scorpion Tank",
"legshot": "Shotgun",
"legsrail": "Railgun Spider",
"legsco": "Gladiator",
"legshot": "Phalanx",
"legsrail": "Arquebus",
"legstr": "Strider",
"legstronghold": "Stronghold",
"legstarfall": "Starfall",
"legvcarry": "Light Drone Carrier",
"legvcarry": "Mantis",
"legvenator": "Venator",
"legvision": "Vision",
"legvp": "Legion Vehicle Lab",
"legwhisper": "Whisper",
"legwin": "Wind Turbine",
"legwint2": "Tech 2 Wind Turbine",
"lootboxbronze": "Bronze Resource Generator",
"lootboxgold": "Gold Resource Generator",
"lootboxnano_t1": "Bronze Unit Printer",
Expand Down Expand Up @@ -1384,7 +1385,7 @@
"legdrone": "Light Combat Drone",
"legfig": "Fighter / Scout Drone",
"legfloat": "Heavy Convertible Tank/Boat",
"legflak": "Antiair Gatling Gun",
"legflak": "Anti-Air Gatling Gun",
"legfort": "Flying Fortress",
"leggant": "Produces Experimental Units",
"leggat": "Armored Assault Tank",
Expand Down Expand Up @@ -1426,6 +1427,7 @@
"legvp": "Vehicle Lab",
"legwhisper": "Radar / Sonar Plane",
"legwin": "Produces Energy. Depends on wind strength.",
"legwint2": "Produces Energy. Depends on wind strength.",
"lootboxbronze": "Capture & Transport",
"lootboxgold": "Capture & Transport",
"lootboxnano_t1": "Portable Factory. Capture & Transport",
Expand Down
Loading

0 comments on commit 35c3c7a

Please sign in to comment.