Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git "a/C:\\Users\\Will\\AppData\\Local\\Temp\\OASqFa_ship.cpp" "b/code\\ship\\ship.cpp"
- index 6b89b0c..7cfaeb3 100644
- --- "a/C:\\Users\\Will\\AppData\\Local\\Temp\\OASqFa_ship.cpp"
- +++ "b/code\\ship\\ship.cpp"
- @@ -10019,6 +10019,8 @@ void change_ship_type(int n, int ship_type, int by_sexp)
- float hull_pct, shield_pct;
- physics_info ph_inf;
- + int targeted_subsys = -1; // used to carry over subsystem target if the player was targeting this ship
- +
- Assert( n >= 0 && n < MAX_SHIPS );
- sp = &Ships[n];
- @@ -10026,6 +10028,14 @@ void change_ship_type(int n, int ship_type, int by_sexp)
- if (sp->ship_info_index == ship_type)
- return;
- + if (Objects[Player_ai->target_objnum].instance == n)
- + {
- + if (Player_ai->targeted_subsys)
- + {
- + targeted_subsys = -2; // flag the subsystem saving code that it needs to look for a match
- + }
- + }
- +
- swp = &sp->weapons;
- sip = &(Ship_info[ship_type]);
- sip_orig = &Ship_info[sp->ship_info_index];
- @@ -10089,6 +10099,11 @@ void change_ship_type(int n, int ship_type, int by_sexp)
- break;
- }
- + if (targeted_subsys == -2 && Player_ai->targeted_subsys == ss)
- + {
- + targeted_subsys = num_saved_subsystems; // we use the index later to restore the target
- + }
- +
- // save subsys information
- subsys_names[num_saved_subsystems] = new char[NAME_LENGTH];
- strcpy(subsys_names[num_saved_subsystems], ss->system_info->subobj_name);
- @@ -10105,6 +10120,13 @@ void change_ship_type(int n, int ship_type, int by_sexp)
- num_saved_subsystems++;
- ss = GET_NEXT(ss);
- }
- + 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);
- +
- + if (targeted_subsys != -1)
- + {
- + 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
- + Player_ai->targeted_subsys_parent = -1;
- + }
- // point to new ship data
- ship_model_change(n, ship_type);
- @@ -10187,6 +10209,11 @@ void change_ship_type(int n, int ship_type, int by_sexp)
- if (!subsystem_stricmp(ss->system_info->subobj_name, subsys_names[i]))
- {
- ss->current_hits = ss->max_hits * subsys_pcts[i];
- + if (targeted_subsys == i) // the old subsystem is the one the player was targeting
- + {
- + set_targeted_subsys(Player_ai, ss, n);
- + targeted_subsys = -1;
- + }
- break;
- }
- }
- @@ -10195,6 +10222,11 @@ void change_ship_type(int n, int ship_type, int by_sexp)
- }
- ship_recalc_subsys_strength(sp);
- + if (targeted_subsys > -1) // failed to find a match to the previously-targeted subsystem
- + {
- + hud_cease_subsystem_targeting(0);
- + }
- +
- // now free the memory
- for (i = 0; i < sip_orig->n_subsystems; i++)
- delete[] subsys_names[i];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement