MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / FindUnit

Method FindUnit

engine/Poseidon/UI/Map/UIMapMain.cpp:1659–1689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1657}
1658
1659void CStaticMapMain::FindUnit(AICenter* center, Vector3Par pt, SignInfo& info, float& minDist)
1660{
1661 if (!center)
1662 {
1663 return;
1664 }
1665
1666 for (int i = 0; i < center->NGroups(); i++)
1667 {
1668 AIGroup* grp = center->GetGroup(i);
1669 if (!grp)
1670 {
1671 continue;
1672 }
1673 for (int j = 0; j < MAX_UNITS_PER_GROUP; j++)
1674 {
1675 AIUnit* unit = grp->UnitWithID(j + 1);
1676 if (!unit)
1677 {
1678 continue;
1679 }
1680 float dist = (pt - unit->Position()).SquareSizeXZ();
1681 if (dist < minDist)
1682 {
1683 minDist = dist;
1684 info._type = signUnit;
1685 info._unit = unit;
1686 }
1687 }
1688 }
1689}
1690
1691void CStaticMapMain::FindWaypoint(AICenter* myCenter, AIGroup* myGroup, Vector3Par pt, SignInfo& info, float& minDist)
1692{

Callers 3

OnCreateCtrlMethod · 0.45
DrawExtMethod · 0.45
OnLButtonClickMethod · 0.45

Calls 5

NGroupsMethod · 0.80
UnitWithIDMethod · 0.80
GetGroupMethod · 0.45
SquareSizeXZMethod · 0.45
PositionMethod · 0.45

Tested by

no test coverage detected