diff --git a/code/missionui/redalert.cpp b/code/missionui/redalert.cpp index f668505fe7c..5632b6dbb0e 100644 --- a/code/missionui/redalert.cpp +++ b/code/missionui/redalert.cpp @@ -936,6 +936,14 @@ void red_alert_bash_ship_status() // assign the wave number to the wing wingp->current_wave = rws->latest_wave; + + // make sure that num_waves can accommodate the new value of current_wave. + // this would happen if the mission we are entering has too few waves. + if (wingp->num_waves < wingp->current_wave) + { + mprintf(("Red alert warning: wing %s in the current mission has fewer waves than in the last mission. Bashing the number of waves from %i to %i.\n", wingp->name, wingp->num_waves, wingp->current_wave)); + wingp->num_waves = wingp->current_wave; + } if (rws->latest_wave > 1) { diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 33496fa13b6..6c0af566125 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -11949,8 +11949,9 @@ void change_ship_type(int n, int ship_type, int by_sexp) } // 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; + if (!(Game_mode & GM_IN_MISSION) && !(Fred_running) && (p_objp != nullptr)) { + Objects[sp->objnum].phys_info.speed = p_objp->initial_velocity * sip->max_speed / 100.0f; + // prev_ramp_vel needs to be in local coordinates // set z of prev_ramp_vel to initial velocity vm_vec_zero(&Objects[sp->objnum].phys_info.prev_ramp_vel);