General code cleanup (#125) #127
No reviewers
Labels
No labels
assets
bug
duplicate
enhancement
help wanted
invalid
question
testing
ui
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
liamjd/UntitledColonyBuilder!127
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "125-general-code-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #125
A general cleanup following the review after #72: dead code removed, small duplications tidied, one hot-path lookup made constant-time, and eight throwaway tools deleted. No behaviour changes. The bugs found in the same review are #124, and are deliberately left alone here, including the
Pawns.taskssetter that never disconnects the old manager.Removed (nothing called these)
GameState:set_debug_mode(), which would also have emitteddebug_mode_changedtwice;contract_start_date, which was assigned but never read; andrun_day().BuildingPanel's ownbuilding_type_selectedsignal. The panel emits GameState's signal of the same name.Building.to_debug_string(), and the UTF-8 BOM at the top ofbuilding.gd.BuildingFootprint._print_cells().Task.required_role,remove_subtask()anddump(). #74 will bring roles back properly, not as a string.TerrainGrid: thewalkablecount and the print that was commented out, so_build_navigation()now returns nothing; and the unusedthresholdlocal inis_sloped().Tidied
Pawn.NO_DESTINATIONreplaces six copies ofVector3(-1, -1, -1).Pawns:task_completed,task_cancelledandtask_releasednow connect directly to a single_release_pawn_from_task(task), replacing three identical handlers. Also removed a doc line that appeared twice, a staleTODO(#75), and a redundantERR_SKIPbranch.PlacementController: the five invalid placement reasons share onematcharm.Buildings: dropped a line that was commented out, and the!= nullchecks in front ofis, which is already false on null.DebugLayer: the text for each pawn and task label is built by one helper each. The task list now looks up each label once instead of twice.Optimised
TerrainGrid.is_in_main_region()did a linearArray.has()over the landmass, up to about 4,000 cells.Task.can_start()calls it for every task, for every idle pawn, on every tick. It now reads_main_region_set, aDictionary._set_main_region()is the only function that writes either the set or the array, so the two can't drift apart. The array stays, becauserandom_walkable_position()indexes into it.Pawns._check_path_collision()now works out the building's cells once, not once per waypoint.Tools
Deleted eight of the scripts marked "THROWAWAY … Delete after use", all for closed issues:
probe_menu_rects,probe_screen,probe_menu_clickthrough,probe_demolish_click,screenshot_buildings,screenshot_building_blocks_path,screenshot_path_overlay,screenshot_window_resize.CLAUDE.md referred readers to
screenshot_path_overlay.gdfor why-sscripts must not name project types. That pointer, and the ones in the two tools that stay, now namescreenshot_building_states.gd, which already carries the full explanation.Decisions
is_sloped()andneighbouring_cells()are kept, even though only tests call them. They have 7 tests of their own, andtest_placement_rules.gdrefers tois_sloped()by name to explain why placement uses a different rule. Deleting them would mean rewriting that reasoning for very little gain.tools/screenshot_entrance_arrow.gdis kept so the arrow fix in #124 can be checked headed. Delete it with that fix.Verification
main.🤖 Generated with Claude Code