Skip to content

[Minor] Repair the manager after unit conversion #1650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

a851903106
Copy link
Contributor

@a851903106 a851903106 commented May 3, 2025

子机部署变形3
After the conversion, the unit may lose the manager or retain some unnecessary ones. now they have been repaired.

In rulesmd.ini:

[SOMETECHNO]                            ; TechnoType
Convert.ResetMindControl=               ; boolean, default to false
  • After the unit conversion is completed, its mind control can be reset.
  • If Convert.ResetMindControl=no and there are no warheads in the unit that use MindControl=yes, then the controlled units that exceed the maximum value will be released.

单位在变形后会丢失管理器或是留下一些不需要的管理器,现在它们被修复了。

In rulesmd.ini:

[SOMETECHNO]                            ; TechnoType
Convert.ResetMindControl=               ; boolean, default to false
  • 单位变形结束后可以重置其心灵控制。
  • 如果Convert.ResetMindControl=no且单位没有任何使用了MindControl=yes的弹头,那么超出最大值的被控制单位会得到解放。

@github-actions github-actions bot added the Minor Documentation is not required label May 3, 2025
Copy link

github-actions bot commented May 3, 2025

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
Copy link
Contributor

A topic that I think might need to be discussed: Is it necessary to forcefully clear its corresponding state?
In this PR, if a unit obtains a mind control weapon after conversion, then create a new manager for it. If a unit loses the mind control weapon after conversion, then forcefully release the units it has controlled and delete the manager.
Personally, I'm more inclined to only forcefully maintain those situations that might lead to a crash. That is: if a unit obtains a mind control weapon after conversion, then create a new manager for it, because if not, the game will crash. If a unit loses the mind control weapon after conversion, then do nothing, because this won't affect the game's continued operation.
I've marked this PR as needs discussion, hoping that the author and others who are following this PR can exchange their opinions on this topic.

@TaranDahl TaranDahl added ❓Phobos bug Something isn't working properly Interaction Something related to interaction with other extension, program etc. Needs testing ⚙️T2 T2 maintainer review is sufficient Needs discussion labels May 3, 2025
@a851903106
Copy link
Contributor Author

I'm not sure about this, but for things like SpawnManager, I think it's necessary to delete them when they're not in use.

@a851903106
Copy link
Contributor Author

A topic that I think might need to be discussed: Is it necessary to forcefully clear its corresponding state? In this PR, if a unit obtains a mind control weapon after conversion, then create a new manager for it. If a unit loses the mind control weapon after conversion, then forcefully release the units it has controlled and delete the manager. Personally, I'm more inclined to only forcefully maintain those situations that might lead to a crash. That is: if a unit obtains a mind control weapon after conversion, then create a new manager for it, because if not, the game will crash. If a unit loses the mind control weapon after conversion, then do nothing, because this won't affect the game's continued operation. I've marked this PR as needs discussion, hoping that the author and others who are following this PR can exchange their opinions on this topic.

Well, I wrote a new tag to make it less obligatory.

@Coronia Coronia requested a review from CrimRecya May 6, 2025 03:08
Copy link
Contributor

@CrimRecya CrimRecya left a comment

Choose a reason for hiding this comment

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

I'm not sure there may be also some things that need to be noted:

  • Turret/barrel recoil data
  • Cloak
  • Sight (If not in motion)
  • Bomb sight (If not in motion)
  • Sensors sight (If not in motion)

pFirstPassenger->Transporter = pFoot;

if (pFirstPassenger->NextObject)
pFirstPassenger = abstract_cast<FootClass*>(pFirstPassenger->NextObject);
Copy link
Contributor

Choose a reason for hiding this comment

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

if (const auto pNextPassenger = abstract_cast<FootClass*>(pFirstPassenger->NextObject))
	pFirstPassenger = pNextPassenger;

Comment on lines 307 to 308
if (pType->Strength == pToType->Strength)
pThis->Health = oldHealth;
Copy link
Contributor

