New Feature: Support Convert to another type. - #2294
Conversation
|
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. |
TaranDahl
left a comment
There was a problem hiding this comment.
I see no other issues.
|
喵? |
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. |
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>
… space 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>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Align the actual building placement in ConvertToTypeEx with the deploy cursor check so that the building ends up centered on the deploying unit. Extract the shared top-left cell computation into BuildingTypeExt::GetDeployBuildingTopLeftCell, mirroring the vanilla deploy logic which offsets by (-1,-1) for foundations larger than 2x2.
There was a problem hiding this comment.
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 inTechnoExt::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
ConvertToTypeExcallsSyncStatus(which can transfer mind control, shields, attached effects, etc.) beforeForceCreate. IfForceCreatefails, 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
ConvertToTypeExcallsSyncStatusbefore attemptingUnlimbothe new unit. IfUnlimbofails, 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).ConvertToTypeExcurrently includesAbstractType::AircraftTypein 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.
| const auto pType = pThis->GetTechnoType(); | ||
|
|
||
| // It really should be at the beginning. | ||
| if (pType == pToType || pType->WhatAmI() != pToType->WhatAmI()) | ||
| if (pType == pToType) | ||
| { | ||
| Debug::Log("Incompatible types between %s and %s\n", pThis->get_ID(), pToType->get_ID()); | ||
| return false; | ||
| } |
| // This line will break the bahavior of UnDeploysInto buildings. However, it might serve a purpose that no one knows yet | ||
| // Comment out the line instead of removing it for now, so we can turn to it if something related goes wrong in the future |
| if (!builtOnCanBeBuiltOn && (pCell->OccupationFlags & (skipFlag ? 0x03 : 0x3F))) | ||
| return CanNotExistHere; |
Summary
Refactored the underlying type conversion system (
ConvertToType/ConvertToTypeEx) to support cross-type conversion between allTechnoTypeclasses exceptAircraftType. AddedUndeploysInto.ConvertToas a new conversion trigger onBuildingType.Changes
Core: rewritten conversion logic
ConvertToTypeand newConvertToTypeExnow handle cross-type conversion via creating a new object + destroying the old one, supportingInfantryType,UnitType, andBuildingType.AircraftTypeis only supported for same-type conversion (in-place type pointer update).PendingConvertTechnoTypeprocessed inOnEarlyUpdate— used when the source unit needs to finish its current animation frame before being destroyed.This improvement applies to all existing conversion paths (
Convert.Deploy,Convert.Undeploy,Convert.HumanToComputer,Convert.ComputerToHuman, etc.).New feature:
UndeploysInto.ConvertToBuildingTypetagUndeploysInto.ConvertTospecifies a targetTechnoType.UndeploysIntocreates the vehicle, it is converted to the target type on the next frame.Refactor
TransferMindControlOnDeployfromHooks.DeploysInto.cppintoTechnoExtas a reusable static method.Selection preservation
Documentation
Updated
New-or-Enhanced-Logics.mdwith documentation forUndeploysInto.ConvertTo, the expanded type support inConvert.Deploy/Convert.Undeploy, and a warning that cross-type conversion creates a new object and destroys the old one.Files Changed
src/Ext/Techno/Body.cppConvertToTypeExcross-type conversion,ConvertToTypesame-type fallback, property transfersrc/Ext/Techno/Body.hPendingConvertTechnoType, static method declarationssrc/Ext/Techno/Body.Update.cppsrc/Ext/Unit/Hooks.DeploysInto.cppTechnoExt, addUndeploysInto.ConvertTohooksrc/Ext/BuildingType/Body.h/.cppUndeploysInto.ConvertTotagdocs/New-or-Enhanced-Logics.md