Skip to content

New Feature: Support Convert to another type. - #2294

Open
frg2089 wants to merge 9 commits into
Phobos-developers:developfrom
ShimakazeProject:develop
Open

New Feature: Support Convert to another type.#2294
frg2089 wants to merge 9 commits into
Phobos-developers:developfrom
ShimakazeProject:develop

Conversation

@frg2089

@frg2089 frg2089 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What kind of change is this?

  • New feature, vanilla bugfix or enhancement of a released feature - changelog, docs and credits entries are needed.
  • Improvement to a new (unreleased) feature - docs and credits entries are needed; no changelog entry (Skip Changelog).
  • Bugfix to a new (unreleased) feature - credits entry is needed; no changelog or docs entries (Skip Changelog, Skip Docs).
  • Bugfix to an old (released) feature - changelog and credits entries are needed; no docs entry (Skip Docs).
  • Completely minor change (e.g. a typo fix) - no entries are needed (Skip Changelog, Skip Docs, Skip Credits).

Description

This PR allows Phobos TechnoType conversion logic to convert between different TechnoType categories.

Changes

  • Generalized TechnoExt::ConvertToType to accept TechnoClass instead of only FootClass.
  • Added support for conversions between infantry, vehicles, aircraft and buildings.
  • Added support for conversions involving BuildingType, including building-to-building conversions.
  • Same-category conversions between non-building TechnoTypes continue to use the existing in-place conversion logic.
  • Cross-category conversions and conversions involving buildings create a new object, transfer applicable state, and remove the original object.
  • Transferable state includes:
    • Health percentage
    • Veterancy
    • Mind control
    • Shield state
    • Invulnerability
    • Attached effects
    • Armor and firepower multipliers
    • Target
    • Destination
    • Current mission
    • Selection state
    • FootClass speed multiplier where applicable
  • Added building placement and coordinate handling for converted buildings.
  • Preserved building deployment and buildup initialization when the conversion result is a building.
  • Reused the conversion logic for Convert.Deploy, Convert.Undeploy, Ammo.AutoConvertType and Convert.Health.
  • Moved health-based automatic conversion into the common TechnoClass update path.
  • Unified deployment placement checks for vehicles and infantry.
  • Convert.Deploy conversions to buildings now validate building placement rules before execution.
  • Cross-category conversions do not depend on Ares 3.0 and use Phobos' own conversion implementation.

Notes

Because cross-category conversions create a new map object, some state or associations attached to the original object may not be preserved.

@frg2089 frg2089 changed the title Refactor type conversion logic to support cross-type conversion and add UndeploysInto.ConvertTo trigger New Feature: Support Convert to another type. Jul 18, 2026
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Unit/Hooks.DeploysInto.cpp Outdated
Comment thread src/Ext/Techno/Body.Update.cpp Outdated
Comment thread docs/New-or-Enhanced-Logics.md Outdated
@frg2089
frg2089 marked this pull request as draft July 18, 2026 17:38
@github-actions

github-actions Bot commented Jul 18, 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.

@frg2089
frg2089 marked this pull request as ready for review July 19, 2026 02:21
Comment thread src/Ext/Techno/Body.cpp Outdated

@TaranDahl TaranDahl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see no other issues.

@TaranDahl TaranDahl added Needs testing ⚙️T1 T1 maintainer review is sufficient labels Jul 23, 2026
@TaranDahl
TaranDahl requested a review from NetsuNegi July 23, 2026 10:27
@frg2089

frg2089 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

喵?

@TaranDahl

Copy link
Copy Markdown
Contributor

喵?

Since this is your first PR submission, your code will need reviews from more maintainers before it can be merged. This is the rule of Phobos.

@frg2089

frg2089 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Since this is your first PR submission, your code will need reviews from more maintainers before it can be merged. This is the rule of Phobos.

OK, I will stop resolving the conflict before there are further results.

@frg2089
frg2089 deleted the branch Phobos-developers:develop August 23, 2026 04:15
@frg2089 frg2089 closed this Aug 23, 2026
@frg2089
frg2089 deleted the develop branch August 23, 2026 04:15
@frg2089
frg2089 restored the develop branch August 23, 2026 04:17
@frg2089 frg2089 reopened this Aug 23, 2026
Copilot AI lite review requested due to automatic review settings August 23, 2026 04:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors Phobos’ TechnoType conversion pipeline to support cross-category conversions (object replacement) across Infantry/Unit/Building types, adds a new BuildingType INI trigger (UndeploysInto.ConvertTo) to convert the undeployed unit on the next frame, and updates documentation/changelog/credits accordingly.

