Find flat role index for given side and 1-based slot number Returns -1 if not found, -2 if slot is occupied by another human
| 65 | } |
| 66 | |
| 67 | // Find flat role index for given side and 1-based slot number |
| 68 | // Returns -1 if not found, -2 if slot is occupied by another human |
| 69 | static int FindRoleForAssign(TargetSide side, int slot, int myPlayer) |
| 70 | { |
| 71 | int sideCount = 0; |
| 72 | for (int i = 0; i < GetNetworkManager().NPlayerRoles(); i++) |
| 73 | { |
| 74 | const PlayerRole* role = GetNetworkManager().GetPlayerRole(i); |
| 75 | if (!role || role->side != side) |
| 76 | continue; |
| 77 | sideCount++; |
| 78 | if (sideCount == slot) |
| 79 | { |
| 80 | if (role->player != NO_PLAYER && role->player != AI_PLAYER && role->player != myPlayer) |
| 81 | return -2; // occupied |
| 82 | return i; |
| 83 | } |
| 84 | } |
| 85 | return -1; // slot doesn't exist |
| 86 | } |
| 87 |
no test coverage detected