Remove dead code, tidy duplication, and index the main region #125
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Dead code, small duplications and one cheap optimisation, found in a whole-project review after #72 merged (
2ad4d63). None of it changes behaviour. The bugs from the same review are in #124, and theBuildingTaskrefactor is #126.Remove: nothing calls these
GameState.set_debug_mode()(globals/GameState.gd:75). It would also emitdebug_mode_changedtwice, because the setter already emits it.GameState.contract_start_date: assigned in_ready(), never read.GameState.run_day().BuildingPanel's ownsignal building_type_selected(ui/building_panel/building_panel.gd:20). The panel emits GameState's signal of the same name instead.Building.to_debug_string().BuildingFootprint._print_cells().Task.required_role,Task.remove_subtask(),Task.dump(). #74 will bring roles back properly, not as a string.TerrainGrid.generate(): the unusedwalkablelocal (line 130) and theprintbelow it, which is commented out._build_navigation()can then stop returning a count.TerrainGrid.is_sloped(): the unusedthresholdlocal (line 383).Decide: only the tests call these
TerrainGrid.is_sloped()andneighbouring_cells(). Placement usesPlacementRules' level-spread rule instead. Either delete them along with their tests, or give them a real caller.Tidy
entities/pawns/pawns.gd:168-171: one doc line appears twice, plus a staleTODO(#75): the body. The body exists now.pawns.gd:184-186:if … == ERR_SKIP: continuefollowed by an unconditionalcontinue. Only the second is needed.pawns.gd:255-267: three identical signal handlers. Connecttask_completed,task_cancelledandtask_releaseddirectly to one handler that takes aTask.Vector3(-1.0, -1.0, -1.0)is written out six times acrosspawn.gdandpawns.gdas "no destination". It should be one constant onPawn.placement_controller.gd:135-149: fourmatcharms all assignINVALID_TINT. They can be one arm.ui/debug_layer.gd: the text for each pawn label (lines 78, 88) and each task label (100, 105) is built in two places. One helper each.buildings.gd:275: a line that's commented out.buildings.gd:267:existing_task != null and existing_task is ….isis already false on null.entities/buildings/building.gdbegins with a UTF-8 BOM.Throwaway tools
Nine scripts in
tools/are labelled "THROWAWAY … Delete after use", and every issue they were written for is closed:probe_menu_rects,probe_screen,probe_menu_clickthrough,probe_demolish_click,screenshot_buildings,screenshot_entrance_arrow,screenshot_building_blocks_path,screenshot_path_overlay,screenshot_window_resize.Two things to deal with first:
screenshot_path_overlay.gdfor why-sharnesses avoid project types. Move that explanation into CLAUDE.md before deleting it, or keep that file as the reference example.screenshot_entrance_arrow.gduntil the arrow fix in #124 has been checked headed.Optimise:
is_in_main_region()TerrainGrid.is_in_main_region()(terrain_grid.gd:624) callsArray.has()on_main_region. On a 64×64 map that's a linear scan of up to about 4,000 cells. It sits on the hottest path in the game:Task.can_start()calls it for every task, for every idle pawn, on every tick.Fix: keep a
Dictionary[Vector2i, bool]alongside_main_region, rebuilt in_find_largest_region().random_walkable_position()still needs the array for indexing.While in
pawns.gd:_check_path_collision()(line 219) rebuildsbuilding.cells()for every waypoint. Compute it once before the loop.Deliberately left alone
PawnRole,PawnLeveland the commented-out pawn fields: placeholders for #74.GameCalendarfunctions: a tested API, planned for forecasting.count_of()copyingvalues().PlacementRuleslooping over the cells four times.PlacementControllerandDemolishController: that belongs to #78's shared picker.terrain_grid.gd: that belongs to #46.Acceptance criteria
is_sloped()/neighbouring_cells()made and recorded in the PR-sexplanation preservedis_in_main_region()is a constant-time lookup; existing tests for main region and spawning still pass