-
-
Notifications
You must be signed in to change notification settings - Fork 103
[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
base: develop
Are you sure you want to change the base?
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. |
A topic that I think might need to be discussed: Is it necessary to forcefully clear its corresponding state? |
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. |
Well, I wrote a new tag to make it less obligatory. |
There was a problem hiding this 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)
src/Ext/Techno/Body.Update.cpp
Outdated
pFirstPassenger->Transporter = pFoot; | ||
|
||
if (pFirstPassenger->NextObject) | ||
pFirstPassenger = abstract_cast<FootClass*>(pFirstPassenger->NextObject); |
There was a problem hiding this comment.
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;
src/Ext/Techno/Body.cpp
Outdated
if (pType->Strength == pToType->Strength) | ||
pThis->Health = oldHealth; |
There was a problem hiding this comment.
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);
src/Ext/Techno/Body.cpp
Outdated
if (pType == pToType || | ||
pType->WhatAmI() != pToType->WhatAmI()) | ||
{ | ||
Debug::Log("Incompatible types between %s and %s\n", pThis->get_ID(), pToType->get_ID()); | ||
return false; | ||
} |
There was a problem hiding this 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 if Ares has already prompted this message?
src/Ext/Techno/Body.Update.cpp
Outdated
{ | ||
const auto pSlave = pSlaveNode->Slave; | ||
|
||
if (pSlave && pSlaveNode->State != SlaveControlStatus::Dead) |
There was a problem hiding this comment.
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
.
src/Ext/Techno/Body.Update.cpp
Outdated
{ | ||
pSlave->RegisterDestruction(pThis); | ||
pSlave->UnInit(); | ||
pSlaveManager->LostSlave(pSlave); |
There was a problem hiding this comment.
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.
src/Ext/Techno/Body.Update.cpp
Outdated
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); | ||
} |
There was a problem hiding this comment.
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.
src/Ext/Techno/Body.Update.cpp
Outdated
{ | ||
if (!pSpawnManager || pType->Spawns != pSpawnManager->SpawnType) | ||
{ | ||
if (pSpawnManager && pType->Spawns != pSpawnManager->SpawnType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (pSpawnManager)
src/Ext/Techno/Body.Update.cpp
Outdated
{ | ||
if (!pSlaveManager || pSlaveManager->SlaveType != pType->Enslaves) | ||
{ | ||
if (pSlaveManager && pSlaveManager->SlaveType != pType->Enslaves) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (pSlaveManager)
src/Ext/Techno/Body.Update.cpp
Outdated
} | ||
} | ||
|
||
auto& pAirstrike = pThis->Airstrike; |
There was a problem hiding this comment.
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.
src/Ext/Techno/Body.Update.cpp
Outdated
else if (pTemporalImUsing) | ||
{ | ||
if (pTemporalImUsing->Target) | ||
pTemporalImUsing->Detach(); |
There was a problem hiding this comment.
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.
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 |
Hmmm ...... I shouldn't need to transform the building. |
After the conversion, the unit may lose the manager or retain some unnecessary ones. now they have been repaired.
In
rulesmd.ini
:Convert.ResetMindControl=no
and there are no warheads in the unit that useMindControl=yes
, then the controlled units that exceed the maximum value will be released.单位在变形后会丢失管理器或是留下一些不需要的管理器,现在它们被修复了。
In
rulesmd.ini
:Convert.ResetMindControl=no
且单位没有任何使用了MindControl=yes
的弹头,那么超出最大值的被控制单位会得到解放。