From ee28362f423656c33561adef340a1166e0f23b10 Mon Sep 17 00:00:00 2001 From: Zacam Date: Mon, 3 Dec 2012 01:06:58 +0000 Subject: [PATCH] Trunk Sync: r9389 --- code/ai/aicode.cpp | 2 +- code/graphics/gropengltnl.cpp | 3 +- code/math/vecmat.cpp | 2 +- code/object/collideshipship.cpp | 8 +++--- code/ship/ship.cpp | 49 ++++++++++++++++++--------------- 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index 2b70b5f2fa..d33ed6d95a 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -4821,7 +4821,7 @@ void evade_weapon() rdot = vm_vec_dot(&Pl_objp->orient.vec.rvec, &vec_from_enemy); udot = vm_vec_dot(&Pl_objp->orient.vec.uvec, &vec_from_enemy); - if (aip->ai_profile_flags & AIPF_ALLOW_VERTICAL_DODGE && abs(udot) > abs(rdot)) + if (aip->ai_profile_flags & AIPF_ALLOW_VERTICAL_DODGE && fl_abs(udot) > fl_abs(rdot)) { if ((udot < -0.5f) || (udot > 0.5f)) vm_vec_scale_add(&goal_point, &Pl_objp->pos, &Pl_objp->orient.vec.uvec, -200.0f); diff --git a/code/graphics/gropengltnl.cpp b/code/graphics/gropengltnl.cpp index 57dd05ed5c..599ccc8130 100644 --- a/code/graphics/gropengltnl.cpp +++ b/code/graphics/gropengltnl.cpp @@ -1493,8 +1493,9 @@ void gr_opengl_start_instance_matrix(vec3d *offset, matrix *rotation) vm_matrix_to_rot_axis_and_angle(rotation, &ang, &axis); glTranslatef( offset->xyz.x, offset->xyz.y, offset->xyz.z ); - if (abs(ang) > 0.0f) + if (fl_abs(ang) > 0.0f) { glRotatef( fl_degrees(ang), axis.xyz.x, axis.xyz.y, axis.xyz.z ); + } GL_CHECK_FOR_ERRORS("end of start_instance_matrix()"); diff --git a/code/math/vecmat.cpp b/code/math/vecmat.cpp index 8a3999cf85..29c91a0be8 100644 --- a/code/math/vecmat.cpp +++ b/code/math/vecmat.cpp @@ -2768,7 +2768,7 @@ void vm_vec_dist_squared_to_line(vec3d *p, vec3d *l0, vec3d *l1, vec3d *nearest, //Scales the vector in-place so that the longest dimension = scale void vm_vec_boxscale(vec2d *vec, float scale) { - float ratio = 1.0f / MAX(abs(vec->x), abs(vec->y)); + float ratio = 1.0f / MAX(fl_abs(vec->x), fl_abs(vec->y)); vec->x *= ratio; vec->y *= ratio; } diff --git a/code/object/collideshipship.cpp b/code/object/collideshipship.cpp index 9bc6ac55aa..a8fa246e55 100644 --- a/code/object/collideshipship.cpp +++ b/code/object/collideshipship.cpp @@ -679,11 +679,11 @@ void calculate_ship_ship_collision_physics(collision_info_struct *ship_ship_hit_ light_local_vel.xyz.z < light_sip->collision_physics.landing_max_z && light_local_vel.xyz.z > light_sip->collision_physics.landing_min_z && light_local_vel.xyz.y > light_sip->collision_physics.landing_min_y && - abs(light_local_vel.xyz.x) < light_sip->collision_physics.landing_max_x && + fl_abs(light_local_vel.xyz.x) < light_sip->collision_physics.landing_max_x && light_uvec_dot_norm > 0 && light_fvec_dot_norm < light_sip->collision_physics.landing_max_angle && light_fvec_dot_norm > light_sip->collision_physics.landing_min_angle && - abs(light_rvec_dot_norm) < light_sip->collision_physics.landing_max_rot_angle) + fl_abs(light_rvec_dot_norm) < light_sip->collision_physics.landing_max_rot_angle) { ship_ship_hit_info->is_landing = true; } @@ -776,11 +776,11 @@ void calculate_ship_ship_collision_physics(collision_info_struct *ship_ship_hit_ light_local_vel.xyz.z < light_sip->collision_physics.reorient_max_z && light_local_vel.xyz.z > light_sip->collision_physics.reorient_min_z && light_local_vel.xyz.y > light_sip->collision_physics.reorient_min_y && - abs(light_local_vel.xyz.x) < light_sip->collision_physics.reorient_max_x && + fl_abs(light_local_vel.xyz.x) < light_sip->collision_physics.reorient_max_x && light_uvec_dot_norm > 0 && light_fvec_dot_norm < light_sip->collision_physics.reorient_max_angle && light_fvec_dot_norm > light_sip->collision_physics.reorient_min_angle && - abs(light_rvec_dot_norm) < light_sip->collision_physics.reorient_max_rot_angle) + fl_abs(light_rvec_dot_norm) < light_sip->collision_physics.reorient_max_rot_angle) { vec3d landing_delta_rotvel; landing_delta_rotvel.xyz.x = (light_fvec_dot_norm * light_sip->collision_physics.reorient_mult) diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index c9eb96ad98..47d31e8520 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -8974,32 +8974,37 @@ void change_ship_type(int n, int ship_type, int by_sexp) // Goober5000 - maintain the original hull, shield, and subsystem percentages... gah + // ...except when in FRED, because this stuff is handled in the missionparse/missionsave part. The E - // hull - if (sp->special_hitpoints) { - hull_pct = objp->hull_strength / sp->ship_max_hull_strength; + if (!Fred_running) { + // hull + if (sp->special_hitpoints) { + hull_pct = objp->hull_strength / sp->ship_max_hull_strength; + } else { + Assert( Ship_info[sp->ship_info_index].max_hull_strength > 0.0f ); + hull_pct = objp->hull_strength / Ship_info[sp->ship_info_index].max_hull_strength; + } + + // extra check + Assert(hull_pct > 0.0f && hull_pct <= 1.0f); + CLAMP(hull_pct, 0.1f, 1.0f); + + // shield + if (sp->special_shield > 0) { + shield_pct = shield_get_strength(objp) / sp->ship_max_shield_strength; + } else if (Ship_info[sp->ship_info_index].max_shield_strength > 0.0f) { + shield_pct = shield_get_strength(objp) / Ship_info[sp->ship_info_index].max_shield_strength; + } else { + shield_pct = 0.0f; + } + + // extra check + Assert(shield_pct >= 0.0f && shield_pct <= 1.0f); + CLAMP(shield_pct, 0.0f, 1.0f); } else { - Assert( Ship_info[sp->ship_info_index].max_hull_strength > 0.0f ); - hull_pct = objp->hull_strength / Ship_info[sp->ship_info_index].max_hull_strength; + shield_pct = hull_pct = 1.0f; } - // extra check - Assert(hull_pct > 0.0f && hull_pct <= 1.0f); - CLAMP(hull_pct, 0.1f, 1.0f); - - // shield - if (sp->special_shield > 0) { - shield_pct = shield_get_strength(objp) / sp->ship_max_shield_strength; - } else if (Ship_info[sp->ship_info_index].max_shield_strength > 0.0f) { - shield_pct = shield_get_strength(objp) / Ship_info[sp->ship_info_index].max_shield_strength; - } else { - shield_pct = 0.0f; - } - - // extra check - Assert(shield_pct >= 0.0f && shield_pct <= 1.0f); - CLAMP(shield_pct, 0.0f, 1.0f); - // subsystems int num_saved_subsystems = 0; char **subsys_names = new char *[sip_orig->n_subsystems];