Skip to content

fix: hardcoded values counting vehicles (and marines) on managmenet pane.#1052

Merged
OH296 merged 4 commits intoAdeptus-Dominus:mainfrom
swang300:management_counting
Nov 6, 2025
Merged

fix: hardcoded values counting vehicles (and marines) on managmenet pane.#1052
OH296 merged 4 commits intoAdeptus-Dominus:mainfrom
swang300:management_counting

Conversation

@swang300
Copy link
Contributor

@swang300 swang300 commented Nov 5, 2025

…management screen, hopefully

Purpose and Description

  • Vehicles were not being counted correctly on the management screen. fixed
  • also, fixed some hardcoded values to check array length.

Testing done

  • None, and I understand the risks.

Related things and/or additional context

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Optimised data iteration throughout the management system to use dynamic sizing based on actual data rather than fixed limits, improving resource efficiency.
    • Refined vehicle and unit counting mechanisms to ensure accurate tallies across companies.
    • Improved consistency in data handling operations and sequencing for better system reliability.

Walkthrough

Tech-Priest: Iteration logic for units and vehicles was refactored to use data-driven array lengths (obj_ini.TTRPG and obj_ini.veh_role per company). Indexing moved to zero-based arrays, Captain detection switched to name string comparison, and vehicle counting was consolidated and relocated outside inner unit loops.

Changes

Cohort / File(s) Summary
Management script update
scripts/scr_management/scr_management.gml
Iteration over units switched from obj_ini.name[0] indexing to obj_ini.TTRPG[company] array; unit lookup uses unit = obj_ini.TTRPG[company][i]; Captain check changed to unit.name() = role_names[eROLE.Captain]; vehicle counting moved to iterate obj_ini.veh_role[company] via array_length.
Vehicle counting refactor
scripts/scr_vehicle_count/scr_vehicle_count.gml
Replaced fixed loops (0..10, 1..100) with ranges driven by obj_ini.companies and array_length(obj_ini.veh_role[j]); indexing shifted to 0-based and traversal bounds now reflect actual data lengths.
Vehicle ordering adjustments
scripts/scr_vehicle_order/scr_vehicle_order.gml
Replaced fixed-size loops (301, 150, 1..vehicle_count) with array_length(obj_ini.veh_role[company_number]) and 0..vehicle_count-1 bounds; moved reset_vehicle_variable_arrays and adjusted when vehicle_count is incremented relative to data copy.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify no off-by-one errors from 1-based → 0-based conversion.
  • Confirm obj_ini.TTRPG[company] structure matches prior expectations.
  • Check vehicle string matches and that vehicle counting relocation preserves semantics.
  • Review order of reset_vehicle_variable_arrays and vehicle_count increments in scr_vehicle_order.gml.

Possibly related PRs

Suggested labels

PR: Fix, Size: Small

Suggested reviewers

  • Blogaugis

Tech-Priest: The arrays whisper their bounds; heed them, and prevent the silent rupture of indices.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title follows conventional commits format with 'fix' type and provides a specific summary of the changes, though exceeds 50-character recommendation at 73 characters.
Description check ✅ Passed Description covers all required template sections (Purpose, Testing done, Context) with adequate detail about the vehicle counting fixes and hardcoded value replacements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@github-actions github-actions bot added Size: Tiny Type: Fix This is a fix for a bug labels Nov 5, 2025
@swang300 swang300 changed the title fixed hardcoded vehicle iterations, also fixed company counts on the … Fix: hardcoded values counting vehicles (and marines) on managmenet pane. Nov 5, 2025
@swang300 swang300 changed the title Fix: hardcoded values counting vehicles (and marines) on managmenet pane. fix hardcoded values counting vehicles (and marines) on managmenet pane. Nov 5, 2025
@swang300 swang300 changed the title fix hardcoded values counting vehicles (and marines) on managmenet pane. fix: hardcoded values counting vehicles (and marines) on managmenet pane. Nov 5, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 5, 2025
Copy link
Collaborator

@OH296 OH296 left a comment

Choose a reason for hiding this comment

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

one minor change otherwise all seems good to me, as a note we generally are trying to avoid the use of then and are swapping it out with the more conventional if (condition){<do thing>} format but that is a a lesser concern that i'm not going to enforce minor changes

@OH296
Copy link
Collaborator

OH296 commented Nov 6, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
scripts/scr_vehicle_order/scr_vehicle_order.gml (2)

45-49: Tech-Priest, heretical corruption detected in the logic-circuits.

The comparison operators have been replaced with assignment runes. The variable _is_vehicle_role shall always resolve to truth, and the sacred role-designations shall be overwritten with each iterative pass.

Apply this ritual of correction:

-        var _is_vehicle_role =
-        	veh_role[company_number][i] = "Rhino" // TODO change to enums/string ids
-        	|| veh_role[company_number][i] = "Predator"
-        	|| veh_role[company_number][i] = "Whirlwind"
-        	|| veh_role[company_number][i] = "Land Speeder"
-        	|| veh_role[company_number][i] = "Land Raider";
+        var _is_vehicle_role =
+        	veh_role[company_number][i] == "Rhino" // TODO change to enums/string ids
+        	|| veh_role[company_number][i] == "Predator"
+        	|| veh_role[company_number][i] == "Whirlwind"
+        	|| veh_role[company_number][i] == "Land Speeder"
+        	|| veh_role[company_number][i] == "Land Raider";

72-87: Grave inconsistency detected in the indexing protocol.

