diff --git a/code/ai/aibig.cpp b/code/ai/aibig.cpp index 20b5a802e2..4702fc9de7 100644 --- a/code/ai/aibig.cpp +++ b/code/ai/aibig.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Ship/AiBig.cpp $ - * $Revision: 1.12 $ - * $Date: 2006-02-25 21:46:59 $ + * $Revision: 1.13 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * C module for AI code related to large ships * * $Log: not supported by cvs2svn $ + * Revision 1.12 2006/02/25 21:46:59 Goober5000 + * spelling + * * Revision 1.11 2006/01/13 03:30:59 Goober5000 * übercommit of custom IFF stuff :) * @@ -491,11 +494,12 @@ void ai_bpap(object *objp, vec3d *attacker_objp_pos, vec3d *attacker_objp_fvec, model_octant *octp; polymodel *pm; int i, q, octs[4]; + ship_info *sip = &Ship_info[Ships[objp->instance].ship_info_index]; best_point = objp->pos; nearest_dist = weapon_travel_dist; - model_which_octant_distant_many(attacker_objp_pos, Ships[objp->instance].modelnum, &objp->orient, &objp->pos, &pm, octs); + model_which_octant_distant_many(attacker_objp_pos, sip->model_num, &objp->orient, &objp->pos, &pm, octs); num_tries = (int) (vm_vec_dist(&objp->pos, attacker_objp_pos)/objp->radius); @@ -570,7 +574,7 @@ done_1: } mc_info mc; - mc.model_num = Ships[objp->instance].modelnum; + mc.model_num = sip->model_num; mc.orient = &objp->orient; mc.pos = &objp->pos; mc.p0 = attacker_objp_pos; @@ -772,7 +776,7 @@ int ai_big_maybe_follow_subsys_path(int do_dot_check) int subsys_path_num, subsys_in_sight, checked_sight; float dist; - pm = model_get( Ships[Pl_objp->instance].modelnum ); + pm = model_get( Ship_info[Ships[Pl_objp->instance].ship_info_index].model_num ); // If attacking a subsystem, ensure that we have an unobstructed line of sight... if not, then move // towards path linked to subsystem @@ -788,7 +792,7 @@ int ai_big_maybe_follow_subsys_path(int do_dot_check) // get world pos of eye (stored in geye) ep = &(pm->view_positions[0] ); - model_find_world_point( &geye, &ep->pnt, Ships[Pl_objp->instance].modelnum, 0, &Pl_objp->orient, &Pl_objp->pos ); + model_find_world_point( &geye, &ep->pnt, pm->id, 0, &Pl_objp->orient, &Pl_objp->pos ); // get world pos of subsystem vm_vec_unrotate(&gsubpos, &aip->targeted_subsys->system_info->pnt, &En_objp->orient); @@ -1284,7 +1288,7 @@ void ai_big_chase() case SM_ATTACK: case SM_SUPER_ATTACK: case SM_ATTACK_FOREVER: - ai_big_chase_attack(aip, sip, &enemy_pos, dist_to_enemy, shipp->modelnum); + ai_big_chase_attack(aip, sip, &enemy_pos, dist_to_enemy, sip->model_num); break; case SM_EVADE: @@ -1516,7 +1520,7 @@ void ai_big_attack_get_data(vec3d *enemy_pos, float *dist_to_enemy, float *dot_t predicted_enemy_pos=*enemy_pos; } else { vec3d gun_pos, pnt; - polymodel *po = model_get( shipp->modelnum ); + polymodel *po = model_get( Ship_info[shipp->ship_info_index].model_num ); float weapon_speed; // Compute position of gun in absolute space and use that as fire position. diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index c25fd9d1af..8bf9c371ae 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Ship/AiCode.cpp $ - * $Revision: 1.100 $ - * $Date: 2007-02-18 06:16:46 $ + * $Revision: 1.101 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * AI code that does interesting stuff * * $Log: not supported by cvs2svn $ + * Revision 1.100 2007/02/18 06:16:46 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 1.99 2007/02/11 21:26:34 Goober5000 * massive shield infrastructure commit * @@ -2930,7 +2933,7 @@ int get_nearest_bbox_point(object *ship_obj, vec3d *start, vec3d *box_pt) { vec3d temp, rf_start; polymodel *pm; - pm = model_get(Ships[ship_obj->instance].modelnum); + pm = model_get(Ship_info[Ships[ship_obj->instance].ship_info_index].model_num); // get start in ship rf vm_vec_sub(&temp, start, &ship_obj->pos); @@ -3681,7 +3684,7 @@ void copy_xlate_model_path_points(object *objp, model_path *mp, int dir, int cou } // Goober5000 - check for rotating submodels - modelnum = Ships[objp->instance].modelnum; + modelnum = Ship_info[Ships[objp->instance].ship_info_index].model_num; pm = model_get(modelnum); if ((mp->parent_submodel >= 0) && (pm->submodel[mp->parent_submodel].movement_type >= 0)) { @@ -3750,7 +3753,7 @@ void create_model_path(object *pl_objp, object *mobjp, int path_num, int subsys_ ai_info *aip = &Ai_info[shipp->ai_index]; // ship_info *osip = &Ship_info[Ships[mobjp->instance].ship_info_index]; - polymodel *pm = model_get(Ships[mobjp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[mobjp->instance].ship_info_index].model_num); int num_points; model_path *mp; pnode *ppfp_start = Ppfp; @@ -3831,7 +3834,7 @@ void create_model_exit_path(object *pl_objp, object *mobjp, int path_num, int co ai_info *aip = &Ai_info[shipp->ai_index]; // ship_info *osip = &Ship_info[Ships[mobjp->instance].ship_info_index]; - polymodel *pm = model_get(Ships[mobjp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[mobjp->instance].ship_info_index].model_num); int num_points; model_path *mp; pnode *ppfp_start = Ppfp; @@ -3905,7 +3908,7 @@ void ai_find_path(object *pl_objp, int objnum, int path_num, int exit_flag, int polymodel *pm; ship *shipp = &Ships[objp->instance]; - pm = model_get( shipp->modelnum ); + pm = model_get(Ship_info[shipp->ship_info_index].model_num); if(pm->n_paths <= path_num) Error(LOCATION,"ai_find_path tring to find a path (%d) that doesn't exist, on ship %s", path_num, shipp->ship_name); // Assert(pm->n_paths > path_num); @@ -4187,7 +4190,7 @@ void ai_dock_with_object(object *docker, int docker_index, object *dockee, int d #ifndef NDEBUG if (dock_type == AIDO_UNDOCK) { - polymodel *pm = model_get(Ships[dockee->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[dockee->instance].ship_info_index].model_num); Assert( pm->docking_bays[dockee_index].num_spline_paths > 0 ); } #endif @@ -4572,7 +4575,7 @@ int get_base_path_info(int path_cur, int goal_objnum, model_path **pmp, mp_vert pnode *pn = &Path_points[path_cur]; ship *shipp = &Ships[Objects[goal_objnum].instance]; // ship_info *sip = &Ship_info[shipp->ship_info_index]; - polymodel *pm = model_get(shipp->modelnum); + polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); //static int debug_last_index = -1; *pmpv = NULL; *pmp = NULL; @@ -4606,7 +4609,7 @@ void modify_model_path_points(object *objp) ai_info *aip = &Ai_info[Ships[objp->instance].ai_index]; object *mobjp = &Objects[aip->path_objnum]; // ship_info *osip = &Ship_info[Ships[mobjp->instance].ship_info_index]; - polymodel *pm = model_get(Ships[mobjp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[mobjp->instance].ship_info_index].model_num); pnode *pnp; int path_num, dir; @@ -4808,7 +4811,7 @@ float ai_path() gobjp = &Objects[aip->goal_objnum]; gshipp = &Ships[gobjp->instance]; - pm = model_get( gshipp->modelnum ); + pm = model_get(Ship_info[gshipp->ship_info_index].model_num); num_paths = pm->n_paths; Assert(num_paths > 0); @@ -7075,11 +7078,10 @@ int might_hit_teammate(object *firing_objp) void render_all_ship_bay_paths(object *objp) { int i,j,color; - ship *sp = &Ships[objp->instance]; polymodel *pm; model_path *mp; - pm = model_get(sp->modelnum); + pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num); vec3d global_path_point; vertex v, prev_vertex; @@ -7117,11 +7119,10 @@ void render_all_ship_bay_paths(object *objp) void render_all_subsys_paths(object *objp) { int i,j,color; - ship *sp = &Ships[objp->instance]; polymodel *pm; model_path *mp; - pm = model_get(sp->modelnum); + pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num); vec3d global_path_point; vertex v, prev_vertex; @@ -7167,14 +7168,14 @@ void render_path_points(object *objp) return; dobjp = &Objects[aip->goal_objnum]; - pm = model_get(Ships[dobjp->instance].modelnum); + pm = model_get(Ship_info[Ships[dobjp->instance].ship_info_index].model_num); vec3d dock_point, global_dock_point; vertex v; ship_model_start(&Objects[aip->goal_objnum]); if (pm->n_docks) { dock_point = pm->docking_bays[0].pnt[0]; - model_find_world_point(&global_dock_point, &dock_point, Ships[dobjp->instance].modelnum, 0, &dobjp->orient, &dobjp->pos ); + model_find_world_point(&global_dock_point, &dock_point, pm->id, 0, &dobjp->orient, &dobjp->pos ); g3_rotate_vertex(&v, &global_dock_point); gr_set_color(255, 255, 255); g3_draw_sphere( &v, 1.5f); @@ -7348,7 +7349,7 @@ void set_predicted_enemy_pos(vec3d *predicted_enemy_pos, object *pobjp, object * // but don't bias team v. team missions if ( !((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)) ) { - if (iff_x_attacks_y(Ships[pobjp->instance].team, Player_ship->team)) + if (iff_x_attacks_y(shipp->team, Player_ship->team)) range_time += The_mission.ai_profile->in_range_time[Game_skill_level]; } //nprintf(("AI", "time enemy in range = %7.3f\n", aip->time_enemy_in_range)); @@ -7361,11 +7362,11 @@ void set_predicted_enemy_pos(vec3d *predicted_enemy_pos, object *pobjp, object * } else { float collision_time; vec3d gun_pos, pnt; - polymodel *po = model_get( shipp->modelnum ); + polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); // Compute position of gun in absolute space and use that as fire position. - if(po->gun_banks != NULL){ - pnt = po->gun_banks[0].pnt[0]; + if(pm->gun_banks != NULL){ + pnt = pm->gun_banks[0].pnt[0]; } else { pnt = Objects[shipp->objnum].pos; } @@ -7639,8 +7640,9 @@ int avoid_player(object *objp, vec3d *goal_pos) int will_collide_pp(vec3d *p0, vec3d *p1, float radius, object *big_objp, vec3d *collision_point) { mc_info mc; + polymodel *pm = model_get(Ship_info[Ships[big_objp->instance].ship_info_index].model_num); - mc.model_num = Ships[big_objp->instance].modelnum; // Fill in the model to check + mc.model_num = pm->id; // Fill in the model to check mc.orient = &big_objp->orient; // The object's orient mc.pos = &big_objp->pos; // The object's position mc.p0 = p0; // Point 1 of ray to check @@ -7650,7 +7652,6 @@ int will_collide_pp(vec3d *p0, vec3d *p1, float radius, object *big_objp, vec3d mc.radius = radius; // Only check the 2nd lowest hull object - polymodel *pm = model_get(Ships[big_objp->instance].modelnum); mc.submodel_num = pm->detail[0]; //pm->submodel->num_details-2]; model_collide(&mc); @@ -8657,18 +8658,17 @@ void ai_chase_big_get_separations(object *attack_objp, object *target_objp, vec3 float temp, r_target, r_attacker, h_attacker, h_target; float perp_dist; vec3d vec_to_target; - polymodel *pm; // get parameters of ships (as cylinders - radius and height) + polymodel *pm = model_get(Ship_info[Ships[attack_objp->instance].ship_info_index].model_num); + // get radius of attacker (for rotations about forward) - pm = model_get(Ships[attack_objp->instance].modelnum); temp = MAX(pm->maxs.xyz.x, pm->maxs.xyz.y); r_attacker = MAX(-pm->mins.xyz.x, -pm->mins.xyz.y); r_attacker = MAX(temp, r_attacker); h_attacker = MAX(-pm->mins.xyz.z, pm->maxs.xyz.z); // get radius of target (for rotations about forward) - pm = model_get(Ships[attack_objp->instance].modelnum); temp = MAX(pm->maxs.xyz.x, pm->maxs.xyz.y); r_target = MAX(-pm->mins.xyz.x, -pm->mins.xyz.y); r_target = MAX(temp, r_target); @@ -8694,18 +8694,17 @@ void ai_chase_big_parallel_set_goal(vec3d *goal_pos, object *attack_objp, object float temp, r_target, r_attacker, h_attacker, h_target; float separation, optimal_separation; vec3d horz_vec_to_target; - polymodel *pm; // get parameters of ships (as cylinders - radius and height) + polymodel *pm = model_get(Ship_info[Ships[attack_objp->instance].ship_info_index].model_num); + // get radius of attacker (for rotations about forward) - pm = model_get(Ships[attack_objp->instance].modelnum); temp = MAX(pm->maxs.xyz.x, pm->maxs.xyz.y); r_attacker = MAX(-pm->mins.xyz.x, -pm->mins.xyz.y); r_attacker = MAX(temp, r_attacker); h_attacker = MAX(-pm->mins.xyz.z, pm->maxs.xyz.z); // get radius of target (for rotations about forward) - pm = model_get(Ships[attack_objp->instance].modelnum); temp = MAX(pm->maxs.xyz.x, pm->maxs.xyz.y); r_target = MAX(-pm->mins.xyz.x, -pm->mins.xyz.y); r_target = MAX(temp, r_target); @@ -8990,8 +8989,8 @@ void ai_chase() float dist_to_enemy, time_to_enemy; float dot_to_enemy, dot_from_enemy, real_dot_to_enemy; vec3d player_pos, enemy_pos, predicted_enemy_pos, real_vec_to_enemy, predicted_vec_to_enemy; - ship_info *sip = &Ship_info[Ships[Pl_objp->instance].ship_info_index]; - ship *shipp = &Ships[Pl_objp->instance]; + ship *shipp = &Ships[Pl_objp->instance]; + ship_info *sip = &Ship_info[shipp->ship_info_index]; ship_weapon *swp = &shipp->weapons; ai_info *aip = &Ai_info[shipp->ai_index]; int enemy_sip_flags, enemy_shipp_flags2; @@ -9162,7 +9161,7 @@ void ai_chase() return; } - ai_chase_attack(aip, sip, &predicted_enemy_pos, dist_to_enemy, shipp->modelnum); + ai_chase_attack(aip, sip, &predicted_enemy_pos, dist_to_enemy, sip->model_num); break; case SM_EVADE_SQUIGGLE: @@ -9793,8 +9792,8 @@ float dock_orient_and_approach(object *docker_objp, int docker_index, object *do sip0 = &Ship_info[Ships[docker_objp->instance].ship_info_index]; sip1 = &Ship_info[Ships[dockee_objp->instance].ship_info_index]; - pm0 = model_get( sip0->modelnum ); - pm1 = model_get( sip1->modelnum ); + pm0 = model_get( sip0->model_num ); + pm1 = model_get( sip1->model_num ); Assert( docker_index >= 0 ); Assert( dockee_index >= 0 ); @@ -9807,8 +9806,8 @@ float dock_orient_and_approach(object *docker_objp, int docker_index, object *do int dockee_rotating_submodel = find_parent_rotating_submodel(pm1, dockee_index); // Goober5000 - move docking points with submodels if necessary, for both docker and dockee - find_adjusted_dockpoint_info(&docker_p0, &docker_p1, &docker_p0_norm, docker_objp, pm0, sip0->modelnum, -1, docker_index); - find_adjusted_dockpoint_info(&dockee_p0, &dockee_p1, &dockee_p0_norm, dockee_objp, pm1, sip1->modelnum, dockee_rotating_submodel, dockee_index); + find_adjusted_dockpoint_info(&docker_p0, &docker_p1, &docker_p0_norm, docker_objp, pm0, sip0->model_num, -1, docker_index); + find_adjusted_dockpoint_info(&dockee_p0, &dockee_p1, &dockee_p0_norm, dockee_objp, pm1, sip1->model_num, dockee_rotating_submodel, dockee_index); // Goober5000 - find average of point vm_vec_avg(&docker_point, &docker_p0, &docker_p1); @@ -9826,7 +9825,7 @@ float dock_orient_and_approach(object *docker_objp, int docker_index, object *do ship_model_start(dockee_objp); // get submodel center - model_find_submodel_offset(&submodel_offset, sip1->modelnum, dockee_rotating_submodel); + model_find_submodel_offset(&submodel_offset, sip1->model_num, dockee_rotating_submodel); vm_vec_add(&submodel_pos, &dockee_objp->pos, &submodel_offset); // get angular velocity of dockpoint @@ -10508,7 +10507,7 @@ float get_cylinder_points(object *other_objp, object *cyl_objp, vec3d *axis_pt, Assert(cyl_objp->type == OBJ_SHIP); // get radius of cylinder - polymodel *pm = model_get(Ships[cyl_objp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[cyl_objp->instance].ship_info_index].model_num); float tempx, tempy; tempx = MAX(-pm->mins.xyz.x, pm->maxs.xyz.x); tempy = MAX(-pm->mins.xyz.y, pm->maxs.xyz.y); @@ -10570,7 +10569,7 @@ void ai_big_guard() // get z extents float min_z, max_z, length; - polymodel *pm = model_get(Ships[guard_objp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[guard_objp->instance].ship_info_index].model_num); min_z = pm->mins.xyz.z; max_z = pm->maxs.xyz.z; length = max_z - min_z; @@ -11318,7 +11317,7 @@ void ai_dock() Assert(goal_objp != NULL); ship_info *goal_sip = &Ship_info[Ships[goal_objp->instance].ship_info_index]; char *goal_ship_class_name = goal_sip->name; - char *goal_dock_path_name = model_get(goal_sip->modelnum)->paths[aip->mp_index].name; + char *goal_dock_path_name = model_get(goal_sip->model_num)->paths[aip->mp_index].name; Warning(LOCATION, "Ship class %s has only %i points on dock path \"%s\". Recommended minimum number of points is 4. "\ "Docking along that path will look strange. You may wish to edit the model.", goal_ship_class_name, aip->path_length, goal_dock_path_name); @@ -13288,26 +13287,22 @@ int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int allowed_path_ { int path_index; int bay_path; - ship *shipp = NULL, *parent_shipp = NULL; - polymodel *pm; - ai_info *aip; - ship_bay *bay; pnode *pnp; vec3d *next_point; - shipp = &Ships[pl_objp->instance]; - aip = &Ai_info[shipp->ai_index]; + ship *shipp = &Ships[pl_objp->instance]; + ai_info *aip = &Ai_info[shipp->ai_index]; if ( parent_objnum == -1 ) { Int3(); return -1; } - parent_shipp = &Ships[Objects[parent_objnum].instance]; + object *parent_objp = &Objects[parent_objnum]; + ship *parent_shipp = &Ships[parent_objp->instance]; - Assert(parent_shipp != NULL); - pm = model_get( parent_shipp->modelnum ); - bay = pm->ship_bay; + polymodel *pm = model_get( Ship_info[parent_shipp->ship_info_index].model_num ); + ship_bay *bay = pm->ship_bay; if ( bay == NULL ) return -1; @@ -13350,13 +13345,14 @@ int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int allowed_path_ // notify parent that I'll want to leave parent_shipp->bay_doors_wanting_open++; + // keep track of my own status as well shipp->bay_doors_need_open = true; shipp->bay_doors_launched_from = bay_path; - shipp->bay_doors_parent_shipnum = Objects[parent_objnum].instance; + shipp->bay_doors_parent_shipnum = parent_objp->instance; // create the path for pl_objp to follow - create_model_exit_path(pl_objp, &Objects[parent_objnum], path_index, pm->paths[path_index].nverts); + create_model_exit_path(pl_objp, parent_objp, path_index, pm->paths[path_index].nverts); // Set this flag, so we don't bother recreating the path... we won't need to update the path // that has just been created. @@ -13374,7 +13370,7 @@ int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int allowed_path_ // record the parent objnum, since we'll need it once we're done with following the path aip->goal_objnum = parent_objnum; - aip->goal_signature = Objects[parent_objnum].signature; + aip->goal_signature = parent_objp->signature; aip->mode = AIM_BAY_EMERGE; aip->submode_start_time = Missiontime; @@ -13393,6 +13389,7 @@ int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int allowed_path_ pl_objp->phys_info.prev_ramp_vel.xyz.z = speed; pl_objp->phys_info.forward_thrust = 0.0f; // How much the forward thruster is applied. 0-1. */ + //due to the door animations the ship has to remain still untill the doors are open vec3d vel = ZERO_VECTOR; pl_objp->phys_info.vel = vel; @@ -13552,32 +13549,29 @@ int ai_find_closest_depart_path(ai_info *aip, polymodel *pm, int allowed_path_ma // 0 => found depart path int ai_acquire_depart_path(object *pl_objp, int parent_objnum, int allowed_path_mask) { - int objnum, path_index; - polymodel *pm; - ai_info *aip; - ship *shipp; - ship_bay *bay; + int path_index = -1; + int ship_bay_path = -1; - shipp = &Ships[pl_objp->instance]; - aip = &Ai_info[shipp->ai_index]; + ship *shipp = &Ships[pl_objp->instance]; + ai_info *aip = &Ai_info[shipp->ai_index]; - objnum = parent_objnum; - if ( objnum < 0 ) + if ( parent_objnum < 0 ) { // try to locate a capital ship on the same team: int shipnum = ship_get_ship_with_dock_bay(shipp->team); if (shipnum >= 0) - objnum = Ships[shipnum].objnum; + parent_objnum = Ships[shipnum].objnum; } aip->path_start = -1; - if ( objnum < 0 ) + if ( parent_objnum < 0 ) return -1; - pm = model_get( Ships[Objects[objnum].instance].modelnum ); - bay = pm->ship_bay; + object *parent_objp = &Objects[parent_objnum]; + polymodel *pm = model_get(Ship_info[Ships[parent_objp->instance].ship_info_index].model_num ); + ship_bay *bay = pm->ship_bay; if ( bay == NULL ) return -1; @@ -13585,8 +13579,6 @@ int ai_acquire_depart_path(object *pl_objp, int parent_objnum, int allowed_path_ return -1; /* - - path_index = -1; for ( i = 0; i < sb->num_paths; i++ ) { if ( !(sb->depart_flags & (1<depart_flags |= (1<path_indexes[ship_bay_path]; aip->submode_parm0 = ship_bay_path; @@ -13609,21 +13600,22 @@ int ai_acquire_depart_path(object *pl_objp, int parent_objnum, int allowed_path_ } // notify parent that I'll want to enter bay - Ships[Objects[objnum].instance].bay_doors_wanting_open++; + Ships[parent_objp->instance].bay_doors_wanting_open++; + // keep track of my own status as well shipp->bay_doors_need_open = true; shipp->bay_doors_launched_from = ship_bay_path; - shipp->bay_doors_parent_shipnum = Objects[objnum].instance; + shipp->bay_doors_parent_shipnum = parent_objp->instance; Assert(pm->n_paths > path_index); - ai_find_path(pl_objp, objnum, path_index, 0); + ai_find_path(pl_objp, parent_objnum, path_index, 0); // Set this flag, so we don't bother recreating the path... we won't need to update the path // that has just been created. aip->ai_flags &= ~AIF_USE_STATIC_PATH; - aip->goal_objnum = objnum; - aip->goal_signature = Objects[objnum].signature; + aip->goal_objnum = parent_objnum; + aip->goal_signature = parent_objp->signature; aip->mode = AIM_BAY_DEPART; shipp->flags |= SF_DEPART_DOCKBAY; @@ -13688,7 +13680,7 @@ void ai_bay_depart() polymodel *pm; ship_bay *bay; - pm = model_get( Ships[Objects[aip->goal_objnum].instance].modelnum ); + pm = model_get(Ship_info[Ships[Objects[aip->goal_objnum].instance].ship_info_index].model_num); bay = pm->ship_bay; if ( bay != NULL ) { bay->depart_flags &= ~(1<submode_parm0); @@ -16251,7 +16243,7 @@ int ai_return_path_num_from_dockbay(object *dockee_objp, int dockbay_index) int path_num; polymodel *pm; - pm = model_get( Ships[dockee_objp->instance].modelnum ); + pm = model_get(Ship_info[Ships[dockee_objp->instance].ship_info_index].model_num ); // sanity checks Assert(pm->n_docks > dockbay_index); diff --git a/code/ai/aigoals.cpp b/code/ai/aigoals.cpp index 2dd07e91d3..dbab52269b 100644 --- a/code/ai/aigoals.cpp +++ b/code/ai/aigoals.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Ship/AiGoals.cpp $ - * $Revision: 1.34 $ - * $Date: 2007-02-10 06:39:43 $ + * $Revision: 1.35 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * File to deal with manipulating AI goals, etc. * * $Log: not supported by cvs2svn $ + * Revision 1.34 2007/02/10 06:39:43 Goober5000 + * new feature: shield generators that control whether the shield is up + * * Revision 1.33 2007/02/10 04:49:22 Goober5000 * prevent the AI from falling into the black hole of disarming a turretless ship * @@ -1209,7 +1212,7 @@ int ai_goal_find_dockpoint(int shipnum, int dock_type) // only check 100 points for sanity's sake while (loop_count < 100) { - dock_index = model_find_dock_index(shipp->modelnum, dock_type, dock_index+1); + dock_index = model_find_dock_index(Ship_info[shipp->ship_info_index].model_num, dock_type, dock_index+1); // not found? if (dock_index == -1) @@ -1242,7 +1245,7 @@ int ai_goal_find_dockpoint(int shipnum, int dock_type) Warning(LOCATION, "Too many iterations while looking for a dockpoint on %s. Either there was a bug or this is an übership.\n", shipp->ship_name); // if we're here, just return the first dockpoint - return model_find_dock_index(shipp->modelnum, dock_type); + return model_find_dock_index(Ship_info[shipp->ship_info_index].model_num, dock_type); } // function to fix up dock point references for objects. @@ -2066,7 +2069,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) // this goal will get removed. if ( (aigp->ai_mode == AI_GOAL_DOCK) && (status == SHIP_STATUS_ARRIVED) ) { if (!(aigp->flags & AIGF_DOCKER_INDEX_VALID)) { - modelnum = Ships[objp->instance].modelnum; + modelnum = Ship_info[Ships[objp->instance].ship_info_index].model_num; Assert( modelnum >= 0 ); index = model_find_dock_name_index(modelnum, aigp->docker.name); aigp->docker.index = index; @@ -2076,7 +2079,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) if (!(aigp->flags & AIGF_DOCKEE_INDEX_VALID)) { sindex = ship_name_lookup(aigp->ship_name); if ( sindex != -1 ) { - modelnum = Ships[sindex].modelnum; + modelnum = Ship_info[Ships[sindex].ship_info_index].model_num; index = model_find_dock_name_index(modelnum, aigp->dockee.name); aigp->dockee.index = index; aigp->flags |= AIGF_DOCKEE_INDEX_VALID; diff --git a/code/ai/aiturret.cpp b/code/ai/aiturret.cpp index 4620466d70..2e8fdd6af3 100644 --- a/code/ai/aiturret.cpp +++ b/code/ai/aiturret.cpp @@ -1,12 +1,15 @@ /* * $Logfile: /Freespace2/code/ai/aiturret.cpp $ - * $Revision: 1.57 $ - * $Date: 2007-02-18 06:16:46 $ + * $Revision: 1.58 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * Functions for AI control of turrets * * $Log: not supported by cvs2svn $ + * Revision 1.57 2007/02/18 06:16:46 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 1.56 2007/02/11 06:19:05 Goober5000 * invert the do-collision flag into a don't-do-collision flag, plus fixed a wee lab bug * @@ -1076,7 +1079,8 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object vm_vec_normalized_dir(&v2e, predicted_enemy_pos, &gun_pos); if (vm_vec_dot(&v2e, gvec) > tp->turret_fov) { - ret_val = model_rotate_gun(shipp->modelnum, ss->system_info, &Objects[parent_objnum].orient, + ret_val = model_rotate_gun(Ship_info[shipp->ship_info_index].model_num, + ss->system_info, &Objects[parent_objnum].orient, &ss->submodel_info_1.angs, &ss->submodel_info_2.angs, &Objects[parent_objnum].pos, predicted_enemy_pos); } diff --git a/code/asteroid/asteroid.cpp b/code/asteroid/asteroid.cpp index d6ca462c99..aa21a1cff3 100644 --- a/code/asteroid/asteroid.cpp +++ b/code/asteroid/asteroid.cpp @@ -9,13 +9,19 @@ /* * $Logfile: /Freespace2/code/Asteroid/Asteroid.cpp $ - * $Revision: 2.44 $ - * $Date: 2007-02-11 09:37:18 $ - * $Author: taylor $ + * $Revision: 2.45 $ + * $Date: 2007-02-20 04:20:10 $ + * $Author: Goober5000 $ * * C module for asteroid code * * $Log: not supported by cvs2svn $ + * Revision 2.44 2007/02/11 09:37:18 taylor + * dd VALID_FNAME() macro and put it around a few places (more to come) + * clean out some old variables + * move CLAMP() macro from opengl header to global header + * update COUNT_ESTIMATE to match new bmpman changes + * * Revision 2.43 2007/01/15 08:05:47 wmcoolmon * Maintain "fileless fs2" capability; change ScriptingVariables library to HookVariables(hv) * @@ -1368,7 +1374,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos int mc_ret_val = 0; if ( asteroid_hit_info->heavy == ship_obj ) { // ship is heavier, so asteroid is sphere. Check sphere collision against ship poly model - mc.model_num = Ships[ship_obj->instance].modelnum; // Fill in the model to check + mc.model_num = Ship_info[Ships[ship_obj->instance].ship_info_index].model_num; // Fill in the model to check mc.orient = &ship_obj->orient; // The object's orient mc.radius = pasteroid->radius; mc.flags = (MC_CHECK_MODEL | MC_CHECK_SPHERELINE); @@ -1399,7 +1405,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos model_get_rotating_submodel_list(submodel_list, &num_rotating_submodels, heavy_obj); // Get polymodel and turn off all rotating submodels, collide against only 1 at a time. - pm = model_get(Ships[heavy_obj->instance].modelnum); + pm = model_get(Ship_info[Ships[heavy_obj->instance].ship_info_index].model_num); // turn off all rotating submodels and test for collision int i; @@ -1493,7 +1499,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos mc.model_num = Asteroid_info[Asteroids[num].asteroid_type].model_num[asteroid_subtype]; // Fill in the model to check model_clear_instance( mc.model_num ); mc.orient = &pasteroid->orient; // The object's orient - mc.radius = model_get_core_radius( Ships[ship_obj->instance].modelnum ); + mc.radius = model_get_core_radius(Ship_info[Ships[ship_obj->instance].ship_info_index].model_num); // check for collision between asteroid model and ship sphere mc.flags = (MC_CHECK_MODEL | MC_CHECK_SPHERELINE); @@ -1928,7 +1934,7 @@ void asteroid_test_collide(object *asteroid_obj, object *ship_obj, mc_info *mc, ship_model_start(ship_obj); - mc->model_num = Ships[ship_obj->instance].modelnum; // Fill in the model to check + mc->model_num = Ship_info[Ships[ship_obj->instance].ship_info_index].model_num; // Fill in the model to check mc->orient = &ship_obj->orient; // The object's orientation mc->pos = &ship_obj->pos; // The object's position mc->p0 = &asteroid_obj->pos; // Point 1 of ray to check diff --git a/code/debris/debris.cpp b/code/debris/debris.cpp index 3adf6e7a89..e97bd4ac0e 100644 --- a/code/debris/debris.cpp +++ b/code/debris/debris.cpp @@ -9,13 +9,17 @@ /* * $Logfile: /Freespace2/code/Debris/Debris.cpp $ - * $Revision: 2.30 $ - * $Date: 2007-02-11 09:22:29 $ - * $Author: taylor $ + * $Revision: 2.31 $ + * $Date: 2007-02-20 04:20:10 $ + * $Author: Goober5000 $ * * Code for the pieces of exploding object debris. * * $Log: not supported by cvs2svn $ + * Revision 2.30 2007/02/11 09:22:29 taylor + * remove NO_SOUND + * fix debris recycling + * * Revision 2.29 2006/12/28 00:59:19 wmcoolmon * WMC codebase commit. See pre-commit build thread for details on changes. * @@ -1247,7 +1251,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co int mc_ret_val = 0; if ( debris_hit_info->heavy == ship_obj ) { // ship is heavier, so debris is sphere. Check sphere collision against ship poly model - mc.model_num = Ships[ship_obj->instance].modelnum; // Fill in the model to check + mc.model_num = Ship_info[Ships[ship_obj->instance].ship_info_index].model_num; // Fill in the model to check mc.orient = &ship_obj->orient; // The object's orient mc.radius = pdebris->radius; mc.flags = (MC_CHECK_MODEL | MC_CHECK_SPHERELINE); @@ -1278,7 +1282,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co model_get_rotating_submodel_list(submodel_list, &num_rotating_submodels, heavy_obj); // Get polymodel and turn off all rotating submodels, collide against only 1 at a time. - pm = model_get(Ships[heavy_obj->instance].modelnum); + pm = model_get(Ship_info[Ships[heavy_obj->instance].ship_info_index].model_num); // turn off all rotating submodels and test for collision int i; @@ -1373,7 +1377,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co mc.submodel_num = Debris[num].submodel_num; model_clear_instance( mc.model_num ); mc.orient = &pdebris->orient; // The object's orient - mc.radius = model_get_core_radius( Ships[ship_obj->instance].modelnum ); + mc.radius = model_get_core_radius(Ship_info[Ships[ship_obj->instance].ship_info_index].model_num); // check for collision between debris model and ship sphere mc.flags = (MC_CHECK_MODEL | MC_SUBMODEL | MC_CHECK_SPHERELINE); diff --git a/code/fred2/fredrender.cpp b/code/fred2/fredrender.cpp index b2836b3e45..097d734f6e 100644 --- a/code/fred2/fredrender.cpp +++ b/code/fred2/fredrender.cpp @@ -9,14 +9,17 @@ /* * $Logfile: /Freespace2/code/fred2/FredRender.cpp $ - * $Revision: 1.8 $ - * $Date: 2006-12-28 00:59:20 $ - * $Author: wmcoolmon $ + * $Revision: 1.9 $ + * $Date: 2007-02-20 04:20:10 $ + * $Author: Goober5000 $ * * Handles rendering the scene in the window for Fred. Also handles several other * miscellaneous tasks. * * $Log: not supported by cvs2svn $ + * Revision 1.8 2006/12/28 00:59:20 wmcoolmon + * WMC codebase commit. See pre-commit build thread for details on changes. + * * Revision 1.7 2006/11/06 05:58:05 taylor * add a "Render full detail" view option to render models at their full detail for the LOD (for render/detail boxes, Mantis bug #1121) * @@ -803,7 +806,7 @@ void fredhtl_render_subsystem_bounding_box(subsys_to_render * s2r) { vertex text_center; - polymodel *pm = model_get(Ships[s2r->ship_obj->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[s2r->ship_obj->instance].ship_info_index].model_num); int subobj_num = s2r->cur_subsys->system_info->subobj_num; bsp_info *bsp = &pm->submodel[subobj_num]; char buf[256]; @@ -1063,15 +1066,15 @@ void render_one_model_nohtl(object *objp) z = objp->instance; - model_clear_instance( Ships[z].modelnum ); + model_clear_instance( Ship_info[Ships[z].ship_info_index].model_num ); // if (!viewpoint || OBJ_INDEX(objp) != cur_object_index) { if (Fred_outline) { model_set_outline_color(Fred_outline >> 16, (Fred_outline >> 8) & 0xff, Fred_outline & 0xff); - model_render(Ships[z].modelnum, &objp->orient, &objp->pos, j | MR_SHOW_OUTLINE, -1, -1, Ships[z].replacement_textures); + model_render(Ship_info[Ships[z].ship_info_index].model_num, &objp->orient, &objp->pos, j | MR_SHOW_OUTLINE, -1, -1, Ships[z].replacement_textures); } else { - model_render(Ships[z].modelnum, &objp->orient, &objp->pos, j, -1, -1, Ships[z].replacement_textures); + model_render(Ship_info[Ships[z].ship_info_index].model_num, &objp->orient, &objp->pos, j, -1, -1, Ships[z].replacement_textures); } } @@ -1193,7 +1196,7 @@ void render_one_model_htl(object *objp) z = objp->instance; - model_clear_instance( Ships[z].modelnum ); + model_clear_instance( Ship_info[Ships[z].ship_info_index].model_num ); if(!Lighting_on) { j |= MR_NO_LIGHTING; @@ -1210,7 +1213,7 @@ void render_one_model_htl(object *objp) } g3_done_instance(0); - model_render(Ships[z].modelnum, &objp->orient, &objp->pos, j, -1, -1, Ships[z].replacement_textures); + model_render(Ship_info[Ships[z].ship_info_index].model_num, &objp->orient, &objp->pos, j, -1, -1, Ships[z].replacement_textures); } else { int r = 0, g = 0, b = 0; @@ -2175,10 +2178,10 @@ int object_check_collision(object *objp, vec3d *p0, vec3d *p1, vec3d *hitpos) return 0; if ((Show_ship_models || Show_outlines) && (objp->type == OBJ_SHIP)) { - mc.model_num = Ships[objp->instance].modelnum; // Fill in the model to check + mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; // Fill in the model to check } else if ((Show_ship_models || Show_outlines) && (objp->type == OBJ_START)) { - mc.model_num = Ships[objp->instance].modelnum; // Fill in the model to check + mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; // Fill in the model to check } else return fvi_ray_sphere(hitpos, p0, p1, &objp->pos, (objp->radius > 0.1f) ? objp->radius : LOLLIPOP_SIZE); diff --git a/code/fred2/fredview.cpp b/code/fred2/fredview.cpp index 91256c72a2..064a9b212f 100644 --- a/code/fred2/fredview.cpp +++ b/code/fred2/fredview.cpp @@ -9,9 +9,9 @@ /* * $Logfile: /Freespace2/code/Fred2/FREDView.cpp $ - * $Revision: 1.13 $ - * $Date: 2007-02-15 02:03:56 $ - * $Author: phreak $ + * $Revision: 1.14 $ + * $Date: 2007-02-20 04:20:10 $ + * $Author: Goober5000 $ * * View class for a document/view architechure design program, which we don't * want or need, but MFC forces us to use. This is the main place we handle @@ -19,6 +19,9 @@ * There is also a lot of our code in here related to these things. * * $Log: not supported by cvs2svn $ + * Revision 1.13 2007/02/15 02:03:56 phreak + * Apparently Visual C++ 2005 follows standard syntax rules. + * * Revision 1.12 2006/11/06 05:58:05 taylor * add a "Render full detail" view option to render models at their full detail for the LOD (for render/detail boxes, Mantis bug #1121) * @@ -3223,13 +3226,13 @@ int CFREDView::global_error_check() return internal_error("Docking illegal between \"%s\" and \"%s\" (initially docked)", Ships[i].ship_name, Ships[ship].ship_name); } - z = get_docking_list(Ships[i].modelnum); + z = get_docking_list(Ship_info[Ships[i].ship_info_index].model_num); point = dock_ptr->dockpoint_used; if (point < 0 || point >= z){ internal_error("Invalid docker point (\"%s\" initially docked with \"%s\")", Ships[i].ship_name, Ships[ship].ship_name); } - z = get_docking_list(Ships[ship].modelnum); + z = get_docking_list(Ship_info[Ships[ship].ship_info_index].model_num); point = dock_find_dockpoint_used_by_object(dock_ptr->docked_objp, &Objects[Ships[i].objnum]); if (point < 0 || point >= z){ internal_error("Invalid dockee point (\"%s\" initially docked with \"%s\")", Ships[i].ship_name, Ships[ship].ship_name); @@ -4083,7 +4086,7 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing) if (!ship_docking_valid(ship, inst)) return "Docking illegal between given ship types"; - model1 = Ships[ship].modelnum; + model1 = Ship_info[Ships[ship].ship_info_index].model_num; num = get_docking_list(model1); for (j=0; jAddString(model_get_dock_name(Ships[m_ship].modelnum, dockpoint)); + z = lstDockerPoints->AddString(model_get_dock_name(Ship_info[Ships[m_ship].ship_info_index].model_num, dockpoint)); lstDockerPoints->SetItemData(z, dockpoint); } @@ -509,7 +509,7 @@ void initial_status::change_docker_point(bool store_selection) else { // populate with all possible dockees - list_dockees(model_get_dock_index_type(Ships[m_ship].modelnum, cur_docker_point)); + list_dockees(model_get_dock_index_type(Ship_info[Ships[m_ship].ship_info_index].model_num, cur_docker_point)); // see if there's a dockee here if (dockpoint_array[cur_docker_point].dockee_shipnum >= 0) @@ -571,7 +571,7 @@ void initial_status::change_dockee(bool store_selection) if (dockpoint_array[cur_docker_point].dockee_point >= 0) { // select the dockpoint - cboDockeePoints->SelectString(-1, model_get_dock_name(Ships[cur_dockee].modelnum, dockpoint_array[cur_docker_point].dockee_point)); + cboDockeePoints->SelectString(-1, model_get_dock_name(Ship_info[Ships[cur_dockee].ship_info_index].model_num, dockpoint_array[cur_docker_point].dockee_point)); change_dockee_point(false); } // there might not be any dockpoints available @@ -676,7 +676,7 @@ void initial_status::list_dockees(int dock_types) continue; // dock types must match - if (!(model_get_dock_types(Ships[ship].modelnum) & dock_types)) + if (!(model_get_dock_types(Ship_info[Ships[ship].ship_info_index].model_num) & dock_types)) continue; // add to list @@ -703,10 +703,10 @@ void initial_status::list_dockee_points(int shipnum) return; // get the required dock type(s) - int dock_type = model_get_dock_index_type(shipp->modelnum, cur_docker_point); + int dock_type = model_get_dock_index_type(Ship_info[shipp->ship_info_index].model_num, cur_docker_point); // populate with the right kind of dockee points - for (int i = 0; i < model_get_num_dock_points(other_shipp->modelnum); i++) + for (int i = 0; i < model_get_num_dock_points(Ship_info[other_shipp->ship_info_index].model_num); i++) { // make sure this dockpoint is not occupied by someone else object *docked_objp = dock_find_object_at_dockpoint(&Objects[other_shipp->objnum], i); @@ -714,11 +714,11 @@ void initial_status::list_dockee_points(int shipnum) continue; // make sure its type matches - if (!(model_get_dock_index_type(other_shipp->modelnum, i) & dock_type)) + if (!(model_get_dock_index_type(Ship_info[other_shipp->ship_info_index].model_num, i) & dock_type)) continue; // add to list - z = cboDockeePoints->AddString(model_get_dock_name(other_shipp->modelnum, i)); + z = cboDockeePoints->AddString(model_get_dock_name(Ship_info[other_shipp->ship_info_index].model_num, i)); cboDockeePoints->SetItemData(z, i); } } diff --git a/code/fred2/management.cpp b/code/fred2/management.cpp index 69e1b98968..a4244f295b 100644 --- a/code/fred2/management.cpp +++ b/code/fred2/management.cpp @@ -9,8 +9,8 @@ /* * $Logfile: /Freespace2/code/Fred2/Management.cpp $ - * $Revision: 1.32 $ - * $Date: 2007-02-18 06:16:46 $ + * $Revision: 1.33 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * This file handles the management of Objects, Ships, Wings, etc. Basically @@ -19,6 +19,9 @@ * function. * * $Log: not supported by cvs2svn $ + * Revision 1.32 2007/02/18 06:16:46 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 1.31 2007/02/11 21:26:34 Goober5000 * massive shield infrastructure commit * @@ -2438,7 +2441,7 @@ void set_valid_dock_points(int ship, int type, CComboBox *box) { int i, z, num, model; - model = Ships[ship].modelnum; + model = Ship_info[Ships[ship].ship_info_index].model_num; num = model_get_num_dock_points(model); for (i=0; iinstance].modelnum ); + pm = model_get( Ship_info[Ships[objp->instance].ship_info_index].model_num ); Assert( pm ); if ( pm->ship_bay && (pm->ship_bay->num_paths > 0) ) { id = box->AddString(Ships[get_ship_from_obj(objp)].ship_name); diff --git a/code/fred2/missionsave.cpp b/code/fred2/missionsave.cpp index c1e0e3f7db..bc679c49c6 100644 --- a/code/fred2/missionsave.cpp +++ b/code/fred2/missionsave.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Fred2/MissionSave.cpp $ - * $Revision: 1.33 $ - * $Date: 2007-02-11 21:26:34 $ + * $Revision: 1.34 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * Mission saving in Fred. * * $Log: not supported by cvs2svn $ + * Revision 1.33 2007/02/11 21:26:34 Goober5000 + * massive shield infrastructure commit + * * Revision 1.32 2007/01/15 13:42:59 karajorma * Hmmm. Forgot to commit changes to support network variables and setting ammo/weapons to HEAD as well as 3.6.9. * @@ -1481,12 +1484,12 @@ void CFred_mission_save::save_single_dock_instance(ship *shipp, dock_instance *d // write docker (actually dockee) point required_string_fred("$Docker Point:", "$Name:"); parse_comments(); - fout(" %s", model_get_dock_name(other_shipp->modelnum, dock_find_dockpoint_used_by_object(other_objp, objp))); + fout(" %s", model_get_dock_name(Ship_info[other_shipp->ship_info_index].model_num, dock_find_dockpoint_used_by_object(other_objp, objp))); // write dockee (actually docker) point required_string_fred("$Dockee Point:", "$Name:"); parse_comments(); - fout(" %s", model_get_dock_name(shipp->modelnum, dock_find_dockpoint_used_by_object(objp, other_objp))); + fout(" %s", model_get_dock_name(Ship_info[shipp->ship_info_index].model_num, dock_find_dockpoint_used_by_object(objp, other_objp))); } int CFred_mission_save::save_objects() @@ -1682,7 +1685,7 @@ int CFred_mission_save::save_objects() fout("\n+Arrival Paths: ( "); - pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].modelnum); + pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num); for (j = 0; j < pm->ship_bay->num_paths; j++) { if (Ships[i].arrival_path_mask & (1 << j)) @@ -1738,7 +1741,7 @@ int CFred_mission_save::save_objects() fout("\n+Departure Paths: ( "); - pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].modelnum); + pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num); for (j = 0; j < pm->ship_bay->num_paths; j++) { if (Ships[i].departure_path_mask & (1 << j)) @@ -2308,7 +2311,7 @@ int CFred_mission_save::save_wings() fout("\n+Arrival Paths: ( "); - pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].modelnum); + pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num); for (j = 0; j < pm->ship_bay->num_paths; j++) { if (Wings[i].arrival_path_mask & (1 << j)) @@ -2364,7 +2367,7 @@ int CFred_mission_save::save_wings() fout("\n+Departure Paths: ( "); - pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].modelnum); + pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num); for (j = 0; j < pm->ship_bay->num_paths; j++) { if (Wings[i].departure_path_mask & (1 << j)) diff --git a/code/fred2/restrictpaths.cpp b/code/fred2/restrictpaths.cpp index 11ac78c0ea..0502195459 100644 --- a/code/fred2/restrictpaths.cpp +++ b/code/fred2/restrictpaths.cpp @@ -6,13 +6,17 @@ /* * $Logfile: /Freespace2/code/FRED2/RestrictPaths.cpp $ - * $Revision: 1.4 $ - * $Date: 2006-06-04 01:01:52 $ + * $Revision: 1.5 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * Code for restricting arrival/departure to specific bays * * $Log: not supported by cvs2svn $ + * Revision 1.4 2006/06/04 01:01:52 Goober5000 + * add fighterbay restriction code + * --Goober5000 + * * Revision 1.3 2006/05/31 03:05:42 Goober5000 * some cosmetic changes in preparation for bay arrival/departure code * --Goober5000 @@ -68,7 +72,7 @@ END_MESSAGE_MAP() BOOL restrict_paths::OnInitDialog() { // get stuff from params - m_model = model_get(Ship_info[m_ship_class].modelnum); + m_model = model_get(Ship_info[m_ship_class].model_num); Assert(m_model->ship_bay); m_num_paths = m_model->ship_bay->num_paths; Assert(m_num_paths > 0); diff --git a/code/fred2/sexp_tree.cpp b/code/fred2/sexp_tree.cpp index e9acf78c3a..ebe2f6d00a 100644 --- a/code/fred2/sexp_tree.cpp +++ b/code/fred2/sexp_tree.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Fred2/Sexp_tree.cpp $ - * $Revision: 1.16 $ - * $Date: 2007-01-15 13:42:59 $ - * $Author: karajorma $ + * $Revision: 1.17 $ + * $Date: 2007-02-20 04:20:10 $ + * $Author: Goober5000 $ * * Sexp tree handler class. Almost everything is handled by this class. * * $Log: not supported by cvs2svn $ + * Revision 1.16 2007/01/15 13:42:59 karajorma + * Hmmm. Forgot to commit changes to support network variables and setting ammo/weapons to HEAD as well as 3.6.9. + * * Revision 1.15 2006/12/28 00:59:20 wmcoolmon * WMC codebase commit. See pre-commit build thread for details on changes. * @@ -5300,7 +5303,7 @@ sexp_list_item *sexp_tree::get_listing_opf_docker_point(int parent_node) sh = ship_name_lookup(tree_nodes[z].text, 1); if (sh >= 0) { - z = get_docking_list(Ships[sh].modelnum); + z = get_docking_list(Ship_info[Ships[sh].ship_info_index].model_num); for (i=0; i= 0) { - z = get_docking_list(Ships[sh].modelnum); + z = get_docking_list(Ship_info[Ships[sh].ship_info_index].model_num); for (i=0; i EnableWindow(TRUE); m_subsys_box[item] -> ResetContent(); for (i=0; i GetItemData(m_object[item]); if ((mode == AI_GOAL_DOCK) && (m_data[item] >= 0)) { - num = get_docking_list(Ships[m_data[item] & DATA_MASK].modelnum); + num = get_docking_list(Ship_info[Ships[m_data[item] & DATA_MASK].ship_info_index].model_num); m_dock2_box[item] -> EnableWindow(TRUE); m_dock2_box[item] -> ResetContent(); for (i=0; imodel_num = model_load(sip->pof_file, 0, NULL); + + model_used[sip->model_num % MAX_POLYGON_MODELS]++; + model_id[sip->model_num % MAX_POLYGON_MODELS] = sip->model_num; } Texture_fp = fopen( NOX("ShipTextures.txt"), "wt" ); diff --git a/code/hud/hudshield.cpp b/code/hud/hudshield.cpp index 2554e1eb91..e8cc5117ad 100644 --- a/code/hud/hudshield.cpp +++ b/code/hud/hudshield.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Hud/HUDshield.cpp $ - * $Revision: 2.43 $ - * $Date: 2007-02-16 23:49:28 $ + * $Revision: 2.44 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * C file for the display and management of the HUD shield * * $Log: not supported by cvs2svn $ + * Revision 2.43 2007/02/16 23:49:28 Goober5000 + * ugh... reverting this, because it was done wrong + * * Revision 2.42 2007/02/11 21:26:34 Goober5000 * massive shield infrastructure commit * @@ -634,7 +637,7 @@ void hud_shield_show(object *objp) ship_model_start(objp); //if(!digitus_improbus) { - model_render( sp->modelnum, &object_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, -1, -1, sp->replacement_textures); + model_render( sip->model_num, &object_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, -1, -1, sp->replacement_textures); } /*else { diff --git a/code/hud/hudtarget.cpp b/code/hud/hudtarget.cpp index 310369eed6..0452fe0383 100644 --- a/code/hud/hudtarget.cpp +++ b/code/hud/hudtarget.cpp @@ -9,13 +9,17 @@ /* * $Logfile: /Freespace2/code/Hud/HUDtarget.cpp $ - * $Revision: 2.99 $ - * $Date: 2007-02-11 09:20:00 $ - * $Author: taylor $ + * $Revision: 2.100 $ + * $Date: 2007-02-20 04:20:10 $ + * $Author: Goober5000 $ * * C module to provide HUD targeting functions * * $Log: not supported by cvs2svn $ + * Revision 2.99 2007/02/11 09:20:00 taylor + * little bit of cleanup + * more fixage for hidden jumpnodes (Mantis #1149) + * * Revision 2.98 2007/01/08 00:50:58 Goober5000 * remove WMC's limbo code, per our discussion a few months ago * this will later be handled by copying ship stats using sexps or scripts @@ -2562,7 +2566,7 @@ float hud_find_target_distance( object *targetee, object *targeter ) // Which model is it? switch( targetee->type ) { case OBJ_SHIP: - model_num = Ships[targetee->instance].modelnum; + model_num = Ship_info[Ships[targetee->instance].ship_info_index].model_num; break; case OBJ_DEBRIS: // model_num = Debris[targetee->instance].model_num; @@ -3038,7 +3042,7 @@ void hud_target_in_reticle_new() switch (A->type) { case OBJ_SHIP: - mc.model_num = Ships[A->instance].modelnum; + mc.model_num = Ship_info[Ships[A->instance].ship_info_index].model_num; break; case OBJ_DEBRIS: mc.model_num = Debris[A->instance].model_num; @@ -3786,7 +3790,7 @@ void hud_show_message_sender() switch ( targetp->type ) { case OBJ_SHIP: - modelnum = target_shipp->modelnum; + modelnum = Ship_info[target_shipp->ship_info_index].model_num; bound_rval = model_find_2d_bound_min( modelnum, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 ); break; @@ -3936,7 +3940,7 @@ void hud_show_selection_set() switch ( targetp->type ) { case OBJ_SHIP: - modelnum = target_shipp->modelnum; + modelnum = Ship_info[target_shipp->ship_info_index].model_num; bound_rval = model_find_2d_bound_min( modelnum, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 ); break; @@ -3984,7 +3988,7 @@ void hud_show_brackets(object *targetp, vertex *projected_v) switch ( targetp->type ) { case OBJ_SHIP: - modelnum = Ships[targetp->instance].modelnum; + modelnum = Ship_info[Ships[targetp->instance].ship_info_index].model_num; bound_rc = model_find_2d_bound_min( modelnum, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 ); if ( bound_rc != 0 ) { draw_box = FALSE; @@ -4466,7 +4470,7 @@ void hud_show_lead_indicator(vec3d *target_world_pos) vec3d *rel_pos; vertex lead_target_vertex; object *targetp; - polymodel *po; + polymodel *pm; ship_weapon *swp; weapon_info *wip; weapon_info *tmp=NULL; @@ -4495,7 +4499,7 @@ void hud_show_lead_indicator(vec3d *target_world_pos) return; } - po = model_get( Player_ship->modelnum ); + pm = model_get(Ship_info[Player_ship->ship_info_index].model_num); swp = &Player_ship->weapons; // Added to take care of situation where there are no primary banks on the player ship @@ -4508,8 +4512,8 @@ void hud_show_lead_indicator(vec3d *target_world_pos) return; wip = &Weapon_info[swp->primary_bank_weapons[bank_to_fire]]; - if (po->n_guns && bank_to_fire != -1 ) { - rel_pos = &po->gun_banks[bank_to_fire].pnt[0]; + if (pm->n_guns && bank_to_fire != -1 ) { + rel_pos = &pm->gun_banks[bank_to_fire].pnt[0]; } else { rel_pos = NULL; } diff --git a/code/hud/hudtargetbox.cpp b/code/hud/hudtargetbox.cpp index d942f9112d..7b321b4bb7 100644 --- a/code/hud/hudtargetbox.cpp +++ b/code/hud/hudtargetbox.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Hud/HUDtargetbox.cpp $ - * $Revision: 2.69 $ - * $Date: 2007-02-11 21:26:34 $ + * $Revision: 2.70 $ + * $Date: 2007-02-20 04:20:10 $ * $Author: Goober5000 $ * * C module for drawing the target monitor box on the HUD * * $Log: not supported by cvs2svn $ + * Revision 2.69 2007/02/11 21:26:34 Goober5000 + * massive shield infrastructure commit + * * Revision 2.68 2007/01/07 12:53:35 taylor * add position info for weapon energy text * make sure that we can't target a hidden jumpnode @@ -1441,7 +1444,7 @@ int hud_targetbox_subsystem_in_view(object *target_objp, int *sx, int *sy) // get screen coords, adjusting for autocenter Assert(target_objp->type == OBJ_SHIP); if (target_objp->type == OBJ_SHIP) { - pm = model_get(Ships[target_objp->instance].modelnum); + pm = model_get(Ship_info[Ships[target_objp->instance].ship_info_index].model_num); if (pm->flags & PM_FLAG_AUTOCEN) { vec3d temp, delta; vm_vec_copy_scale(&temp, &pm->autocenter, -1.0f); @@ -1518,13 +1521,11 @@ void hud_maybe_render_cargo_scan(ship_info *target_sip) // orient => Orientation of object at the origin void hud_targetbox_get_eye(vec3d *eye_pos, matrix *orient, int ship_num) { - ship *shipp; polymodel *pm; eye *ep; vec3d origin = ZERO_VECTOR; - shipp = &Ships[ship_num]; - pm = model_get( shipp->modelnum ); + pm = model_get(Ship_info[Ships[ship_num].ship_info_index].model_num); // If there is no eye, don't do anything if ( pm->n_view_positions == 0 ) { @@ -1533,7 +1534,7 @@ void hud_targetbox_get_eye(vec3d *eye_pos, matrix *orient, int ship_num) ep = &(pm->view_positions[0] ); - model_find_world_point( eye_pos, &ep->pnt, shipp->modelnum, ep->parent, orient, &origin ); + model_find_world_point( eye_pos, &ep->pnt, pm->id, ep->parent, orient, &origin ); } // ------------------------------------------------------------------------------------- @@ -1602,10 +1603,10 @@ void hud_render_target_ship(object *target_objp) } // maybe render a special hud-target-only model - if(target_sip->modelnum_hud >= 0){ - model_render( target_sip->modelnum_hud, &target_objp->orient, &obj_pos, flags | MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING); + if(target_sip->model_num_hud >= 0){ + model_render( target_sip->model_num_hud, &target_objp->orient, &obj_pos, flags | MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING); } else { - model_render( target_shipp->modelnum, &target_objp->orient, &obj_pos, flags | MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, -1, -1, target_shipp->replacement_textures); + model_render( target_sip->model_num, &target_objp->orient, &obj_pos, flags | MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, -1, -1, target_shipp->replacement_textures); } ship_model_stop( target_objp ); @@ -1755,12 +1756,15 @@ void hud_render_target_weapon(object *target_objp) viewed_model_num = target_wip->model_num; hud_target_lod = target_wip->hud_target_lod; if ( is_homing && is_player_missile ) { + ship *homing_shipp = &Ships[wp->homing_object->instance]; + ship_info *homing_sip = &Ship_info[homing_shipp->ship_info_index]; + viewer_obj = target_objp; viewed_obj = wp->homing_object; missile_view = TRUE; - viewed_model_num = Ships[wp->homing_object->instance].modelnum; - replacement_textures = Ships[wp->homing_object->instance].replacement_textures; - hud_target_lod = Ship_info[Ships[wp->homing_object->instance].ship_info_index].hud_target_lod; + viewed_model_num = homing_sip->model_num; + replacement_textures = homing_shipp->replacement_textures; + hud_target_lod = homing_sip->hud_target_lod; } if (Targetbox_wire!=0) @@ -2161,7 +2165,7 @@ void hud_show_target_data(float frametime) gr_printf(sx, sy, "Targ size: %dx%d", Hud_target_w, Hud_target_h ); sy += dy; - polymodel *pm = model_get( shipp->modelnum ); + polymodel *pm = model_get(sip->model_num); gr_printf(sx, sy, "POF:%s", pm->filename ); sy += dy; diff --git a/code/io/keycontrol.cpp b/code/io/keycontrol.cpp index e110d04c69..78098c437c 100644 --- a/code/io/keycontrol.cpp +++ b/code/io/keycontrol.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Io/KeyControl.cpp $ - * $Revision: 2.76 $ - * $Date: 2007-02-10 06:39:43 $ + * $Revision: 2.77 $ + * $Date: 2007-02-20 04:20:18 $ * $Author: Goober5000 $ * * Routines to read and deal with keyboard input. * * $Log: not supported by cvs2svn $ + * Revision 2.76 2007/02/10 06:39:43 Goober5000 + * new feature: shield generators that control whether the shield is up + * * Revision 2.75 2007/02/10 00:18:22 taylor * remove NO_SOUND * @@ -2004,10 +2007,9 @@ void game_process_pause_key() } #define WITHIN_BBOX() do { \ - float scale = 2.0f; \ - polymodel *pm = model_get(s_check->modelnum); \ - collided = 0; \ - if(pm != NULL){ \ + if (pm != NULL) { \ + float scale = 2.0f; \ + collided = 0; \ vec3d temp = new_obj->pos; \ vec3d gpos; \ vm_vec_sub2(&temp, &hit_check->pos); \ @@ -2019,8 +2021,7 @@ void game_process_pause_key() } while(0) #define MOVE_AWAY_BBOX() do { \ - polymodel *pm = model_get(s_check->modelnum); \ - if(pm != NULL){ \ + if (pm != NULL) { \ switch((int)frand_range(0.0f, 3.9f)){ \ case 0: \ new_obj->pos.xyz.x += 200.0f; \ @@ -2144,6 +2145,7 @@ void game_process_cheats(int k) Objects[objnum].pos.xyz.x += 1.0f; } + polymodel *pm = model_get(Ship_info[s_check->ship_info_index].model_num); WITHIN_BBOX(); if(collided){ MOVE_AWAY_BBOX(); diff --git a/code/mission/missionparse.cpp b/code/mission/missionparse.cpp index 9cd675b999..ff3ed15676 100644 --- a/code/mission/missionparse.cpp +++ b/code/mission/missionparse.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Mission/MissionParse.cpp $ - * $Revision: 2.215 $ - * $Date: 2007-02-18 06:16:47 $ + * $Revision: 2.216 $ + * $Date: 2007-02-20 04:20:18 $ * $Author: Goober5000 $ * * main upper level code for parsing stuff * * $Log: not supported by cvs2svn $ + * Revision 2.215 2007/02/18 06:16:47 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.214 2007/02/13 01:46:03 Goober5000 * fix a hideous bug with the knossos special warp stuff * (how did this ever actually work correctly?) @@ -2609,7 +2612,7 @@ void position_ship_for_knossos_warpin(p_object *p_objp) // position self for warp on plane of device vec3d new_point; - polymodel *pm = model_get(shipp->modelnum); + polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); float dist = fvi_ray_plane(&new_point, &knossos_objp->pos, &knossos_objp->orient.vec.fvec, &p_objp->pos, &p_objp->orient.vec.fvec, 0.0f); float desired_dist = -pm->mins.xyz.z; @@ -2655,8 +2658,8 @@ void parse_dock_one_docked_object(p_object *pobjp, p_object *parent_pobjp) } // resolve names to dockpoints - dockpoint = model_find_dock_name_index(Ships[objp->instance].modelnum, dockpoint_name); - parent_dockpoint = model_find_dock_name_index(Ships[parent_objp->instance].modelnum, parent_dockpoint_name); + dockpoint = model_find_dock_name_index(Ship_info[Ships[objp->instance].ship_info_index].model_num, dockpoint_name); + parent_dockpoint = model_find_dock_name_index(Ship_info[Ships[parent_objp->instance].ship_info_index].model_num, parent_dockpoint_name); // check valid if ((dockpoint < 0) || (parent_dockpoint < 0)) @@ -2890,7 +2893,7 @@ int parse_create_object_sub(p_object *p_objp) // now fill them in for (i = 0; i < p_objp->num_texture_replacements; i++) { - pm = model_get(sip->modelnum); + pm = model_get(sip->model_num); // look for textures for (j = 0; j < pm->n_textures; j++) @@ -3069,7 +3072,7 @@ int parse_create_object_sub(p_object *p_objp) free_sexp2(p_objp->ai_goals); // free up sexp nodes for reuse, since they aren't needed anymore. } - Assert(shipp->modelnum != -1); + Assert(sip->model_num != -1); // initialize subsystem statii here. The subsystems are given a percentage damaged. So a percent value // of 20% means that the subsystem is 20% damaged (*not* 20% of max hits). This is opposite the way @@ -3249,7 +3252,7 @@ int parse_create_object_sub(p_object *p_objp) // create sparks on a ship whose hull is damaged. We will create two sparks for every 20% // of hull damage done. 100 means no sparks. between 80 and 100 do two sparks. 60 and 80 is // four, etc. - pm = model_get(shipp->modelnum); // changed from sip to Ships[] by Goober5000 + pm = model_get(sip->model_num); max_allowed_sparks = get_max_sparks(&Objects[objnum]); num_sparks = (int)((100.0f - p_objp->initial_hull) / 5.0f); if (num_sparks > max_allowed_sparks) @@ -3260,7 +3263,7 @@ int parse_create_object_sub(p_object *p_objp) vec3d v1, v2; // DA 10/20/98 - sparks must be chosen on the hull and not any submodel - submodel_get_two_random_points(shipp->modelnum, pm->detail[0], &v1, &v2); + submodel_get_two_random_points(sip->model_num, pm->detail[0], &v1, &v2); ship_hit_sparks_no_rotate(&Objects[objnum], &v1); // ship_hit_sparks_no_rotate(&Objects[objnum], &v2); } @@ -4068,7 +4071,7 @@ void mission_parse_maybe_create_parse_object(p_object *pobjp) if (!Fred_running) { int i; - shipfx_blow_up_model(objp, Ships[objp->instance].modelnum, 0, 0, &objp->pos); + shipfx_blow_up_model(objp, Ship_info[Ships[objp->instance].ship_info_index].model_num, 0, 0, &objp->pos); objp->flags |= OF_SHOULD_BE_DEAD; // once the ship is exploded, find the debris pieces belonging to this object, mark them diff --git a/code/missionui/missionbrief.cpp b/code/missionui/missionbrief.cpp index cddb551f5e..1fe0fdde95 100644 --- a/code/missionui/missionbrief.cpp +++ b/code/missionui/missionbrief.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/MissionUI/MissionBrief.cpp $ - * $Revision: 2.43 $ - * $Date: 2006-12-28 00:59:32 $ - * $Author: wmcoolmon $ + * $Revision: 2.44 $ + * $Date: 2007-02-20 04:20:18 $ + * $Author: Goober5000 $ * * C module that contains code to display the mission briefing to the player * * $Log: not supported by cvs2svn $ + * Revision 2.43 2006/12/28 00:59:32 wmcoolmon + * WMC codebase commit. See pre-commit build thread for details on changes. + * * Revision 2.42 2006/05/13 07:09:25 taylor * minor cleanup and a couple extra error checks * get rid of some wasteful math from the gr_set_proj_matrix() calls @@ -1665,7 +1668,7 @@ void brief_get_closeup_ship_modelnum(brief_icon *ci) sp = &Ships[objp->instance]; if ( sp->ship_info_index == ci->ship_class ) { ci->ship_class = sp->ship_info_index; - ci->modelnum = sp->modelnum; + ci->modelnum = Ship_info[sp->ship_info_index].model_num; ci->radius = objp->radius; break; } @@ -1970,11 +1973,11 @@ void brief_do_frame(float frametime) Closeup_icon->ship_class--; ship_info *sip = &Ship_info[Closeup_icon->ship_class]; - if (sip->modelnum < 0) - sip->modelnum = model_load(sip->pof_file, 0, NULL); + if (sip->model_num < 0) + sip->model_num = model_load(sip->pof_file, 0, NULL); mprintf(("Shiptype = %d (%s)\n", Closeup_icon->ship_class, sip->name)); - mprintf(("Modelnum = %d (%s)\n", sip->modelnum, sip->pof_file)); + mprintf(("Modelnum = %d (%s)\n", sip->model_num, sip->pof_file)); brief_setup_closeup(Closeup_icon); } @@ -1986,11 +1989,11 @@ void brief_do_frame(float frametime) Closeup_icon->ship_class++; ship_info *sip = &Ship_info[Closeup_icon->ship_class]; - if (sip->modelnum < 0) - sip->modelnum = model_load(sip->pof_file, 0, NULL); + if (sip->model_num < 0) + sip->model_num = model_load(sip->pof_file, 0, NULL); mprintf(("Shiptype = %d (%s)\n", Closeup_icon->ship_class, sip->name)); - mprintf(("Modelnum = %d (%s)\n", sip->modelnum, sip->pof_file)); + mprintf(("Modelnum = %d (%s)\n", sip->model_num, sip->pof_file)); brief_setup_closeup(Closeup_icon); } diff --git a/code/missionui/missionshipchoice.cpp b/code/missionui/missionshipchoice.cpp index 00377d5d6c..24fa366af7 100644 --- a/code/missionui/missionshipchoice.cpp +++ b/code/missionui/missionshipchoice.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/MissionUI/MissionShipChoice.cpp $ - * $Revision: 2.67 $ - * $Date: 2006-12-28 00:59:32 $ - * $Author: wmcoolmon $ + * $Revision: 2.68 $ + * $Date: 2007-02-20 04:20:18 $ + * $Author: Goober5000 $ * * C module to allow player ship selection for the mission * * $Log: not supported by cvs2svn $ + * Revision 2.67 2006/12/28 00:59:32 wmcoolmon + * WMC codebase commit. See pre-commit build thread for details on changes. + * * Revision 2.66 2006/11/06 05:43:36 taylor * fix a memory leak that Valgrind was complaining about (happens mainly when you have a mission without a briefing) * @@ -2451,7 +2454,7 @@ void start_ship_animation(int ship_class, int play_sound) // page in ship textures properly (takes care of nondimming pixels) model_page_in_textures(ShipSelectModelNum, ship_class); - if (sip->modelnum < 0) + if (sip->model_num < 0) { mprintf(("Couldn't load model file in missionshipchoice.cpp - tell UnknownPlayer")); } diff --git a/code/model/modelinterp.cpp b/code/model/modelinterp.cpp index e2a7e810e8..8823b355f9 100644 --- a/code/model/modelinterp.cpp +++ b/code/model/modelinterp.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Model/ModelInterp.cpp $ - * $Revision: 2.189 $ - * $Date: 2007-02-18 06:16:47 $ + * $Revision: 2.190 $ + * $Date: 2007-02-20 04:20:18 $ * $Author: Goober5000 $ * * Rendering models, I think. * * $Log: not supported by cvs2svn $ + * Revision 2.189 2007/02/18 06:16:47 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.188 2007/02/16 22:09:05 Goober5000 * remove obsolete and misleading comments which should have been edited when the code was upgraded * @@ -5385,7 +5388,7 @@ float get_world_closest_box_point_with_delta(vec3d *closest_box_point, object *b int modelnum; // get modelnum - modelnum = Ships[box_obj->instance].modelnum; + modelnum = Ship_info[Ships[box_obj->instance].ship_info_index].model_num; // rotate start_point to box_obj RF vm_vec_sub(&temp, start_point, &box_obj->pos); @@ -6741,16 +6744,16 @@ int model_should_render_engine_glow(int objnum, int bank_obj) if (obj->type == OBJ_SHIP) { ship_subsys *ssp; ship *shipp = &Ships[obj->instance]; - ship_info *si = &Ship_info[shipp->ship_info_index]; + ship_info *sip = &Ship_info[shipp->ship_info_index]; - if(bank_obj >= si->n_subsystems){ - Error( LOCATION, "thruster bank is linked to subsystem #%d, wich is out of bounds, on model %s", bank_obj, model_get(shipp->modelnum)->filename); + if(bank_obj >= sip->n_subsystems){ + Error( LOCATION, "thruster bank is linked to subsystem #%d, which is out of bounds, on model %s", bank_obj, sip->pof_file); return 1; } char subname[MAX_NAME_LEN]; // shipp->subsystems isn't always valid here so don't use it - strncpy(subname, si->subsystems[bank_obj].subobj_name, MAX_NAME_LEN); + strncpy(subname, sip->subsystems[bank_obj].subobj_name, MAX_NAME_LEN); ssp = GET_FIRST(&shipp->subsys_list); while ( ssp != END_OF_LIST( &shipp->subsys_list ) ) { diff --git a/code/model/modelread.cpp b/code/model/modelread.cpp index 92c353289e..1807e17440 100644 --- a/code/model/modelread.cpp +++ b/code/model/modelread.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Model/ModelRead.cpp $ - * $Revision: 2.128 $ - * $Date: 2007-02-18 06:16:47 $ + * $Revision: 2.129 $ + * $Date: 2007-02-20 04:20:18 $ * $Author: Goober5000 $ * * file which reads and deciphers POF information * * $Log: not supported by cvs2svn $ + * Revision 2.128 2007/02/18 06:16:47 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.127 2007/02/10 06:39:43 Goober5000 * new feature: shield generators that control whether the shield is up * @@ -1436,12 +1439,12 @@ void model_unload(int modelnum, int force) // run through Ship_info[] and if the model has been loaded we'll need to reset the modelnum to -1. for (i = 0; i < Num_ship_classes; i++) { - if ( pm->id == Ship_info[i].modelnum ) { - Ship_info[i].modelnum = -1; + if ( pm->id == Ship_info[i].model_num ) { + Ship_info[i].model_num = -1; } - if ( pm->id == Ship_info[i].modelnum_hud ) { - Ship_info[i].modelnum_hud = -1; + if ( pm->id == Ship_info[i].model_num_hud ) { + Ship_info[i].model_num_hud = -1; } } @@ -3915,7 +3918,7 @@ void model_find_obj_dir(vec3d *w_vec, vec3d *m_vec, object *ship_obj, int sub_mo Assert(ship_obj->type == OBJ_SHIP); - polymodel *pm = model_get(Ships[ship_obj->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[ship_obj->instance].ship_info_index].model_num); vec = *m_vec; mn = sub_model_num; @@ -4457,7 +4460,7 @@ void model_get_rotating_submodel_list(int *submodel_list, int *num_rotating_subm Assert(objp->type == OBJ_SHIP); // Check if not currently rotating - then treat as part of superstructure. - int modelnum = Ships[objp->instance].modelnum; + int modelnum = Ship_info[Ships[objp->instance].ship_info_index].model_num; polymodel *pm = model_get(modelnum); bsp_info *child_submodel; diff --git a/code/network/multi_respawn.cpp b/code/network/multi_respawn.cpp index 43569aa041..6e7c27c4dc 100644 --- a/code/network/multi_respawn.cpp +++ b/code/network/multi_respawn.cpp @@ -9,11 +9,14 @@ /* * $Logfile: /Freespace2/code/Network/multi_respawn.cpp $ - * $Revision: 2.12 $ - * $Date: 2006-02-06 02:06:02 $ - * $Author: wmcoolmon $ + * $Revision: 2.13 $ + * $Date: 2007-02-20 04:20:18 $ + * $Author: Goober5000 $ * * $Log: not supported by cvs2svn $ + * Revision 2.12 2006/02/06 02:06:02 wmcoolmon + * Various fixes; very beginnings of Directives scripting support + * * Revision 2.11 2006/01/13 03:31:09 Goober5000 * übercommit of custom IFF stuff :) * @@ -906,10 +909,9 @@ void multi_respawn_check_ai() */ #define WITHIN_BBOX() do { \ - float scale = 2.0f; \ - polymodel *pm = model_get(s_check->modelnum); \ - collided = 0; \ - if(pm != NULL){ \ + if (pm != NULL) { \ + float scale = 2.0f; \ + collided = 0; \ vec3d temp = new_obj->pos; \ vec3d gpos; \ vm_vec_sub2(&temp, &hit_check->pos); \ @@ -921,8 +923,7 @@ void multi_respawn_check_ai() } while(0) #define MOVE_AWAY_BBOX() do { \ - polymodel *pm = model_get(s_check->modelnum); \ - if(pm != NULL){ \ + if (pm != NULL) { \ switch((int)frand_range(0.0f, 3.9f)){ \ case 0: \ new_obj->pos.xyz.x += 200.0f; \ @@ -970,7 +971,7 @@ void multi_respawn_place(object *new_obj, int team) // if we have a relevant respawn ship if((pri != NULL) && (pri_obj != NULL)){ // pick a point just outside his bounding box - polymodel *pm = model_get(pri->modelnum); + polymodel *pm = model_get(Ship_info[pri->ship_info_index].model_num); // hmm, ugly. Pick a point 2000 meters to the y direction if(pm == NULL){ @@ -1057,6 +1058,7 @@ void multi_respawn_place(object *new_obj, int team) new_obj->pos.xyz.x += 1.0f; } + polymodel *pm = model_get(Ship_info[s_check->ship_info_index].model_num); WITHIN_BBOX(); if(collided){ MOVE_AWAY_BBOX(); diff --git a/code/network/multimsgs.cpp b/code/network/multimsgs.cpp index faa4fe459d..1346f9eca2 100644 --- a/code/network/multimsgs.cpp +++ b/code/network/multimsgs.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Network/MultiMsgs.cpp $ - * $Revision: 2.67 $ - * $Date: 2007-02-18 06:17:09 $ + * $Revision: 2.68 $ + * $Date: 2007-02-20 04:20:18 $ * $Author: Goober5000 $ * * C file that holds functions for the building and processing of multiplayer packets * * $Log: not supported by cvs2svn $ + * Revision 2.67 2007/02/18 06:17:09 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.66 2007/02/11 21:26:35 Goober5000 * massive shield infrastructure commit * @@ -3059,7 +3062,7 @@ void send_ship_kill_packet( object *objp, object *other_objp, float percent_kill } // find out the next network signature that will be used for the debris pieces. - model = Ships[objp->instance].modelnum; + model = Ship_info[Ships[objp->instance].ship_info_index].model_num; pm = model_get(model); debris_signature = 0; if ( pm && !vaporized ) { @@ -6913,7 +6916,7 @@ void process_shield_explosion_packet( ubyte *data, header *hinfo) return; } - pm = model_get(Ships[objp->instance].modelnum); + pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num); shieldp = &pm->shield; Assert( utri_num < shieldp->ntris ); stri = shieldp->tris[utri_num]; diff --git a/code/object/collideshipship.cpp b/code/object/collideshipship.cpp index 5f2addc9b6..403594fc27 100644 --- a/code/object/collideshipship.cpp +++ b/code/object/collideshipship.cpp @@ -9,13 +9,17 @@ /* * $Logfile: /Freespace2/code/Object/CollideShipShip.cpp $ - * $Revision: 2.24 $ - * $Date: 2007-02-19 07:24:51 $ - * $Author: wmcoolmon $ + * $Revision: 2.25 $ + * $Date: 2007-02-20 04:20:27 $ + * $Author: Goober5000 $ * * Routines to detect collisions and do physics, damage, etc for ships and ships * * $Log: not supported by cvs2svn $ + * Revision 2.24 2007/02/19 07:24:51 wmcoolmon + * WMCoolmon experiences a duh moment. Move scripting collision variable declarations in front of overrides, to give + * them access to these (somewhat useful) variables + * * Revision 2.23 2007/02/11 21:26:35 Goober5000 * massive shield infrastructure commit * @@ -702,15 +706,12 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * object *heavy_obj = ship_ship_hit_info->heavy; object *light_obj = ship_ship_hit_info->light; int player_involved; // flag to indicate that A or B is the Player_obj - int num; //, player_check=0; Assert( heavy_obj->type == OBJ_SHIP ); Assert( light_obj->type == OBJ_SHIP ); - num = heavy_obj->instance; - Assert( num >= 0 ); - - Assert( Ships[num].objnum == OBJ_INDEX(heavy_obj)); + ship *heavy_shipp = &Ships[heavy_obj->instance]; + ship *light_shipp = &Ships[light_obj->instance]; // AL 12-4-97: we use the player_involved flag to ensure collisions are always // done with the player, regardless of team. @@ -721,8 +722,10 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * } // Make ships that are warping in not get collision detection done - if ( Ships[num].flags & SF_ARRIVING ) - return 0; +// if ( heavy_shipp->flags & SF_ARRIVING ) { + if ( heavy_shipp->flags & SF_ARRIVING_STAGE_1 ) { + return 0; + } // Don't do collision detection for docking ships, since they will always collide while trying to dock if ( ships_are_docking(heavy_obj, light_obj) ) { @@ -742,13 +745,13 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * return 0; } - //nprintf(("AI", "Frame %i: Collision between %s and %s\n", Framecount, Ships[heavy_obj->instance].ship_name, Ships[light_obj->instance].ship_name)); + //nprintf(("AI", "Frame %i: Collision between %s and %s\n", Framecount, heavy_shipp->ship_name, light_shipp->ship_name)); #ifndef NDEBUG // Don't do collision detection on a pair of ships on the same team. // Change this someday, but for now, it's a problem. if ( !Collide_friendly ) { // Collide_friendly is a global value changed via debug console - if ( (!player_involved) && (Ships[heavy_obj->instance].team == Ships[light_obj->instance].team) ) { + if ( (!player_involved) && (heavy_shipp->team == light_shipp->team) ) { return 0; } } @@ -756,7 +759,7 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * // Apparently we're doing same team collisions. // But, if both are offscreen, ignore the collision - if (Ships[heavy_obj->instance].team == Ships[light_obj->instance].team) { + if (heavy_shipp->team == light_shipp->team) { // if ((Game_mode & GM_MULTIPLAYER) || (!(heavy_obj->flags & OF_WAS_RENDERED) && !(light_obj->flags & OF_WAS_RENDERED))) // mwa 4/28/98 -- don't understand why GM_MULTIPLAYER was included in this line. All clients // need to do all collisions for their own ship. removing the multiplayer part of next if statement. @@ -767,11 +770,11 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * } // If either of these objects doesn't get collision checks, abort. - if (Ship_info[Ships[num].ship_info_index].flags & SIF_NO_COLLIDE) { + if (Ship_info[heavy_shipp->ship_info_index].flags & SIF_NO_COLLIDE) { return 0; } - if (Ship_info[Ships[light_obj->instance].ship_info_index].flags & SIF_NO_COLLIDE) { + if (Ship_info[light_shipp->ship_info_index].flags & SIF_NO_COLLIDE) { return 0; } @@ -782,7 +785,7 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * // vec3d submodel_hit; // Do in heavy object RF - mc.model_num = Ships[num].modelnum; // Fill in the model to check + mc.model_num = Ship_info[heavy_shipp->ship_info_index].model_num; // Fill in the model to check mc.orient = &heavy_obj->orient; // The object's orient vec3d zero, p0, p1; @@ -814,12 +817,12 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * // Set up collision info mc.pos = &zero; // The object's position mc.p1 = &p1; // Point 2 of ray to check - mc.radius = model_get_core_radius( Ships[light_obj->instance].modelnum ); + mc.radius = model_get_core_radius(Ship_info[light_shipp->ship_info_index].model_num); mc.flags = (MC_CHECK_MODEL | MC_CHECK_SPHERELINE); // flags // Only check invisible face polygons for ship:ship of different teams. - if ( !(Ships[heavy_obj->instance].flags2 & SF2_DONT_COLLIDE_INVIS) ) { - if ((heavy_obj->flags & OF_PLAYER_SHIP) || (light_obj->flags & OF_PLAYER_SHIP) || (Ships[heavy_obj->instance].team != Ships[light_obj->instance].team) ) { + if ( !(heavy_shipp->flags2 & SF2_DONT_COLLIDE_INVIS) ) { + if ((heavy_obj->flags & OF_PLAYER_SHIP) || (light_obj->flags & OF_PLAYER_SHIP) || (heavy_shipp->team != light_shipp->team) ) { mc.flags |= MC_CHECK_INVISIBLE_FACES; } } @@ -850,7 +853,7 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * model_get_rotating_submodel_list(submodel_list, &num_rotating_submodels, heavy_obj); - pm = model_get(Ships[heavy_obj->instance].modelnum); + pm = model_get(Ship_info[heavy_shipp->ship_info_index].model_num); // turn off all rotating submodels and test for collision int i; @@ -1011,11 +1014,11 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * #endif // Update ai to deal with collisions - if (heavy_obj-Objects == Ai_info[Ships[light_obj->instance].ai_index].target_objnum) { - Ai_info[Ships[light_obj->instance].ai_index].ai_flags |= AIF_TARGET_COLLISION; + if (heavy_obj-Objects == Ai_info[light_shipp->ai_index].target_objnum) { + Ai_info[light_shipp->ai_index].ai_flags |= AIF_TARGET_COLLISION; } - if (light_obj-Objects == Ai_info[Ships[heavy_obj->instance].ai_index].target_objnum) { - Ai_info[Ships[heavy_obj->instance].ai_index].ai_flags |= AIF_TARGET_COLLISION; + if (light_obj-Objects == Ai_info[heavy_shipp->ai_index].target_objnum) { + Ai_info[heavy_shipp->ai_index].ai_flags |= AIF_TARGET_COLLISION; } // SET PHYSICS PARAMETERS @@ -1043,7 +1046,7 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * vm_vec_sub(&diff, &temp2, &temp1); ship_model_start( heavy_obj ); - pm = model_get(Ships[heavy_obj->instance].modelnum); + pm = model_get(heavy_shipp->modelnum); world_find_model_point(&temp3, hitpos, pm, ship_ship_hit_info->submodel_num, &heavy_obj->orient, &heavy_obj->pos); ship_model_stop( heavy_obj ); @@ -1058,10 +1061,7 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info, vec3d * calculate_ship_ship_collision_physics(ship_ship_hit_info); // Provide some separation for the case of same team - if (Ships[heavy_obj->instance].team == Ships[light_obj->instance].team) { - ship *heavy_shipp = &Ships[heavy_obj->instance]; - ship *light_shipp = &Ships[light_obj->instance]; - + if (heavy_shipp->team == light_shipp->team) { // If a couple of small ships, just move them apart. if ((Ship_info[heavy_shipp->ship_info_index].flags & SIF_SMALL_SHIP) && (Ship_info[light_shipp->ship_info_index].flags & SIF_SMALL_SHIP)) { @@ -1258,7 +1258,7 @@ void calculate_ship_ship_collision_physics(collision_info_struct *ship_ship_hit_ if (ship_ship_hit_info->submodel_rot_hit == 1) { bool set_model = false; - polymodel *pm = model_get(Ships[heavy->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[heavy->instance].ship_info_index].model_num); // be sure model is set if (pm->submodel[ship_ship_hit_info->submodel_num].sii == NULL) { @@ -1268,7 +1268,7 @@ void calculate_ship_ship_collision_physics(collision_info_struct *ship_ship_hit_ // set point on axis of rotating submodel if not already set. if (!pm->submodel[ship_ship_hit_info->submodel_num].sii->axis_set) { - model_init_submodel_axis_pt(pm->submodel[ship_ship_hit_info->submodel_num].sii, Ships[heavy->instance].modelnum, ship_ship_hit_info->submodel_num); + model_init_submodel_axis_pt(pm->submodel[ship_ship_hit_info->submodel_num].sii, pm->id, ship_ship_hit_info->submodel_num); } vec3d omega, axis, r_rot; @@ -1958,7 +1958,7 @@ void collect_ship_ship_physics_info(object *heavy, object *light, mc_info *mc_in vec3d *heavy_collide_cm_pos = &ship_ship_hit_info->heavy_collision_cm_pos; vec3d *light_collide_cm_pos = &ship_ship_hit_info->light_collision_cm_pos; - float core_rad = model_get_core_radius( Ships[light->instance].modelnum ); + float core_rad = model_get_core_radius(Ship_info[Ships[light->instance].ship_info_index].model_num); // get info needed for ship_ship_collision_physics Assert(mc_info->hit_dist > 0); diff --git a/code/object/collideshipweapon.cpp b/code/object/collideshipweapon.cpp index 6bf270fb07..0a927f4b5a 100644 --- a/code/object/collideshipweapon.cpp +++ b/code/object/collideshipweapon.cpp @@ -9,13 +9,17 @@ /* * $Logfile: /Freespace2/code/Object/CollideShipWeapon.cpp $ - * $Revision: 2.42 $ - * $Date: 2007-02-19 07:24:51 $ - * $Author: wmcoolmon $ + * $Revision: 2.43 $ + * $Date: 2007-02-20 04:20:27 $ + * $Author: Goober5000 $ * * Routines to detect collisions and do physics, damage, etc for weapons and ships * * $Log: not supported by cvs2svn $ + * Revision 2.42 2007/02/19 07:24:51 wmcoolmon + * WMCoolmon experiences a duh moment. Move scripting collision variable declarations in front of overrides, to give + * them access to these (somewhat useful) variables + * * Revision 2.41 2007/02/18 06:17:10 Goober5000 * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner * @@ -466,7 +470,7 @@ int ship_weapon_check_collision(object *ship_objp, object *weapon_objp, float ti int valid_hit_occurred = 0; // If this is set, then hitpos is set int quadrant_num = -1; - polymodel *pm = model_get( shipp->modelnum ); + polymodel *pm = model_get(sip->model_num); // total time is flFrametime + time_limit (time_limit used to predict collisions into the future) vec3d weapon_end_pos; @@ -476,7 +480,7 @@ int ship_weapon_check_collision(object *ship_objp, object *weapon_objp, float ti // Goober5000 - I tried to make collision code here much saner... here begin the (major) changes // set up collision structs - mc.model_num = shipp->modelnum; + mc.model_num = sip->model_num; mc.submodel_num = -1; mc.orient = &ship_objp->orient; mc.pos = &ship_objp->pos; diff --git a/code/object/objcollide.cpp b/code/object/objcollide.cpp index af775b28d2..c3207efcaa 100644 --- a/code/object/objcollide.cpp +++ b/code/object/objcollide.cpp @@ -9,14 +9,19 @@ /* * $Logfile: /Freespace2/code/Object/ObjCollide.cpp $ - * $Revision: 2.14 $ - * $Date: 2007-02-10 00:08:59 $ - * $Author: taylor $ + * $Revision: 2.15 $ + * $Date: 2007-02-20 04:20:27 $ + * $Author: Goober5000 $ * * Helper routines for all the collision detection functions * Also keeps track of all the object pairs. * * $Log: not supported by cvs2svn $ + * Revision 2.14 2007/02/10 00:08:59 taylor + * performance optimizations: + * - fvi_ray_boundingbox() is faster and should be less prone to compiler/optimization/platform specific issues + * - clean up or obj_check_all_collisions() which is a good bit faster now + * * Revision 2.13 2006/12/28 00:59:39 wmcoolmon * WMC codebase commit. See pre-commit build thread for details on changes. * @@ -1098,7 +1103,7 @@ int pp_collide(vec3d *curpos, vec3d *goalpos, object *goalobjp, float radius) ship_model_start(goalobjp); - mc.model_num = Ships[goalobjp->instance].modelnum; // Fill in the model to check + mc.model_num = Ship_info[Ships[goalobjp->instance].ship_info_index].model_num; // Fill in the model to check mc.orient = &goalobjp->orient; // The object's orient mc.pos = &goalobjp->pos; // The object's position mc.p0 = curpos; // Point 1 of ray to check diff --git a/code/object/object.cpp b/code/object/object.cpp index 42a1a98332..b292da2f41 100644 --- a/code/object/object.cpp +++ b/code/object/object.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Object/Object.cpp $ - * $Revision: 2.72 $ - * $Date: 2007-02-19 07:55:20 $ - * $Author: wmcoolmon $ + * $Revision: 2.73 $ + * $Date: 2007-02-20 04:20:27 $ + * $Author: Goober5000 $ * * Code to manage objects * * $Log: not supported by cvs2svn $ + * Revision 2.72 2007/02/19 07:55:20 wmcoolmon + * More scripting tweaks/bugfixes. + * * Revision 2.71 2007/02/16 07:06:46 Goober5000 * uhh... wrong? * @@ -1372,9 +1375,11 @@ void obj_move_call_physics(object *objp, float frametime) if ( objp->flags & OF_PHYSICS ) { // only set phys info if ship is not dead if ((objp->type == OBJ_SHIP) && !(Ships[objp->instance].flags & SF_DYING)) { + ship *shipp = &Ships[objp->instance]; float engine_strength; - engine_strength = ship_get_subsystem_strength(&Ships[objp->instance], SUBSYSTEM_ENGINE); - if ( ship_subsys_disrupted(&Ships[objp->instance], SUBSYSTEM_ENGINE) ) { + + engine_strength = ship_get_subsystem_strength(shipp, SUBSYSTEM_ENGINE); + if ( ship_subsys_disrupted(shipp, SUBSYSTEM_ENGINE) ) { engine_strength=0.0f; } @@ -1382,44 +1387,47 @@ void obj_move_call_physics(object *objp, float frametime) vm_vec_zero(&objp->phys_info.desired_vel); vm_vec_zero(&objp->phys_info.desired_rotvel); objp->phys_info.flags |= (PF_REDUCED_DAMP | PF_DEAD_DAMP); - objp->phys_info.side_slip_time_const = Ship_info[Ships[objp->instance].ship_info_index].damp * 4.0f; + objp->phys_info.side_slip_time_const = Ship_info[shipp->ship_info_index].damp * 4.0f; } // else { // DA: comment out lines that resets PF_DEAD_DAMP after every frame. // This is now reset during engine repair. // objp->phys_info.flags &= ~(PF_REDUCED_DAMP | PF_DEAD_DAMP); - // objp->phys_info.side_slip_time_const = Ship_info[Ships[objp->instance].ship_info_index].damp; + // objp->phys_info.side_slip_time_const = Ship_info[shipp->ship_info_index].damp; // } - for(int i = 0; i < Ships[objp->instance].weapons.num_secondary_banks; i++) + + for (int i = 0; i < shipp->weapons.num_secondary_banks; i++) { - if(Ships[objp->instance].weapons.secondary_bank_ammo[i] == 0)continue; //if there are no missles left don't bother - polymodel *pm = model_get(Ships[objp->instance].modelnum); - if(pm==NULL)continue; - int points = pm->missile_banks[i].num_slots; - int missles_left = Ships[objp->instance].weapons.secondary_bank_ammo[i]; - int next_point = Ships[objp->instance].weapons.secondary_next_slot[i]; + if (shipp->weapons.secondary_bank_ammo[i] == 0) + continue; + + int points = model_get(Ship_info[shipp->ship_info_index].model_num)->missile_banks[i].num_slots; + int missles_left = shipp->weapons.secondary_bank_ammo[i]; + int next_point = shipp->weapons.secondary_next_slot[i]; //ok so...we want to move up missles but only if there is a missle there to be moved up //there is a missle behind next_point, and how ever many missles there are left after that - if(points>missles_left){ - //there are more slots than missles left, so not all of the slots will have missles drawen on them - for(int K = next_point; Kinstance].secondary_point_reload_pct[i][k]; - if(s_pct < 1.0)s_pct += Ships[objp->instance].reload_time[i] * frametime; - if(s_pct > 1.0)s_pct = 1.0f; + if (points > missles_left) { + //there are more slots than missles left, so not all of the slots will have missles drawn on them + for (int k = next_point; k < next_point+missles_left; k ++) { + float &s_pct = shipp->secondary_point_reload_pct[i][k % points]; + if (s_pct < 1.0) + s_pct += shipp->reload_time[i] * frametime; + if (s_pct > 1.0) + s_pct = 1.0f; } - }else{ + } else { //we don't have to worry about such things - for(int k = 0; kinstance].secondary_point_reload_pct[i][k]; - if(s_pct < 1.0)s_pct += Ships[objp->instance].reload_time[i] * frametime; - if(s_pct > 1.0)s_pct = 1.0f; + for (int k = 0; k < points; k++) { + float &s_pct = shipp->secondary_point_reload_pct[i][k]; + if (s_pct < 1.0) + s_pct += shipp->reload_time[i] * frametime; + if (s_pct > 1.0) + s_pct = 1.0f; } } } - } // if a weapon is flagged as dead, kill its engines just like a ship diff --git a/code/object/objectdock.cpp b/code/object/objectdock.cpp index 4ceec5e975..a4344088a1 100644 --- a/code/object/objectdock.cpp +++ b/code/object/objectdock.cpp @@ -6,13 +6,17 @@ /* * $Logfile: /Freespace2/code/Object/ObjectDock.cpp $ - * $Revision: 2.12 $ - * $Date: 2006-07-21 05:41:10 $ + * $Revision: 2.13 $ + * $Date: 2007-02-20 04:20:27 $ * $Author: Goober5000 $ * * Implementation of new docking system * * $Log: not supported by cvs2svn $ + * Revision 2.12 2006/07/21 05:41:10 Goober5000 + * add another method for calculating dimensions of docked objects, plus improve an existing one + * --Goober5000 + * * Revision 2.11 2006/04/20 06:32:23 Goober5000 * proper capitalization according to Volition * @@ -546,7 +550,7 @@ void dock_calc_max_cross_sectional_radius_squared_perpendicular_to_line_helper(o // grab our model Assert(objp->type == OBJ_SHIP); - pm = model_get(Ships[objp->instance].modelnum); + pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num); // set up the points we want to check memset(local_point, 0, sizeof(vec3d) * 6); @@ -595,7 +599,7 @@ void dock_calc_max_semilatus_rectum_squared_parallel_to_directrix_helper(object // grab our model Assert(objp->type == OBJ_SHIP); - pm = model_get(Ships[objp->instance].modelnum); + pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num); // set up the points we want to check memset(local_point, 0, sizeof(vec3d) * 6); diff --git a/code/parse/lua.cpp b/code/parse/lua.cpp index 42fcd83ccb..5af1301ae1 100644 --- a/code/parse/lua.cpp +++ b/code/parse/lua.cpp @@ -3536,9 +3536,9 @@ ADE_FUNC(renderTechModel, l_Shipclass, "X1, Y1, X2, Y2, [Rotation %, Pitch %, Ba ship_info *sip = &Ship_info[idx]; //Make sure model is loaded - sip->modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0], 0); + sip->model_num = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0], 0); - if(sip->modelnum < 0) + if(sip->model_num < 0) return ade_set_args(L, "b", false); //Handle angles @@ -3571,9 +3571,9 @@ ADE_FUNC(renderTechModel, l_Shipclass, "X1, Y1, X2, Y2, [Rotation %, Pitch %, Ba light_rotate_all(); //Draw the ship!! - model_clear_instance(sip->modelnum); + model_clear_instance(sip->model_num); model_set_detail_level(0); - model_render(sip->modelnum, &orient, &vmd_zero_vector, MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING); + model_render(sip->model_num, &orient, &vmd_zero_vector, MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING); //OK we're done if (!Cmdline_nohtl) @@ -4172,7 +4172,7 @@ ADE_VIRTVAR(Position, l_Subsystem, "lvector", "Subsystem position with regards t if(!sso->IsValid()) return ADE_RETURN_NIL; - polymodel *pm = model_get(Ships[sso->objp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[sso->objp->instance].ship_info_index].model_num); Assert(pm != NULL); bsp_info *sm = &pm->submodel[sso->ss->system_info->subobj_num]; @@ -4193,7 +4193,7 @@ ADE_VIRTVAR(GunPosition, l_Subsystem, "lvector", "Subsystem gun position with re if(!sso->IsValid()) return ADE_RETURN_NIL; - polymodel *pm = model_get(Ships[sso->objp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[sso->objp->instance].ship_info_index].model_num); Assert(pm != NULL); if(sso->ss->system_info->turret_gun_sobj < 0) @@ -4358,7 +4358,7 @@ ADE_FUNC(__len, l_ShipTextures, NULL, NULL, NULL) if(!objh->IsValid()) return ADE_RETURN_NIL; - polymodel *pm = model_get(Ships[objh->objp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[objh->objp->instance].ship_info_index].model_num); if(pm == NULL) return ADE_RETURN_FALSE; @@ -4378,7 +4378,7 @@ ADE_INDEXER(l_ShipTextures, "Texture name or index", "Texture", "Ship textures") return ade_set_error(L, "o", l_Texture.Set(-1)); ship *shipp = &Ships[oh->objp->instance]; - polymodel *pm = model_get(shipp->modelnum); + polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); int idx = -1; int i; @@ -4628,26 +4628,6 @@ ADE_VIRTVAR(HitpointsMax, l_Ship, "number", "Total hitpoints") return ade_set_args(L, "f", shipp->ship_max_hull_strength); } -ADE_VIRTVAR(Model, l_Ship, "model", "Ship's model") -{ - object_h *objh; - int newmodel = -1; - if(!ade_get_args(L, "o|b", l_Ship.GetPtr(&objh), l_Model.Get(&newmodel))) - return ade_set_error(L, "o", l_Model.Set(-1)); - - if(!objh->IsValid()) - return ade_set_error(L, "o", l_Model.Set(-1)); - - ship *shipp = &Ships[objh->objp->instance]; - - if(ADE_SETTING_VAR) - { - shipp->modelnum = newmodel; - } - - return ade_set_args(L, "o", l_Model.Set(shipp->modelnum)); -} - ADE_VIRTVAR(PrimaryBanks, l_Ship, "weaponbanktype", "Array of primary weapon banks") { object_h *objh; diff --git a/code/parse/sexp.cpp b/code/parse/sexp.cpp index 82aa7facd6..fe8eb8944e 100644 --- a/code/parse/sexp.cpp +++ b/code/parse/sexp.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/parse/SEXP.CPP $ - * $Revision: 2.304 $ - * $Date: 2007-02-20 01:40:57 $ + * $Revision: 2.305 $ + * $Date: 2007-02-20 04:20:27 $ * $Author: Goober5000 $ * * main sexpression generator * * $Log: not supported by cvs2svn $ + * Revision 2.304 2007/02/20 01:40:57 Goober5000 + * *** empty log message *** + * * Revision 2.303 2007/02/18 06:17:10 Goober5000 * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner * @@ -3553,7 +3556,7 @@ int check_sexp_syntax(int node, int return_type, int recursive, int *bad_node, i return SEXP_CHECK_INVALID_SHIP; // should have already been caught earlier, but just in case.. } - model = Ships[ship_num].modelnum; + model = Ship_info[Ships[ship_num].ship_info_index].model_num; z = model_get_num_dock_points(model); for (i=0; imodelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]); + sip->model_num = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]); } // Goober5000 @@ -5741,11 +5744,11 @@ int sexp_special_warp_dist( int n) // get distance vec3d hit_pt; float dist = fvi_ray_plane(&hit_pt, &warp_objp->pos, &warp_objp->orient.vec.fvec, &ship_objp->pos, &ship_objp->orient.vec.fvec, 0.0f); - polymodel *pm = model_get(Ships[shipnum].modelnum); + polymodel *pm = model_get(Ship_info[Ships[shipnum].ship_info_index].model_num); dist += pm->mins.xyz.z; // return as a percent of length - return (int) (100.0f * dist / ship_get_length(&Ships[shipnum])); + return (int) (100.0f * dist / ship_class_get_length(&Ship_info[Ships[shipnum].ship_info_index])); } diff --git a/code/ship/shield.cpp b/code/ship/shield.cpp index 846691096e..cf9b543c0d 100644 --- a/code/ship/shield.cpp +++ b/code/ship/shield.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Ship/Shield.cpp $ - * $Revision: 2.52 $ - * $Date: 2007-02-18 06:17:34 $ + * $Revision: 2.53 $ + * $Date: 2007-02-20 04:20:27 $ * $Author: Goober5000 $ * * Stuff pertaining to shield graphical effects, etc. * * $Log: not supported by cvs2svn $ + * Revision 2.52 2007/02/18 06:17:34 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.51 2007/02/16 22:25:21 Goober5000 * fixed another of bobboau's stupid bugs * @@ -1202,7 +1205,7 @@ void create_shield_explosion_all(object *objp) for (i=0; imodelnum, &objp->orient, &objp->pos, &Shield_points[i].hit_point, Shield_points[i].shield_tri); + create_shield_explosion(objnum, Ship_info[shipp->ship_info_index].model_num, &objp->orient, &objp->pos, &Shield_points[i].hit_point, Shield_points[i].shield_tri); count--; if (count <= 0){ break; @@ -1239,7 +1242,7 @@ void ship_draw_shield( object *objp) Assert(objp->instance >= 0); - model_num = Ships[objp->instance].modelnum; + model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; if ( Fred_running ) return; diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 4650102cb9..fb514bb581 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -10,13 +10,16 @@ /* * $Logfile: /Freespace2/code/Ship/Ship.cpp $ - * $Revision: 2.404 $ - * $Date: 2007-02-18 06:17:34 $ + * $Revision: 2.405 $ + * $Date: 2007-02-20 04:20:27 $ * $Author: Goober5000 $ * * Ship (and other object) handling functions * * $Log: not supported by cvs2svn $ + * Revision 2.404 2007/02/18 06:17:34 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.403 2007/02/16 23:18:15 Goober5000 * this should be based on a flag or something, not automatically tied into the power output * @@ -2678,7 +2681,7 @@ char current_ship_table[MAX_PATH_LEN + MAX_FILENAME_LEN]; //rather than simply replacing the previous entry void init_ship_entry(int ship_info_index) { - Assert(ship_info_index > -1 && ship_info_index < MAX_SHIP_CLASSES); + Assert(ship_info_index >= 0 && ship_info_index < MAX_SHIP_CLASSES); ship_info *sip = &Ship_info[ship_info_index]; int i,j; @@ -2882,8 +2885,8 @@ void init_ship_entry(int ship_info_index) sip->n_subsystems = 0; sip->subsystems = NULL; - sip->modelnum = -1; - sip->modelnum_hud = -1; + sip->model_num = -1; + sip->model_num_hud = -1; } // function to parse the information for a specific ship type. @@ -3247,7 +3250,7 @@ int parse_ship(bool replace) { stuff_string(buf, F_NAME, SHIP_MULTITEXT_LENGTH); j = warptype_match(buf); - if(j > -1) { + if(j >= 0) { sip->warpin_type = j; } else { Warning(LOCATION, "Invalid warpin type '%s' specified for ship '%s'", buf, sip->name); @@ -3290,7 +3293,7 @@ int parse_ship(bool replace) { stuff_string(buf, F_NAME, SHIP_MULTITEXT_LENGTH); j = warptype_match(buf); - if(j > -1) { + if(j >= 0) { sip->warpout_type = j; } else { Warning(LOCATION, "Invalid warpout type '%s' specified for ship '%s'", buf, sip->name); @@ -4177,7 +4180,7 @@ strcpy(parse_error_text, temp_error); stuff_int(&idx); } - if(idx > -1 && idx < sip->num_maneuvering) { + if(idx >= 0 && idx < sip->num_maneuvering) { mtp = &sip->maneuvering[idx]; } else if(idx < 0) { if(sip->num_maneuvering < MAX_MAN_THRUSTERS) { @@ -4213,9 +4216,9 @@ strcpy(parse_error_text, temp_error); tex_id = bm_load_animation(name_tmp, &tex_nframes, &tex_fps, 1); if(tex_id < 0) tex_id = bm_load(name_tmp); - if(tex_id > -1) + if(tex_id >= 0) { - if(mtp->tex_id > -1) { + if(mtp->tex_id >= 0) { bm_unload(mtp->tex_id); } @@ -4678,7 +4681,7 @@ void parse_ship_type() } int idx = ship_type_name_lookup(name_buf); - if(idx > -1) + if(idx >= 0) { stp = &Ship_types[idx]; } @@ -5054,7 +5057,7 @@ void ship_init() for(j = 0; j < stp->ai_actively_pursues_temp.size(); j++) { idx = ship_type_name_lookup((char*)stp->ai_actively_pursues_temp[j].c_str()); - if(idx > -1) { + if(idx >= 0) { stp->ai_actively_pursues.push_back(idx); } } @@ -5279,7 +5282,7 @@ void physics_ship_init(object *objp) { ship_info *sinfo = &Ship_info[Ships[objp->instance].ship_info_index]; physics_info *pi = &objp->phys_info; - polymodel *pm = model_get( Ships[objp->instance].modelnum ); + polymodel *pm = model_get(sinfo->model_num); // use mass and I_body_inv from POF read into polymodel physics_init(pi); @@ -5350,7 +5353,7 @@ int ship_get_type(char* output, ship_info *sip) // by a value in the mission file. int ship_get_default_orders_accepted( ship_info *sip ) { - if(sip->class_type > -1) { + if(sip->class_type >= 0) { return Ship_types[sip->class_type].ai_player_orders; } else { return 0; @@ -5704,7 +5707,7 @@ void ship_set(int ship_index, int objnum, int ship_type) for(i = 0; i < sip->n_subsystems; i++){ model_subsystem* ms = &sip->subsystems[i]; - if(ms->subobj_num > -1)ms->trigger.snd_pnt = get_submodel_offset(sip->modelnum, ms->subobj_num); + if(ms->subobj_num >= 0)ms->trigger.snd_pnt = get_submodel_offset(sip->modelnum, ms->subobj_num); else ms->trigger.snd_pnt = ms->pnt; ms->trigger.obj_num = objnum; } @@ -5809,7 +5812,7 @@ void ship_copy_subsystem_fixup(ship_info *sip) { int i, model_num; - model_num = sip->modelnum; + model_num = sip->model_num; // since we allow a model file to be shared between several ships, we must check to be sure that our // subsystems have been loaded properly @@ -5828,7 +5831,7 @@ void ship_copy_subsystem_fixup(ship_info *sip) for ( i = 0; i < Num_ship_classes; i++ ) { model_subsystem *msp; - if ( (Ship_info[i].modelnum != model_num) || (&Ship_info[i] == sip) ){ + if ( (Ship_info[i].model_num != model_num) || (&Ship_info[i] == sip) ){ continue; } @@ -5862,19 +5865,8 @@ void subsys_set(int objnum, int ignore_subsys_info) for ( i = 0; i < sinfo->n_subsystems; i++ ) { - // maybe use the duplicate info - if (shipp->modelnum != sinfo->modelnum) - { - Assert(shipp->subsystems); - - model_system = &(shipp->subsystems[i]); - } - else - { - model_system = &(sinfo->subsystems[i]); - } - - if ( model_system->model_num == -1 ) { + model_system = &(sinfo->subsystems[i]); + if (model_system->model_num < 0) { Warning (LOCATION, "Invalid subobj_num or model_num in subsystem '%s' on ship type '%s'.\nNot linking into ship!\n\n(This warning means that a subsystem was present in %s and not present in the model\nit should probably be removed from the table or added to the model.)\n", model_system->subobj_name, sinfo->name, current_ship_table ); continue; } @@ -6003,12 +5995,11 @@ void subsys_set(int objnum, int ignore_subsys_info) // Render docking information, NOT while in object's reference frame. void render_dock_bays(object *objp) { -// ship_info *sip; polymodel *pm; dock_bay *db; // sip = &Ship_info[Ships[objp->instance].ship_info_index]; - pm = model_get( Ships[objp->instance].modelnum ); + pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num); if (pm->docking_bays == NULL) return; @@ -6159,7 +6150,7 @@ void ship_render(object * obj) Assert( num >= 0); ship *shipp = &Ships[num]; ship *warp_shipp = NULL; - ship_info *si = &Ship_info[Ships[num].ship_info_index]; + ship_info *sip = &Ship_info[Ships[num].ship_info_index]; bool reset_proj_when_done = false; bool is_first_stage_arrival = false; dock_function_info dfi; @@ -6215,7 +6206,7 @@ void ship_render(object * obj) } } - if(!(si->flags2 & SIF2_SHOW_SHIP_MODEL) && !(Viewer_mode & VM_TOPDOWN)) + if (!(sip->flags2 & SIF2_SHOW_SHIP_MODEL) && !(Viewer_mode & VM_TOPDOWN)) { return; } @@ -6283,14 +6274,14 @@ void ship_render(object * obj) for (i=0; iarc_timestamp[i] ) ) { // render_flags |= MR_ALWAYS_REDRAW; // Turn off model caching if arcing. - model_add_arc( shipp->modelnum, -1, &shipp->arc_pts[i][0], &shipp->arc_pts[i][1], shipp->arc_type[i] ); + model_add_arc(sip->model_num, -1, &shipp->arc_pts[i][0], &shipp->arc_pts[i][1], shipp->arc_type[i]); } } } // if((shipp->end_death_time - shipp->death_time) <= 0)shipp->end_death_time = 0; // if((timestamp() - shipp->death_time) <= 0)shipp->end_death_time = 0; - /* if( !( shipp->large_ship_blowup_index > -1 ) && timestamp_elapsed(shipp->death_time) && shipp->end_death_time){ + /* if( !( shipp->large_ship_blowup_index >= 0 ) && timestamp_elapsed(shipp->death_time) && shipp->end_death_time){ splodeingtexture = si->splodeing_texture; splodeing = true; splode_level = ((float)timestamp() - (float)shipp->death_time) / ((float)shipp->end_death_time - (float)shipp->death_time); @@ -6300,7 +6291,7 @@ void ship_render(object * obj) }*/ // if(splode_level<=0.0f)shipp->end_death_time = 0; - if ( shipp->large_ship_blowup_index > -1 ) { + if ( shipp->large_ship_blowup_index >= 0 ) { shipfx_large_blowup_render(shipp); } else { @@ -6308,11 +6299,11 @@ void ship_render(object * obj) //WMC - I suppose this is a bit hackish. physics_info *pi = &Objects[shipp->objnum].phys_info; float render_amount; + fx_batcher.allocate(sip->num_maneuvering); //Act as if all thrusters are going. - - for(int i = 0; i < si->num_maneuvering; i++) + for(int i = 0; i < sip->num_maneuvering; i++) { - man_thruster *mtp = &si->maneuvering[i]; + man_thruster *mtp = &sip->maneuvering[i]; render_amount = 0.0f; @@ -6352,7 +6343,7 @@ void ship_render(object * obj) if(shipp->thrusters_start[i] <= 0) { shipp->thrusters_start[i] = timestamp(); - if(mtp->start_snd > -1) + if(mtp->start_snd >= 0) snd_play_3d( &Snds[mtp->start_snd], &mtp->pos, &Eye_position, 0.0f, &obj->phys_info.vel ); } @@ -6360,7 +6351,7 @@ void ship_render(object * obj) //it is specified //it isn't assigned already //start sound doesn't exist or has finished - if(mtp->loop_snd > -1 + if(mtp->loop_snd >= 0 && shipp->thrusters_sounds[i] < 0 && (mtp->start_snd < 0 || (snd_get_duration(mtp->start_snd) < timestamp() - shipp->thrusters_start[i])) ) @@ -6370,7 +6361,7 @@ void ship_render(object * obj) //Draw graphics //Skip invalid ones - if(mtp->tex_id > -1) + if(mtp->tex_id >= 0) { float rad = mtp->radius; if(rad <= 0.0f) @@ -6408,13 +6399,13 @@ void ship_render(object * obj) else if(shipp->thrusters_start[i] > 0) { shipp->thrusters_start[i] = 0; - if(shipp->thrusters_sounds[i] > -1) + if(shipp->thrusters_sounds[i] >= 0) { obj_snd_delete(OBJ_INDEX(obj), shipp->thrusters_sounds[i]); shipp->thrusters_sounds[i] = -1; } - if(mtp->stop_snd > -1) + if(mtp->stop_snd >= 0) { //Get world pos vec3d start; @@ -6426,7 +6417,7 @@ void ship_render(object * obj) } } - if ( ((shipp->thruster_bitmap > -1) || (shipp->thruster_glow_bitmap > -1)) && (!(shipp->flags & SF_DISABLED)) && (!ship_subsys_disrupted(shipp, SUBSYSTEM_ENGINE)) ) + if ( ((shipp->thruster_bitmap >= 0) || (shipp->thruster_glow_bitmap >= 0)) && (!(shipp->flags & SF_DISABLED)) && (!ship_subsys_disrupted(shipp, SUBSYSTEM_ENGINE)) ) { vec3d ft; @@ -6472,19 +6463,19 @@ void ship_render(object * obj) mst.tertiary_glow_bitmap = shipp->thruster_tertiary_glow_bitmap; mst.rovel = &Objects[shipp->objnum].phys_info.rotvel; - mst.trf1 = si->thruster01_glow_rad_factor; - mst.trf2 = si->thruster02_glow_rad_factor; - mst.trf3 = si->thruster03_glow_rad_factor; - mst.tlf = si->thruster02_glow_len_factor; + mst.trf1 = sip->thruster01_glow_rad_factor; + mst.trf2 = sip->thruster02_glow_rad_factor; + mst.trf3 = sip->thruster03_glow_rad_factor; + mst.tlf = sip->thruster02_glow_len_factor; - model_set_thrust( shipp->modelnum, &ft, shipp->thruster_bitmap, shipp->thruster_glow_bitmap, shipp->thruster_glow_noise, use_AB, &mst ); + model_set_thrust(sip->model_num, &ft, shipp->thruster_bitmap, shipp->thruster_glow_bitmap, shipp->thruster_glow_noise, use_AB, &mst); } render_flags |= MR_SHOW_THRUSTERS; } // fill the model flash lighting values in - shipfx_flash_light_model( obj, shipp ); + shipfx_flash_light_model( obj, sip->model_num ); // If the ship is going "through" the warp effect, then @@ -6566,56 +6557,66 @@ void ship_render(object * obj) //draw weapon models - if(si->draw_models){ + if (sip->draw_models) { + int i,k; ship_weapon *swp = &shipp->weapons; g3_start_instance_matrix(&obj->pos, &obj->orient, true); int save_flags = render_flags; render_flags &= ~MR_SHOW_THRUSTERS; + //primary weapons - int i,k; - for(i = 0; inum_primary_banks; i++){ - if(Weapon_info[swp->primary_bank_weapons[i]].external_model_num == -1 || !si->draw_primary_models[i])continue; - for(k = 0; kmodelnum)->gun_banks[i].num_slots; k++){ + for (i = 0; i < swp->num_primary_banks; i++) { + if (Weapon_info[swp->primary_bank_weapons[i]].external_model_num == -1 || !sip->draw_primary_models[i]) + continue; + + w_bank *bank = &model_get(sip->model_num)->gun_banks[i]; + for(k = 0; k < bank->num_slots; k++) { polymodel* pm = model_get(Weapon_info[swp->primary_bank_weapons[i]].external_model_num); pm->gun_submodel_rotation = shipp->primary_rotate_ang[i]; - model_render(Weapon_info[swp->primary_bank_weapons[i]].external_model_num, &vmd_identity_matrix, &model_get(shipp->modelnum)->gun_banks[i].pnt[k], render_flags); + model_render(Weapon_info[swp->primary_bank_weapons[i]].external_model_num, &vmd_identity_matrix, &bank->pnt[k], render_flags); pm->gun_submodel_rotation = 0.0f; } } //secondary weapons - for(i = 0; inum_secondary_banks; i++){ - if(Weapon_info[swp->secondary_bank_weapons[i]].external_model_num == -1 || !si->draw_secondary_models[i])continue; - for(k = 0; kmodelnum)->missile_banks[i].num_slots; k++){ - - vec3d secondary_waepon_pos = model_get(shipp->modelnum)->missile_banks[i].pnt[k]; - // vm_vec_add(&secondary_waepon_pos, &obj->pos, &model_get(shipp->modelnum)->missile_banks[i].pnt[k]); - - // if(shipp->secondary_point_reload_pct[i][k] != 1.0)vm_vec_scale_add2(&secondary_waepon_pos, &obj->orient.vec.fvec, -(1.0f-shipp->secondary_point_reload_pct[i][k]) * model_get(Weapon_info[swp->secondary_bank_weapons[i]].model_num)->rad); - if(shipp->secondary_point_reload_pct[i][k] <= 0.0)continue; - - vec3d dir = ZERO_VECTOR; - dir.xyz.z = 1.0; - - bool clipping = false; - - /* extern int G3_user_clip; - - if(!G3_user_clip){ - vec3d clip_pnt; - vm_vec_rotate(&clip_pnt, &model_get(shipp->modelnum)->missile_banks[i].pnt[k], &obj->orient); - vm_vec_add2(&clip_pnt, &obj->pos); - g3_start_user_clip_plane(&clip_pnt,&obj->orient.vec.fvec); - clipping = true; - } - */ - vm_vec_scale_add2(&secondary_waepon_pos, &dir, -(1.0f-shipp->secondary_point_reload_pct[i][k]) * model_get(Weapon_info[swp->secondary_bank_weapons[i]].external_model_num)->rad); + for (i = 0; i < swp->num_secondary_banks; i++) { + if (Weapon_info[swp->secondary_bank_weapons[i]].external_model_num == -1 || !sip->draw_secondary_models[i]) + continue; - model_render(Weapon_info[swp->secondary_bank_weapons[i]].external_model_num, &vmd_identity_matrix, &secondary_waepon_pos, render_flags); - if(clipping)g3_stop_user_clip_plane(); + w_bank *bank = &model_get(sip->model_num)->missile_banks[i]; + for(k = 0; k < bank->num_slots; k++) { + vec3d secondary_weapon_pos = bank->pnt[k]; + // vm_vec_add(&secondary_weapon_pos, &obj->pos, &bank->pnt[k]); + + // if(shipp->secondary_point_reload_pct[i][k] != 1.0) + // vm_vec_scale_add2(&secondary_weapon_pos, &obj->orient.vec.fvec, -(1.0f-shipp->secondary_point_reload_pct[i][k]) * model_get(Weapon_info[swp->secondary_bank_weapons[i]].model_num)->rad); + if(shipp->secondary_point_reload_pct[i][k] <= 0.0) + continue; + + vec3d dir = ZERO_VECTOR; + dir.xyz.z = 1.0; + + bool clipping = false; + + /* extern int G3_user_clip; + + if(!G3_user_clip){ + vec3d clip_pnt; + vm_vec_rotate(&clip_pnt, &bank->pnt[k], &obj->orient); + vm_vec_add2(&clip_pnt, &obj->pos); + g3_start_user_clip_plane(&clip_pnt,&obj->orient.vec.fvec); + clipping = true; + } + */ + + vm_vec_scale_add2(&secondary_weapon_pos, &dir, -(1.0f-shipp->secondary_point_reload_pct[i][k]) * model_get(Weapon_info[swp->secondary_bank_weapons[i]].external_model_num)->rad); + + model_render(Weapon_info[swp->secondary_bank_weapons[i]].external_model_num, &vmd_identity_matrix, &secondary_weapon_pos, render_flags); + if(clipping) + g3_stop_user_clip_plane(); } } g3_done_instance(true); @@ -6623,17 +6624,17 @@ void ship_render(object * obj) } // small ships - if((The_mission.flags & MISSION_FLAG_FULLNEB) && (si->flags & SIF_SMALL_SHIP)){ + if ((The_mission.flags & MISSION_FLAG_FULLNEB) && (sip->flags & SIF_SMALL_SHIP)) { // force detail levels float fog_val = neb2_get_fog_intensity(obj); if(fog_val >= 0.6f){ model_set_detail_level(2); - model_render( shipp->modelnum, &obj->orient, &obj->pos, render_flags | MR_LOCK_DETAIL, OBJ_INDEX(obj), -1, shipp->replacement_textures ); + model_render( sip->model_num, &obj->orient, &obj->pos, render_flags | MR_LOCK_DETAIL, OBJ_INDEX(obj), -1, shipp->replacement_textures ); } else { - model_render( shipp->modelnum, &obj->orient, &obj->pos, render_flags, OBJ_INDEX(obj), -1, shipp->replacement_textures ); + model_render( sip->model_num, &obj->orient, &obj->pos, render_flags, OBJ_INDEX(obj), -1, shipp->replacement_textures ); } } else { - model_render( shipp->modelnum, &obj->orient, &obj->pos, render_flags, OBJ_INDEX(obj), -1, shipp->replacement_textures ); + model_render( sip->model_num, &obj->orient, &obj->pos, render_flags, OBJ_INDEX(obj), -1, shipp->replacement_textures ); } // decal_render_all(obj); @@ -6729,7 +6730,7 @@ void ship_render(object * obj) //WMC - based on Bobb's secondary thruster stuff //which was in turn based on the beam code. //I'm gonna need some serious acid to neutralize this base. - if(shipp->warp_anim > -1 && shipp->final_warp_time > timestamp()) + if(shipp->warp_anim >= 0 && shipp->final_warp_time > timestamp()) { fx_batcher.allocate(1); @@ -6742,7 +6743,7 @@ void ship_render(object * obj) rad = sip->warpin_radius; if(rad <= 0.0f) { - polymodel *pm = model_get(shipp->modelnum); + polymodel *pm = model_get(sip->model_num); rad = pm->rad; } @@ -6786,17 +6787,6 @@ void ship_subsystems_delete(ship *shipp) } } -// Goober5000 -void ship_model_subsystems_delete(ship *shipp) -{ - if (shipp->subsystems != NULL) - { - vm_free(shipp->subsystems); - shipp->n_subsystems = 0; - shipp->subsystems = NULL; - } -} - void ship_clear_decals(ship *shipp) { clear_decals(&shipp->ship_decal_system); @@ -6835,13 +6825,10 @@ void ship_delete( object * obj ) // on ship back to the free list for other ships to use. ship_subsystems_delete(&Ships[num]); - // Goober5000 - free model subsys info - ship_model_subsystems_delete(&Ships[num]); - shipp->objnum = -1; // mwa 11/24/97 num_ships--; - if (model_get(shipp->modelnum)->shield.ntris) { + if (model_get(Ship_info[shipp->ship_info_index].model_num)->shield.ntris) { vm_free(shipp->shield_integrity); shipp->shield_integrity = NULL; } @@ -7312,25 +7299,24 @@ void do_dying_undock_physics(object *dying_objp, ship *dying_shipp) // Do the stuff we do in a frame for a ship that's in its death throes. void ship_dying_frame(object *objp, int ship_num) { - ship *sp; - sp = &Ships[ship_num]; - int knossos_ship = false; + ship *shipp = &Ships[ship_num]; - if ( sp->flags & SF_DYING ) { - knossos_ship = (Ship_info[sp->ship_info_index].flags & SIF_KNOSSOS_DEVICE); + if ( shipp->flags & SF_DYING ) { + ship_info *sip = &Ship_info[shipp->ship_info_index]; + int knossos_ship = (sip->flags & SIF_KNOSSOS_DEVICE); // bash hull value toward 0 (from self destruct) if (objp->hull_strength > 0) { - int time_left = timestamp_until(sp->final_death_time); + int time_left = timestamp_until(shipp->final_death_time); float hits_left = objp->hull_strength; objp->hull_strength -= hits_left * (1000.0f * flFrametime) / time_left; } // special case of VAPORIZE - if (sp->flags & SF_VAPORIZE) { - // Assert(Ship_info[sp->ship_info_index].flags & SIF_SMALL_SHIP); - if (timestamp_elapsed(sp->final_death_time)) { + if (shipp->flags & SF_VAPORIZE) { + // Assert(sip->flags & SIF_SMALL_SHIP); + if (timestamp_elapsed(shipp->final_death_time)) { // play death sound snd_play_3d( &Snds[SND_VAPORIZED], &objp->pos, &View_position, objp->radius, NULL, 0, 1.0f, SND_PRIORITY_MUST_PLAY ); @@ -7342,7 +7328,7 @@ void ship_dying_frame(object *objp, int ship_num) // if dying ship is docked, do damage to docked and physics if (object_is_dead_docked(objp)) { - do_dying_undock_physics(objp, sp); + do_dying_undock_physics(objp, shipp); } // do all accounting for respawning client and server side here. @@ -7366,34 +7352,34 @@ void ship_dying_frame(object *objp, int ship_num) // } // bash the desired rotvel - objp->phys_info.desired_rotvel = sp->deathroll_rotvel; + objp->phys_info.desired_rotvel = shipp->deathroll_rotvel; // Do fireballs for Big ship with propagating explostion, but not Kamikaze - if (!(Ai_info[sp->ai_index].ai_flags & AIF_KAMIKAZE) && ship_get_exp_propagates(sp)) { - if ( timestamp_elapsed(Ships[ship_num].next_fireball)) { + if (!(Ai_info[shipp->ai_index].ai_flags & AIF_KAMIKAZE) && ship_get_exp_propagates(shipp)) { + if ( timestamp_elapsed(shipp->next_fireball)) { vec3d outpnt, pnt1, pnt2; - polymodel *pm = model_get(sp->modelnum); + polymodel *pm = model_get(sip->model_num); // Gets two random points on the surface of a submodel - submodel_get_two_random_points(sp->modelnum, pm->detail[0], &pnt1, &pnt2 ); + submodel_get_two_random_points(pm->id, pm->detail[0], &pnt1, &pnt2 ); // vm_vec_avg( &tmp, &pnt1, &pnt2 ); [KNOSSOS get random in plane 1/1.414 in rad - model_find_world_point(&outpnt, &pnt1, sp->modelnum, pm->detail[0], &objp->orient, &objp->pos ); + model_find_world_point(&outpnt, &pnt1, sip->model_num, pm->detail[0], &objp->orient, &objp->pos ); float rad = objp->radius*0.1f; int fireball_type = FIREBALL_EXPLOSION_LARGE1 + rand()%FIREBALL_NUM_LARGE_EXPLOSIONS; fireball_create( &outpnt, fireball_type, OBJ_INDEX(objp), rad, 0, &objp->phys_info.vel ); // start the next fireball up in the next 50 - 200 ms (2-3 per frame) - sp->next_fireball = timestamp_rand(333,500); + shipp->next_fireball = timestamp_rand(333,500); // do sound - maybe start a random sound, if it has played far enough. - do_sub_expl_sound(objp->radius, &outpnt, sp->sub_expl_sound_handle); + do_sub_expl_sound(objp->radius, &outpnt, shipp->sub_expl_sound_handle); } } // create little fireballs for knossos as it dies if (knossos_ship) { - if ( timestamp_elapsed(Ships[ship_num].next_fireball)) { + if ( timestamp_elapsed(shipp->next_fireball)) { vec3d rand_vec, outpnt; // [0-.7 rad] in plane vm_vec_rand_vec_quick(&rand_vec); float scale = -vm_vec_dotprod(&objp->orient.vec.fvec, &rand_vec) * (0.9f + 0.2f * frand()); @@ -7407,7 +7393,7 @@ void ship_dying_frame(object *objp, int ship_num) int fireball_type = FIREBALL_EXPLOSION_LARGE1 + rand()%FIREBALL_NUM_LARGE_EXPLOSIONS; fireball_create( &outpnt, fireball_type, OBJ_INDEX(objp), rad, 0, &objp->phys_info.vel ); // start the next fireball up in the next 50 - 200 ms (2-3 per frame) - sp->next_fireball = timestamp_rand(333,500); + shipp->next_fireball = timestamp_rand(333,500); // emit particles particle_emitter pe; @@ -7429,27 +7415,27 @@ void ship_dying_frame(object *objp, int ship_num) particle_emit( &pe ); // do sound - maybe start a random sound, if it has played far enough. - do_sub_expl_sound(objp->radius, &outpnt, sp->sub_expl_sound_handle); + do_sub_expl_sound(objp->radius, &outpnt, shipp->sub_expl_sound_handle); } } - //nprintf(("AI", "Ship.cpp: Frame=%i, Time = %7.3f, Ship %s will die in %7.3f seconds.\n", Framecount, f2fl(Missiontime), Ships[ship_num].ship_name, (float) timestamp_until(sp->final_death_time)/1000.0f)); - int time_until_minor_explosions = timestamp_until(sp->final_death_time); + //nprintf(("AI", "Ship.cpp: Frame=%i, Time = %7.3f, Ship %s will die in %7.3f seconds.\n", Framecount, f2fl(Missiontime), shipp->ship_name, (float) timestamp_until(sp->final_death_time)/1000.0f)); + int time_until_minor_explosions = timestamp_until(shipp->final_death_time); // if(time_until_minor_explosions < 500) // sp->flare_life += flFrametime; // Wait until just before death and set off some explosions // If it is less than 1/2 second until large explosion, but there is // at least 1/10th of a second left, then create 5 small explosions - if ( (time_until_minor_explosions < 500) && (time_until_minor_explosions > 100) && (!sp->pre_death_explosion_happened) ) { + if ( (time_until_minor_explosions < 500) && (time_until_minor_explosions > 100) && (!shipp->pre_death_explosion_happened) ) { //mprintf(( "Ship almost dying!!\n" )); - sp->next_fireball = timestamp(-1); // never time out again - sp->pre_death_explosion_happened=1; // Mark this event as having occurred + shipp->next_fireball = timestamp(-1); // never time out again + shipp->pre_death_explosion_happened=1; // Mark this event as having occurred - polymodel *pm = model_get(sp->modelnum); + polymodel *pm = model_get(sip->model_num); // Start shockwave for ship with propagating explosion, do now for timing - if ( ship_get_exp_propagates(sp) ) { + if ( ship_get_exp_propagates(shipp) ) { ship_blow_up_area_apply_blast( objp ); } @@ -7463,10 +7449,10 @@ void ship_dying_frame(object *objp, int ship_num) vec3d tmp, outpnt, pnt1, pnt2; // Gets two random points on the surface of a submodel [KNOSSOS] - submodel_get_two_random_points(sp->modelnum, pm->detail[0], &pnt1, &pnt2 ); + submodel_get_two_random_points(pm->id, pm->detail[0], &pnt1, &pnt2 ); vm_vec_avg( &tmp, &pnt1, &pnt2 ); - model_find_world_point(&outpnt, &tmp, sp->modelnum, pm->detail[0], &objp->orient, &objp->pos ); + model_find_world_point(&outpnt, &tmp, pm->id, pm->detail[0], &objp->orient, &objp->pos ); float rad = frand()*0.30f; rad += objp->radius*0.40f; @@ -7474,17 +7460,17 @@ void ship_dying_frame(object *objp, int ship_num) } } - if ( timestamp_elapsed(sp->final_death_time)) { + if ( timestamp_elapsed(shipp->final_death_time)) { - sp->death_time = sp->final_death_time; + shipp->death_time = shipp->final_death_time; - sp->final_death_time = timestamp(-1); // never time out again + shipp->final_death_time = timestamp(-1); // never time out again //mprintf(( "Ship dying!!\n" )); // play ship explosion sound effect, pick appropriate explosion sound int sound_index; - if ( Ship_info[sp->ship_info_index].flags & (SIF_CAPITAL | SIF_KNOSSOS_DEVICE) ) { + if ( sip->flags & (SIF_CAPITAL | SIF_KNOSSOS_DEVICE) ) { sound_index=SND_CAPSHIP_EXPLODE; } else { if ( OBJ_INDEX(objp) & 1 ) { @@ -7498,14 +7484,14 @@ void ship_dying_frame(object *objp, int ship_num) if (objp == Player_obj) joy_ff_explode(); - if ( sp->death_roll_snd != -1 ) { - snd_stop(sp->death_roll_snd); - sp->death_roll_snd = -1; + if ( shipp->death_roll_snd != -1 ) { + snd_stop(shipp->death_roll_snd); + shipp->death_roll_snd = -1; } // if dying ship is docked, do damage to docked and physics if (object_is_dead_docked(objp)) { - do_dying_undock_physics(objp, sp); + do_dying_undock_physics(objp, shipp); } if (!knossos_ship) { @@ -7529,15 +7515,15 @@ void ship_dying_frame(object *objp, int ship_num) } // If this is a large ship with a propagating explosion, set it to blow up. - if ( ship_get_exp_propagates(sp) ) { - if (Ai_info[sp->ai_index].ai_flags & AIF_KAMIKAZE) { + if ( ship_get_exp_propagates(shipp) ) { + if (Ai_info[shipp->ai_index].ai_flags & AIF_KAMIKAZE) { ship_blow_up_area_apply_blast( objp ); } - shipfx_large_blowup_init(sp); + shipfx_large_blowup_init(shipp); // need to timeout immediately to keep physics in sync - sp->really_final_death_time = timestamp(0); - polymodel *pm = model_get(sp->modelnum); - sp->end_death_time = timestamp((int) pm->core_radius); + shipp->really_final_death_time = timestamp(0); + polymodel *pm = model_get(sip->model_num); + shipp->end_death_time = timestamp((int) pm->core_radius); } else { // only do big fireball if not big ship float big_rad; @@ -7550,7 +7536,7 @@ void ship_dying_frame(object *objp, int ship_num) fireball_type = FIREBALL_EXPLOSION_LARGE1; } fireball_objnum = fireball_create( &objp->pos, fireball_type, OBJ_INDEX(objp), big_rad, 0, &objp->phys_info.vel ); - if ( fireball_objnum > -1 ) { + if ( fireball_objnum >= 0 ) { explosion_life = fireball_lifeleft(&Objects[fireball_objnum]); } else { explosion_life = 0.0f; @@ -7563,24 +7549,24 @@ void ship_dying_frame(object *objp, int ship_num) // ship, so instead of just taking this code out, since we might need // it in the future, I disabled it. You can reenable it by changing // the commenting on the following two lines. - sp->end_death_time = sp->really_final_death_time = timestamp( fl2i(explosion_life*1000.0f)/5 ); // Wait till 30% of vclip time before breaking the ship up. - //sp->really_final_death_time = timestamp(0); // Make ship break apart the instant the explosion starts + shipp->end_death_time = shipp->really_final_death_time = timestamp( fl2i(explosion_life*1000.0f)/5 ); // Wait till 30% of vclip time before breaking the ship up. + //shipp->really_final_death_time = timestamp(0); // Make ship break apart the instant the explosion starts } - sp->flags |= SF_EXPLODED; + shipp->flags |= SF_EXPLODED; - if ( !(ship_get_exp_propagates(sp)) ) { + if ( !(ship_get_exp_propagates(shipp)) ) { // apply area of effect blast damage from ship explosion ship_blow_up_area_apply_blast( objp ); } } - if ( timestamp_elapsed(sp->really_final_death_time)) { + if ( timestamp_elapsed(shipp->really_final_death_time)) { //mprintf(( "Ship really dying!!\n" )); // do large_ship_split and explosion - if ( sp->large_ship_blowup_index > -1 ) { - if ( shipfx_large_blowup_do_frame(sp, flFrametime) ) { + if ( shipp->large_ship_blowup_index >= 0 ) { + if ( shipfx_large_blowup_do_frame(shipp, flFrametime) ) { // do all accounting for respawning client and server side here. if(objp == Player_obj) { gameseq_post_event(GS_EVENT_DEATH_BLEW_UP); @@ -7596,7 +7582,7 @@ void ship_dying_frame(object *objp, int ship_num) //fireball_create( &objp->pos, FIREBALL_SHIP_EXPLODE1, OBJ_INDEX(objp), objp->radius/2.0f ); //mprintf(("Frame %i: Died!\n", Framecount)); - shipfx_blow_up_model(objp, Ships[ship_num].modelnum, 0, 20, &objp->pos ); + shipfx_blow_up_model(objp, sip->model_num, 0, 20, &objp->pos ); // do all accounting for respawning client and server side here. if(objp == Player_obj) { @@ -7606,14 +7592,14 @@ void ship_dying_frame(object *objp, int ship_num) objp->flags |= OF_SHOULD_BE_DEAD; ship_destroyed(ship_num); // call ship function to clean up after the ship is destroyed. - sp->really_final_death_time = timestamp( -1 ); // Never time out again! + shipp->really_final_death_time = timestamp( -1 ); // Never time out again! } // If a ship is dying (and not a capital or big ship) then stutter the engine sound - if ( timestamp_elapsed(sp->next_engine_stutter) ) { - if ( !(Ship_info[sp->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) { - sp->flags ^= SF_ENGINES_ON; // toggle state of engines - sp->next_engine_stutter = timestamp_rand(50, 250); + if ( timestamp_elapsed(shipp->next_engine_stutter) ) { + if ( !(sip->flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) { + shipp->flags ^= SF_ENGINES_ON; // toggle state of engines + shipp->next_engine_stutter = timestamp_rand(50, 250); } } } @@ -8506,7 +8492,7 @@ void ship_process_post(object * obj, float frametime) void ship_set_default_weapons(ship *shipp, ship_info *sip) { int i; - polymodel *po; + polymodel *pm; ship_weapon *swp = &shipp->weapons; weapon_info *wip; @@ -8522,38 +8508,38 @@ void ship_set_default_weapons(ship *shipp, ship_info *sip) // Copy the number of primary and secondary banks to ship, and verify that // model is in synch - po = model_get( shipp->modelnum ); + pm = model_get( sip->model_num ); // Primary banks - if ( po->n_guns > sip->num_primary_banks ) { - Assert(po->n_guns <= MAX_SHIP_PRIMARY_BANKS); - Warning(LOCATION, "There are %d primary banks in the model file,\nbut only %d primary banks in %s for %s\n", po->n_guns, sip->num_primary_banks, current_ship_table, sip->name); - for ( i = sip->num_primary_banks; i < po->n_guns; i++ ) { + if ( pm->n_guns > sip->num_primary_banks ) { + Assert(pm->n_guns <= MAX_SHIP_PRIMARY_BANKS); + Warning(LOCATION, "There are %d primary banks in the model file,\nbut only %d primary banks in %s for %s\n", pm->n_guns, sip->num_primary_banks, current_ship_table, sip->name); + for ( i = sip->num_primary_banks; i < pm->n_guns; i++ ) { // Make unspecified weapon for bank be a Light Laser swp->primary_bank_weapons[i] = weapon_info_lookup(NOX("Light Laser")); Assert(swp->primary_bank_weapons[i] >= 0); } - sip->num_primary_banks = po->n_guns; + sip->num_primary_banks = pm->n_guns; } - else if ( po->n_guns < sip->num_primary_banks ) { - Warning(LOCATION, "There are %d primary banks in %s for %s\nbut only %d primary banks in the model\n", sip->num_primary_banks, sip->name, current_ship_table, po->n_guns); - sip->num_primary_banks = po->n_guns; + else if ( pm->n_guns < sip->num_primary_banks ) { + Warning(LOCATION, "There are %d primary banks in %s for %s\nbut only %d primary banks in the model\n", sip->num_primary_banks, sip->name, current_ship_table, pm->n_guns); + sip->num_primary_banks = pm->n_guns; } // Secondary banks - if ( po->n_missiles > sip->num_secondary_banks ) { - Assert(po->n_missiles <= MAX_SHIP_SECONDARY_BANKS); - Warning(LOCATION, "There are %d secondary banks in model,\nbut only %d secondary banks in %s for %s\n", po->n_missiles, sip->num_secondary_banks, current_ship_table, sip->name); - for ( i = sip->num_secondary_banks; i < po->n_missiles; i++ ) { + if ( pm->n_missiles > sip->num_secondary_banks ) { + Assert(pm->n_missiles <= MAX_SHIP_SECONDARY_BANKS); + Warning(LOCATION, "There are %d secondary banks in model,\nbut only %d secondary banks in %s for %s\n", pm->n_missiles, sip->num_secondary_banks, current_ship_table, sip->name); + for ( i = sip->num_secondary_banks; i < pm->n_missiles; i++ ) { // Make unspecified weapon for bank be a Rockeye Missile swp->secondary_bank_weapons[i] = weapon_info_lookup(NOX("Rockeye Missile")); Assert(swp->secondary_bank_weapons[i] >= 0); } - sip->num_secondary_banks = po->n_missiles; + sip->num_secondary_banks = pm->n_missiles; } - else if ( po->n_missiles < sip->num_secondary_banks ) { - Warning(LOCATION, "There are %d secondary banks in %s for %s,\n but only %d secondary banks in the model.\n", sip->num_secondary_banks, current_ship_table, sip->name, po->n_missiles); - sip->num_secondary_banks = po->n_missiles; + else if ( pm->n_missiles < sip->num_secondary_banks ) { + Warning(LOCATION, "There are %d secondary banks in %s for %s,\n but only %d secondary banks in the model.\n", sip->num_secondary_banks, current_ship_table, sip->name, pm->n_missiles); + sip->num_secondary_banks = pm->n_missiles; } // added ballistic primary support - Goober5000 @@ -8619,7 +8605,7 @@ int ship_check_collision_fast( object * obj, object * other_obj, vec3d * hitpos) ship_model_start(obj); // are these needed in this fast case? probably not. - mc.model_num = Ships[num].modelnum; // Fill in the model to check + mc.model_num = Ship_info[Ships[num].ship_info_index].model_num; // Fill in the model to check mc.orient = &obj->orient; // The object's orient mc.pos = &obj->pos; // The object's position mc.p0 = &other_obj->last_pos; // Point 1 of ray to check @@ -8750,12 +8736,7 @@ int ship_create(matrix *orient, vec3d *pos, int ship_type, char *ship_name) // get Allender or Mike if you hit this Assert //WMC - I hope this isn't really needed anymore. Took it out. - sip->modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]); // use the highest detail level - shipp->modelnum = sip->modelnum; - - // model stuff - shipp->n_subsystems = 0; - shipp->subsystems = NULL; + sip->model_num = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]); // use the highest detail level // check for texture_replacement - Goober5000 if (ship_name) @@ -8766,22 +8747,12 @@ int ship_create(matrix *orient, vec3d *pos, int ship_type, char *ship_name) if (!stricmp(ship_name, Texture_replace[i].ship_name)) { // allocate space for subsystems - shipp->n_subsystems = sip->n_subsystems; - if ( shipp->n_subsystems > 0 ) - { - shipp->subsystems = (model_subsystem *)vm_malloc(sizeof(model_subsystem) * shipp->n_subsystems ); - Assert( shipp->subsystems != NULL ); - } // copy original subsys data - for ( i = 0; i < shipp->n_subsystems; i++ ) - { - shipp->subsystems[i] = sip->subsystems[i]; - } // now load the duplicate model - shipp->modelnum = model_load(sip->pof_file, shipp->n_subsystems, &shipp->subsystems[0], 1, 1); - model_duplicate_reskin(shipp->modelnum, ship_name); + + Int3(); break; } } @@ -8793,59 +8764,37 @@ int ship_create(matrix *orient, vec3d *pos, int ship_type, char *ship_name) int idx; for(idx=0; idxpof_file_hud)){ - Ship_info[idx].modelnum = model_load(Ship_info[idx].pof_file, Ship_info[idx].n_subsystems, &Ship_info[idx].subsystems[0]); + Ship_info[idx].model_num = model_load(Ship_info[idx].pof_file, Ship_info[idx].n_subsystems, &Ship_info[idx].subsystems[0]); } } // mow load it for me with no subsystems - sip->modelnum_hud = model_load(sip->pof_file_hud, 0, NULL); - } - - // we must do stuff for both the original and alternate models - Goober5000 - polymodel *pm_orig = model_get(sip->modelnum); - polymodel *pm_alt = NULL; - - if (shipp->modelnum != sip->modelnum) - { - pm_alt = model_get(shipp->modelnum); + sip->model_num_hud = model_load(sip->pof_file_hud, 0, NULL); } + polymodel *pm = model_get(sip->model_num); ship_copy_subsystem_fixup(sip); - show_ship_subsys_count(); - if (pm_alt) - { - show_ship_subsys_count(); // Goober5000 - double if two models - } - if ( sip->num_detail_levels < pm_orig->n_detail_levels ) + if ( sip->num_detail_levels < pm->n_detail_levels ) { - Warning(LOCATION, "For ship '%s', detail level\nmismatch (POF needs %d)", sip->name, pm_orig->n_detail_levels ); + Warning(LOCATION, "For ship '%s', detail level\nmismatch (POF needs %d)", sip->name, pm->n_detail_levels ); - for (i=0; in_detail_levels; i++ ) { + for (i=0; in_detail_levels; i++ ) { sip->detail_distance[i] = 0; } } - // Goober5000 - one for each model for (i=0; inum_detail_levels; i++ ) { - pm_orig->detail_depth[i] = i2fl(sip->detail_distance[i]); + pm->detail_depth[i] = i2fl(sip->detail_distance[i]); } - if (pm_alt) - { - for (i=0; inum_detail_levels; i++ ) { - pm_alt->detail_depth[i] = i2fl(sip->detail_distance[i]); - } - } - - if ( sip->flags & SIF_NAVBUOY ) { // JAS: Nav buoys don't need to do collisions! - objnum = obj_create(OBJ_SHIP, -1, n, orient, pos, model_get_radius(shipp->modelnum), OF_RENDERS | OF_PHYSICS ); + objnum = obj_create(OBJ_SHIP, -1, n, orient, pos, model_get_radius(sip->model_num), OF_RENDERS | OF_PHYSICS ); } else { - objnum = obj_create(OBJ_SHIP, -1, n, orient, pos, model_get_radius(shipp->modelnum), OF_RENDERS | OF_COLLIDES | OF_PHYSICS ); + objnum = obj_create(OBJ_SHIP, -1, n, orient, pos, model_get_radius(sip->model_num), OF_RENDERS | OF_COLLIDES | OF_PHYSICS ); } Assert( objnum >= 0 ); @@ -8870,74 +8819,54 @@ int ship_create(matrix *orient, vec3d *pos, int ship_type, char *ship_name) //ship_set_default_weapons(shipp, sip); // Allocate shield and initialize it. - if (pm_orig->shield.ntris) { - shipp->shield_integrity = (float *)vm_malloc(sizeof(float)*pm_orig->shield.ntris); - for (i=0; ishield.ntris; i++) + if (pm->shield.ntris) { + shipp->shield_integrity = (float *) vm_malloc(sizeof(float) * pm->shield.ntris); + for (i=0; ishield.ntris; i++) shipp->shield_integrity[i] = 1.0f; - } else shipp->shield_integrity = NULL; // allocate memory for keeping glow point bank status (enabled/disabled) - // if alt model too then be sure to use largest number of glow banks for size { - int n_glow_banks = 0; bool val = true; // default value, enabled - if (!pm_alt) - n_glow_banks = pm_orig->n_glow_point_banks; - else - n_glow_banks = MAX(pm_orig->n_glow_point_banks, pm_alt->n_glow_point_banks); - - if (n_glow_banks) - shipp->glow_point_bank_active.resize( n_glow_banks, val ); + if (pm->n_glow_point_banks) + shipp->glow_point_bank_active.resize( pm->n_glow_point_banks, val ); } // fix up references into paths for this ship's model to point to a ship_subsys entry instead // of a submodel index. The ship_subsys entry should be the same for *all* instances of the // same ship. - - // evaluate for both models! - for (int temp = 0; temp < 2; temp++) + if (!(sip->flags & SIF_PATH_FIXUP)) { - polymodel *pm = NULL; - if (temp == 0) pm = pm_orig; - if (temp == 1) pm = pm_alt; - - if (!pm) - continue; - - if ( !(sip->flags & SIF_PATH_FIXUP) || (temp == 1)) + for ( i = 0; i < pm->n_paths; i++ ) { - for ( i = 0; i < pm->n_paths; i++ ) + for ( j = 0; j < pm->paths[i].nverts; j++ ) { - for ( j = 0; j < pm->paths[i].nverts; j++ ) + for ( k = 0; k < pm->paths[i].verts[j].nturrets; k++ ) { - for ( k = 0; k < pm->paths[i].verts[j].nturrets; k++ ) - { - int ptindex = pm->paths[i].verts[j].turret_ids[k]; // this index is a submodel number (ala bspgen) - int index; - ship_subsys *ss; + int ptindex = pm->paths[i].verts[j].turret_ids[k]; // this index is a submodel number (ala bspgen) + int index; + ship_subsys *ss; - // iterate through the ship_subsystems looking for an id that matches - index = 0; - ss = GET_FIRST(&Ships[n].subsys_list); - while ( ss != END_OF_LIST( &Ships[n].subsys_list ) ) { - if ( ss->system_info->subobj_num == ptindex ) { // when these are equal, fix up the ref - pm->paths[i].verts[j].turret_ids[k] = index; // in path structure to index a ship_subsys - break; - } - index++; - ss = GET_NEXT( ss ); + // iterate through the ship_subsystems looking for an id that matches + index = 0; + ss = GET_FIRST(&Ships[n].subsys_list); + while ( ss != END_OF_LIST( &Ships[n].subsys_list ) ) { + if ( ss->system_info->subobj_num == ptindex ) { // when these are equal, fix up the ref + pm->paths[i].verts[j].turret_ids[k] = index; // in path structure to index a ship_subsys + break; } - - if ( ss == END_OF_LIST(&Ships[n].subsys_list) ) - Warning(LOCATION, "Couldn't fix up turret indices in spline path\n\nModel: %s\nPath: %s\nVertex: %d\nTurret model id:%d\n\nThis probably means that the turret was not specified in the ship table(s).", sip->pof_file, pm->paths[i].name, j, ptindex ); + index++; + ss = GET_NEXT( ss ); } + + if ( ss == END_OF_LIST(&Ships[n].subsys_list) ) + Warning(LOCATION, "Couldn't fix up turret indices in spline path\n\nModel: %s\nPath: %s\nVertex: %d\nTurret model id:%d\n\nThis probably means that the turret was not specified in the ship table(s).", sip->pof_file, pm->paths[i].name, j, ptindex ); } } - sip->flags |= SIF_PATH_FIXUP; } + sip->flags |= SIF_PATH_FIXUP; } // reset the damage record fields (for scoring purposes) @@ -8962,36 +8891,35 @@ int ship_create(matrix *orient, vec3d *pos, int ship_type, char *ship_name) shipp->wing_status_wing_index = -1; // wing index (0-4) in wingman status gauge shipp->wing_status_wing_pos = -1; // wing position (0-5) in wingman status gauge - trail_info *ci; //first try at ABtrails -Bobboau shipp->ab_count = 0; - if(sip->flags & SIF_AFTERBURNER) + if (sip->flags & SIF_AFTERBURNER) { - for(i = 0; i < pm_orig->n_thrusters; i++) + for (i = 0; i < pm->n_thrusters; i++) { - thruster_bank *bank = &pm_orig->thrusters[i]; + thruster_bank *bank = &pm->thrusters[i]; - for(j = 0; j < bank->num_points; j++) + for (j = 0; j < bank->num_points; j++) { // this means you've reached the max # of AB trails for a ship Assert(sip->ct_count <= MAX_SHIP_CONTRAILS); - ci = &shipp->ab_info[shipp->ab_count]; + trail_info *ci = &shipp->ab_info[shipp->ab_count]; // ci = &sip->ct_info[sip->ct_count++]; if (bank->points[j].norm.xyz.z > -0.5) continue;// only make ab trails for thrusters that are pointing backwards ci->pt = bank->points[j].pnt;//offset - ci->w_start = bank->points[j].radius * sip->ABwidth_factor;//width * table loaded width factor + ci->w_start = bank->points[j].radius * sip->ABwidth_factor; //width * table loaded width factor ci->w_end = 0.05f;//end width - ci->a_start = 1.0f * sip->ABAlpha_factor;//start alpha * table loaded alpha factor + ci->a_start = 1.0f * sip->ABAlpha_factor; //start alpha * table loaded alpha factor ci->a_end = 0.0f;//end alpha - ci->max_life = sip->ABlife;// table loaded max life + ci->max_life = sip->ABlife; // table loaded max life ci->stamp = 60; //spew time??? @@ -9029,7 +8957,7 @@ int ship_create(matrix *orient, vec3d *pos, int ship_type, char *ship_name) // input: n => index of ship in Ships[] array // ship_type => ship class (index into Ship_info[]) // -void ship_model_change(int n, int ship_type, int changing_ship_class) +void ship_model_change(int n, int ship_type) { int i; ship_info *sip; @@ -9040,40 +8968,18 @@ void ship_model_change(int n, int ship_type, int changing_ship_class) sp = &Ships[n]; sip = &(Ship_info[ship_type]); - //No need to change model! -C - if(sp->modelnum == sip->modelnum) { - return; - } - - // make sure we can actually change models - if (Ship_info[sp->ship_info_index].n_subsystems != sip->n_subsystems) - { - Warning(LOCATION, "Ship model change failed for %s. Subsystems must match between models.\n", sp->ship_name); - return; - } - - // reset model subsys stuff - ship_model_subsystems_delete(sp); - - // unload old model if we should, helps keep refcount correct and avoid excessive memory usage - if (sp->modelnum >= 0) { - model_unload(sp->modelnum); - } - // get new model - if (sip->modelnum == -1) { - sip->modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]); + if (sip->model_num == -1) { + sip->model_num = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]); } - sp->modelnum = sip->modelnum; - pm = model_get(sp->modelnum); - - Objects[sp->objnum].radius = model_get_radius(sp->modelnum); + pm = model_get(sip->model_num); + Objects[sp->objnum].radius = model_get_radius(pm->id); // page in nondims in game if(!Fred_running){ - model_page_in_textures(sp->modelnum, ship_type); + model_page_in_textures(sip->model_num, ship_type); // also get anything extra (like thrusters graphics) - ship_page_in_model_textures(sp->modelnum, ship_type); + ship_page_in_model_textures(sip->model_num, ship_type); } // allocate memory for keeping glow point bank status (enabled/disabled) @@ -9087,64 +8993,7 @@ void ship_model_change(int n, int ship_type, int changing_ship_class) sp->glow_point_bank_active.resize( pm->n_glow_point_banks, val ); } - // this is only done when changing ship classes - if (changing_ship_class) - { - ship_copy_subsystem_fixup(sip); - } - // this we want to do in game if there's not a ship class change - else - { - ship_subsys *ss; - - // different from our ship class model? - if (sp->modelnum != Ship_info[sp->ship_info_index].modelnum) - { - // redo the subsystems - sp->n_subsystems = sip->n_subsystems; - if ( sp->n_subsystems > 0 ) - { - sp->subsystems = (model_subsystem *)vm_malloc(sizeof(model_subsystem) * sp->n_subsystems ); - Assert( sp->subsystems != NULL ); - } - - // recopy from ship_info - for ( i = 0; i < sp->n_subsystems; i++ ) - { - sp->subsystems[i] = sip->subsystems[i]; - sp->subsystems[i].model_num = sp->modelnum; - } - - // link into the new model - for (ss = GET_FIRST(&sp->subsys_list); ss != END_OF_LIST(&sp->subsys_list); ss = GET_NEXT(ss)) - { - for (i = 0; i < sp->n_subsystems; i++) - { - if (!subsystem_stricmp(ss->system_info->subobj_name, sp->subsystems[i].subobj_name)) - { - ss->system_info = &sp->subsystems[i]; - break; - } - } - } - } - else - { - // link into our original model - for (ss = GET_FIRST(&sp->subsys_list); ss != END_OF_LIST(&sp->subsys_list); ss = GET_NEXT(ss)) - { - for (i = 0; i < sip->n_subsystems; i++) - { - if (!subsystem_stricmp(ss->system_info->subobj_name, sip->subsystems[i].subobj_name)) - { - ss->system_info = &sip->subsystems[i]; - break; - } - } - } - } - } - + ship_copy_subsystem_fixup(sip); if ( sip->num_detail_levels < pm->n_detail_levels ) { Warning(LOCATION, "For ship '%s', detail level\nmismatch (POF needs %d)", sip->name, pm->n_detail_levels ); @@ -9216,8 +9065,8 @@ void change_ship_type(int n, int ship_type, int by_sexp) // point to new ship data + ship_model_change(n, ship_type); sp->ship_info_index = ship_type; - ship_model_change(n, ship_type, 1); // set the correct hull strength @@ -9285,26 +9134,26 @@ void change_ship_type(int n, int ship_type, int by_sexp) sip->ABbitmap = bm_load(sip->ABtrail_bitmap_name); sp->ab_count = 0; - if(sip->flags & SIF_AFTERBURNER) + if (sip->flags & SIF_AFTERBURNER) { - polymodel * pm_orig; - pm_orig = model_get(sp->modelnum); - trail_info *ci; - for(int h = 0; h < pm_orig->n_thrusters; h++) + polymodel *pm = model_get(sip->model_num); + + for (int h = 0; h < pm->n_thrusters; h++) { - for(int j = 0; j < pm_orig->thrusters->num_points; j++) + for (int j = 0; j < pm->thrusters->num_points; j++) { // this means you've reached the max # of AB trails for a ship Assert(sip->ct_count <= MAX_SHIP_CONTRAILS); - ci = &sp->ab_info[sp->ab_count]; + trail_info *ci = &sp->ab_info[sp->ab_count]; // ci = &sip->ct_info[sip->ct_count++]; + // only make ab trails for thrusters that are pointing backwards + if (pm->thrusters[h].points[j].norm.xyz.z > -0.5) + continue; - if(pm_orig->thrusters[h].points[j].norm.xyz.z > -0.5)continue;// only make ab trails for thrusters that are pointing backwards - - ci->pt = pm_orig->thrusters[h].points[j].pnt;//offset - ci->w_start = pm_orig->thrusters[h].points[j].radius * sip->ABwidth_factor;//width * table loaded width factor + ci->pt = pm->thrusters[h].points[j].pnt; //offset + ci->w_start = pm->thrusters[h].points[j].radius * sip->ABwidth_factor; //width * table loaded width factor ci->w_end = 0.05f;//end width @@ -9464,14 +9313,14 @@ int ship_launch_countermeasure(object *objp, int rand_val) // value //fired = cmeasure_create( objp, &pos, shipp->current_cmeasure, rand_val ); cobjnum = weapon_create(&pos, &objp->orient, shipp->current_cmeasure, OBJ_INDEX(objp)); - if(cobjnum > -1) + if (cobjnum >= 0) { cmeasure_set_ship_launch_vel(&Objects[cobjnum], objp, arand); nprintf(("Network", "Cmeasure created by %s\n", shipp->ship_name)); // Play sound effect for counter measure launch Assert(shipp->current_cmeasure < Num_weapon_types); - if ( Weapon_info[shipp->current_cmeasure].launch_snd > -1 ) { + if ( Weapon_info[shipp->current_cmeasure].launch_snd >= 0 ) { snd_play_3d( &Snds[Weapon_info[shipp->current_cmeasure].launch_snd], &pos, &View_position ); } @@ -9890,7 +9739,7 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) } } - polymodel *po = model_get( shipp->modelnum ); + polymodel *pm = model_get( sip->model_num ); next_fire_delay *= 1.0f + (num_primary_banks - 1) * 0.5f; // 50% time penalty if banks linked @@ -9922,8 +9771,8 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) } if (winfo_p->wi_flags2 & WIF2_CYCLE){ - Assert(po->gun_banks[bank_to_fire].num_slots != 0); - swp->next_primary_fire_stamp[bank_to_fire] = timestamp((int)(next_fire_delay / po->gun_banks[bank_to_fire].num_slots)); + Assert(pm->gun_banks[bank_to_fire].num_slots != 0); + swp->next_primary_fire_stamp[bank_to_fire] = timestamp((int)(next_fire_delay / pm->gun_banks[bank_to_fire].num_slots)); //to maintain balence of fighters with more fire points they will fire faster that ships with fewer points }else{ swp->next_primary_fire_stamp[bank_to_fire] = timestamp((int)(next_fire_delay)); @@ -9941,8 +9790,8 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) } - if ( po->n_guns > 0 ) { - int num_slots = po->gun_banks[bank_to_fire].num_slots; + if ( pm->n_guns > 0 ) { + int num_slots = pm->gun_banks[bank_to_fire].num_slots; if(winfo_p->wi_flags & WIF_BEAM){ // the big change I made for fighter beams, if there beams fill out the Fire_Info for a targeting laser then fire it, for each point in the weapon bank -Bobboau swp->next_primary_fire_stamp[bank_to_fire] = timestamp((int)((float) winfo_p->fire_wait * 1000.0f));//doing that time scale thing on enemy fighter is just ugly with beams, especaly ones that have careful timeing @@ -9980,8 +9829,8 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) shipp->beam_sys_info.turret_norm.xyz.x = 0.0f; shipp->beam_sys_info.turret_norm.xyz.y = 0.0f; shipp->beam_sys_info.turret_norm.xyz.z = 1.0f; - shipp->beam_sys_info.model_num = shipp->modelnum; - shipp->beam_sys_info.turret_gun_sobj = po->detail[0]; + shipp->beam_sys_info.model_num = sip->model_num; + shipp->beam_sys_info.turret_gun_sobj = pm->detail[0]; shipp->beam_sys_info.turret_num_firing_points = 1; shipp->beam_sys_info.turret_fov = (float)cos((winfo_p->field_of_fire != 0.0f)?winfo_p->field_of_fire:180); @@ -10010,9 +9859,9 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) }else{ j=v; } - fbfire_info.targeting_laser_offset = po->gun_banks[bank_to_fire].pnt[j]; - shipp->beam_sys_info.pnt = po->gun_banks[bank_to_fire].pnt[j]; - shipp->beam_sys_info.turret_firing_point[0] = po->gun_banks[bank_to_fire].pnt[j]; + fbfire_info.targeting_laser_offset = pm->gun_banks[bank_to_fire].pnt[j]; + shipp->beam_sys_info.pnt = pm->gun_banks[bank_to_fire].pnt[j]; + shipp->beam_sys_info.turret_firing_point[0] = pm->gun_banks[bank_to_fire].pnt[j]; // winfo_p->b_info.beam_type = BEAM_TYPE_C; //mprintf(("I am about to fire a fighter beam4\n")); beam_fire(&fbfire_info); @@ -10144,24 +9993,24 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) { int pt; //point if (winfo_p->wi_flags2 & WIF2_CYCLE){ - //pnt = po->gun_banks[bank_to_fire].pnt[shipp->last_fired_point[bank_to_fire]+j%num_slots]; + //pnt = pm->gun_banks[bank_to_fire].pnt[shipp->last_fired_point[bank_to_fire]+j%num_slots]; pt = shipp->last_fired_point[bank_to_fire]+j%num_slots; //mprintf(("fireing from %d\n",shipp->last_fired_point[bank_to_fire]+j%num_slots)); }else{ - //pnt = po->gun_banks[bank_to_fire].pnt[j]; + //pnt = pm->gun_banks[bank_to_fire].pnt[j]; pt = j; //mprintf(("fireing from %d\n",j)); } int sub_shots = 1; polymodel *weapon_model = NULL; - if(winfo_p->external_model_num > -1){ + if(winfo_p->external_model_num >= 0){ weapon_model = model_get(winfo_p->external_model_num); if(weapon_model->n_guns)sub_shots = weapon_model->gun_banks[0].num_slots; } for(int s = 0; sgun_banks[bank_to_fire].pnt[pt]; + pnt = pm->gun_banks[bank_to_fire].pnt[pt]; if(weapon_model && weapon_model->n_guns)vm_vec_add2(&pnt, &weapon_model->gun_banks[0].pnt[s]); vm_vec_unrotate(&gun_point, &pnt, &obj->orient); @@ -10175,7 +10024,7 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) else { vec3d firing_vec; - vm_vec_unrotate(&firing_vec, &po->gun_banks[bank_to_fire].norm[pt], &obj->orient); + vm_vec_unrotate(&firing_vec, &pm->gun_banks[bank_to_fire].norm[pt], &obj->orient); vm_vector_2_matrix(&firing_orient, &firing_vec, NULL, NULL); } // create the weapon -- the network signature for multiplayer is created inside @@ -10220,7 +10069,7 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) } } // create the muzzle flash effect - shipfx_flash_create( obj, shipp, &pnt, &obj->orient.vec.fvec, 1, weapon ); + shipfx_flash_create( obj, sip->model_num, &pnt, &obj->orient.vec.fvec, 1, weapon ); // maybe shudder the ship - if its me if((winfo_p->wi_flags & WIF_SHUDDER) && (obj == Player_obj) && !(Game_mode & GM_STANDALONE_SERVER)){ @@ -10400,7 +10249,7 @@ void ship_process_targeting_lasers() // if we have a bank to fire - fire it if((shipp->targeting_laser_bank >= 0) && (shipp->targeting_laser_bank < 2)){ // try and get the model - m = model_get(shipp->modelnum); + m = model_get(Ship_info[shipp->ship_info_index].model_num); if(m == NULL){ continue; } @@ -10570,7 +10419,7 @@ int ship_fire_secondary( object *obj, int allow_swarm ) ship_info *sip; weapon_info *wip; ai_info *aip; - polymodel *po; + polymodel *pm; vec3d missile_point, pnt, firing_pos; Assert( obj != NULL ); @@ -10778,17 +10627,17 @@ int ship_fire_secondary( object *obj, int allow_swarm ) } } - po = model_get( shipp->modelnum ); - if ( po->n_missiles > 0 ) { + pm = model_get( sip->model_num ); + if ( pm->n_missiles > 0 ) { int check_ammo; // used to tell if we should check ammo counts or not int num_slots; - if ( bank > po->n_missiles ) { - nprintf(("WARNING","WARNING ==> Tried to fire bank %d, but ship has only %d banks\n", bank+1, po->n_missiles)); + if ( bank > pm->n_missiles ) { + nprintf(("WARNING","WARNING ==> Tried to fire bank %d, but ship has only %d banks\n", bank+1, pm->n_missiles)); return 0; // we can make a quick out here!!! } - num_slots = po->missile_banks[bank].num_slots; + num_slots = pm->missile_banks[bank].num_slots; // determine if there is enough ammo left to fire weapons on this bank. As with primary // weapons, we might or might not check ammo counts depending on game mode, who is firing, @@ -10839,7 +10688,7 @@ int ship_fire_secondary( object *obj, int allow_swarm ) pnt_index = 0; } shipp->secondary_point_reload_pct[bank][pnt_index] = 0.0f; - pnt = po->missile_banks[bank].pnt[pnt_index++]; + pnt = pm->missile_banks[bank].pnt[pnt_index++]; vm_vec_unrotate(&missile_point, &pnt, &obj->orient); vm_vec_add(&firing_pos, &missile_point, &obj->pos); @@ -10855,7 +10704,7 @@ int ship_fire_secondary( object *obj, int allow_swarm ) else { vec3d firing_vec; - vm_vec_unrotate(&firing_vec, &po->missile_banks[bank].norm[pnt_index-1], &obj->orient); + vm_vec_unrotate(&firing_vec, &pm->missile_banks[bank].norm[pnt_index-1], &obj->orient); vm_vector_2_matrix(&firing_orient, &firing_vec, NULL, NULL); } @@ -10866,7 +10715,7 @@ int ship_fire_secondary( object *obj, int allow_swarm ) // create the muzzle flash effect - shipfx_flash_create( obj, shipp, &pnt, &obj->orient.vec.fvec, 0, weapon ); + shipfx_flash_create(obj, sip->model_num, &pnt, &obj->orient.vec.fvec, 0, weapon); /* if ( weapon_num != -1 ) @@ -11596,11 +11445,13 @@ void ship_model_start(object *objp) model_subsystem *psub; ship *shipp; ship_subsys *pss; + int model_num; shipp = &Ships[objp->instance]; + model_num = Ship_info[shipp->ship_info_index].model_num; // First clear all the angles in the model to zero - model_clear_instance(shipp->modelnum); + model_clear_instance(model_num); // Go through all subsystems and bash the model angles for all // the subsystems that need it. @@ -11627,11 +11478,11 @@ void ship_model_start(object *objp) } if ( psub->subobj_num >= 0 ) { - model_set_instance(shipp->modelnum, psub->subobj_num, &pss->submodel_info_1 ); + model_set_instance(model_num, psub->subobj_num, &pss->submodel_info_1 ); } if ( (psub->subobj_num != psub->turret_gun_sobj) && (psub->turret_gun_sobj >= 0) ) { - model_set_instance(shipp->modelnum, psub->turret_gun_sobj, &pss->submodel_info_2 ); + model_set_instance(model_num, psub->turret_gun_sobj, &pss->submodel_info_2 ); } } @@ -11641,12 +11492,12 @@ void ship_model_start(object *objp) // Clears all the instance specific stuff out of the model info void ship_model_stop(object *objp) { - ship *shipp; - - shipp = &Ships[objp->instance]; + Assert(objp != NULL); + Assert(objp->instance >= 0); + Assert(objp->type == OBJ_SHIP); // Then, clear all the angles in the model to zero - model_clear_instance(shipp->modelnum); + model_clear_instance(Ship_info[Ships[objp->instance].ship_info_index].model_num); } @@ -11749,8 +11600,7 @@ void compute_slew_matrix(matrix *orient, angles *a) // eyes have no defined up vector) void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj ) { - ship *shipp = &Ships[obj->instance]; - polymodel *pm = model_get( shipp->modelnum ); + polymodel *pm = model_get(Ship_info[Ships[obj->instance].ship_info_index].model_num); eye *ep = &(pm->view_positions[0]); // vec3d vec; @@ -11764,12 +11614,12 @@ void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj ) // eye points are stored in an array -- the normal viewing position for a ship is the current_eye_index // element. - model_find_world_point( eye_pos, &ep->pnt,shipp->modelnum, ep->parent, &obj->orient, &obj->pos ); + model_find_world_point( eye_pos, &ep->pnt, pm->id, ep->parent, &obj->orient, &obj->pos ); // if ( shipp->current_eye_index == 0 ) { //vm_vec_scale_add(eye_pos, &viewer_obj->pos, &tm.vec.fvec, 2.0f * viewer_obj->radius + Viewer_external_info.distance); *eye_orient = obj->orient; //} else { - // model_find_world_dir( &vec, &ep->norm, shipp->modelnum, ep->parent, &obj->orient, &obj->pos ); + // model_find_world_dir( &vec, &ep->norm, pm->id, ep->parent, &obj->orient, &obj->pos ); // kind of bogus, but use the objects uvec to avoid totally stupid looking behavior. // vm_vector_2_matrix(eye_orient,&vec,&obj->orient.uvec,NULL); //} @@ -13470,14 +13320,14 @@ int ship_navigation_ok_to_warp(ship *sp) // exit: 0 => a valid vector was placed in norm // !0 => an path normal could not be calculated // -int ship_return_subsys_path_normal(ship *sp, ship_subsys *ss, vec3d *gsubpos, vec3d *norm) +int ship_return_subsys_path_normal(ship *shipp, ship_subsys *ss, vec3d *gsubpos, vec3d *norm) { if ( ss->system_info->path_num >= 0 ) { polymodel *pm = NULL; model_path *mp; vec3d *path_point; vec3d gpath_point; - pm = model_get(sp->modelnum); + pm = model_get(Ship_info[shipp->ship_info_index].model_num); Assert( pm != NULL ); if (ss->system_info->path_num > pm->n_paths) { @@ -13492,8 +13342,8 @@ int ship_return_subsys_path_normal(ship *sp, ship_subsys *ss, vec3d *gsubpos, ve // path_point = &mp->verts[mp->nverts-1].pos; path_point = &mp->verts[0].pos; // get path point in world coords - vm_vec_unrotate(&gpath_point, path_point, &Objects[sp->objnum].orient); - vm_vec_add2(&gpath_point, &Objects[sp->objnum].pos); + vm_vec_unrotate(&gpath_point, path_point, &Objects[shipp->objnum].orient); + vm_vec_add2(&gpath_point, &Objects[shipp->objnum].pos); // get unit vector pointing from subsys pos to first path point vm_vec_normalized_dir(norm, &gpath_point, gsubpos); return 0; @@ -13554,7 +13404,7 @@ int ship_subsystem_in_sight(object* objp, ship_subsys* subsys, vec3d *eye_pos, v ship_model_start(objp); - mc.model_num = Ships[objp->instance].modelnum; // Fill in the model to check + mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; // Fill in the model to check mc.orient = &objp->orient; // The object's orientation mc.pos = &objp->pos; // The object's position mc.p0 = eye_pos; // Point 1 of ray to check @@ -14729,7 +14579,7 @@ void ship_page_in() // Mark any ships in the mission as used // for (i=0; i -1) { + if (Ships[i].objnum >= 0) { nprintf(( "Paging","Found ship '%s'\n", Ships[i].ship_name )); ship_class_used[Ships[i].ship_info_index]++; @@ -14772,13 +14622,13 @@ void ship_page_in() // This will go through Subsys_index[] and grab all weapons: primary, secondary, and turrets for (i = p_objp->subsys_index; i < (p_objp->subsys_index + p_objp->subsys_count); i++) { for (j = 0; j < MAX_SHIP_PRIMARY_BANKS; j++) { - if (Subsys_status[i].primary_banks[j] > -1) { + if (Subsys_status[i].primary_banks[j] >= 0) { weapon_mark_as_used(Subsys_status[i].primary_banks[j]); } } for (j = 0; j < MAX_SHIP_SECONDARY_BANKS; j++) { - if (Subsys_status[i].secondary_banks[j] > -1) { + if (Subsys_status[i].secondary_banks[j] >= 0) { weapon_mark_as_used(Subsys_status[i].secondary_banks[j]); } } @@ -14810,9 +14660,9 @@ void ship_page_in() int model_previously_loaded = -1; int ship_previously_loaded = -1; for (j=0; j -1) && !stricmp(sip->pof_file, Ship_info[j].pof_file) ) { + if ( (Ship_info[j].model_num >= 0) && !stricmp(sip->pof_file, Ship_info[j].pof_file) ) { // Model already loaded - model_previously_loaded = Ship_info[j].modelnum; + model_previously_loaded = Ship_info[j].model_num; ship_previously_loaded = j; // the model should already be loaded so this wouldn't take long, but @@ -14825,13 +14675,13 @@ void ship_page_in() } // If the model is previously loaded... - if ( model_previously_loaded > -1 ) { + if ( model_previously_loaded >= 0 ) { // If previously loaded model isn't the same ship class...) if ( ship_previously_loaded != i ) { // update the model number. - sip->modelnum = model_previously_loaded; + sip->model_num = model_previously_loaded; for ( j = 0; j < sip->n_subsystems; j++ ) { sip->subsystems[j].model_num = -1; @@ -14841,19 +14691,19 @@ void ship_page_in() #ifndef NDEBUG for ( j = 0; j < sip->n_subsystems; j++ ) { - Assert( sip->subsystems[j].model_num == sip->modelnum ); + Assert( sip->subsystems[j].model_num == sip->model_num ); } #endif } else { // Just to be safe (I mean to check that my code works...) - Assert( sip->modelnum > -1 ); - Assert( sip->modelnum == model_previously_loaded ); + Assert( sip->model_num >= 0 ); + Assert( sip->model_num == model_previously_loaded ); #ifndef NDEBUG for ( j = 0; j < sip->n_subsystems; j++ ) { //Assert( sip->subsystems[j].model_num == sip->modelnum ); - if(sip->subsystems[j].model_num != sip->modelnum) { + if(sip->subsystems[j].model_num != sip->model_num) { Warning(LOCATION, "Ship '%s' does not have subsystem '%s' linked into the model file, '%s'.", sip->name, sip->subsystems[j].name, sip->pof_file); } } @@ -14861,23 +14711,23 @@ void ship_page_in() } } else { // Model not loaded... so load it and page in its textures - sip->modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]); + sip->model_num = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]); - Assert( sip->modelnum > -1 ); + Assert( sip->model_num >= 0 ); // Verify that all the subsystem model numbers are updated #ifndef NDEBUG for ( j = 0; j < sip->n_subsystems; j++ ) { - Assert( sip->subsystems[j].model_num == sip->modelnum ); // JAS + Assert( sip->subsystems[j].model_num == sip->model_num ); // JAS } #endif } // page in all of the textures if the model got loaded - if ( sip->modelnum > -1 ) { + if ( sip->model_num >= 0 ) { nprintf(( "Paging", "Paging in textures for model '%s'\n", sip->pof_file )); - ship_page_in_model_textures(sip->modelnum, i); + ship_page_in_model_textures(sip->model_num, i); } else { nprintf(( "Paging", "Couldn't load model '%s'\n", sip->pof_file )); } @@ -14967,11 +14817,11 @@ void ship_page_in() bm_page_in_xparent_texture(Wings[i].wing_insignia_texture); } - // page in duplicate model textures - Goober5000 + // page in replacement textures - Goober5000 for (i = 0; i < MAX_SHIPS; i++) { // is this a valid ship? - if ( Ships[i].objnum != -1) + if (Ships[i].objnum >= 0) { // do we have any textures? if (Ships[i].replacement_textures) @@ -14985,15 +14835,6 @@ void ship_page_in() } } } - - // do we have a replacement model? - if ( Ships[i].modelnum != Ship_info[Ships[i].ship_info_index].modelnum ) - { - nprintf(( "Paging", "Paging in textures for model duplicate for ship '%s'\n", Ships[i].ship_name )); - mprintf(( "Paging in textures for model duplicate for ship '%s'\n", Ships[i].ship_name )); - - ship_page_in_model_textures(Ships[i].modelnum); - } } } @@ -15004,7 +14845,7 @@ void ship_page_in() } // Goober5000 - called from ship_page_in() -void ship_page_in_model_textures(int modelnum, int ship_index) +void ship_page_in_model_textures(int modelnum, int ship_type) { int i, j; polymodel *pm; @@ -15065,10 +14906,10 @@ void ship_page_in_model_textures(int modelnum, int ship_index) } } - if (ship_index == -1) + if (ship_type < 0) return; - sip = &Ship_info[ship_index]; + sip = &Ship_info[ship_type]; // afterburner bm_page_in_texture(sip->ABbitmap); @@ -15176,47 +15017,47 @@ void ship_page_out_model_textures(int modelnum, int ship_index) sip = &Ship_info[ship_index]; // afterburner - if (sip->ABbitmap > -1) { + if (sip->ABbitmap >= 0) { bm_page_out(sip->ABbitmap); } // Bobboau's thruster bitmaps - if (sip->thruster_glow_info.normal.first_frame > -1) { + if (sip->thruster_glow_info.normal.first_frame >= 0) { bm_page_out(sip->thruster_glow_info.normal.first_frame); } - if (sip->thruster_glow_info.afterburn.first_frame > -1) { + if (sip->thruster_glow_info.afterburn.first_frame >= 0) { bm_page_out(sip->thruster_glow_info.afterburn.first_frame); } - if (sip->thruster_secondary_glow_info.normal.bitmap > -1) { + if (sip->thruster_secondary_glow_info.normal.bitmap >= 0) { bm_page_out(sip->thruster_secondary_glow_info.normal.bitmap); } - if (sip->thruster_secondary_glow_info.afterburn.bitmap > -1) { + if (sip->thruster_secondary_glow_info.afterburn.bitmap >= 0) { bm_page_out(sip->thruster_secondary_glow_info.afterburn.bitmap); } - if (sip->thruster_tertiary_glow_info.normal.bitmap > -1) { + if (sip->thruster_tertiary_glow_info.normal.bitmap >= 0) { bm_page_out(sip->thruster_tertiary_glow_info.normal.bitmap); } - if (sip->thruster_tertiary_glow_info.afterburn.bitmap > -1) { + if (sip->thruster_tertiary_glow_info.afterburn.bitmap >= 0) { bm_page_out(sip->thruster_tertiary_glow_info.afterburn.bitmap); } // slodeing bitmap - if (sip->splodeing_texture > -1) { + if (sip->splodeing_texture >= 0) { bm_page_out(sip->splodeing_texture); } // thruster/particle bitmaps for (i = 0; in_thruster_particles; i++) { - if (sip->normal_thruster_particles[i].thruster_particle_bitmap01 > -1) { + if (sip->normal_thruster_particles[i].thruster_particle_bitmap01 >= 0) { bm_page_out(sip->normal_thruster_particles[i].thruster_particle_bitmap01); } - if (sip->afterburner_thruster_particles[i].thruster_particle_bitmap01 > -1) { + if (sip->afterburner_thruster_particles[i].thruster_particle_bitmap01 >= 0) { bm_page_out(sip->afterburner_thruster_particles[i].thruster_particle_bitmap01); } } @@ -15240,6 +15081,8 @@ int is_support_allowed(object *objp) return 0; } + ship *shipp = &Ships[objp->instance]; + // make sure, if exiting from bay, that parent ship is in the mission! if (The_mission.support_ships.arrival_location == ARRIVE_FROM_DOCK_BAY) { @@ -15267,7 +15110,7 @@ int is_support_allowed(object *objp) if (Game_mode & GM_NORMAL) { - if ( !(Iff_info[Ships[objp->instance].team].flags & IFFF_SUPPORT_ALLOWED) ) + if ( !(Iff_info[shipp->team].flags & IFFF_SUPPORT_ALLOWED) ) { return 0; } @@ -15286,7 +15129,7 @@ int is_support_allowed(object *objp) if (IS_MISSION_MULTI_COOP) { - if ( !(Iff_info[Ships[objp->instance].team].flags & IFFF_SUPPORT_ALLOWED) ) + if ( !(Iff_info[shipp->team].flags & IFFF_SUPPORT_ALLOWED) ) { return 0; } @@ -15295,15 +15138,15 @@ int is_support_allowed(object *objp) // Goober5000 - extra check for existence of support ship if ( (The_mission.support_ships.ship_class < 0) && - !(The_mission.support_ships.support_available_for_species & (1 << Ship_info[Ships[objp->instance].ship_info_index].species)) ) + !(The_mission.support_ships.support_available_for_species & (1 << Ship_info[shipp->ship_info_index].species)) ) { return 0; } // Goober5000 - extra check to make sure this guy has a rearming dockpoint - if (model_find_dock_index(Ships[objp->instance].modelnum, DOCK_TYPE_REARM) < 0) + if (model_find_dock_index(Ship_info[shipp->ship_info_index].model_num, DOCK_TYPE_REARM) < 0) { - mprintf(("support not allowed for %s because its model lacks a rearming dockpoint\n", Ships[objp->instance].ship_name)); + mprintf(("support not allowed for %s because its model lacks a rearming dockpoint\n", shipp->ship_name)); return 0; } @@ -15465,20 +15308,7 @@ int ship_get_num_subsys(ship *shipp) { Assert(shipp != NULL); - int n_subsys = 0; - - //First case, no model replace - //Second case, model replace has occured - if(shipp->n_subsystems < 1) - { - n_subsys = Ship_info[shipp->ship_info_index].n_subsystems; - } - else - { - n_subsys = shipp->n_subsystems; - } - - return n_subsys; + return Ship_info[shipp->ship_info_index].n_subsystems; } // returns 0 if no conflict, 1 if conflict, -1 on some kind of error with wing struct @@ -15555,7 +15385,7 @@ int ship_get_texture(int bitmap) // check all ship types for(idx=0; idx= 0) && model_find_texture(Ship_info[idx].modelnum, bitmap) == 1){ + if((Ship_info[idx].model_num >= 0) && model_find_texture(Ship_info[idx].model_num, bitmap) == 1){ return idx; } } @@ -15684,7 +15514,7 @@ int check_world_pt_in_expanded_ship_bbox(vec3d *world_pt, object *objp, float de vm_vec_sub(&temp, world_pt, &objp->pos); vm_vec_rotate(&ship_pt, &temp, &objp->orient); - pm = model_get(Ships[objp->instance].modelnum); + pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num); return ( (ship_pt.xyz.x > pm->mins.xyz.x - delta_box) && (ship_pt.xyz.x < pm->maxs.xyz.x + delta_box) @@ -15770,10 +15600,10 @@ int ship_get_species_by_type(int ship_info_index) } // return the length of a ship -float ship_get_length(ship* shipp) +float ship_class_get_length(ship_info *sip) { - Assert(shipp->modelnum > -1); - polymodel *pm = model_get(shipp->modelnum); + Assert(sip->model_num >= 0); + polymodel *pm = model_get(sip->model_num); return (pm->maxs.xyz.z - pm->mins.xyz.z); } @@ -15862,7 +15692,7 @@ int ship_has_dock_bay(int shipnum) polymodel *pm; - pm = model_get( Ships[shipnum].modelnum ); + pm = model_get( Ship_info[Ships[shipnum].ship_info_index].model_num ); Assert( pm ); return ( pm->ship_bay && (pm->ship_bay->num_paths > 0) ); diff --git a/code/ship/ship.h b/code/ship/ship.h index 18f3f6d442..a3808b0f68 100644 --- a/code/ship/ship.h +++ b/code/ship/ship.h @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Ship/Ship.h $ - * $Revision: 2.180 $ - * $Date: 2007-02-18 06:17:34 $ + * $Revision: 2.181 $ + * $Date: 2007-02-20 04:20:27 $ * $Author: Goober5000 $ * * all sorts of cool stuff about ships * * $Log: not supported by cvs2svn $ + * Revision 2.180 2007/02/18 06:17:34 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.179 2007/02/11 21:26:39 Goober5000 * massive shield infrastructure commit * @@ -1284,7 +1287,6 @@ typedef struct ship { int objnum; int ai_index; // Index in Ai_info of ai_info associated with this ship. int ship_info_index; // Index in ship_info for this ship - int modelnum; int hotkey; int escort_priority; int score; @@ -1371,10 +1373,6 @@ typedef struct ship { ship_subsys *last_targeted_subobject[MAX_PLAYERS]; // Last subobject that has been targeted. NULL if none;(player specific) ship_subsys_info subsys_info[SUBSYSTEM_MAX]; // info on particular generic types of subsystems - // subsystem information - Goober5000, in case of duplicate - int n_subsystems; // this number comes from ships.tbl - model_subsystem *subsystems; // see model.h for structure definition - float *shield_integrity; // Integrity at each triangle in shield mesh. // ETS fields @@ -1821,8 +1819,8 @@ typedef struct ship_info { char pof_file_hud[MAX_FILENAME_LEN]; // POF file to load for the HUD target box int num_detail_levels; // number of detail levels for this ship int detail_distance[MAX_SHIP_DETAIL_LEVELS]; // distance to change detail levels at - int modelnum; // ship model - int modelnum_hud; // model to use when rendering to the HUD (eg, mini supercap) + int model_num; // ship model + int model_num_hud; // model to use when rendering to the HUD (eg, mini supercap) int hud_target_lod; // LOD to use for rendering to the HUD targetbox (if not already using special HUD model) float density; // density of the ship in g/cm^3 (water = 1) float damp; // drag @@ -2135,7 +2133,7 @@ extern void ship_level_init(); // called before the start of each level //returns -1 if failed extern int ship_create(matrix * orient, vec3d * pos, int ship_type, char *ship_name = NULL); extern void change_ship_type(int n, int ship_type, int by_sexp = 0); -extern void ship_model_change(int n, int ship_type, int changing_ship_class = 0); +extern void ship_model_change(int n, int ship_type); extern void ship_process_pre( object * objp, float frametime ); extern void ship_process_post( object * objp, float frametime ); extern void ship_render( object * objp ); @@ -2416,8 +2414,8 @@ int ship_is_beginning_warpout_speedup(object *objp); // given a ship info type, return a species int ship_get_species_by_type(int ship_info_index); -// return the length of the ship -float ship_get_length(ship* shipp); +// return the length of the ship class +float ship_class_get_length(ship_info *sip); // Goober5000 - used by change-ai-class extern void ship_set_new_ai_class(int ship_num, int new_ai_class); diff --git a/code/ship/shipfx.cpp b/code/ship/shipfx.cpp index 8356fd9880..50fd6ba981 100644 --- a/code/ship/shipfx.cpp +++ b/code/ship/shipfx.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Ship/ShipFX.cpp $ - * $Revision: 2.86 $ - * $Date: 2007-02-19 07:55:20 $ - * $Author: wmcoolmon $ + * $Revision: 2.87 $ + * $Date: 2007-02-20 04:20:27 $ + * $Author: Goober5000 $ * * Routines for ship effects (as in special) * * $Log: not supported by cvs2svn $ + * Revision 2.86 2007/02/19 07:55:20 wmcoolmon + * More scripting tweaks/bugfixes. + * * Revision 2.85 2007/02/18 06:17:34 Goober5000 * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner * @@ -624,7 +627,7 @@ void shipfx_remove_submodel_ship_sparks(ship *shipp, int submodel_num) void shipfx_subsystem_mabye_create_live_debris(object *ship_obj, ship *ship_p, ship_subsys *subsys, vec3d *exp_center, float exp_mag) { // initializations - polymodel *pm = model_get(ship_p->modelnum); + polymodel *pm = model_get(Ship_info[ship_p->ship_info_index].model_num); int submodel_num = subsys->system_info->subobj_num; submodel_instance_info *sii = &subsys->submodel_info_1; @@ -645,16 +648,16 @@ void shipfx_subsystem_mabye_create_live_debris(object *ship_obj, ship *ship_p, s // make sure the axis point is set if ( !sii->axis_set ) { - model_init_submodel_axis_pt(sii, ship_p->modelnum, submodel_num); + model_init_submodel_axis_pt(sii, pm->id, submodel_num); } // get the rotvel vec3d model_axis, world_axis, rotvel, world_axis_pt; void model_get_rotating_submodel_axis(vec3d *model_axis, vec3d *world_axis, int modelnum, int submodel_num, object *obj); - model_get_rotating_submodel_axis(&model_axis, &world_axis, ship_p->modelnum, submodel_num, ship_obj); + model_get_rotating_submodel_axis(&model_axis, &world_axis, pm->id, submodel_num, ship_obj); vm_vec_copy_scale(&rotvel, &world_axis, sii->cur_turn_rate); - model_find_world_point(&world_axis_pt, &sii->pt_on_axis, ship_p->modelnum, submodel_num, &ship_obj->orient, &ship_obj->pos); + model_find_world_point(&world_axis_pt, &sii->pt_on_axis, pm->id, submodel_num, &ship_obj->orient, &ship_obj->pos); matrix m_rot; // rotation for debris orient about axis vm_quaternion_rotate(&m_rot, vm_vec_mag((vec3d*)&sii->angs), &model_axis); @@ -667,7 +670,7 @@ void shipfx_subsystem_mabye_create_live_debris(object *ship_obj, ship *ship_p, s // get start world pos vm_vec_zero(&start_world_pos); - model_find_world_point(&start_world_pos, &pm->submodel[live_debris_submodel].offset, ship_p->modelnum, live_debris_submodel, &ship_obj->orient, &ship_obj->pos ); + model_find_world_point(&start_world_pos, &pm->submodel[live_debris_submodel].offset, pm->id, live_debris_submodel, &ship_obj->orient, &ship_obj->pos ); // convert to model coord of underlying submodel // set angle to zero @@ -677,13 +680,13 @@ void shipfx_subsystem_mabye_create_live_debris(object *ship_obj, ship *ship_p, s // rotate from submodel coord to world coords // reset angle to current angle pm->submodel[submodel_num].angs = copy_angs; - model_find_world_point(&end_world_pos, &start_model_pos, ship_p->modelnum, submodel_num, &ship_obj->orient, &ship_obj->pos); + model_find_world_point(&end_world_pos, &start_model_pos, pm->id, submodel_num, &ship_obj->orient, &ship_obj->pos); // create fireball here. fireball_create(&end_world_pos, FIREBALL_EXPLOSION_MEDIUM, OBJ_INDEX(ship_obj), pm->submodel[live_debris_submodel].rad); // create debris - live_debris_obj = debris_create(ship_obj, ship_p->modelnum, live_debris_submodel, &end_world_pos, exp_center, 1, exp_mag); + live_debris_obj = debris_create(ship_obj, pm->id, live_debris_submodel, &end_world_pos, exp_center, 1, exp_mag); // only do if debris is created if (live_debris_obj) { @@ -773,7 +776,7 @@ void shipfx_maybe_create_live_debris_at_ship_death( object *ship_obj ) // search for any live debris ship *shipp = &Ships[ship_obj->instance]; - polymodel *pm = model_get(shipp->modelnum); + polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); int live_debris_submodel = -1; for (int idx=0; idxnum_debris_objects; idx++) { @@ -782,7 +785,7 @@ void shipfx_maybe_create_live_debris_at_ship_death( object *ship_obj ) // get submodel that produces live debris int model_get_parent_submodel_for_live_debris( int model_num, int live_debris_model_num ); - int parent = model_get_parent_submodel_for_live_debris( shipp->modelnum, live_debris_submodel); + int parent = model_get_parent_submodel_for_live_debris(pm->id, live_debris_submodel); Assert(parent != -1); // set model values only once (esp blown off) @@ -803,7 +806,7 @@ void shipfx_maybe_create_live_debris_at_ship_death( object *ship_obj ) Assert (pss != NULL); if (pss != NULL) { vec3d exp_center, tmp = ZERO_VECTOR; - model_find_world_point(&exp_center, &tmp, shipp->modelnum, parent, &ship_obj->orient, &ship_obj->pos ); + model_find_world_point(&exp_center, &tmp, pm->id, parent, &ship_obj->orient, &ship_obj->pos ); // if not blown off, blow it off shipfx_subsystem_mabye_create_live_debris(ship_obj, shipp, pss, &exp_center, 3.0f); @@ -824,6 +827,7 @@ void shipfx_maybe_create_live_debris_at_ship_death( object *ship_obj ) void shipfx_blow_off_subsystem(object *ship_obj,ship *ship_p,ship_subsys *subsys, vec3d *exp_center) { vec3d subobj_pos; + int model_num = Ship_info[ship_p->ship_info_index].model_num; model_subsystem *psub = subsys->system_info; @@ -831,16 +835,16 @@ void shipfx_blow_off_subsystem(object *ship_obj,ship *ship_p,ship_subsys *subsys /* if ( psub->turret_gun_sobj > -1 ) - debris_create( ship_obj, ship_p->modelnum, psub->turret_gun_sobj, &subobj_pos, exp_center, 0, 1.0f ); + debris_create( ship_obj, model_num, psub->turret_gun_sobj, &subobj_pos, exp_center, 0, 1.0f ); if ( psub->subobj_num > -1 ) - debris_create( ship_obj, ship_p->modelnum, psub->subobj_num, &subobj_pos, exp_center, 0, 1.0f ); + debris_create( ship_obj, model_num, psub->subobj_num, &subobj_pos, exp_center, 0, 1.0f ); */ // get rid of sparks on submodel that is destroyed shipfx_remove_submodel_ship_sparks(ship_p, psub->subobj_num); // create debris shards - shipfx_blow_up_model(ship_obj, ship_p->modelnum, psub->subobj_num, 50, &subobj_pos ); + shipfx_blow_up_model(ship_obj, model_num, psub->subobj_num, 50, &subobj_pos ); // create live debris objects, if any // TODO: some MULITPLAYER implcations here!! @@ -957,7 +961,7 @@ static float shipfx_calculate_effect_radius( object *objp, int warp_dir ) } float w, h; - polymodel *pm = model_get(Ships[objp->instance].modelnum); + polymodel *pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num); w = pm->maxs.xyz.x - pm->mins.xyz.x; h = pm->maxs.xyz.y - pm->mins.xyz.y; @@ -1003,16 +1007,16 @@ float shipfx_calculate_warp_time(object *objp, int warp_dir) return (float)sip->warpout_time/1000.0f; //Warpin defined } else if ( (warp_dir == WD_WARP_IN) && (sip->warpin_speed != 0.0f) ) { - return ship_get_length(&Ships[objp->instance]) / sip->warpin_speed; + return ship_class_get_length(sip) / sip->warpin_speed; //Warpout defined } else if ( (warp_dir == WD_WARP_OUT) && (sip->warpout_speed != 0.0f) ) { - return ship_get_length(&Ships[objp->instance]) / sip->warpout_speed; + return ship_class_get_length(sip) / sip->warpout_speed; //Player warpout defined } else if ( (warp_dir == WD_WARP_OUT) && (objp == Player_obj) && (sip->warpout_player_speed != 0.0f) ) { - return ship_get_length(&Ships[objp->instance]) / sip->warpout_player_speed; + return ship_class_get_length(sip) / sip->warpout_player_speed; //Player warpout not defined } else if ( (warp_dir == WD_WARP_OUT) && (objp == Player_obj) ) { - return ship_get_length(&Ships[objp->instance]) / PLAYER_WARPOUT_SPEED; + return ship_class_get_length(sip) / PLAYER_WARPOUT_SPEED; } } @@ -1036,7 +1040,7 @@ float shipfx_calculate_warp_dist(object *objp) if (objp->type != OBJ_SHIP) { length = 2.0f * objp->radius; } else { - length = ship_get_length(&Ships[objp->instance]); + length = ship_class_get_length(&Ship_info[Ships[objp->instance].ship_info_index]); } return length; } @@ -1139,7 +1143,7 @@ void shipfx_warpin_start( object *objp ) { Assert(!(Game_mode & GM_MULTIPLAYER)); polymodel *pm; - pm = model_get(shipp->modelnum); + pm = model_get(sip->model_num); vm_vec_scale_add(&shipp->warp_effect_pos, &objp->pos, &objp->orient.vec.fvec, -pm->mins.xyz.z); } else @@ -1337,7 +1341,7 @@ void shipfx_actually_warpout(ship *shipp, object *objp) int compute_special_warpout_stuff(object *objp, float *speed, float *warp_time, vec3d *warp_pos) { object *sp_objp = NULL; - ship *shipp; + ship_info *sip; int valid_reference_ship = FALSE, ref_objnum; vec3d facing_normal, vec_to_knossos, center_pos; float dist_to_plane; @@ -1358,8 +1362,7 @@ int compute_special_warpout_stuff(object *objp, float *speed, float *warp_time, if ((ref_objnum >= 0) && (ref_objnum < MAX_OBJECTS)) { sp_objp = &Objects[ref_objnum]; if (sp_objp->type == OBJ_SHIP) { - shipp = &Ships[sp_objp->instance]; - if (Ship_info[shipp->ship_info_index].flags & SIF_KNOSSOS_DEVICE) { + if (Ship_info[Ships[sp_objp->instance].ship_info_index].flags & SIF_KNOSSOS_DEVICE) { valid_reference_ship = TRUE; } } @@ -1370,10 +1373,11 @@ int compute_special_warpout_stuff(object *objp, float *speed, float *warp_time, mprintf(("special warpout reference ship not found\n")); return -1; } + sip = &Ship_info[Ships[objp->instance].ship_info_index]; //find the actual center of the model - polymodel *pm = model_get(Ships[objp->instance].modelnum); + polymodel *pm = model_get(sip->model_num); vm_vec_add(¢er_pos, &objp->pos, &pm->autocenter); // get facing normal from knossos @@ -1423,9 +1427,11 @@ int compute_special_warpout_stuff(object *objp, float *speed, float *warp_time, void compute_warpout_stuff(object *objp, float *speed, float *warp_time, vec3d *warp_pos) { Assert(objp); // Goober5000 + ship *shipp = &Ships[objp->instance]; + ship_info *sip = &Ship_info[shipp->ship_info_index]; // If we're warping through the knossos, do something different. - if (Ships[objp->instance].special_warp_objnum >= 0) { + if (shipp->special_warp_objnum >= 0) { if (compute_special_warpout_stuff(objp, speed, warp_time, warp_pos) != -1) { return; } else { @@ -1453,15 +1459,15 @@ void compute_warpout_stuff(object *objp, float *speed, float *warp_time, vec3d * dock_calc_docked_center(¢er_pos, objp); else { - polymodel *pm = model_get(Ships[objp->instance].modelnum); + polymodel *pm = model_get(sip->model_num); vm_vec_add(¢er_pos,&objp->pos,&pm->autocenter); } // If this is a huge ship, set the distance to the length of the ship - if (Ship_info[Ships[objp->instance].ship_info_index].flags & SIF_HUGE_SHIP) + if (sip->flags & SIF_HUGE_SHIP) { - ship_move_dist = 0.5f * ship_get_length(&Ships[objp->instance]); + ship_move_dist = 0.5f * ship_class_get_length(sip); } else { @@ -1489,8 +1495,8 @@ void compute_warpout_stuff(object *objp, float *speed, float *warp_time, vec3d * warp_dist = ship_move_dist; // allow for off center - if (Ship_info[Ships[objp->instance].ship_info_index].flags & SIF_HUGE_SHIP) { - polymodel *pm = model_get(Ships[objp->instance].modelnum); + if (sip->flags & SIF_HUGE_SHIP) { + polymodel *pm = model_get(sip->model_num); warp_dist -= pm->mins.xyz.z; } @@ -1746,7 +1752,6 @@ int shipfx_point_in_shadow( vec3d *p0, matrix *src_orient, vec3d *src_pos, float mc_info mc; object *objp; ship_obj *so; - ship *shipp; int n_lights; int idx; @@ -1770,9 +1775,8 @@ int shipfx_point_in_shadow( vec3d *p0, matrix *src_orient, vec3d *src_pos, float for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) { objp = &Objects[so->objnum]; - shipp = &Ships[objp->instance]; - mc.model_num = shipp->modelnum; + mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; mc.orient = &objp->orient; mc.pos = &objp->pos; mc.p0 = &rp0; @@ -1796,7 +1800,6 @@ int shipfx_in_shadow( object * src_obj ) mc_info mc; object *objp; ship_obj *so; - ship *shipp; int n_lights; int idx; @@ -1817,11 +1820,9 @@ int shipfx_in_shadow( object * src_obj ) objp = &Objects[so->objnum]; if ( src_obj != objp ) { - shipp = &Ships[objp->instance]; - vm_vec_scale_add( &rp1, &rp0, &light_dir, objp->radius*10.0f ); - mc.model_num = shipp->modelnum; + mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; mc.orient = &objp->orient; mc.pos = &objp->pos; mc.p0 = &rp0; @@ -1848,7 +1849,6 @@ int shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int sun_n ) mc_info mc; object *objp; ship_obj *so; - ship *shipp; vec3d rp0, rp1; vec3d light_dir; @@ -1865,13 +1865,11 @@ int shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int sun_n ) objp = &Objects[so->objnum]; if ( src_obj != objp ) { - shipp = &Ships[objp->instance]; - vm_vec_scale_add( &rp1, &rp0, &light_dir, objp->radius*10.0f ); ship_model_start(objp); - mc.model_num = shipp->modelnum; + mc.model_num = Ship_info[Ships[objp->instance].ship_info_index].model_num; mc.orient = &objp->orient; mc.pos = &objp->pos; mc.p0 = &rp0; @@ -1958,14 +1956,14 @@ void shipfx_flash_init() // Given that a ship fired a weapon, light up the model // accordingly. -void shipfx_flash_create(object *objp, ship * shipp, vec3d *gun_pos, vec3d *gun_dir, int is_primary, int weapon_info_index) +void shipfx_flash_create(object *objp, int model_num, vec3d *gun_pos, vec3d *gun_dir, int is_primary, int weapon_info_index) { int i; int objnum = OBJ_INDEX(objp); Assert(Ship_flash_inited); - polymodel *pm = model_get( shipp->modelnum ); + polymodel *pm = model_get(model_num); int closest_light = -1; float d, closest_dist = 0.0f; @@ -2044,10 +2042,10 @@ void shipfx_flash_create(object *objp, ship * shipp, vec3d *gun_pos, vec3d *gun_ // ship to the appropriate values. There might not // be any flashes linked to this ship in which // case this function does nothing. -void shipfx_flash_light_model( object *objp, ship * shipp ) +void shipfx_flash_light_model(object *objp, int model_num) { int i, objnum = OBJ_INDEX(objp); - polymodel *pm = model_get( shipp->modelnum ); + polymodel *pm = model_get(model_num); for (i=0; i<=Ship_flash_highest; i++ ) { if ( (Ship_flash[i].objnum == objnum) && (Ship_flash[i].obj_signature==objp->signature) ) { @@ -2056,7 +2054,6 @@ void shipfx_flash_light_model( object *objp, ship * shipp ) pm->lights[Ship_flash[i].light_num].value += v / 255.0f; } } - } // Does whatever processing needs to be done each frame. @@ -2149,7 +2146,7 @@ void shipfx_emit_spark( int n, int sn ) return; // get radius of ship - ship_radius = model_get_radius(shipp->modelnum); + ship_radius = model_get_radius(sip->model_num); // get spark_scale_factor -- how much to increase ship sparks, based on radius if (ship_radius > 40) { @@ -2191,7 +2188,7 @@ void shipfx_emit_spark( int n, int sn ) // get spark position if (shipp->sparks[spark_num].submodel_num != -1) { ship_model_start(obj); - model_find_world_point(&outpnt, &shipp->sparks[spark_num].pos, shipp->modelnum, shipp->sparks[spark_num].submodel_num, &obj->orient, &obj->pos); + model_find_world_point(&outpnt, &shipp->sparks[spark_num].pos, sip->model_num, shipp->sparks[spark_num].submodel_num, &obj->orient, &obj->pos); ship_model_stop(obj); } else { // rotate sparks correctly with current ship orient @@ -2416,7 +2413,7 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) vm_vec_copy_scale(&split_ship->back_ship.clip_plane_norm, &vmd_z_vector, -1.0f); // find the point at which the ship splits (relative to its pivot) - polymodel* pm = model_get(shipp->modelnum); + polymodel* pm = model_get(Ship_info[shipp->ship_info_index].model_num); float init_clip_plane_dist; if (pm->num_split_plane > 0) { int index = rand()%pm->num_split_plane; @@ -2444,7 +2441,7 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) vec3d tmp = ZERO_VECTOR; vec3d tmp1 = pm->submodel[pm->debris_objects[i]].offset; // tmp is world position, temp_pos is world_pivot, tmp1 is offset from world_pivot (in ship local coord) - model_find_world_point(&tmp, &tmp1, shipp->modelnum, -1, &vmd_identity_matrix, &temp_pos ); + model_find_world_point(&tmp, &tmp1, pm->id, -1, &vmd_identity_matrix, &temp_pos ); if (tmp.xyz.z > init_clip_plane_dist) { split_ship->front_ship.draw_debris[i] = DEBRIS_DRAW; split_ship->back_ship.draw_debris[i] = DEBRIS_NONE; @@ -2528,7 +2525,7 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) static void half_ship_render_ship_and_debris(clip_ship* half_ship,ship *shipp) { - polymodel *pm = model_get(shipp->modelnum); + polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); // get rotated clip plane normal and world coord of original ship center vec3d orig_ship_world_center, clip_plane_norm, model_clip_plane_pt, debris_clip_plane_pt; @@ -2579,8 +2576,8 @@ static void half_ship_render_ship_and_debris(clip_ship* half_ship,ship *shipp) // Draw debris, but not live debris if ( !is_live_debris ) { - model_find_world_point(&tmp, &tmp1, shipp->modelnum, -1, &half_ship->orient, &temp_pos); - submodel_render(shipp->modelnum, pm->debris_objects[i], &half_ship->orient, &tmp, render_flags, -1, shipp->replacement_textures); + model_find_world_point(&tmp, &tmp1, pm->id, -1, &half_ship->orient, &temp_pos); + submodel_render(pm->id, pm->debris_objects[i], &half_ship->orient, &tmp, render_flags, -1, shipp->replacement_textures); } // make free piece of debris @@ -2598,7 +2595,7 @@ static void half_ship_render_ship_and_debris(clip_ship* half_ship,ship *shipp) // debris vel (1) split ship vel (2) split ship rotvel (3) random if ( !is_live_debris ) { object* debris_obj; - debris_obj = debris_create(half_ship->parent_obj, shipp->modelnum, pm->debris_objects[i], &tmp, &half_ship->local_pivot, 1, 1.0f); + debris_obj = debris_create(half_ship->parent_obj, pm->id, pm->debris_objects[i], &tmp, &half_ship->local_pivot, 1, 1.0f); // AL: make sure debris_obj isn't NULL! if ( debris_obj ) { vm_vec_scale(&debris_obj->phys_info.rotvel, 4.0f); @@ -2628,7 +2625,7 @@ static void half_ship_render_ship_and_debris(clip_ship* half_ship,ship *shipp) vm_vec_unrotate(&model_clip_plane_pt, &temp, &half_ship->orient); vm_vec_add2(&model_clip_plane_pt, &orig_ship_world_center); g3_start_user_clip_plane( &model_clip_plane_pt, &clip_plane_norm ); - model_render(shipp->modelnum, &half_ship->orient, &orig_ship_world_center, render_flags, -1, -1, shipp->replacement_textures); + model_render(pm->id, &half_ship->orient, &orig_ship_world_center, render_flags, -1, -1, shipp->replacement_textures); } void shipfx_large_blowup_level_init() @@ -2737,7 +2734,7 @@ static void maybe_fireball_wipe(clip_ship* half_ship, int* sound_handle) if ( timestamp_elapsed(half_ship->next_fireball) ) { if ( half_ship->length_left > 0.2f*fl_abs(half_ship->explosion_vel) ) { - polymodel* pm = model_get(Ships[half_ship->parent_obj->instance].modelnum); + polymodel* pm = model_get(Ship_info[Ships[half_ship->parent_obj->instance].ship_info_index].model_num); vec3d model_clip_plane_pt, orig_ship_world_center, temp; @@ -2917,6 +2914,7 @@ void shipfx_do_damaged_arcs_frame( ship *shipp ) int i; int should_arc; object *obj = &Objects[shipp->objnum]; + int model_num = Ship_info[shipp->ship_info_index].model_num; should_arc = 1; int disrupted_arc=0; @@ -2984,8 +2982,8 @@ void shipfx_do_damaged_arcs_frame( ship *shipp ) int n, n_arcs = ((rand()>>5) % 3)+1; // Create 1-3 sparks vec3d v1, v2, v3, v4; - submodel_get_two_random_points( shipp->modelnum, -1, &v1, &v2 ); - submodel_get_two_random_points( shipp->modelnum, -1, &v3, &v4 ); + submodel_get_two_random_points(model_num, -1, &v1, &v2); + submodel_get_two_random_points(model_num, -1, &v3, &v4); // For large ships, cap the length to be 25% of max radius if ( obj->radius > 200.0f ) { @@ -3097,7 +3095,7 @@ void shipfx_do_damaged_arcs_frame( ship *shipp ) int mr = myrand(); if ( mr < RAND_MAX/5 ) { vec3d v1, v2; - submodel_get_two_random_points( shipp->modelnum, -1, &v1, &v2 ); + submodel_get_two_random_points(model_num, -1, &v1, &v2); vec3d static_one; @@ -3297,7 +3295,7 @@ void shipfx_do_shockwave_stuff(ship *shipp, shockwave_create_info *sci) } // get vectors at the head and tail of the object, dead center - pm = model_get(shipp->modelnum); + pm = model_get(sip->model_num); if(pm == NULL){ return; } @@ -3356,9 +3354,8 @@ DCF_BOOL(engine_wash, Wash_on) // Assumes length of engine wash is greater than radius of engine wash hemisphere void engine_wash_ship_process(ship *shipp) { - uint idx; - uint j; - object *objp, *ship_objp, *max_ship_intensity_objp; + uint idx, j; + object *objp, *max_ship_intensity_objp; int started_with_no_wash = shipp->wash_intensity <= 0 ? 1 : 0; if (!Wash_on) { @@ -3369,7 +3366,6 @@ void engine_wash_ship_process(ship *shipp) Assert(shipp->objnum >= 0); objp = &Objects[shipp->objnum]; ship_obj *so; - ship_objp = NULL; vec3d world_thruster_pos, world_thruster_norm, apex, thruster_to_ship, apex_to_ship, temp; float dist_sqr, inset_depth, dot_to_ship, max_ship_intensity; @@ -3410,45 +3406,48 @@ void engine_wash_ship_process(ship *shipp) continue; } - ship_objp = &Objects[so->objnum]; + object *wash_objp = &Objects[so->objnum]; - if (!ship_objp || (ship_objp->instance < 0)) { + if (!wash_objp || (wash_objp->instance < 0) || (wash_objp->type != OBJ_SHIP)) { continue; } + ship *wash_shipp = &Ships[wash_objp->instance]; + ship_info *wash_sip = &Ship_info[wash_shipp->ship_info_index]; + // don't do small ships - if ( (Ship_info[Ships[ship_objp->instance].ship_info_index].flags & SIF_SMALL_SHIP) ) { + if ( (wash_sip->flags & SIF_SMALL_SHIP) ) { continue; } - pm = model_get(Ships[ship_objp->instance].modelnum); + pm = model_get(wash_sip->model_num); float ship_intensity = 0; // if engines disabled, no engine wash - if (ship_get_subsystem_strength(&Ships[ship_objp->instance], SUBSYSTEM_ENGINE) < 0.01) { + if (ship_get_subsystem_strength(wash_shipp, SUBSYSTEM_ENGINE) < 0.01) { continue; } float speed_scale; - if (ship_objp->phys_info.speed > 20.0f) + if (wash_objp->phys_info.speed > 20.0f) speed_scale = 1.0f; else - speed_scale = ship_objp->phys_info.speed/20.0f; + speed_scale = wash_objp->phys_info.speed/20.0f; for (idx = 0; idx < pm->n_thrusters; idx++) { thruster_bank *bank = &pm->thrusters[idx]; // make sure this engine is functional before we try to process a wash from it - if ( !model_should_render_engine_glow(OBJ_INDEX(ship_objp), bank->obj_num) ) { + if ( !model_should_render_engine_glow(OBJ_INDEX(wash_objp), bank->obj_num) ) { continue; } // check if thruster bank has engine wash if (bank->wash_info_pointer == NULL) { // if huge, give default engine wash - if ((Ship_info[Ships[ship_objp->instance].ship_info_index].flags & SIF_HUGE_SHIP) && Engine_wash_info.size()) { + if ((wash_sip->flags & SIF_HUGE_SHIP) && Engine_wash_info.size()) { bank->wash_info_pointer = &Engine_wash_info[0]; - nprintf(("wash", "Adding default engine wash to ship %s", Ship_info[Ships[ship_objp->instance].ship_info_index].name)); + nprintf(("wash", "Adding default engine wash to ship %s", wash_sip->name)); } else { continue; } @@ -3460,11 +3459,11 @@ void engine_wash_ship_process(ship *shipp) for (j=0; jnum_points; j++) { // get world pos of thruster - vm_vec_unrotate(&world_thruster_pos, &bank->points[j].pnt, &ship_objp->orient); - vm_vec_add2(&world_thruster_pos, &ship_objp->pos); + vm_vec_unrotate(&world_thruster_pos, &bank->points[j].pnt, &wash_objp->orient); + vm_vec_add2(&world_thruster_pos, &wash_objp->pos); // get world norm of thruster; - vm_vec_unrotate(&world_thruster_norm, &bank->points[j].norm, &ship_objp->orient); + vm_vec_unrotate(&world_thruster_norm, &bank->points[j].norm, &wash_objp->orient); // get vector from thruster to ship vm_vec_sub(&thruster_to_ship, &objp->pos, &world_thruster_pos); @@ -3518,7 +3517,7 @@ void engine_wash_ship_process(ship *shipp) shipp->wash_intensity += ship_intensity * speed_scale; if (ship_intensity > max_ship_intensity) { max_ship_intensity = ship_intensity; - max_ship_intensity_objp = ship_objp; + max_ship_intensity_objp = wash_objp; } } @@ -3535,7 +3534,7 @@ void engine_wash_ship_process(ship *shipp) damage = (0.001f * 0.003f * ENGINE_WASH_CHECK_INTERVAL * shipp->ship_max_hull_strength * shipp->wash_intensity); } - ship_apply_wash_damage(&Objects[shipp->objnum], max_ship_intensity_objp, damage); + ship_apply_wash_damage(objp, max_ship_intensity_objp, damage); // if we had no wash before now, add the wash object sound if(started_with_no_wash){ diff --git a/code/ship/shipfx.h b/code/ship/shipfx.h index d30dafa1ec..22ab0a089f 100644 --- a/code/ship/shipfx.h +++ b/code/ship/shipfx.h @@ -9,13 +9,18 @@ /* * $Logfile: /Freespace2/code/Ship/ShipFX.h $ - * $Revision: 2.12 $ - * $Date: 2006-07-09 01:55:42 $ + * $Revision: 2.13 $ + * $Date: 2007-02-20 04:20:27 $ * $Author: Goober5000 $ * * Routines for ship effects (as in special) * * $Log: not supported by cvs2svn $ + * Revision 2.12 2006/07/09 01:55:42 Goober5000 + * consolidate the "for reals" crap into a proper ship flag; also move the limbo flags over to SF2_*; etc. + * this should fix Mantis #977 + * --Goober5000 + * * Revision 2.10 2006/03/31 10:20:01 wmcoolmon * Prelim. BSG warpin effect stuff * @@ -233,13 +238,13 @@ void shipfx_flash_init(); // accordingly. // Set is_primary to non-zero if this is a primary weapon. // Gun_pos should be in object's frame of reference, not world!!! -void shipfx_flash_create(object *objp, ship * shipp, vec3d *gun_pos, vec3d *gun_dir, int is_primary, int weapon_info_index); +void shipfx_flash_create(object *objp, int model_num, vec3d *gun_pos, vec3d *gun_dir, int is_primary, int weapon_info_index); // Sets the flash lights in the model used by this // ship to the appropriate values. There might not // be any flashes linked to this ship in which // case this function does nothing. -void shipfx_flash_light_model(object *objp, ship * shipp ); +void shipfx_flash_light_model(object *objp, int model_num); // Does whatever processing needs to be done each frame. void shipfx_flash_do_frame(float frametime); diff --git a/code/ship/shiphit.cpp b/code/ship/shiphit.cpp index 7c37bf1034..31be91bd01 100644 --- a/code/ship/shiphit.cpp +++ b/code/ship/shiphit.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Ship/ShipHit.cpp $ - * $Revision: 2.76 $ - * $Date: 2007-02-19 20:39:10 $ - * $Author: wmcoolmon $ + * $Revision: 2.77 $ + * $Date: 2007-02-20 04:20:27 $ + * $Author: Goober5000 $ * * Code to deal with a ship getting hit by something, be it a missile, dog, or ship. * * $Log: not supported by cvs2svn $ + * Revision 2.76 2007/02/19 20:39:10 wmcoolmon + * More minor tweaks/fixes + * * Revision 2.75 2007/02/11 21:26:39 Goober5000 * massive shield infrastructure commit * @@ -896,11 +899,6 @@ void do_subobj_destroyed_stuff( ship *ship_p, ship_subsys *subsys, vec3d* hitpos for ( i = 0; i < sip->n_subsystems; i++ ) { if ( &(sip->subsystems[i]) == psub ) break; - - // check alt stuff too - Goober5000 - if ( ship_p->modelnum != sip->modelnum ) - if ( &(ship_p->subsystems[i]) == psub ) - break; } Assert( i < sip->n_subsystems ); Assert( i < 65535 ); @@ -1638,12 +1636,13 @@ int choose_next_spark(object *ship_obj, vec3d *hitpos) vec3d world_hitpos[MAX_SHIP_HITS]; spark_pair spark_pairs[MAX_SPARK_PAIRS]; ship *shipp = &Ships[ship_obj->instance]; + ship_info *sip = &Ship_info[shipp->ship_info_index]; // only choose next spark when all slots are full Assert(get_max_sparks(ship_obj) == Ships[ship_obj->instance].num_hits); // get num_sparks - num_sparks = Ships[ship_obj->instance].num_hits; + num_sparks = shipp->num_hits; Assert(num_sparks <= MAX_SHIP_HITS); // get num_spark_paris -- only sort these @@ -1657,7 +1656,7 @@ int choose_next_spark(object *ship_obj, vec3d *hitpos) model_started = true; ship_model_start(ship_obj); } - model_find_world_point(&world_hitpos[spark_num], &shipp->sparks[spark_num].pos, shipp->modelnum, shipp->sparks[spark_num].submodel_num, &ship_obj->orient, &ship_obj->pos); + model_find_world_point(&world_hitpos[spark_num], &shipp->sparks[spark_num].pos, sip->model_num, shipp->sparks[spark_num].submodel_num, &ship_obj->orient, &ship_obj->pos); } else { // rotate sparks correctly with current ship orient vm_vec_unrotate(&world_hitpos[spark_num], &shipp->sparks[spark_num].pos, &ship_obj->orient); @@ -1738,15 +1737,16 @@ int choose_next_spark(object *ship_obj, vec3d *hitpos) void ship_hit_create_sparks(object *ship_obj, vec3d *hitpos, int submodel_num) { vec3d tempv; - ship *ship_p = &Ships[ship_obj->instance]; + ship *shipp = &Ships[ship_obj->instance]; + ship_info *sip = &Ship_info[shipp->ship_info_index]; int n, max_sparks; - n = ship_p->num_hits; + n = shipp->num_hits; max_sparks = get_max_sparks(ship_obj); if (n >= max_sparks) { - if ( Ship_info[ship_p->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP) ) { + if (sip->flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) { // large ship, choose intelligently n = choose_next_spark(ship_obj, hitpos); } else { @@ -1754,15 +1754,13 @@ void ship_hit_create_sparks(object *ship_obj, vec3d *hitpos, int submodel_num) n = rand() % max_sparks; } } else { - ship_p->num_hits++; + shipp->num_hits++; } - ship *pship = &Ships[ship_obj->instance]; - bool instancing = false; // decide whether to do instancing if (submodel_num != -1) { - polymodel *pm = model_get(pship->modelnum); + polymodel *pm = model_get(sip->model_num); if (pm->detail[0] != submodel_num) { // submodel is not hull // OPTIMIZE ... check if submodel can not rotate @@ -1774,10 +1772,10 @@ void ship_hit_create_sparks(object *ship_obj, vec3d *hitpos, int submodel_num) // get the hit position in the subobject RF ship_model_start(ship_obj); vec3d temp_zero, temp_x, temp_y, temp_z; - model_find_world_point(&temp_zero, &vmd_zero_vector, pship->modelnum, submodel_num, &ship_obj->orient, &ship_obj->pos); - model_find_world_point(&temp_x, &vmd_x_vector, pship->modelnum, submodel_num, &ship_obj->orient, &ship_obj->pos); - model_find_world_point(&temp_y, &vmd_y_vector, pship->modelnum, submodel_num, &ship_obj->orient, &ship_obj->pos); - model_find_world_point(&temp_z, &vmd_z_vector, pship->modelnum, submodel_num, &ship_obj->orient, &ship_obj->pos); + model_find_world_point(&temp_zero, &vmd_zero_vector, sip->model_num, submodel_num, &ship_obj->orient, &ship_obj->pos); + model_find_world_point(&temp_x, &vmd_x_vector, sip->model_num, submodel_num, &ship_obj->orient, &ship_obj->pos); + model_find_world_point(&temp_y, &vmd_y_vector, sip->model_num, submodel_num, &ship_obj->orient, &ship_obj->pos); + model_find_world_point(&temp_z, &vmd_z_vector, sip->model_num, submodel_num, &ship_obj->orient, &ship_obj->pos); ship_model_stop(ship_obj); // find submodel x,y,z axes @@ -1790,24 +1788,24 @@ void ship_hit_create_sparks(object *ship_obj, vec3d *hitpos, int submodel_num) vm_vec_sub(&diff, hitpos, &temp_zero); // find displacement from submodel origin in submodel RF - ship_p->sparks[n].pos.xyz.x = vm_vec_dotprod(&diff, &temp_x); - ship_p->sparks[n].pos.xyz.y = vm_vec_dotprod(&diff, &temp_y); - ship_p->sparks[n].pos.xyz.z = vm_vec_dotprod(&diff, &temp_z); - ship_p->sparks[n].submodel_num = submodel_num; - ship_p->sparks[n].end_time = timestamp(-1); + shipp->sparks[n].pos.xyz.x = vm_vec_dotprod(&diff, &temp_x); + shipp->sparks[n].pos.xyz.y = vm_vec_dotprod(&diff, &temp_y); + shipp->sparks[n].pos.xyz.z = vm_vec_dotprod(&diff, &temp_z); + shipp->sparks[n].submodel_num = submodel_num; + shipp->sparks[n].end_time = timestamp(-1); } else { // Rotate hitpos into ship_obj's frame of reference. vm_vec_sub(&tempv, hitpos, &ship_obj->pos); - vm_vec_rotate(&ship_p->sparks[n].pos, &tempv, &ship_obj->orient); - ship_p->sparks[n].submodel_num = -1; - ship_p->sparks[n].end_time = timestamp(-1); + vm_vec_rotate(&shipp->sparks[n].pos, &tempv, &ship_obj->orient); + shipp->sparks[n].submodel_num = -1; + shipp->sparks[n].end_time = timestamp(-1); } // Create the first wave of sparks shipfx_emit_spark(ship_obj->instance, n); if ( n == 0 ) { - ship_p->next_hit_spark = timestamp(0); // when a hit spot will spark + shipp->next_hit_spark = timestamp(0); // when a hit spot will spark } } diff --git a/code/starfield/supernova.cpp b/code/starfield/supernova.cpp index 9b804f8362..8636de8e54 100644 --- a/code/starfield/supernova.cpp +++ b/code/starfield/supernova.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Starfield/Supernova.cpp $ - * $Revision: 2.10 $ - * $Date: 2006-12-28 00:59:48 $ - * $Author: wmcoolmon $ + * $Revision: 2.11 $ + * $Date: 2007-02-20 04:20:38 $ + * $Author: Goober5000 $ * * Include file for nebula stuff * * $Log: not supported by cvs2svn $ + * Revision 2.10 2006/12/28 00:59:48 wmcoolmon + * WMC codebase commit. See pre-commit build thread for details on changes. + * * Revision 2.9 2006/08/20 00:51:06 taylor * maybe optimize the (PI/2), (PI*2) and (RAND_MAX/2) stuff a little bit * @@ -202,7 +205,7 @@ void supernova_do_particles() // emit for(idx=0; idx<10; idx++){ - submodel_get_two_random_points(Player_ship->modelnum, 0, &ta, &tb); + submodel_get_two_random_points(Ship_info[Player_ship->ship_info_index].model_num, 0, &ta, &tb); // rotate into world space vm_vec_unrotate(&a, &ta, &Player_obj->orient); diff --git a/code/weapon/beam.cpp b/code/weapon/beam.cpp index f7342a8c16..1c99a00aca 100644 --- a/code/weapon/beam.cpp +++ b/code/weapon/beam.cpp @@ -9,13 +9,16 @@ /* * $Logfile: /Freespace2/code/Weapon/Beam.cpp $ - * $Revision: 2.82 $ - * $Date: 2007-02-18 06:17:48 $ + * $Revision: 2.83 $ + * $Date: 2007-02-20 04:20:38 $ * $Author: Goober5000 $ * * all sorts of cool stuff about ships * * $Log: not supported by cvs2svn $ + * Revision 2.82 2007/02/18 06:17:48 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.81 2007/02/11 21:26:39 Goober5000 * massive shield infrastructure commit * @@ -2313,7 +2316,7 @@ int beam_get_model(object *objp) switch(objp->type){ case OBJ_SHIP: - return Ships[objp->instance].modelnum; + return Ship_info[Ships[objp->instance].ship_info_index].model_num; case OBJ_WEAPON: Assert(Weapons[objp->instance].weapon_info_index >= 0); diff --git a/code/weapon/weapons.cpp b/code/weapon/weapons.cpp index b0ddb9787c..79e31c2bdd 100644 --- a/code/weapon/weapons.cpp +++ b/code/weapon/weapons.cpp @@ -12,6 +12,9 @@ * * * $Log: not supported by cvs2svn $ + * Revision 2.196 2007/02/18 06:17:48 Goober5000 + * revert Bobboau's commits for the past two months; these will be added in later in a less messy/buggy manner + * * Revision 2.195 2007/02/11 21:26:39 Goober5000 * massive shield infrastructure commit * @@ -5874,7 +5877,7 @@ void weapon_area_apply_blast(vec3d *force_apply_pos, object *ship_obj, vec3d *bl vm_vec_sub(&vec_ship_to_impact, blast_pos, &ship_obj->pos); - pm = model_get(Ships[ship_obj->instance].modelnum); + pm = model_get(Ship_info[Ships[ship_obj->instance].ship_info_index].model_num); Assert ( pm != NULL ); if (make_shockwave) { diff --git a/projects/MSVC_6/code.dsp b/projects/MSVC_6/code.dsp index d6d07a98eb..1f68457f55 100644 --- a/projects/MSVC_6/code.dsp +++ b/projects/MSVC_6/code.dsp @@ -1480,6 +1480,10 @@ SOURCE=..\..\code\Model\ModelCollide.cpp # End Source File # Begin Source File +SOURCE=..\..\code\model\modeldiff.cpp +# End Source File +# Begin Source File + SOURCE=..\..\code\Model\ModelInterp.cpp # End Source File # Begin Source File