Choose a reason for hiding this comment

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

pThis->Health = Math::max(1, oldHealth * pToType->Strength / pType->Strength);

Comment on lines 294 to 299
if (pType == pToType ||
pType->WhatAmI() != pToType->WhatAmI())
{
Debug::Log("Incompatible types between %s and %s\n", pThis->get_ID(), pToType->get_ID());
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if Ares has already prompted this message?

{
const auto pSlave = pSlaveNode->Slave;

if (pSlave && pSlaveNode->State != SlaveControlStatus::Dead)
Copy link
Contributor

Choose a reason for hiding this comment

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

From 0x6B0B4C, it seems that there is no reason to check pSlaveNode->State != SlaveControlStatus::Dead.

{
pSlave->RegisterDestruction(pThis);
pSlave->UnInit();
pSlaveManager->LostSlave(pSlave);
Copy link
Contributor

Choose a reason for hiding this comment

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

pSlaveNode->Slave = nullptr; is OK. No more cycle and no more start timer.

Comment on lines 824 to 852
for (auto pSpawnNode : pSpawnManager->SpawnedNodes)
{
const auto pAircraft = pSpawnNode->Unit;
auto& Status = pSpawnNode->Status;

if (!pAircraft || Status == SpawnNodeStatus::Dead ||
Status == SpawnNodeStatus::Idle || Status == SpawnNodeStatus::Reloading)
continue;

pAircraft->SpawnOwner = nullptr;

if (Status == SpawnNodeStatus::TakeOff)
{
Kamikaze::Instance.Remove(pAircraft);
pAircraft->UnInit();
}
else
{
if (pSpawnNode->IsSpawnMissile)
pAircraft->ReceiveDamage(&pAircraft->Health, 0, RulesClass::Instance->C4Warhead, nullptr, true, false, pOwner);
else
pAircraft->Crash(nullptr);
}

pSpawnNode->Unit = nullptr;
Status = SpawnNodeStatus::Dead;
pSpawnNode->IsSpawnMissile = false;
pSpawnNode->SpawnTimer.Start(pSpawnManager->RegenRate);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any special difference between these and pSpawnManager->KillNodes();? It's best to comment on it.

{
if (!pSpawnManager || pType->Spawns != pSpawnManager->SpawnType)
{
if (pSpawnManager && pType->Spawns != pSpawnManager->SpawnType)
Copy link
Contributor

Choose a reason for hiding this comment

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

if (pSpawnManager)

{
if (!pSlaveManager || pSlaveManager->SlaveType != pType->Enslaves)
{
if (pSlaveManager && pSlaveManager->SlaveType != pType->Enslaves)
Copy link
Contributor

Choose a reason for hiding this comment

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

if (pSlaveManager)

}
}

auto& pAirstrike = pThis->Airstrike;
Copy link
Contributor

Choose a reason for hiding this comment

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

If you don't intend to clear it, you can put it in the later code.

else if (pTemporalImUsing)
{
if (pTemporalImUsing->Target)
pTemporalImUsing->Detach();
Copy link
Contributor

Choose a reason for hiding this comment

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

pTemporalImUsing->LetGo(); may be better.

@TaranDahl
Copy link
Contributor

Btw, I once investigated these attributes that might need to be adjusted during conversion. If you want to fully handle the problems caused by conversion, this might be helpful to you. TaranDahl@c94c168
iirc I checked CTOR, Init, and Limbo before, but not Unlimbo.

@a851903106
Copy link
Contributor Author

Btw, I once investigated these attributes that might need to be adjusted during conversion. If you want to fully handle the problems caused by conversion, this might be helpful to you. TaranDahl@c94c168 iirc I checked CTOR, Init, and Limbo before, but not Unlimbo.

Hmmm ...... I shouldn't need to transform the building.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Interaction Something related to interaction with other extension, program etc. Minor Documentation is not required Needs testing ❓Phobos bug Something isn't working properly ⚙️T2 T2 maintainer review is sufficient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants