Skip to content

Perf/refactor: use StructureTypes, remove territoryBound#3238

Merged
DevelopingTom merged 1 commit intomainfrom
structuretypes-replaces-territorybound
Feb 18, 2026
Merged

Perf/refactor: use StructureTypes, remove territoryBound#3238
DevelopingTom merged 1 commit intomainfrom
structuretypes-replaces-territorybound

Conversation

@VariableVince
Copy link
Contributor

@VariableVince VariableVince commented Feb 18, 2026

Description:

PR 6/x in effort to break up PR #3220. Follows on already merged #3237. Precedes #3239.

Please see if these can be merged for v30.

  • PlayerImpl: validStructureSpawnTiles did a filter on unit types to get isTerroritoryBound units, on every call again. It read this from unit info in DefaultConfig. While having it centrally in DefaultConfig unitInfo is good for maintainability, other code uses hardcoded StructureTypes and isisStructureType from Game.ts. Which has the same purpose and thus contains the same unit types. StructureTypes and isisStructureType do need manual maintainance outside of DefaultConfig. And are more bug prone/less type safe. But, using them gives more speed compared to getting these unit types out of DefaultConfig unitInfo centrally with some cached function in GameImpl for example (tested with buildableUnits and MIRVPerf.ts). So I went with StructureTypes in validStructureSpawnTiles too.

  • PlayerExecution: now validStructureSpawnTiles no longer needs isTerritoryBound (see the point above), PlayerExecution is the last place where it was used. Replaced it for isStructureType here too (since it has the same meaning and outcome).

  • Game.ts and DefaultConfig unitInfo: remove the now unused territoryBound. As it was only used in validStructureSpawnTiles and PlayerExecution and has been replaced in both (see the two points above).

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

tryout33

@VariableVince VariableVince added this to the v30 milestone Feb 18, 2026
@VariableVince VariableVince self-assigned this Feb 18, 2026
@VariableVince VariableVince requested a review from a team as a code owner February 18, 2026 22:34
@VariableVince VariableVince added the Performance Performance optimization label Feb 18, 2026
@VariableVince VariableVince added the Refactor Code cleanup, technical debt, refactoring, and architecture improvements. label Feb 18, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

This refactoring removes the territoryBound boolean property from unit configurations and replaces territory-bound checks with direct isStructureType function calls, shifting from property-based to type-based unit classification.

Changes

Cohort / File(s) Summary
Interface and Configuration Updates
src/core/game/Game.ts, src/core/configuration/DefaultConfig.ts
Removed the territoryBound boolean property from UnitInfo interface and all corresponding unit type configurations (15 units affected in DefaultConfig).
Logic Migration to Type-Based Checks
src/core/execution/PlayerExecution.ts, src/core/game/PlayerImpl.ts
Updated unit classification logic to use isStructureType function instead of territoryBound property checks; eliminated dynamic filtering based on territory bound status in favor of passing predefined StructureTypes directly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

Boundaries fade, types take the stage 🎭
Properties retire from the code's page 📜
Structure shines through, clean and clear ✨
Simple checks now replace the old frontier 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: replacing territoryBound with StructureTypes for performance and refactoring.
Description check ✅ Passed The description is well-related to the changeset, explaining the rationale for using StructureTypes instead of territoryBound across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@DevelopingTom DevelopingTom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@github-project-automation github-project-automation bot moved this from Triage to Final Review in OpenFront Release Management Feb 18, 2026
@DevelopingTom DevelopingTom added this pull request to the merge queue Feb 18, 2026
Merged via the queue into main with commit 8b66c8b Feb 18, 2026
16 checks passed
@DevelopingTom DevelopingTom deleted the structuretypes-replaces-territorybound branch February 18, 2026 22:45
@github-project-automation github-project-automation bot moved this from Final Review to Complete in OpenFront Release Management Feb 18, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 19, 2026
## Description:

PR 7/x in effort to break up PR #3220. Follows on already merged #3238.

Please see if these can be merged for v30.

-**RadialMenuElements**: 
- _getAllEnabledUnits_: use camelCase instead of PascalCase so change
Units into units.
- _getAllEnabledUnits_: use StructureTypes to loop through instead of
having 6 individual lines of code to check if a structure is enabled.
StructureTypes contains and will keep containing the same structures as
those that are checked here. PR 3220 will later on also replace the
individual lines for the attack type units into a loop with a newly
introduced Types array, in the same way as we do in this PR with
StructureTypes.
- _getAllEnabledUnits_: rename the long named const
addStructureIfEnabled to just addIfEnabled, which is clear enough from
the context it is used in.

-**PlayerImpl**
- _buildableUnits_: removed unnecessary "as BuildableUnit" after the
in-loop return; the function itself already says it returns
BuildableUnit[].

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

tryout33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance Performance optimization Refactor Code cleanup, technical debt, refactoring, and architecture improvements.

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants

Comments