// build a list of respawn points for the mission void multi_respawn_build_points() { ship_obj *moveup; respawn_point *r; // respawn points Multi_respawn_point_count = 0; Multi_next_respawn_point = 0; moveup = GET_FIRST(&Ship_obj_list); while(moveup != END_OF_LIST(&Ship_obj_list)){ // player ships if(Objects[moveup->objnum].flags & (OF_PLAYER_SHIP | OF_COULD_BE_PLAYER)){ r = &Multi_respawn_points[Multi_respawn_point_count++]; r->pos = Objects[moveup->objnum].pos; r->team = Ships[Objects[moveup->objnum].instance].team; } moveup = GET_NEXT(moveup); } // priority respawn points Multi_respawn_priority_count = 0; moveup = GET_FIRST(&Ship_obj_list); while(moveup != END_OF_LIST(&Ship_obj_list)){ // stuff info if((Ships[Objects[moveup->objnum].instance].respawn_priority > 0) && (Multi_respawn_priority_count < MAX_PRIORITY_POINTS)){ r = &Multi_respawn_priority_ships[Multi_respawn_priority_count++]; strcpy(r->ship_name, Ships[Objects[moveup->objnum].instance].ship_name); r->team = Ships[Objects[moveup->objnum].instance].team; } moveup = GET_NEXT(moveup); } }
//-------------------------------------------------------------------------- // Name AddIdentToHash // // Adds an identifier to the list, keeping the list sorted by scope nesting // level. Higher nesting levels are at start of list, smaller at the end. // // Note: for debugging purposes we make sure that there is no already inserted // ident with the same scope nesting. //-------------------------------------------------------------------------- static void AddIdentToHash ( TListRoot * pList, TLocalIdent * pIdent ) { int identLevel; // nesting level of the ident being added TLocalIdent * pCur; identLevel = pIdent->parentScope->level; // Skip all idents with greater scope nesting // for ( pCur = (TLocalIdent *)pList->Flink; !END_OF_LIST( pList, pCur ) && pCur->parentScope->level > identLevel; pCur = (TLocalIdent *)pCur->nameLink.Flink ) {}; ASSERT( END_OF_LIST( pList, pCur ) || pCur->parentScope->level < identLevel ); // they can't be equal // Insert before _pCur_ // INSERT_TAIL_LIST( &pCur->nameLink, &pIdent->nameLink ); };
//-------------------------------------------------------------------------- // Name FindScopeIdent // // Finds an ident with this name and specified scope. //-------------------------------------------------------------------------- TLocalIdent * _FindScopeIdent ( TListRoot * pTab, TScope * pScope ) { TLocalIdent * pCur; int scopeLevel; scopeLevel = pScope->level; // Iterate through all symbols. The scopes are ordered decreasingly. // So, as soon as we reach a smaller scope, we can abort the search. // for ( pCur = (TLocalIdent *)pTab->Flink; !END_OF_LIST( pTab, pCur ); pCur = (TLocalIdent *)pCur->nameLink.Flink ) { int lev; ASSERT( pCur->parentScope ); lev = pCur->parentScope->level; if (lev == scopeLevel) { ASSERT( pCur->parentScope == pScope ); return pCur; } else if (lev < scopeLevel) break; } return NULL; };
// Update the status of the wingman status void hud_wingman_status_update() { if ( timestamp_elapsed(HUD_wingman_update_timer) ) { int wing_index,wing_pos; ship_obj *so; object *ship_objp; ship *shipp; HUD_wingman_update_timer=timestamp(HUD_WINGMAN_UPDATE_STATUS_INTERVAL); for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) { ship_objp = &Objects[so->objnum]; shipp = &Ships[ship_objp->instance]; wing_index = shipp->wing_status_wing_index; wing_pos = shipp->wing_status_wing_pos; if ( (wing_index >= 0) && (wing_pos >= 0) && !(ship_objp->flags & OF_SHOULD_BE_DEAD) ) { HUD_wingman_status[wing_index].used = 1; if (!(shipp->flags & SF_DEPARTING) ) { HUD_wingman_status[wing_index].status[wing_pos] = HUD_WINGMAN_STATUS_ALIVE; } HUD_wingman_status[wing_index].hull[wing_pos] = get_hull_pct(ship_objp); if ( HUD_wingman_status[wing_index].hull[wing_pos] <= 0 ) { HUD_wingman_status[wing_index].status[wing_pos] = HUD_WINGMAN_STATUS_DEAD; } } } } }
void camera::set_object_host(object *objp, int n_object_host_submodel) { if(objp == NULL) object_host = object_h(); object_host = object_h(objp); object_host_submodel = n_object_host_submodel; set_custom_position_function(NULL); set_custom_orientation_function(NULL); if(n_object_host_submodel > 0) { if(objp->type == OBJ_SHIP) { ship_subsys* ssp = GET_FIRST(&Ships[objp->instance].subsys_list); while ( ssp != END_OF_LIST( &Ships[objp->instance].subsys_list ) ) { if(ssp->system_info->subobj_num == n_object_host_submodel) { if(ssp->system_info->type == SUBSYSTEM_TURRET) { set_custom_position_function(get_turret_cam_pos); set_custom_orientation_function(get_turret_cam_orient); } } ssp = GET_NEXT( ssp ); } } } }
void red_alert_bash_subsys_status(red_alert_ship_status *ras, ship *shipp) { ship_subsys *ss; int i, count = 0; int list_size; // restore from ship_exited if ( (ras->ship_class == RED_ALERT_DESTROYED_SHIP_CLASS) || (ras->ship_class == RED_ALERT_PLAYER_DEL_SHIP_CLASS) ) { return; } ss = GET_FIRST(&shipp->subsys_list); while ( ss != END_OF_LIST( &shipp->subsys_list ) ) { // using at() here for the bounds check, although out-of-bounds should // probably never happen here try { ss->current_hits = ras->subsys_current_hits.at(count); } catch (std::out_of_range range) { break; } if (ss->current_hits <= 0) { ss->submodel_info_1.blown_off = 1; } ss = GET_NEXT( ss ); count++; } list_size = (int)ras->subsys_aggregate_current_hits.size(); CLAMP(list_size, 0, SUBSYSTEM_MAX); for (i = 0; i < list_size; i++) { shipp->subsys_info[i].aggregate_current_hits = ras->subsys_aggregate_current_hits[i]; } }
void WeaponEditorDlg::update_pilot() { int i; object *ptr; ship_weapon *weapon; if (m_multi_edit) { ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) && (ptr->flags[Object::Object_Flags::Marked])) { weapon = &Ships[ptr->instance].weapons; if (pilot.ai_class >= 0) weapon->ai_class = pilot.ai_class; for (i=0; i<MAX_SHIP_PRIMARY_BANKS; i++) if (pilot.primary_bank_weapons[i] != -2) weapon->primary_bank_weapons[i] = pilot.primary_bank_weapons[i]; for (i=0; i<MAX_SHIP_SECONDARY_BANKS; i++) { if (pilot.secondary_bank_weapons[i] != -2) weapon->secondary_bank_weapons[i] = pilot.secondary_bank_weapons[i]; if (pilot.secondary_bank_ammo[i] >= 0) weapon->secondary_bank_ammo[i] = pilot.secondary_bank_ammo[i]; } } ptr = GET_NEXT(ptr); } } }
// recvfrom for multilag int multi_lag_recvfrom(uint s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen) { lag_buf *moveup = NULL; lag_buf *item = NULL; // now determine if we have any pending packets - find the first one moveup=GET_FIRST(&Lag_used_list); while ( moveup!=END_OF_LIST(&Lag_used_list) ) { // if the timestamp has elapsed if((s == (SOCKET)moveup->socket) && ((moveup->stamp <= 0) || timestamp_elapsed(moveup->stamp))){ item = moveup; break; } moveup = GET_NEXT(moveup); } // if this happens, it means that the multi_lag_select() returned an improper value Assert(item); // stuff the data Assert(item->data_len <= len); memcpy(buf, item->data, item->data_len); Assertion(Tcp_active, "multi_lag_recvfrom(): TCP/IP is not active!"); memcpy(from, &item->ip_addr, sizeof(SOCKADDR_IN)); // stick the item back on the free list multi_lag_put_free(item); // return the size in bytes return item->data_len; }
void ship_select::OnOK() { int i; object *ptr; unmark_all(); update_status(); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->flags & OF_TEMP_MARKED) mark_object(OBJ_INDEX(ptr)); ptr = GET_NEXT(ptr); } if (query_valid_object() && (Marked == 1) && (Objects[cur_object_index].type == OBJ_POINT)) { Assert(Briefing_dialog); Briefing_dialog->icon_select(Objects[cur_object_index].instance); } else { if (Briefing_dialog) Briefing_dialog->icon_select(-1); } filter_ships = m_filter_ships; filter_starts = m_filter_starts; filter_waypoints = m_filter_waypoints; for (i = 0; i < MAX_IFFS; i++) filter_iff[i] = m_filter_iff[i]; CDialog::OnOK(); }
void ship_select::OnOK() { object *ptr; unmark_all(); update_status(); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->flags & OF_TEMP_MARKED) mark_object(OBJ_INDEX(ptr)); ptr = GET_NEXT(ptr); } if (query_valid_object() && (Marked == 1) && (Objects[cur_object_index].type == OBJ_POINT)) { Assert(Briefing_dialog); Briefing_dialog->icon_select(Objects[cur_object_index].instance); } else { if (Briefing_dialog) Briefing_dialog->icon_select(-1); } filter_ships = m_filter_ships; filter_starts = m_filter_starts; filter_waypoints = m_filter_waypoints; filter_friendly = m_filter_friendly; filter_hostile = m_filter_hostile; filter_neutral = m_filter_neutral; filter_unknown = m_filter_unknown; CDialog::OnOK(); }
BOOL ShipSpecialDamage::OnInitDialog() { // TODO: Add extra initialization here // get ship num object *objp; m_ship_num = -1; objp = GET_FIRST(&obj_used_list); while (objp != END_OF_LIST(&obj_used_list)) { if ((objp->type == OBJ_START) || (objp->type == OBJ_SHIP)) { if (objp->flags & OF_MARKED) { m_ship_num = objp->instance; break; } } objp = GET_NEXT(objp); } if (Ships[m_ship_num].special_exp_index == -1) { // get default_table_values ship_info *sip; sip = &Ship_info[Ships[m_ship_num].ship_info_index]; m_inner_rad = (int)sip->inner_rad; m_outer_rad = (int)sip->outer_rad; m_damage = (int) sip->damage; m_blast = (int) sip->blast; m_shock_enabled = (int) sip->explosion_propagates; m_shock_speed = (int) sip->shockwave_speed; m_special_exp_enabled = FALSE; if (m_inner_rad < 10) m_inner_rad = 10; if (m_outer_rad < 11) m_outer_rad = 11; if (m_shock_speed < 10) m_shock_speed = 10; } else { int index = Ships[m_ship_num].special_exp_index; Assert( (index > 0) && (index < MAX_SEXP_VARIABLES-5) ); m_inner_rad = atoi(Sexp_variables[index++].text); m_outer_rad = atoi(Sexp_variables[index++].text); m_damage = atoi(Sexp_variables[index++].text); m_blast = atoi(Sexp_variables[index++].text); m_shock_enabled = atoi(Sexp_variables[index++].text); m_shock_speed = atoi(Sexp_variables[index++].text); m_special_exp_enabled = TRUE; } CDialog::OnInitDialog(); // maybe gray out lots of stuff DoGray(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL ship_select::OnInitDialog() { int i; object *ptr; CDialog::OnInitDialog(); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { ptr->flags.set(Object::Object_Flags::Temp_marked, ptr->flags[Object::Object_Flags::Marked]); ptr = GET_NEXT(ptr); } list_size = 0; create_list(); // init dialog stuff for (i = 0; i < MAX_IFFS; i++) { if (i < Num_iffs) { GetDlgItem(IDC_FILTER_SHIPS_IFF[i])->SetWindowText(Iff_info[i].iff_name); } GetDlgItem(IDC_FILTER_SHIPS_IFF[i])->ShowWindow(i < Num_iffs); } for (i = 0; i < Num_iffs; i++) GetDlgItem(IDC_FILTER_SHIPS_IFF[i])->EnableWindow(m_filter_ships); wlist_size = wplist_size = 0; wing_index.clear(); wing_sel_last.clear(); // Elements 0 - wlist_size are wings, and elements wlist_size - wplist_size are waypoint paths m_wing_list.ResetContent(); wlist_size = 0; for (i=0; i<MAX_WINGS; i++) { if (Wings[i].wave_count) { m_wing_list.AddString(Wings[i].name); wing_sel_last.push_back(0); wing_index.push_back(i); wlist_size++; } } wplist_size = wlist_size; SCP_list<waypoint_list>::iterator ii; for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii) { m_wing_list.AddString(ii->get_name()); wing_sel_last.push_back(0); wing_index.push_back(i); wplist_size++; } return TRUE; }
// Draw all the active radar blips void HudGaugeRadarOrb::drawBlips(int blip_type, int bright, int distort) { blip *b = NULL; blip *blip_head = NULL; vec3d pos; Assert((blip_type >= 0) && (blip_type < MAX_BLIP_TYPES)); // Need to set font. font::set_font(font::FONT1); // get the appropriate blip list if (bright) blip_head = &Blip_bright_list[blip_type]; else blip_head = &Blip_dim_list[blip_type]; // draw all blips of this type for (b = GET_FIRST(blip_head); b != END_OF_LIST(blip_head); b = GET_NEXT(b)) { gr_set_color_fast(b->blip_color); plotBlip(b, &pos); // maybe draw cool blip to indicate current target if (b->flags & BLIP_CURRENT_TARGET) { b->rad = Radar_blip_radius_target; target_position = pos; } else { b->rad = Radar_blip_radius_normal; } // maybe distort blip if (distort) { blipDrawDistorted(b, &pos); } else if (b->flags & BLIP_DRAW_DISTORTED) { blipDrawFlicker(b, &pos); } else { if (b->radar_image_2d >= 0 || b->radar_color_image_2d >= 0) { drawContactImage(&pos, b->rad, b->radar_image_2d, b->radar_color_image_2d, b->radar_projection_size); } else { drawContactHtl(&pos,b->rad); } } } }
// Try and find a new locking point void hud_lock_get_new_lock_pos(object *target_objp, vector *lock_world_pos) { ship *target_shipp=NULL; int lock_in_range=0; float best_lock_dot=-1.0f, lock_dot=-1.0f; ship_subsys *ss; vector subsys_world_pos, vec_to_lock; if ( target_objp->type == OBJ_SHIP ) { target_shipp = &Ships[target_objp->instance]; } // if a large ship, lock to pos closest to center and within range if ( (target_shipp) && (Ship_info[target_shipp->ship_info_index].flags & (SIF_BIG_SHIP|SIF_HUGE_SHIP)) ) { // check all the subsystems and the center of the ship // assume best lock pos is the center of the ship *lock_world_pos=target_objp->pos; Player->locking_on_center=1; Player->locking_subsys=NULL; Player->locking_subsys_parent=-1; lock_in_range = hud_lock_world_pos_in_range(lock_world_pos, &vec_to_lock); vm_vec_normalize(&vec_to_lock); if ( lock_in_range ) { best_lock_dot=vm_vec_dot(&Player_obj->orient.vec.fvec, &vec_to_lock); } // take center if reasonable dot if ( best_lock_dot > 0.95 ) { return; } // iterate through subsystems to see if we can get a better choice ss = GET_FIRST(&target_shipp->subsys_list); while ( ss != END_OF_LIST( &target_shipp->subsys_list ) ) { // get world pos of subsystem get_subsystem_world_pos(target_objp, ss, &subsys_world_pos); if ( hud_lock_world_pos_in_range(&subsys_world_pos, &vec_to_lock) ) { vm_vec_normalize(&vec_to_lock); lock_dot=vm_vec_dot(&Player_obj->orient.vec.fvec, &vec_to_lock); if ( lock_dot > best_lock_dot ) { best_lock_dot=lock_dot; Player->locking_on_center=0; Player->locking_subsys=ss; Player->locking_subsys_parent=Player_ai->target_objnum; *lock_world_pos=subsys_world_pos; } } ss = GET_NEXT( ss ); } } else { // if small ship (or weapon), just go for the center *lock_world_pos = target_objp->pos; Player->locking_on_center=1; Player->locking_subsys=NULL; Player->locking_subsys_parent=-1; } }
void hud_goto_pos(int delta) { int pos=0, font_height = gr_get_font_height(); if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) { int count = 0, y = 0; line_node *ptr; if (EMPTY(&Msg_scrollback_used_list) || !HUD_msg_inited) return; ptr = GET_FIRST(&Msg_scrollback_used_list); while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) { if (ptr->source != HUD_SOURCE_HIDDEN) { if (count == Scroll_offset) { pos = y; break; } y += font_height + ptr->y; count++; } ptr = GET_NEXT(ptr); } Scroll_offset = count = y = 0; ptr = GET_FIRST(&Msg_scrollback_used_list); while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) { if (ptr->source != HUD_SOURCE_HIDDEN) { if (y <= pos + delta) Scroll_offset = count; y += font_height + ptr->y; count++; } ptr = GET_NEXT(ptr); } } else { pos = Scroll_offset * font_height; pos += delta; Scroll_offset = pos / font_height; } }
BOOL ship_select::OnInitDialog() { int i, flags; object *ptr; wlist_size = wplist_size = 0; CDialog::OnInitDialog(); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { flags = ptr->flags & ~OF_TEMP_MARKED; if (flags & OF_MARKED) flags |= OF_TEMP_MARKED; else flags &= ~OF_TEMP_MARKED; ptr->flags = flags; ptr = GET_NEXT(ptr); } list_size = 0; create_list(); GetDlgItem(IDC_FILTER_SHIPS_FRIENDLY)->EnableWindow(m_filter_ships); GetDlgItem(IDC_FILTER_SHIPS_HOSTILE)->EnableWindow(m_filter_ships); GetDlgItem(IDC_FILTER_SHIPS_NEUTRAL)->EnableWindow(m_filter_ships); GetDlgItem(IDC_FILTER_SHIPS_UNKNOWN)->EnableWindow(m_filter_ships); // Elements 0 - wlist_size are wings, and elements wlist_size - wplist_size are waypoint paths m_wing_list.ResetContent(); wlist_size = 0; for (i=0; i<MAX_WINGS; i++) { if (Wings[i].wave_count) { m_wing_list.AddItem(Wings[i].name, RGB(255,255,0)); //m_wing_list.AddString(Wings[i].name); wing_sel_last[wlist_size] = 0; wing_index[wlist_size++] = i; } } /*wplist_size = wlist_size; for (i=0; i<Num_waypoint_lists; i++) { //m_wing_list.AddString(Waypoint_lists[i].name); wing_sel_last[wplist_size] = 0; wing_index[wplist_size++] = i; }*/ BOOL bRet = m_cBrush.CreateSolidBrush(RGB(0, 0, 0)); m_hBrush = (HBRUSH)m_cBrush; SetTimer(1, 100, 0); return TRUE; }
void create_wing_dlg::OnOK() { char msg[512]; int i; object *ptr; UpdateData(TRUE); UpdateData(TRUE); m_name = drop_white_space((char *)(LPCSTR) m_name); if (m_name.IsEmpty()) { MessageBox("You must give a name before you can continue."); return; } for (i=0; i<MAX_WINGS; i++) if (!stricmp(Wings[i].name, m_name) && Wings[i].wave_count) { sprintf(msg, "The name \"%s\" is already being used by another wing", m_name); MessageBox(msg); return; } ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->type == OBJ_SHIP) { i = ptr->instance; if (!strnicmp(m_name, Ships[i].ship_name, strlen(m_name))) { char *namep; namep = Ships[i].ship_name + strlen(m_name); if (*namep == ' ') { namep++; while (*namep) { if (!isdigit(*namep)) break; namep++; } } if (!*namep) { MessageBox("This wing name is already being used by a ship"); return; } } } ptr = GET_NEXT(ptr); } for (i=0; i<MAX_WAYPOINT_LISTS; i++) if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name)) { MessageBox("This wing name is already being used by a waypoint path"); return; } CDialog::OnOK(); }
void HudGaugeRadarStd::drawBlips(int blip_type, int bright, int distort) { blip *b = NULL; blip *blip_head = NULL; int x, y; Assert((blip_type >= 0) && (blip_type < MAX_BLIP_TYPES)); // Need to set font. gr_set_font(FONT1); // get the appropriate blip list if (bright) blip_head = &Blip_bright_list[blip_type]; else blip_head = &Blip_dim_list[blip_type]; // draw all blips of this type for (b = GET_FIRST(blip_head); b != END_OF_LIST(blip_head); b = GET_NEXT(b)) { gr_set_color_fast(b->blip_color); plotBlip(b, &x, &y); // maybe draw cool blip to indicate current target if (b->flags & BLIP_CURRENT_TARGET) { b->rad = Radar_blip_radius_target; current_target_x = x; current_target_y = y; } else { b->rad = Radar_blip_radius_normal; } // maybe distort blip if (distort) { blipDrawDistorted(b, x, y); } else if (b->flags & BLIP_DRAW_DISTORTED) { blipDrawFlicker(b, x, y); } else { if (b->radar_image_2d == -1 && b->radar_color_image_2d == -1) drawContactCircle(x, y, b->rad); else drawContactImage(x, y, b->rad, b->radar_image_2d, b->radar_color_image_2d, b->radar_image_size); } } }
// Draw all the active radar blips void draw_radar_blips_std(int blip_type, int bright, int distort) { blip* b = NULL; blip* blip_head = NULL; Assert((blip_type >= 0) && (blip_type < MAX_BLIP_TYPES)); // Need to set font. gr_set_font(FONT1); // get the appropriate blip list if (bright) blip_head = &Blip_bright_list[blip_type]; else blip_head = &Blip_dim_list[blip_type]; // draw all blips of this type for (b = GET_FIRST(blip_head); b != END_OF_LIST(blip_head); b = GET_NEXT(b)) { gr_set_color_fast(b->blip_color); // maybe draw cool blip to indicate current target if (b->flags & BLIP_CURRENT_TARGET) { b->rad = Current_radar_global->Radar_blip_radius_target[gr_screen.res]; current_target_x = b->x; current_target_y = b->y; } else { b->rad = Current_radar_global->Radar_blip_radius_normal[gr_screen.res]; } // maybe distort blip if (distort) { radar_blip_draw_distorted_std(b); } else if (b->flags & BLIP_DRAW_DISTORTED) { radar_blip_draw_flicker_std(b); } else { if (b->radar_image_2d == -1) radar_draw_circle_std(b->x, b->y, b->rad); else radar_draw_image_std(b->x, b->y, b->rad, b->radar_image_2d, b->radar_image_size); } } }
void orient_editor::OnOK() { vec3d delta, pos; object *ptr; UpdateData(TRUE); pos.xyz.x = convert(m_position_x); pos.xyz.y = convert(m_position_y); pos.xyz.z = convert(m_position_z); if ((((CButton *) GetDlgItem(IDC_POINT_TO_OBJECT))->GetCheck() == 1) || (((CButton *) GetDlgItem(IDC_POINT_TO_LOCATION))->GetCheck() == 1)) set_modified(); vm_vec_sub(&delta, &pos, &Objects[cur_object_index].pos); if (delta.xyz.x || delta.xyz.y || delta.xyz.z) set_modified(); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->flags & OF_MARKED) { vm_vec_add2(&ptr->pos, &delta); update_object(ptr); } ptr = GET_NEXT(ptr); } ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->flags & OF_MARKED) object_moved(ptr); ptr = GET_NEXT(ptr); } theApp.record_window_data(&Object_wnd_data, this); CDialog::OnOK(); }
void briefing_editor_dlg::OnPropagateIcons() { object *ptr; ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if ((ptr->type == OBJ_POINT) && (ptr->flags & OF_MARKED)) { propagate_icon(ptr->instance); } ptr = GET_NEXT(ptr); } }
void save_hotkeys() { ship_obj *so; int i; for (i=0; i<MAX_KEYED_TARGETS; i++) { hud_target_hotkey_clear(i); for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) { if ( Hotkey_bits[Objects[so->objnum].instance] & (1 << i) ) { hud_target_hotkey_add_remove(i, &Objects[so->objnum], HOTKEY_USER_ADDED ); } } } }
BOOL ShipSpecialHitpoints::OnInitDialog() { // get ship num object *objp; m_ship_num = -1; objp = GET_FIRST(&obj_used_list); while (objp != END_OF_LIST(&obj_used_list)) { if ((objp->type == OBJ_START) || (objp->type == OBJ_SHIP)) { if (objp->flags & OF_MARKED) { m_ship_num = objp->instance; break; } } objp = GET_NEXT(objp); } if (Ships[m_ship_num].special_hitpoint_index == -1) { // get default_table_values ship_info *sip; sip = &Ship_info[Ships[m_ship_num].ship_info_index]; m_shields = (int)sip->initial_shield_strength; m_hull = (int)sip->initial_hull_strength; m_special_hitpoints_enabled = FALSE; if (m_shields < 0) m_shields = 0; if (m_hull < 10) m_hull = 10; } else { int index = Ships[m_ship_num].special_hitpoint_index; // Assert( (index > 0) && (index < MAX_SEXP_VARIABLES-(BLOCK_HITPOINT_SIZE-1)) ); m_shields = atoi(Sexp_variables[index++].text); m_hull = atoi(Sexp_variables[index++].text); m_special_hitpoints_enabled = TRUE; } CDialog::OnInitDialog(); // maybe gray out lots of stuff DoGray(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void ShipGoalsDlg::update() { int i; if (goalp) { for (i=0; i<ED_MAX_GOALS; i++) update_item(i); verify_orders(); } else { object *ptr; ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) && (ptr->flags[Object::Object_Flags::Marked])) { goalp = Ai_info[Ships[ptr->instance].ai_index].goals; for (i=0; i<ED_MAX_GOALS; i++) update_item(i, 1); } ptr = GET_NEXT(ptr); } ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) && (ptr->flags[Object::Object_Flags::Marked])) { self_ship = ptr->instance; goalp = Ai_info[Ships[self_ship].ai_index].goals; verify_orders(self_ship); } ptr = GET_NEXT(ptr); } } }
void mission_hotkey_validate() { htarget_list *hitem, *plist; object *A; int obj_valid, i; for ( i = 0; i < MAX_KEYED_TARGETS; i++ ) { plist = &(Players[Player_num].keyed_targets[i]); if ( EMPTY( plist ) ) // no items in list, then do nothing continue; hitem = GET_FIRST(plist); while ( hitem != END_OF_LIST(plist) ) { // ensure this object is still valid and in the obj_used_list obj_valid = FALSE; for ( A = GET_FIRST(&obj_used_list); A !=END_OF_LIST(&obj_used_list); A = GET_NEXT(A) ) { if ( A->signature == hitem->objp->signature ) { obj_valid = TRUE; break; } } if ( obj_valid == FALSE ) { htarget_list *temp; temp = GET_NEXT(hitem); list_remove( plist, hitem ); list_append( &htarget_free_list, hitem ); hitem->objp = NULL; hitem = temp; continue; } hitem = GET_NEXT( hitem ); } // end while } // end for }
void ship_flags_dlg::OnOK() { object *objp; objp = GET_FIRST(&obj_used_list); while (objp != END_OF_LIST(&obj_used_list)) { if ((objp->type == OBJ_START) || (objp->type == OBJ_SHIP)) { if (objp->flags & OF_MARKED) update_ship(objp->instance); } objp = GET_NEXT(objp); } CDialog::OnOK(); }
// how many lines to skip int hud_get_scroll_max_pos() { int max = 0, font_height = gr_get_font_height(); if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) { int count = 0; line_node *ptr; // number of pixels in excess of what can be displayed int excess = Scroll_max - Hud_mission_log_list_coords[gr_screen.res][3]; if (EMPTY(&Msg_scrollback_used_list) || !HUD_msg_inited) { max = 0; } else { ptr = GET_FIRST(&Msg_scrollback_used_list); while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) { if (ptr->source != HUD_SOURCE_HIDDEN) { if (excess > 0) { excess -= font_height; count++; } if (excess <= 0) { max = count; break; } // spacing between lines excess -= ptr->y; } ptr = GET_NEXT(ptr); } } } else { max = (Scroll_max - Hud_mission_log_list_coords[gr_screen.res][3]) / font_height; } if (max < 0) max = 0; return max; }
/** * @brief Free all anim instances that are on the anim_render_list. * * @param screen_id Optional parameter that lets you only free a subset of the anim instances. * A screen_id of 0 is the default value, and this is used for animations that always play when * they are placed on the aim_render_list. */ void anim_release_all_instances(int screen_id) { anim_instance* A; anim_instance* temp; if ( Anim_inited == FALSE ) return; A = GET_FIRST(&anim_render_list); while( A !=END_OF_LIST(&anim_render_list) ) { temp = GET_NEXT(A); if ( A->screen_id == screen_id || screen_id == 0 ) { anim_release_render_instance(A); } A = temp; } }
// hud_free_scrollback_list() will free the memory that was allocated to store the messages // for the scroll-back list // void hud_free_scrollback_list() { line_node *A; // check if the list has been inited yet. If not, return with doing nothing. if ( Msg_scrollback_used_list.next == NULL || Msg_scrollback_used_list.prev == NULL ) return; A = GET_FIRST(&Msg_scrollback_used_list); while( A !=END_OF_LIST(&Msg_scrollback_used_list) ) { if ( A->text != NULL ) { vm_free(A->text); A->text = NULL; } A = GET_NEXT(A); } }
// Return true if objp will collide with some large object. // Don't check for an object this ship is docked to. int collide_predict_large_ship(object *objp, float distance) { object *objp2; vec3d cur_pos, goal_pos; ship_info *sip; sip = &Ship_info[Ships[objp->instance].ship_info_index]; cur_pos = objp->pos; vm_vec_scale_add(&goal_pos, &cur_pos, &objp->orient.vec.fvec, distance); for ( objp2 = GET_FIRST(&obj_used_list); objp2 != END_OF_LIST(&obj_used_list); objp2 = GET_NEXT(objp2) ) { if ((objp != objp2) && (objp2->type == OBJ_SHIP)) { if (Ship_info[Ships[objp2->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) { if (dock_check_find_docked_object(objp, objp2)) continue; if (cpls_aux(&goal_pos, objp2, objp)) return 1; } } else if (!(sip->flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) && (objp2->type == OBJ_ASTEROID)) { if (vm_vec_dist_quick(&objp2->pos, &objp->pos) < (distance + objp2->radius)*2.5f) { vec3d pos, delvec; int count; float d1; d1 = 2.5f * distance + objp2->radius; count = (int) (d1/(objp2->radius + objp->radius)); // Scale up distance, else looks like there would be a collision. pos = cur_pos; vm_vec_normalized_dir(&delvec, &goal_pos, &cur_pos); vm_vec_scale(&delvec, d1/count); for (; count>0; count--) { if (vm_vec_dist_quick(&pos, &objp2->pos) < objp->radius + objp2->radius) return 1; vm_vec_add2(&pos, &delvec); } } } } return 0; }