spaceship/tests/test_planet_setup_export_names.gd
Loïc Wisniewski df4d5e35f9 Find the planet setups in an exported build
The registry scanned res://PlanetSetups for names ending ".tres". An export
does not ship those: text resources are converted to binary and the pack
carries "<name>.tres.remap", which ResourceLoader follows when asked for the
original path. So the scan found nothing in the web build, every planet drew
no setup, and since #211 the setup IS the garrison - every world in the
deployed game was deserted, with nothing logged to say why. Confirmed by
reading index.pck, which holds rocky_default.tres.remap and no .tres.

The suite runs from source, where the bug cannot occur, so the name
resolution is its own function and tested against the exact strings the pack
contains.

Also: the planning centre listed transporters and repair drones but
set_vessel_target() still refused anything not fleet-eligible, so both rows
had buttons that did nothing - the worst shape a refusal can take. Listing
and setting read the same rule now, and a standing order is only offered to
a crafter that can actually take it.

And two quests close the chain: the tentacle world, which the scanner will
not offer until the story hands it over, and the Warden itself.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
2026-09-07 13:55:41 +02:00

67 lines
2.9 KiB
GDScript

extends SceneTree
# The setup registry has to find its maps in an EXPORTED build, not only when
# run from source.
#
# An export converts text resources to binary and ships "<name>.tres.remap"
# in place of "<name>.tres" - the remap points at the converted file and
# ResourceLoader follows it when asked for the original path. The scan matched
# on ".tres", so in the exported web build it found nothing: every planet drew
# no setup, and since #211 the setup IS the garrison, so every world was
# empty. Nothing was logged; the planets were simply deserted.
#
# The suite runs from source, where the bug cannot appear, so this tests the
# name resolution directly against what a pack actually contains.
#
# Covers:
# A. the names a source tree lists
# B. the names an exported pack lists - the case that was broken
# C. things that are not setups are still ignored
# D. and the shipped maps really are all found when run from source
const SETUPS = preload("res://surface/PlanetSetups.gd")
func _initialize() -> void:
# --- A. from source ------------------------------------------------
for name in ["rocky_default.tres", "gas_default.tres"]:
if SETUPS.setup_file_name(name) != name:
return _fail("'%s' is not recognised from a source tree" % name)
# --- B. from a pack ------------------------------------------------
# Exactly the entries found inside the built index.pck.
for name in ["rocky_default.tres.remap", "ResearchLabSetup.tres.remap",
"researtch_lab_garrison.tres.remap", "gas_default.tres.remap"]:
var resolved: String = SETUPS.setup_file_name(name)
if resolved != name.get_basename():
return _fail("exported entry '%s' resolved to '%s', expected '%s'" \
% [name, resolved, name.get_basename()])
# A binary resource shipped directly is a setup too.
if SETUPS.setup_file_name("rocky_default.res") != "rocky_default.res":
return _fail("a binary .res setup is not recognised")
print("both spellings resolve: rocky_default.tres and .tres.remap")
# --- C. and nothing else is dragged in -----------------------------
for name in ["rocky_default.tres.import", "notes.txt", "icon.png",
"rocky_default.png.remap", ""]:
if SETUPS.setup_file_name(name) != "":
return _fail("'%s' was taken for a setup" % name)
print("non-setup entries are ignored, remapped or not")
# --- D. the shipped maps are all found -----------------------------
# Guards the other half: a resolver that is right about names is no use
# if the scan around it stops finding the real files.
var found: Array = []
for setup in SETUPS.all():
found.append(String(setup.setup_id))
if found.size() < 4:
return _fail("the registry found %d shipped setups: %s" % [found.size(), found])
print("registry finds %d shipped setups: %s" % [found.size(), found])
print("TEST_PLANET_SETUP_EXPORT_NAMES: PASS")
quit(0)
func _fail(message: String) -> void:
print("TEST_PLANET_SETUP_EXPORT_NAMES: FAIL (%s)" % message)
quit(1)