Author Topic: Patch [committed]: fix initial velocity getting lost when changing ship  (Read 1616 times)

0 Members and 1 Guest are viewing this topic.

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Patch [committed]: fix initial velocity getting lost when changing ship
If you change your ship in the loadout screen, then any initial velocity set in FRED will be lost. This fixes that.

Code: [Select]
Index: ship.cpp
===================================================================
--- ship.cpp (revision 8006)
+++ ship.cpp (working copy)
@@ -8742,6 +8742,7 @@
  swp = &sp->weapons;
  sip_orig = &Ship_info[sp->ship_info_index];
  objp = &Objects[sp->objnum];
+ p_objp = mission_parse_get_parse_object(sp->ship_name);
  ph_inf = objp->phys_info;
 
 
@@ -8808,7 +8809,6 @@
 
  // make sure that shields are disabled/enabled if they need to be - Chief1983
  if (!Fred_running) {
- p_objp = mission_parse_get_parse_object(sp->ship_name);
  if ((p_objp->flags2 & P2_OF_FORCE_SHIELDS_ON) && (sp->ship_max_shield_strength > 0.0f)) {
  objp->flags &= ~OF_NO_SHIELDS;
  } else if ((p_objp->flags & P_OF_NO_SHIELDS) || (sp->ship_max_shield_strength == 0.0f)) {
@@ -9042,6 +9042,14 @@
  sp->shield_recharge_index = sp_orig.shield_recharge_index;
  sp->engine_recharge_index = sp_orig.engine_recharge_index;
  }
+
+ // zookeeper - If we're switching in the loadout screen, make sure we retain initial velocity set in FRED
+ if (!(Game_mode & GM_IN_MISSION) && !(Fred_running)) {
+ Objects[sp->objnum].phys_info.speed = (float) p_objp->initial_velocity * sip->max_speed / 100.0f;
+ Objects[sp->objnum].phys_info.vel.xyz.z = Objects[sp->objnum].phys_info.speed;
+ Objects[sp->objnum].phys_info.prev_ramp_vel = Objects[sp->objnum].phys_info.vel;
+ Objects[sp->objnum].phys_info.desired_vel = Objects[sp->objnum].phys_info.vel;
+ }
 }
 
 #ifndef NDEBUG
« Last Edit: November 28, 2011, 05:16:38 am by zookeeper »

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Patch: fix initial velocity getting lost when changing ship
I checked it over; it looks good.  Committed in 8028.