| 55 | } |
| 56 | |
| 57 | void CDragger::LookForPlayersToDrag() |
| 58 | { |
| 59 | // Create a list of players who are in the range of the dragger |
| 60 | CEntity *apPlayersInRange[MAX_CLIENTS]; |
| 61 | std::fill(std::begin(apPlayersInRange), std::end(apPlayersInRange), nullptr); |
| 62 | |
| 63 | int NumPlayersInRange = GameServer()->m_World.FindEntities(m_Pos, |
| 64 | g_Config.m_SvDraggerRange - CCharacterCore::PhysicalSize(), |
| 65 | apPlayersInRange, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); |
| 66 | |
| 67 | // The closest player (within range) in a team is selected as the target |
| 68 | int aClosestTargetIdInTeam[MAX_CLIENTS]; |
| 69 | bool aCanStillBeTeamTarget[MAX_CLIENTS]; |
| 70 | bool aIsTarget[MAX_CLIENTS]; |
| 71 | int aMinDistInTeam[MAX_CLIENTS]; |
| 72 | std::fill(std::begin(aCanStillBeTeamTarget), std::end(aCanStillBeTeamTarget), false); |
| 73 | std::fill(std::begin(aMinDistInTeam), std::end(aMinDistInTeam), 0); |
| 74 | std::fill(std::begin(aIsTarget), std::end(aIsTarget), false); |
| 75 | std::fill(std::begin(aClosestTargetIdInTeam), std::end(aClosestTargetIdInTeam), -1); |
| 76 | |
| 77 | for(int i = 0; i < NumPlayersInRange; i++) |
| 78 | { |
| 79 | CCharacter *pTarget = static_cast<CCharacter *>(apPlayersInRange[i]); |
| 80 | const int &TargetTeam = pTarget->Team(); |
| 81 | |
| 82 | // Do not create a dragger beam for super player |
| 83 | if(TargetTeam == TEAM_SUPER) |
| 84 | { |
| 85 | continue; |
| 86 | } |
| 87 | // If the dragger is disabled for the target's team, no dragger beam will be generated |
| 88 | if(m_Layer == LAYER_SWITCH && m_Number > 0 && |
| 89 | !Switchers()[m_Number].m_aStatus[TargetTeam]) |
| 90 | { |
| 91 | continue; |
| 92 | } |
| 93 | |
| 94 | // Dragger beams can be created only for reachable, alive players |
| 95 | int IsReachable = |
| 96 | m_IgnoreWalls ? |
| 97 | !GameServer()->Collision()->IntersectNoLaserNoWalls(m_Pos, pTarget->m_Pos, nullptr, nullptr) : |
| 98 | !GameServer()->Collision()->IntersectNoLaser(m_Pos, pTarget->m_Pos, nullptr, nullptr); |
| 99 | if(IsReachable && pTarget->IsAlive()) |
| 100 | { |
| 101 | const int &TargetClientId = pTarget->GetPlayer()->GetCid(); |
| 102 | // Solo players are dragged independently from the rest of the team |
| 103 | if(pTarget->Teams()->m_Core.GetSolo(TargetClientId)) |
| 104 | { |
| 105 | aIsTarget[TargetClientId] = true; |
| 106 | } |
| 107 | else |
| 108 | { |
| 109 | int Distance = distance(pTarget->m_Pos, m_Pos); |
| 110 | if(aMinDistInTeam[TargetTeam] == 0 || aMinDistInTeam[TargetTeam] > Distance) |
| 111 | { |
| 112 | aMinDistInTeam[TargetTeam] = Distance; |
| 113 | aClosestTargetIdInTeam[TargetTeam] = TargetClientId; |
| 114 | } |
nothing calls this directly
no test coverage detected