Skip to content

Adjust recruitable status on team member discharge#2248

Open
TaranDahl wants to merge 2 commits into
Phobos-developers:developfrom
TaranDahl:RecruitableB
Open

Adjust recruitable status on team member discharge#2248
TaranDahl wants to merge 2 commits into
Phobos-developers:developfrom
TaranDahl:RecruitableB

Conversation

@TaranDahl

@TaranDahl TaranDahl commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This is an extension to #2022

Teams

Adjust recruitable status on team member discharge

  • In vanilla, when a unit is added to a team, its RecruitableB flag is overwritten by the team's AreTeamMembersRecruitable setting. When the unit is discharged from the team, the flag is not restored. The following settings allow a team to reset this flag when discharging its members.
    • [General] → IsDischargedMemberAutocreateRecruitable sets the global default value.
    • [TeamType] → IsDischargedMemberAutocreateRecruitable overrides the global default for a specific team type.
    • If set to a value greater than 0, the discharged unit is forcibly marked as recruitable.
    • If set to 0, the discharged unit is forcibly marked as not recruitable.
    • If set to a value less than 0 (default: -1), the original game behavior is preserved.

In rulesmd.ini:

[General]
IsDischargedMemberAutocreateRecruitable=-1  ; integer

[SOMETEAMTYPE]                               ; TeamType
IsDischargedMemberAutocreateRecruitable=     ; integer, default to [General] -> IsDischargedMemberAutocreateRecruitable

Summary by CodeRabbit

Release Notes

  • New Features

    • Added configurable control over recruitable status when team members are discharged. Global settings and per-team-type overrides allow precise control over whether discharged units retain or reset their recruitable status.
  • Documentation

    • Added comprehensive documentation for the new team member recruitable status adjustment feature, including configuration examples and translations.

@TaranDahl TaranDahl added Needs testing ⚙️T1 T1 maintainer review is sufficient ❓Unhardcoding / Customization Make something more tweakable labels Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements configurable control over the RecruitableB flag when team members are discharged. A new TeamTypeExt extension framework allows per-team-type settings to override a global default, resolving vanilla behavior where discharged units retain their recruitable status instead of being restored.

Changes

Recruitable Status on Team Member Discharge

