Restore the crafter binding lost in an over-wide edit
This is the actual cause of "the build a ship menu buttons do nothing", reported four times. Opening the crafter panel stopped recording WHICH crafter: when the auto-unload was replaced with an explicit store button, the replaced block reached one line further up than intended and took `craft_building_id = current_building.building_id` with it. Every handler in the panel then bailed out at its `if craft_building_id == 0` guard, while the panel itself still opened and Close still worked - because Close is the only button that does not need the binding. The silent `return` on that guard is what let it pass unnoticed, so it now says so instead. The test was complicit: it set craft_building_id by hand, which skipped the exact step that was broken. It now parks the fleet on the crafter, waits for the action button to debounce in, and presses it - the way the game does. Verified against the broken code: it fails with "opening the panel did not record which crafter". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
7a8f521941
commit
fe1c721d64
2 changed files with 52 additions and 4 deletions
|
|
@ -297,6 +297,12 @@ func _on_action_pressed() -> void:
|
|||
_refresh_load_ore()
|
||||
_refresh_skill_menu()
|
||||
elif current_building.building_type == GameState.BUILDING_SHIP_CRAFTER:
|
||||
# Remembered explicitly: _process() clears current_building while any
|
||||
# menu is open, so by the next frame the panel would no longer know
|
||||
# which crafter it belongs to. Losing this line makes every button in
|
||||
# the panel bail out at its `== 0` guard while the panel itself still
|
||||
# opens - which reads as "the buttons do nothing".
|
||||
craft_building_id = current_building.building_id
|
||||
craft_menu.visible = true
|
||||
_refresh_craft_status()
|
||||
elif current_building.building_type == GameState.BUILDING_SHIP_LAB:
|
||||
|
|
@ -640,6 +646,7 @@ func _refresh_craft_status() -> void:
|
|||
|
||||
func _on_craft_interceptor() -> void:
|
||||
if craft_building_id == 0:
|
||||
_say("No crafter selected - reopen this panel from the building")
|
||||
return
|
||||
# Still refused when there is nowhere to put the vessel - queueing an
|
||||
# order that can never be delivered would just bank vessels_owed forever.
|
||||
|
|
@ -679,6 +686,7 @@ func _report_order(product: String) -> void:
|
|||
|
||||
func _on_store_ore() -> void:
|
||||
if craft_building_id == 0:
|
||||
_say("No crafter selected - reopen this panel from the building")
|
||||
return
|
||||
if GameState.fleet_cargo <= 0:
|
||||
_say("The fleet is carrying nothing - load ore at the mothership first")
|
||||
|
|
@ -689,6 +697,7 @@ func _on_store_ore() -> void:
|
|||
|
||||
func _on_craft_transporter() -> void:
|
||||
if craft_building_id == 0:
|
||||
_say("No crafter selected - reopen this panel from the building")
|
||||
return
|
||||
if not GameState.queue_order(craft_building_id, GameState.PRODUCT_TRANSPORTER):
|
||||
# Two different refusals, and the player needs to know WHICH.
|
||||
|
|
@ -801,6 +810,7 @@ func _refresh_lab() -> void:
|
|||
|
||||
func _on_craft_shield() -> void:
|
||||
if craft_building_id == 0:
|
||||
_say("No crafter selected - reopen this panel from the building")
|
||||
return
|
||||
if not GameState.shield_vessel_unlocked():
|
||||
_say("Shield vessels must be unlocked at a ship lab first")
|
||||
|
|
|
|||
Loading…
Reference in a new issue