| 103 | } |
| 104 | |
| 105 | void IGameController::EvaluateSpawnType(CSpawnEval *pEval, ESpawnType SpawnType, int ClientId) |
| 106 | { |
| 107 | const bool PlayerCollision = GameServer()->GlobalTuning()->m_PlayerCollision; |
| 108 | |
| 109 | bool PlayerCollisionDisabled = false; |
| 110 | CCharacter *pPlayerCharacter = GameServer()->GetPlayerChar(ClientId); |
| 111 | if(pPlayerCharacter) |
| 112 | PlayerCollisionDisabled = pPlayerCharacter->GetCore().m_CollisionDisabled; |
| 113 | |
| 114 | // make sure players keep spawning at the same tile |
| 115 | // on race maps no matter what |
| 116 | if(!PlayerCollision && pEval->m_Got) |
| 117 | return; |
| 118 | |
| 119 | // j == 0: Find an empty slot, j == 1: Take any slot if no empty one found |
| 120 | for(int j = 0; j < 2; j++) |
| 121 | { |
| 122 | // get spawn point |
| 123 | for(const vec2 &SpawnPoint : m_avSpawnPoints[SpawnType]) |
| 124 | { |
| 125 | vec2 P = SpawnPoint; |
| 126 | if(j == 0) |
| 127 | { |
| 128 | // check if the position is occupado |
| 129 | CEntity *apEnts[MAX_CLIENTS]; |
| 130 | int Num = GameServer()->m_World.FindEntities(SpawnPoint, 64, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); |
| 131 | vec2 aPositions[5] = {vec2(0.0f, 0.0f), vec2(-32.0f, 0.0f), vec2(0.0f, -32.0f), vec2(32.0f, 0.0f), vec2(0.0f, 32.0f)}; // start, left, up, right, down |
| 132 | int Result = -1; |
| 133 | for(int Index = 0; Index < 5 && Result == -1; ++Index) |
| 134 | { |
| 135 | Result = Index; |
| 136 | if(!PlayerCollision || PlayerCollisionDisabled) |
| 137 | break; |
| 138 | for(int c = 0; c < Num; ++c) |
| 139 | { |
| 140 | CCharacter *pChr = static_cast<CCharacter *>(apEnts[c]); |
| 141 | const bool CanCollide = pChr->CanCollide(ClientId) && !pChr->GetCore().m_CollisionDisabled; |
| 142 | |
| 143 | if(GameServer()->Collision()->CheckPoint(SpawnPoint + aPositions[Index]) || |
| 144 | (CanCollide && distance(pChr->m_Pos, SpawnPoint + aPositions[Index]) <= pChr->GetProximityRadius())) |
| 145 | { |
| 146 | Result = -1; |
| 147 | break; |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | if(Result == -1) |
| 152 | continue; // try next spawn point |
| 153 | |
| 154 | P += aPositions[Result]; |
| 155 | } |
| 156 | |
| 157 | float S = EvaluateSpawnPos(pEval, P, ClientId); |
| 158 | if(!pEval->m_Got || (j == 0 && pEval->m_Score > S)) |
| 159 | { |
| 160 | pEval->m_Got = true; |
| 161 | pEval->m_Score = S; |
| 162 | pEval->m_Pos = P; |
nothing calls this directly
no test coverage detected