Changes:

  • Added cross-category conversion via TechnoExt::ConvertToTypeEx (create new object + destroy old), with deferred conversion support (PendingConvertTechnoType) processed in TechnoExt::OnEarlyUpdate.
  • Centralized status transfer during deploy/undeploy (mind control, shields, invulnerability, attached effects, multipliers, etc.) via TechnoExt::SyncStatus.
  • Added deploy feedback improvements and documented the new conversion behaviors (including zh_CN locale updates and credits/changelog entries).

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Misc/Hooks.BugFixes.cpp Switches deploy-to-fire checks to TechnoExt::CanDeployIntoBuilding.
src/Ext/Unit/Hooks.DeploysInto.cpp Uses TechnoExt::SyncStatus, adds UndeploysInto.ConvertTo deferral, adds deploy action hook, adjusts deploy placement/desync logic.
src/Ext/Unit/Hooks.DeployFire.cpp Adds NoDeploy feedback (EVA) when Convert.Deploy targets a building without sufficient space.
src/Ext/Unit/Body.h Removes UnitExt deployer/static deploy checks now moved into TechnoExt.
src/Ext/Unit/Body.cpp Removes UnitExt::Deployer and UnitExt::CanDeployIntoBuilding implementation.
src/Ext/Techno/Body.Update.cpp Processes deferred conversions (PendingConvertTechnoType) during early update.
src/Ext/Techno/Body.h Adds PendingConvertTechnoType, Deployer, and new conversion/status-transfer method declarations.
src/Ext/Techno/Body.cpp Implements SyncStatus, moves deploy-related helpers into TechnoExt, and adds ConvertToTypeEx for cross-category conversions.
src/Ext/BuildingType/Body.h Adds UndeploysInto_ConvertTo storage and declares a helper for deploy cell computation.
src/Ext/BuildingType/Body.cpp Implements GetDeployBuildingTopLeftCell, reads/serializes UndeploysInto.ConvertTo.
docs/Whats-New.md Adds changelog entries for cross-category conversion and related improvements.
docs/New-or-Enhanced-Logics.md Documents UndeploysInto.ConvertTo.
docs/Fixed-or-Improved-Logics.md Updates “fixed/improved” notes for conversion behavior and feedback.
docs/locale/zh_CN/LC_MESSAGES/Whats-New.po Adds zh_CN translations for new changelog bullets.
docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po Adds zh_CN translations for UndeploysInto.ConvertTo docs.
docs/locale/zh_CN/LC_MESSAGES/Fixed-or-Improved-Logics.po Updates zh_CN translations to match new conversion/feedback entries.
docs/locale/zh_CN/LC_MESSAGES/CREDITS.po Adds zh_CN credits entries for the contributor.
CREDITS.md Adds credits entries for the new conversion features and preservation behaviors.
Suppressed comments (3)

src/Ext/Techno/Body.cpp:526

  • ConvertToTypeEx calls SyncStatus (which can transfer mind control, shields, attached effects, etc.) before ForceCreate. If ForceCreate fails, the source unit's state may already have been mutated (e.g., mind control freed), leaving it in an inconsistent state.
		SyncStatus(pThis, pBuilding);

		pBuilding->QueueMission(Mission::Construction, false);
		pBuilding->NextMission();

src/Ext/Techno/Body.cpp:576

  • ConvertToTypeEx calls SyncStatus before attempting Unlimbo the new unit. If Unlimbo fails, the rollback path re-unlimbos the old unit but does not restore any state already transferred (mind control, attached effects, etc.). Move status transfer until after the new unit has been successfully placed.
		if (auto const pUnit = static_cast<FootClass*>(pToType->CreateObject(pHouse)))
		{
			SyncStatus(pThis, pUnit);

			// Remove old techno from map
			pThis->Limbo();

src/Ext/Techno/Body.cpp:568

  • PR description says cross-category conversion should not support AircraftType (only same-type in-place conversion). ConvertToTypeEx currently includes AbstractType::AircraftType in the cross-type object-replacement path, which contradicts that behavior.
	case AbstractType::InfantryType:
	case AbstractType::UnitType:
	case AbstractType::AircraftType:

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Unit/Hooks.DeploysInto.cpp
Comment thread src/Ext/Unit/Hooks.DeploysInto.cpp Outdated
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
@frg2089
frg2089 force-pushed the develop branch 2 times, most recently from 1e729ed to 7233fdb Compare August 25, 2026 11:17
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp
…rsion and improve code clarity

Co-authored-by: Netsu_Negi <71598172+NetsuNegi@users.noreply.github.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants