Checks if vehicle can deploy into a building at its current location. If unit has no DeploysInto set returns noDeploysIntoDefaultValue (def = false) instead.
| 424 | |
| 425 | // Checks if vehicle can deploy into a building at its current location. If unit has no DeploysInto set returns noDeploysIntoDefaultValue (def = false) instead. |
| 426 | bool TechnoExt::CanDeployIntoBuilding(UnitClass* pThis, bool noDeploysIntoDefaultValue) |
| 427 | { |
| 428 | if (!pThis) |
| 429 | return false; |
| 430 | |
| 431 | auto const pDeployType = pThis->Type->DeploysInto; |
| 432 | |
| 433 | if (!pDeployType) |
| 434 | return noDeploysIntoDefaultValue; |
| 435 | |
| 436 | auto mapCoords = CellClass::Coord2Cell(pThis->GetCoords()); |
| 437 | |
| 438 | if (pDeployType->GetFoundationWidth() > 2 || pDeployType->GetFoundationHeight(false) > 2) |
| 439 | mapCoords += CellStruct { -1, -1 }; |
| 440 | |
| 441 | // The vanilla game used an inappropriate approach here, resulting in potential risk of desync. |
| 442 | // Now, through additional checks, we can directly exclude the unit who want to deploy. |
| 443 | TechnoExt::Deployer = pThis; |
| 444 | const bool canDeploy = pDeployType->CanCreateHere(mapCoords, pThis->Owner); |
| 445 | TechnoExt::Deployer = nullptr; |
| 446 | |
| 447 | return canDeploy; |
| 448 | } |
| 449 | |
| 450 | bool TechnoExt::IsTypeImmune(TechnoClass* pThis, TechnoClass* pSource) |
| 451 | { |
nothing calls this directly
no outgoing calls
no test coverage detected