Layer / File(s) Summary
Global rules configuration foundation
src/Ext/Rules/Body.h, src/Ext/Rules/Body.cpp
RulesExt gains IsDischargedMemberAutocreateRecruitable field with default value -1, loaded from [General] INI and included in save/load serialization.
TeamType extension framework
src/Ext/TeamType/Body.h, src/Ext/TeamType/Body.cpp
New TeamTypeExt extension provides per-team-type override via Nullable IsDischargedMemberAutocreateRecruitable field. Implements INI and stream persistence with CTOR/DTOR hooks for allocation/deallocation and save/load hooks for state management.
Build and registry integration
Phobos.vcxproj, src/Phobos.Ext.cpp
TeamType source and header files added to project build. TeamTypeExt registered in PhobosTypeRegistry for global dispatch.
Member discharge logic implementation
src/Misc/Hooks.BugFixes.cpp
TeamClass_LiberateMember_Start hook retrieves TeamTypeExt setting and conditionally sets discharged member's RecruitableB: true for value > 0, false for value = 0, or preserves original for value < 0.
User documentation and metadata
CREDITS.md, docs/AI-Scripting-and-Mapping.md, docs/Whats-New.md, docs/locale/zh_CN/LC_MESSAGES/*
Documentation explains Teams feature with [General] and [TeamType] configuration options. Changelog and credits updated with links to documentation. English and Chinese translations provided.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through discharge flows,
Now teaching teams where order goes,
With recruitable flags that bend to will,
Per-team control, at last fulfilled!
Click goes the INI, save goes the stream—
Phobos extensions: a coder's dream! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adjusting recruitable status behavior when team members are discharged, which aligns with all file modifications.
Description check ✅ Passed The PR description comprehensively explains the feature, including vanilla behavior, new configuration options, value semantics, and INI examples, meeting the informational requirements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/Ext/TeamType/Body.cpp

In file included from src/Ext/TeamType/Body.cpp:1:
src/Ext/TeamType/Body.h:2:10: fatal error: 'TeamTypeClass.h' file not found
2 | #include <TeamTypeClass.h>
| ^~~~~~~~~~~~~~~~~
1 error generated.
src/Ext/TeamType/Body.cpp:9:1-15:1: ERROR translating statement 'CompoundStmt'
Aborting translation of method 'TeamTypeExt::ExtData::LoadFromINIFile' in file 'src/Ext/TeamType/Body.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.loop in file "src/list.ml", line 944, chara

... [truncated 2200 characters] ...

t.add_method in file "src/clang/cFrontend_decl.ml" (inlined), line 54, characters 4-52
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl.add_method_if_create_procdesc in file "src/clang/cFrontend_decl.ml" (inlined), line 123, characters 16-158
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl in file "src/clang/cFrontend_decl.ml", line 126, characters 17-97
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_methods in file "src/clang/cFrontend_decl.ml" (inlined), line 270, characters 8-122
Called from Stdlib__List.iter in file "list.ml" (inlined), line 110, characters 12-15
Called from Stdlib__List.iter in file "list.ml" (inlined), line 108, characters 13-64
Called from Base__List0.iter in file "src/list0

src/Ext/Rules/Body.cpp

In file included from src/Ext/Rules/Body.cpp:1:
src/Ext/Rules/Body.h:3:10: fatal error: 'RulesClass.h' file not found
3 | #include <RulesClass.h>
| ^~~~~~~~~~~~~~
1 error generated.
src/Ext/Rules/Body.cpp:481:1-488:1: ERROR translating statement 'CompoundStmt'
Aborting translation of method 'RulesExt::ExtData::InitializeAfterAllLoaded' in file 'src/Ext/Rules/Body.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.loop in file "src/list.ml", line 944, characters 13-17

... [truncated 2200 characters] ...

in file "src/clang/cFrontend_decl.ml" (inlined), line 54, characters 4-52
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl.add_method_if_create_procdesc in file "src/clang/cFrontend_decl.ml" (inlined), line 123, characters 16-158
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl in file "src/clang/cFrontend_decl.ml", line 126, characters 17-97
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_methods in file "src/clang/cFrontend_decl.ml" (inlined), line 270, characters 8-122
Called from Stdlib__List.iter in file "list.ml" (inlined), line 110, characters 12-15
Called from Stdlib__List.iter in file "list.ml" (inlined), line 108, characters 13-64
Called from Base__List0.iter in file "src/list0.ml" (inline

src/Misc/Hooks.BugFixes.cpp

src/Misc/Hooks.BugFixes.cpp:1:10: fatal error: 'AircraftTrackerClass.h' file not found
1 | #include <AircraftTrackerClass.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
src/Misc/Hooks.BugFixes.cpp:590:2-9: ERROR translating statement 'ReturnStmt'
Aborting translation of method '_BombClass_Detonate_DamageArea' in file 'src/Misc/Hooks.BugFixes.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.loop in file "src/list.ml", line 944, characters 13-17
Called from Base__Li

... [truncated 2200 characters] ...

e "src/clang/cTrans.ml", line 4784, characters 10-1023
Called from ClangFrontend__CTrans.CTrans_funct.instruction in file "src/clang/cTrans.ml" (inlined), line 4765, characters 38-71
Called from ClangFrontend__CTrans.CTrans_funct.exec_with_node_creation in file "src/clang/cTrans.ml" (inlined), line 104, characters 20-38
Called from ClangFrontend__CTrans.CTrans_funct.get_clang_stmt_trans in file "src/clang/cTrans.ml" (inlined), line 5395, characters 4-69
Called from ClangFrontend__CTrans.CTrans_funct.get_custom_stmt_trans in file "src/clang/cTrans.ml", line 5401, characters 8-55
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs.exec_trans_instrs_rev in file "src/clang/cTrans.ml" (inlined), line 5365, characters 28-54
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_i

  • 1 others

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
docs/locale/zh_CN/LC_MESSAGES/AI-Scripting-and-Mapping.po (1)

6-6: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Clear the catalog-level fuzzy marker after updating this translation.

The file was updated for new source strings, so leaving #, fuzzy keeps the catalog marked as needing review.

Proposed fix
-#, fuzzy

As per coding guidelines, "update .po entries marked fuzzy when English source docs change".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/locale/zh_CN/LC_MESSAGES/AI-Scripting-and-Mapping.po` at line 6, The
catalog entry still has the `#, fuzzy` marker which must be cleared after
updating translations; open the PO file and remove the `#, fuzzy` flag (or
change it to `#, reviewed` per your workflow) for the updated message in
AI-Scripting-and-Mapping.po, ensure the translated string is correct and
up-to-date with the English source, then save and run your usual PO
validation/compilation (e.g., msgfmt or your CI linter) so the catalog is no
longer marked as needing review.

Source: Coding guidelines

🧹 Nitpick comments (1)
docs/locale/zh_CN/LC_MESSAGES/CREDITS.po (1)

2485-2486: 💤 Low value

Optional: Consider terminology refinement for "discharge"

The translation "小队成员解散时调整可招募性" is understandable and conveys the meaning. However, "解散" typically means "disband" (implying the entire team dissolves), while the English "discharge" refers to removing individual members from a team.

For slightly better precision, consider:

  • "小队成员释放时调整可招募性" (using "释放" = release)
  • "调整解散小队成员的可招募性" (restructured)

The current translation is acceptable, so this is purely an optional refinement for terminology precision.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/locale/zh_CN/LC_MESSAGES/CREDITS.po` around lines 2485 - 2486, The msgid
"Adjust recruitable status on team member discharge" currently has msgstr
"小队成员解散时调整可招募性" which uses "解散" (disband) and may misrepresent "discharge" as
removing an individual; update the translation in this PO entry (the msgstr for
that msgid) to a more precise option such as "小队成员释放时调整可招募性" or "调整解散小队成员的可招募性"
(choose one) to better reflect removing a member rather than disbanding the
whole team.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/AI-Scripting-and-Mapping.md`:
- Line 986: Update the inline comment for the INI key
IsDischargedMemberAutocreateRecruitable to correct the grammar: change "default
to" to "defaults to" so the comment reads "defaults to [General] ->
IsDischargedMemberAutocreateRecruitable"; locate the line containing
IsDischargedMemberAutocreateRecruitable and replace the phrase accordingly.

In `@src/Misc/Hooks.BugFixes.cpp`:
- Line 3221: The statement calling TeamTypeExt::ExtMap.Find is missing a
terminating semicolon; update the line that reads "const auto pTeamTypeExt =
TeamTypeExt::ExtMap.Find(pTeam->Type)" (referencing pTeam and pTeamTypeExt) to
end with a semicolon so it becomes a valid C++ statement and the file compiles.

---

Outside diff comments:
In `@docs/locale/zh_CN/LC_MESSAGES/AI-Scripting-and-Mapping.po`:
- Line 6: The catalog entry still has the `#, fuzzy` marker which must be
cleared after updating translations; open the PO file and remove the `#, fuzzy`
flag (or change it to `#, reviewed` per your workflow) for the updated message
in AI-Scripting-and-Mapping.po, ensure the translated string is correct and
up-to-date with the English source, then save and run your usual PO
validation/compilation (e.g., msgfmt or your CI linter) so the catalog is no
longer marked as needing review.

---

Nitpick comments:
In `@docs/locale/zh_CN/LC_MESSAGES/CREDITS.po`:
- Around line 2485-2486: The msgid "Adjust recruitable status on team member
discharge" currently has msgstr "小队成员解散时调整可招募性" which uses "解散" (disband) and
may misrepresent "discharge" as removing an individual; update the translation
in this PO entry (the msgstr for that msgid) to a more precise option such as
"小队成员释放时调整可招募性" or "调整解散小队成员的可招募性" (choose one) to better reflect removing a
member rather than disbanding the whole team.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6baa07e7-22f2-45f1-ac39-ef780c23ea31

📥 Commits

Reviewing files that changed from the base of the PR and between 5f56ef2 and 745a7bc.

📒 Files selected for processing (13)
  • CREDITS.md
  • Phobos.vcxproj
  • docs/AI-Scripting-and-Mapping.md
  • docs/Whats-New.md
  • docs/locale/zh_CN/LC_MESSAGES/AI-Scripting-and-Mapping.po
  • docs/locale/zh_CN/LC_MESSAGES/CREDITS.po
  • docs/locale/zh_CN/LC_MESSAGES/Whats-New.po
  • src/Ext/Rules/Body.cpp
  • src/Ext/Rules/Body.h
  • src/Ext/TeamType/Body.cpp
  • src/Ext/TeamType/Body.h
  • src/Misc/Hooks.BugFixes.cpp
  • src/Phobos.Ext.cpp

Comment thread docs/AI-Scripting-and-Mapping.md
Comment thread src/Misc/Hooks.BugFixes.cpp Outdated
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@phoboscn-bot

Copy link
Copy Markdown

To Chinese users:
This pull request has been mentioned on Phobos CN. There might be relevant details there:

致中文用户:
此拉取请求已在 Phobos CN 上被提及。那里可能有相关详细信息:

https://www.phoboscn.top/t/topic/351/28

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

Labels

Needs testing ⚙️T1 T1 maintainer review is sufficient ❓Unhardcoding / Customization Make something more tweakable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants