int hotkey_build_team_listing(int enemy_team_mask, int y, bool list_enemies) { ship_obj *so; const char *str = NULL; int i, j, s, z, start, team_mask; int font_height = gr_get_font_height(); if (list_enemies) { str = XSTR( "Enemy ships", 403); team_mask = enemy_team_mask; } else { str = XSTR( "Friendly ships", 402); team_mask = ~enemy_team_mask; } for (i=0; i<MAX_SHIPS; i++) if (iff_matches_mask(Ships[i].team, team_mask)) break; if (i >= MAX_SHIPS) return y; hotkey_line_add(str, HOTKEY_LINE_HEADING, 0, y); y += 2; start = Num_lines; for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) { int shipnum; // don't process non-ships, or the player ship if ( (Game_mode & GM_NORMAL) && (so->objnum == OBJ_INDEX(Player_obj)) ) continue; shipnum = Objects[so->objnum].instance; // filter out cargo containers, navbouys, etc, and non-ships if ( Ship_info[Ships[shipnum].ship_info_index].class_type < 0 || !(Ship_types[Ship_info[Ships[shipnum].ship_info_index].class_type].hud_bools & STI_HUD_HOTKEY_ON_LIST )) continue; // don't process ships invisible to sensors, dying or departing if ( Ships[shipnum].flags & (SF_HIDDEN_FROM_SENSORS|SF_DYING|SF_DEPARTING) ) continue; // if a ship's hotkey is the last hotkey on the list, then maybe make the hotkey -1 if // we are now in mission. Otherwise, skip this ship if ( Ships[shipnum].hotkey == MAX_KEYED_TARGETS ) { if ( !(Game_mode & GM_IN_MISSION) ) continue; // skip to next ship Ships[shipnum].hotkey = -1; } // be sure this ship isn't in a wing, and that the teams match if ( iff_matches_mask(Ships[shipnum].team, team_mask) && (Ships[shipnum].wingnum < 0) ) { hotkey_line_add_sorted(Ships[shipnum].ship_name, HOTKEY_LINE_SHIP, shipnum, start); } } for (i=0; i<Num_wings; i++) { if (Wings[i].current_count && (Wings[i].ship_index[Wings[i].special_ship] >= 0) && iff_matches_mask(Ships[Wings[i].ship_index[Wings[i].special_ship]].team, team_mask)) { // special check for the player's wing. If he's in a wing, and the only guy left, don't // do anything if ( (Player_ship->wingnum == i) && (Wings[i].current_count == 1) ) continue; // if a ship's hotkey is the last hotkey on the list, then maybe make the hotkey -1 if // we are now in mission. Otherwise, skip this ship if ( Wings[i].hotkey == MAX_KEYED_TARGETS ) { if ( !(Game_mode & GM_IN_MISSION) ) continue; // skip to next ship Wings[i].hotkey = -1; } // don't add any wing data whose ships are hidden from sensors for ( j = 0; j < Wings[i].current_count; j++ ) { if ( Ships[Wings[i].ship_index[j]].flags & SF_HIDDEN_FROM_SENSORS ) break; } // if we didn't reach the end of the list, don't display the wing if ( j < Wings[i].current_count ) continue; z = hotkey_line_add_sorted(Wings[i].name, HOTKEY_LINE_WING, i, start); if (Wings[i].flags & WF_EXPANDED) { for (j=0; j<Wings[i].current_count; j++) { s = Wings[i].ship_index[j]; z = hotkey_line_insert(z + 1, Ships[s].ship_name, HOTKEY_LINE_SUBSHIP, s); } } } } for (i=start; i<Num_lines; i++) { if (Hotkey_lines[i].type == HOTKEY_LINE_SUBSHIP) y += font_height; else y += font_height + 2; Hotkey_lines[i].y = y; } y += font_height + 8; return y; }
int hotkey_build_team_listing(int team, int y) { ship_obj *so; char *str = NULL; int i, j, s, z, start; int font_height = gr_get_font_height(); for (i=0; i<MAX_SHIPS; i++) if (hotkey_get_team(i) == team) break; if (i >= MAX_SHIPS) return y; if (team == Player_ship->team) str = XSTR( "Friendly ships", 402); else { str = XSTR( "Enemy ships", 403); } hotkey_line_add(str, HOTKEY_LINE_HEADING, 0, y); y += 2; start = Num_lines; // next loop used to loop through max ships, comparing team values. MWA changed this to iterate // through object list. Seemed safer since it doesn't rely on the team value getting reset to // a bogus value between missions //for (i=0; i<MAX_SHIPS; i++) { // if ((Ships[i].team == team) && (Ships[i].wingnum < 0)) { // hotkey_line_add_sorted(Ships[i].ship_name, HOTKEY_LINE_SHIP, i, start); // } for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) { int shipnum; // don't process non-ships, or the player ship if ( (Game_mode & GM_NORMAL) && (so->objnum == OBJ_INDEX(Player_obj)) ) continue; shipnum = Objects[so->objnum].instance; // filter out cargo containers, navbouys, etc if ( (Ship_info[Ships[shipnum].ship_info_index].flags & SIF_HARMLESS) && !(Ship_info[Ships[shipnum].ship_info_index].flags & SIF_ESCAPEPOD) ) continue; // don't process non-ships (dunno what that would be, though). if (Ship_info[Ships[shipnum].ship_info_index].flags & SIF_NO_SHIP_TYPE) continue; // don't process ships invisible to sensors, dying or departing if ( Ships[shipnum].flags & (SF_HIDDEN_FROM_SENSORS|SF_DYING|SF_DEPARTING) ) continue; // if a ship's hotkey is the last hotkey on the list, then maybe make the hotkey -1 if // we are now in mission. Otherwise, skip this ship if ( Ships[shipnum].hotkey == MAX_KEYED_TARGETS ) { if ( !(Game_mode & GM_IN_MISSION) ) continue; // skip to next ship Ships[shipnum].hotkey = -1; } // be sure this ship isn't in a wing, and that the teams match if ( (hotkey_get_team(shipnum) == team) && (Ships[shipnum].wingnum < 0) ) { hotkey_line_add_sorted(Ships[shipnum].ship_name, HOTKEY_LINE_SHIP, shipnum, start); } } for (i=0; i<num_wings; i++) { if (Wings[i].current_count && (hotkey_get_team( Wings[i].ship_index[Wings[i].special_ship] ) == team)) { // special check for the player's wing. If he's in a wing, and the only guy left, don't // do anything if ( (Player_ship->wingnum == i) && (Wings[i].current_count == 1) ) continue; // if a ship's hotkey is the last hotkey on the list, then maybe make the hotkey -1 if // we are now in mission. Otherwise, skip this ship if ( Wings[i].hotkey == MAX_KEYED_TARGETS ) { if ( !(Game_mode & GM_IN_MISSION) ) continue; // skip to next ship Wings[i].hotkey = -1; } // don't add any wing data whose ships are hidden from sensors for ( j = 0; j < Wings[i].current_count; j++ ) { if ( Ships[Wings[i].ship_index[j]].flags & SF_HIDDEN_FROM_SENSORS ) break; } // if we didn't reach the end of the list, don't display the wing if ( j < Wings[i].current_count ) continue; z = hotkey_line_add_sorted(Wings[i].name, HOTKEY_LINE_WING, i, start); if (Wings[i].flags & WF_EXPANDED) { for (j=0; j<Wings[i].current_count; j++) { s = Wings[i].ship_index[j]; z = hotkey_line_insert(z + 1, Ships[s].ship_name, HOTKEY_LINE_SUBSHIP, s); } } } } z = HOTKEY_LINE_HEADING; for (i=start; i<Num_lines; i++) { if (Hotkey_lines[i].type == HOTKEY_LINE_SUBSHIP) y += font_height; else y += font_height + 2; Hotkey_lines[i].y = y; } y += font_height + 8; return y; }