The final loop now iterates from the void-point (0), yet scr_add_vehicle.gml:14 deliberately begins iteration at unity, implying index 0 is reserved or sanctified. This mismatch will corrupt the data-matrix when vehicle assignment and reordering functions collide.

The code commences iteration at index 1 and searches for empty vehicle slots, suggesting index 0 must remain untouched. Your reordering sequence must either:

  • Begin iteration at index 1 to align with scr_add_vehicle.gml, or
  • Confirm that the entire vehicle system has been migrated to 0-based indexing and update scr_add_vehicle.gml accordingly.

Verify the indexing doctrine across all vehicle-access functions before this ritual completes.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77b88bf and c6160f1.

📒 Files selected for processing (1)
  • scripts/scr_vehicle_order/scr_vehicle_order.gml (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.gml

⚙️ CodeRabbit configuration file

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

Files:

  • scripts/scr_vehicle_order/scr_vehicle_order.gml
**/*.*

⚙️ CodeRabbit configuration file

**/*.*: - Having humanly understandable and maintainable code is the top most priority.

  • DRY (Don't repeat yourself) principle is also very important.
  • If a TODO comment is added, ask the user if you should create a GitHub issue for this TODO.
  • If a TODO comment is deleted, remind the user if there is an active GitHub issue related to that comment.

Files:

  • scripts/scr_vehicle_order/scr_vehicle_order.gml
🧠 Learnings (2)
📓 Common learnings
Learnt from: EttyKitty
Repo: Adeptus-Dominus/ChapterMaster PR: 647
File: scripts/scr_en_weapon/scr_en_weapon.gml:24-928
Timestamp: 2025-03-29T10:30:25.598Z
Learning: A data-driven approach for weapon management in `scripts/scr_en_weapon/scr_en_weapon.gml` is planned for a future PR, not within the scope of PR #647.
Learnt from: VanWeapon
Repo: Adeptus-Dominus/ChapterMaster PR: 725
File: scripts/scr_special_view/scr_special_view.gml:49-49
Timestamp: 2025-04-15T10:54:19.720Z
Learning: In the ChapterMaster codebase, obj_ini.role[100][2] and obj_ini.role[100][eROLE.ChapterMaster] reference different roles, and both are needed in conditions checking for specific types of units. Numeric indices should not be assumed to match their corresponding enum values without verification.
Learnt from: MCPO-Spartan-117
Repo: Adeptus-Dominus/ChapterMaster PR: 508
File: scripts/scr_specialist_training/scr_specialist_training.gml:371-371
Timestamp: 2025-02-24T07:38:42.267Z
Learning: The spec_train_data array index for Techmarine training data is 0, as confirmed by the maintainer.
Learnt from: VanWeapon
Repo: Adeptus-Dominus/ChapterMaster PR: 725
File: scripts/scr_initialize_custom/scr_initialize_custom.gml:2474-2572
Timestamp: 2025-04-15T11:03:37.154Z
Learning: In the ChapterMaster initialization code, negative values in the company structure (e.g., for vehicles like rhinos, landspeeders) are acceptable as only positive values will result in units being created.
Learnt from: EttyKitty
Repo: Adeptus-Dominus/ChapterMaster PR: 0
File: :0-0
Timestamp: 2025-04-05T20:54:45.813Z
Learning: EttyKitty requested a rework of the vehicle and marine recovery system in ChapterMaster. The current system allows guaranteed recovery with enough recovery points, while the proposed system would use random chance modified by techmarine skill and item bonuses.
Learnt from: EttyKitty
Repo: Adeptus-Dominus/ChapterMaster PR: 0
File: :0-0
Timestamp: 2025-03-20T22:22:57.319Z
Learning: In the ChapterMaster game PR #424, the psychic power system was changed to be data-driven, with perils now able to occur on both successful and failed casts but with reduced frequency overall.
📚 Learning: 2025-04-15T10:54:19.720Z
Learnt from: VanWeapon
Repo: Adeptus-Dominus/ChapterMaster PR: 725
File: scripts/scr_special_view/scr_special_view.gml:49-49
Timestamp: 2025-04-15T10:54:19.720Z
Learning: In the ChapterMaster codebase, obj_ini.role[100][2] and obj_ini.role[100][eROLE.ChapterMaster] reference different roles, and both are needed in conditions checking for specific types of units. Numeric indices should not be assumed to match their corresponding enum values without verification.

Applied to files:

  • scripts/scr_vehicle_order/scr_vehicle_order.gml
🔇 Additional comments (2)
scripts/scr_vehicle_order/scr_vehicle_order.gml (2)

25-40: Tech-Priest, the machine-spirit acknowledges your correction.

The iterative bounds now draw from the data-matrix itself rather than rigid numerals etched in stone. This aligns with the sacred principles of adaptability.


43-43: Tech-Priest, the iterative boundary has been purified.

The machine-spirit no longer references immutable numerals but instead queries the data-structure's true extent.

@swang300
Copy link
Contributor Author

swang300 commented Nov 6, 2025

Looks good on the change, looks like you committed it already.

@OH296 OH296 merged commit 429fefa into Adeptus-Dominus:main Nov 6, 2025
3 checks passed
Blogaugis pushed a commit to Blogaugis/Space-Brigade-Master that referenced this pull request Nov 15, 2025
…ane. (Adeptus-Dominus#1052)

Co-authored-by: Nelsonh <81228864+OH296@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Tiny Type: Fix This is a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants