Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions luarules/gadgets/game_quick_start.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ local shouldRunGadget = modOptions and modOptions.quick_start and (
)
if not shouldRunGadget then return false end

local overrideQuickStartResources = modOptions.override_quick_start_resources or 0

local shouldApplyFactoryDiscount = modOptions.quick_start == "factory_discount" or
modOptions.quick_start == "factory_discount_only" or
(modOptions.quick_start == "default" and (modOptions.temp_enable_territorial_domination or modOptions.deathmode == "territorial_domination"))
Expand Down Expand Up @@ -545,7 +547,7 @@ local function initializeCommander(commanderID, teamID)

local currentMetal = Spring.GetTeamResources(teamID, "metal") or 0
local currentEnergy = Spring.GetTeamResources(teamID, "energy") or 0
local budget = (modOptions.override_quick_start_resources and modOptions.override_quick_start_resources > 0) and modOptions.override_quick_start_resources or quickStartAmountConfig[modOptions.quick_start_amount == "default" and "normal" or modOptions.quick_start_amount]
local budget = (overrideQuickStartResources > 0) and overrideQuickStartResources or quickStartAmountConfig[modOptions.quick_start_amount == "default" and "normal" or modOptions.quick_start_amount]

local commanderX, commanderY, commanderZ = spGetUnitPosition(commanderID)
if not commanderX or not commanderY or not commanderZ then
Expand Down Expand Up @@ -904,7 +906,7 @@ function gadget:Initialize()
local quickStartAmount = modOptions.quick_start_amount or "normal"
local immediateBudget = quickStartAmountConfig[quickStartAmount] or quickStartAmountConfig.normal

local finalBudget = modOptions.override_quick_start_resources > 0 and modOptions.override_quick_start_resources or immediateBudget
local finalBudget = overrideQuickStartResources > 0 and overrideQuickStartResources or immediateBudget
Spring.SetGameRulesParam("quickStartBudgetBase", finalBudget)
Spring.SetGameRulesParam("quickStartFactoryDiscountAmount", FACTORY_DISCOUNT)
local cheapestEconomicCost = calculateCheapestEconomicStructure()
Expand All @@ -923,4 +925,4 @@ function gadget:Initialize()
end
end
end
end
end
35 changes: 35 additions & 0 deletions luaui/Tests/quick_start_resources.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
local quickStartAmountConfig = {
small = 800,
normal = 1200,
large = 2400,
}

function skip()
local modOptions = Spring.GetModOptions() or {}
return modOptions.quick_start ~= "enabled"
end

function test()
local modOptions = Spring.GetModOptions() or {}
local override = tonumber(modOptions.override_quick_start_resources) or 0
local amount = modOptions.quick_start_amount
if amount == nil or amount == "default" then
amount = "normal"
end

local expectedBudget = override > 0 and override or quickStartAmountConfig[amount]
assert(expectedBudget ~= nil, "Unexpected quick_start_amount value: " .. tostring(amount))

local budgetParam = Spring.GetGameRulesParam("quickStartBudgetBase")

assert(
budgetParam == expectedBudget,
string.format(
"quickStartBudgetBase mismatch: got %s, expected %s (override=%s amount=%s)",
tostring(budgetParam),
tostring(expectedBudget),
tostring(override),
tostring(amount)
)
)
end
2 changes: 1 addition & 1 deletion modoptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ local options = {
desc = "Override the quick start starting resources. Set to 0 to use default behavior.",
type = "number",
def = 0,
min = 100,
min = 0,
max = 10000,
step = 1,
section = "options_extra",
Expand Down
10 changes: 9 additions & 1 deletion tools/headless_testing/download-engine.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/bin/bash
set -euo pipefail

mkdir -p "$ENGINE_DESTINATION"

TEMP_FILE=$(mktemp --suffix=.7z)
cleanup() { rm -f "$TEMP_FILE"; }
trap cleanup EXIT

curl -L "$ENGINE_URL" -o "$TEMP_FILE" && 7z x "$TEMP_FILE" -o"$ENGINE_DESTINATION" && rm -f temp.7z
# Retry download a few times and fail fast on HTTP errors (GitHub can occasionally serve HTML error pages).
curl -fL --retry 5 --retry-delay 2 --retry-all-errors "$ENGINE_URL" -o "$TEMP_FILE"

# Validate the archive before extracting so we don't proceed with a bad download.
7z t "$TEMP_FILE" >/dev/null
7z x "$TEMP_FILE" -o"$ENGINE_DESTINATION"
Loading