int Player_GetSlot(char *arg) { int response; // Try getting the slot by name or id. if ((response = Player_StringtoSlot(arg)) >= 0 ) //|| response == PLAYER_ID_NOMATCH) { return response; } // We didn't find any player or ID that matched // so we'll try treating it as the players // sorted position. if (arg[0] != '#') { return response; } if ((response = Player_NumtoSlot(Q_atoi(arg + 1))) >= 0) { return response; } return PLAYER_NUM_NOMATCH; }
void CL_TrackTeam_f(void) { int i, teamchoice, team_slot_count = 0; if (cls.state < ca_connected) { Com_Printf("You must be connected to track\n", Cmd_Argv(0)); return; } if (!cl.spectator) { Com_Printf("You can only track in spectator mode\n", Cmd_Argv(0)); return; } if (Cmd_Argc() != 2) { Com_Printf("Usage: %s < 1 | 2 >\n", Cmd_Argv(0)); return; } // Get the team. teamchoice = atoi(Cmd_Args()); if(!currteam[0]) { // Find the the first team. for(i = 0; i < MAX_CLIENTS; i++) { if(VALID_PLAYER(i) && strcmp(currteam, cl.players[i].team) != 0) { strlcpy(currteam, cl.players[i].team, sizeof(currteam)); break; } } } // Find the team members. for(i = 0; i < MAX_CLIENTS; i++) { // Find the player slot to track. if(!cl.players[i].spectator && strcmp(cl.players[i].name, "") && teamchoice == 1 && !strcmp(currteam, cl.players[i].team)) { mv_trackslots[team_slot_count] = Player_StringtoSlot (cl.players[i].name); team_slot_count++; } else if(!cl.players[i].spectator && strcmp(cl.players[i].name, "") && teamchoice == 2 && strcmp(currteam, cl.players[i].team)) { mv_trackslots[team_slot_count] = Player_StringtoSlot (cl.players[i].name); team_slot_count++; } // Don't go out of bounds in the mv_trackslots array. if(team_slot_count == 4) { break; } } cl_multiview.value = team_slot_count; }