// combine complete escort list with Escort_ships, keeping valid hit info void merge_escort_lists(escort_info *complete_escorts, int num_complete_escorts) { int i, j, top_complete_escorts; int valid_hit_info[MAX_COMPLETE_ESCORT_LIST]; // may be > 1 ship change to list (ie, 2 or 3 culled during same frame) // set Num_escort_ships and cap Num_escort_ships = num_complete_escorts; if (Num_escort_ships > Max_escort_ships) { Num_escort_ships = Max_escort_ships; } // nothing to do if (Num_escort_ships == 0) { return; } // check used as a flag whether top slots in complete_escorts were copied // this is important re. hit info for (i=0; i<Max_escort_ships; i++) { valid_hit_info[i] = 0; } // get the top slots in complete escort list that will be copied onto Escort_ships top_complete_escorts = num_complete_escorts; if (top_complete_escorts > Max_escort_ships) { top_complete_escorts = Max_escort_ships; } // copy for Escort_ships to complete_escorts to retain hit_info if(!((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT))) { for (i=0; i<top_complete_escorts; i++) { for (j=0; j<Num_escort_ships; j++) { if (Escort_ships[j].obj_signature == complete_escorts[i].obj_signature) { complete_escorts[i] = Escort_ships[j]; valid_hit_info[i] = 1; break; } } } // copy top slots to Escort_ships for (i=0; i<top_complete_escorts; i++) { Escort_ships[i] = complete_escorts[i]; // check all ships are valid int objnum = Escort_ships[i].objnum; Assert( objnum >=0 && objnum < MAX_OBJECTS ); if((objnum < 0) || (objnum >= MAX_OBJECTS)){ continue; } if ( !valid_hit_info[i] ) { shield_info_reset(&Escort_ships[i].hit_info); } } } // reset Num_escort_ships Num_escort_ships = top_complete_escorts; }
// ---------------------------------------------------------------------- // hud_escort_clear_all() // void hud_escort_clear_all() { int i; Num_escort_ships = 0; for ( i = 0; i < Max_escort_ships; i++ ) { Escort_ships[i].obj_signature = -99; Escort_ships[i].np_id = -1; shield_info_reset(&Escort_ships[i].hit_info); } }
// reset the timers and hit flags for the shield gauges // // This needs to be called whenever the player selects a new target // // input: player => optional parameter (default value 0). This is to indicate that player shield hit // info should be reset. This is normally not the case. // is for the player's current target void hud_shield_hit_reset(object *objp, int player) { shield_hit_info *shi; if (player) { shi = &Shield_hit_data[SHIELD_HIT_PLAYER]; } else { shi = &Shield_hit_data[SHIELD_HIT_TARGET]; } shield_info_reset(objp, shi); }