Advertisement
MageKing17

ship.cpp.patch

Jun 28th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.79 KB | None | 0 0
  1. diff --git "a/C:\\Users\\Will\\AppData\\Local\\Temp\\OASqFa_ship.cpp" "b/code\\ship\\ship.cpp"
  2. index 6b89b0c..7cfaeb3 100644
  3. --- "a/C:\\Users\\Will\\AppData\\Local\\Temp\\OASqFa_ship.cpp"
  4. +++ "b/code\\ship\\ship.cpp"
  5. @@ -10019,6 +10019,8 @@ void change_ship_type(int n, int ship_type, int by_sexp)
  6.     float hull_pct, shield_pct;
  7.     physics_info ph_inf;
  8.  
  9. +   int targeted_subsys = -1;   // used to carry over subsystem target if the player was targeting this ship
  10. +
  11.     Assert( n >= 0 && n < MAX_SHIPS );
  12.     sp = &Ships[n];
  13.  
  14. @@ -10026,6 +10028,14 @@ void change_ship_type(int n, int ship_type, int by_sexp)
  15.     if (sp->ship_info_index == ship_type)
  16.         return;
  17.  
  18. +   if (Objects[Player_ai->target_objnum].instance == n)
  19. +   {
  20. +       if (Player_ai->targeted_subsys)
  21. +       {
  22. +           targeted_subsys = -2;   // flag the subsystem saving code that it needs to look for a match
  23. +       }
  24. +   }
  25. +
  26.     swp = &sp->weapons;
  27.     sip = &(Ship_info[ship_type]);
  28.     sip_orig = &Ship_info[sp->ship_info_index];
  29. @@ -10089,6 +10099,11 @@ void change_ship_type(int n, int ship_type, int by_sexp)
  30.             break;
  31.         }
  32.  
  33. +       if (targeted_subsys == -2 && Player_ai->targeted_subsys == ss)
  34. +       {
  35. +           targeted_subsys = num_saved_subsystems; // we use the index later to restore the target
  36. +       }
  37. +
  38.         // save subsys information
  39.         subsys_names[num_saved_subsystems] = new char[NAME_LENGTH];
  40.         strcpy(subsys_names[num_saved_subsystems], ss->system_info->subobj_name);
  41. @@ -10105,6 +10120,13 @@ void change_ship_type(int n, int ship_type, int by_sexp)
  42.         num_saved_subsystems++;
  43.         ss = GET_NEXT(ss);
  44.     }
  45. +   Assertion(targeted_subsys != -2, "Failed to find the player's currently-targeted subsystem (%s) in change_ship_type(); get a coder!\n", Player_ai->targeted_subsys->system_info->name);
  46. +
  47. +   if (targeted_subsys != -1)
  48. +   {
  49. +       Player_ai->targeted_subsys = NULL;  // Clear this so that Player_ai->last_subsys_target won't point to a subsystem from the old list later
  50. +       Player_ai->targeted_subsys_parent = -1;
  51. +   }
  52.  
  53.     // point to new ship data
  54.     ship_model_change(n, ship_type);
  55. @@ -10187,6 +10209,11 @@ void change_ship_type(int n, int ship_type, int by_sexp)
  56.             if (!subsystem_stricmp(ss->system_info->subobj_name, subsys_names[i]))
  57.             {
  58.                 ss->current_hits = ss->max_hits * subsys_pcts[i];
  59. +               if (targeted_subsys == i)   // the old subsystem is the one the player was targeting
  60. +               {
  61. +                   set_targeted_subsys(Player_ai, ss, n);
  62. +                   targeted_subsys = -1;
  63. +               }
  64.                 break;
  65.             }
  66.         }
  67. @@ -10195,6 +10222,11 @@ void change_ship_type(int n, int ship_type, int by_sexp)
  68.     }
  69.     ship_recalc_subsys_strength(sp);
  70.  
  71. +   if (targeted_subsys > -1)   // failed to find a match to the previously-targeted subsystem
  72. +   {
  73. +       hud_cease_subsystem_targeting(0);
  74. +   }
  75. +
  76.     // now free the memory
  77.     for (i = 0; i < sip_orig->n_subsystems; i++)
  78.         delete[] subsys_names[i];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement