@@ -7397,21 +7397,31 @@ void ship_cleanup(int shipnum, int cleanup_mode)
73977397 object *objp = &Objects[shipp->objnum];
73987398
73997399 // add the information to the exited ship list
7400- if (!(cleanup_mode & SHIP_REDALERT)) {
7401- if (cleanup_mode & SHIP_DESTROYED) {
7402- ship_add_exited_ship(shipp, Ship::Exit_Flags::Destroyed);
7403- } else {
7404- // (cleanup_mode & (SHIP_DEPARTED | SHIP_VANISHED)
7405- ship_add_exited_ship(shipp, Ship::Exit_Flags::Departed);
7406- }
7407- } else {
7408- // (cleanup_mode & SHIP_REDALERT)
7400+ switch (cleanup_mode) {
7401+ case SHIP_DESTROYED:
7402+ ship_add_exited_ship(shipp, Ship::Exit_Flags::Destroyed);
7403+ break;
7404+ case SHIP_DEPARTED:
7405+ case SHIP_DEPARTED_WARP:
7406+ case SHIP_DEPARTED_BAY:
7407+ ship_add_exited_ship(shipp, Ship::Exit_Flags::Departed);
7408+ break;
7409+ case SHIP_DESTROYED_REDALERT:
7410+ case SHIP_DEPARTED_REDALERT:
74097411 // Ship was removed in previous mission. Mark as "player deleted" for this mission
74107412 ship_add_exited_ship(shipp, Ship::Exit_Flags::Player_deleted);
7413+ break;
7414+ case SHIP_VANISHED:
7415+ // Do nothing
7416+ break;
7417+ default:
7418+ // Can't Happen
7419+ Assertion(false, "Unknown cleanup_mode '%i' passed to ship_cleanup!", cleanup_mode);
7420+ break;
74117421 }
74127422
74137423 // record kill?
7414- if (!( cleanup_mode & SHIP_REDALERT) && (cleanup_mode & SHIP_DESTROYED) ) {
7424+ if (cleanup_mode == SHIP_DESTROYED) {
74157425 // determine if we need to count this ship as a kill in counting number of kills per ship type
74167426 // look at the ignore flag for the ship (if not in a wing), or the ignore flag for the wing
74177427 // (if the ship is in a wing), and add to the kill count if the flags are not set
@@ -7425,7 +7435,7 @@ void ship_cleanup(int shipnum, int cleanup_mode)
74257435
74267436 // add mission log entry?
74277437 // (vanished ships and red-alert deleted ships have no log, and destroyed ships are logged in ship_hit_kill)
7428- if (! (cleanup_mode & SHIP_REDALERT) && (cleanup_mode & SHIP_DEPARTED)) {
7438+ if ((cleanup_mode == SHIP_DEPARTED_WARP) || (cleanup_mode == SHIP_DEPARTED_BAY) || (cleanup_mode == SHIP_DEPARTED)) {\
74297439 // see if this ship departed within the radius of a jump node -- if so, put the node name into
74307440 // the secondary mission log field
74317441 CJumpNode *jnp = jumpnode_get_which_in(objp);
@@ -7436,52 +7446,83 @@ void ship_cleanup(int shipnum, int cleanup_mode)
74367446 }
74377447
74387448#ifndef NDEBUG
7439- // add a debug log entry
7440- if (cleanup_mode & SHIP_DESTROYED) {
7441- nprintf(("Alan", "SHIP DESTROYED: %s", shipp->ship_name));
7442- } else if (cleanup_mode & SHIP_DEPARTED) {
7443- nprintf(("Alan", "SHIP DEPARTED: %s", shipp->ship_name));
7444- } else {
7445- nprintf(("Alan", "SHIP VANISHED: %s", shipp->ship_name));
7446- }
7447-
7448- // if it was removed via red_alert_delete_ship, log it as such
7449- if (cleanup_mode & SHIP_REDALERT) {
7450- nprintf(("Alan", "(RED-ALERT)\n"));
7451- } else {
7452- nprintf(("Alan", "\n"));
7449+ switch (cleanup_mode) {
7450+ case SHIP_DESTROYED:
7451+ nprintf(("Alan", "SHIP DESTROYED: %s'\n'", shipp->ship_name));
7452+ break;
7453+ case SHIP_DEPARTED:
7454+ case SHIP_DEPARTED_WARP:
7455+ case SHIP_DEPARTED_BAY:
7456+ nprintf(("Alan", "SHIP DEPARTED: %s'\n'", shipp->ship_name));
7457+ break;
7458+ case SHIP_DESTROYED_REDALERT:
7459+ nprintf(("Alan", "SHIP REDALERT DESTROYED: %s'\n'", shipp->ship_name));
7460+ break;
7461+ case SHIP_DEPARTED_REDALERT:
7462+ nprintf(("Alan", "SHIP REDALERT DEPARTED: %s'\n'", shipp->ship_name));
7463+ break;
7464+ case SHIP_VANISHED:
7465+ nprintf(("Alan", "SHIP VANISHED: %s'\n'", shipp->ship_name));
7466+ break;
7467+ default:
7468+ // Can't Happen, but we should've already caught this
7469+ Assertion(false, "Unknown cleanup_mode '%i' passed to ship_cleanup!", cleanup_mode);
7470+ break;
74537471 }
74547472#endif
74557473
74567474 // update wingman status gauge
74577475 if ( (shipp->wing_status_wing_index >= 0) && (shipp->wing_status_wing_pos >= 0) ) {
7458- if (cleanup_mode & SHIP_DESTROYED) {
7476+ switch (cleanup_mode) {
7477+ case SHIP_DESTROYED:
7478+ case SHIP_DESTROYED_REDALERT:
74597479 hud_set_wingman_status_dead(shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
7460- } else if ((cleanup_mode & SHIP_DEPARTED) && !(cleanup_mode & SHIP_REDALERT)){
7480+ break;
7481+ case SHIP_DEPARTED:
7482+ case SHIP_DEPARTED_WARP:
7483+ case SHIP_DEPARTED_BAY:
7484+ case SHIP_DEPARTED_REDALERT:
74617485 hud_set_wingman_status_departed(shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
7462- } else {
7486+ break;
7487+ case SHIP_VANISHED:
74637488 hud_set_wingman_status_none(shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
7489+ break;
7490+ default:
7491+ // Can't Happen, but we should've already caught this
7492+ Assertion(false, "Unknown cleanup_mode '%i' passed to ship_cleanup!", cleanup_mode);
7493+ break;
74647494 }
74657495 }
74667496
74677497 // if ship belongs to a wing, do the wing cleanup
74687498 if ( shipp->wingnum != -1 ) {
74697499 wing *wingp = &Wings[shipp->wingnum];
74707500
7471- if (cleanup_mode & SHIP_DESTROYED) {
7501+ switch (cleanup_mode) {
7502+ case SHIP_DESTROYED:
7503+ case SHIP_DESTROYED_REDALERT:
74727504 wingp->total_destroyed++;
7473- } else if (cleanup_mode & SHIP_DEPARTED) {
7505+ break;
7506+ case SHIP_DEPARTED:
7507+ case SHIP_DEPARTED_WARP:
7508+ case SHIP_DEPARTED_BAY:
7509+ case SHIP_DEPARTED_REDALERT:
74747510 wingp->total_departed++;
7475- } else {
7511+ break;
7512+ case SHIP_VANISHED:
74767513 wingp->total_vanished++;
7514+ break;
7515+ default:
7516+ // Can't Happen, but we should've already caught this
7517+ Assertion(false, "Unknown cleanup_mode '%i' passed to ship_cleanup!", cleanup_mode);
7518+ break;
74777519 }
7478-
74797520 ship_wing_cleanup(shipnum, wingp);
74807521 }
74817522
74827523 // Note, this call to ai_ship_destroy must come after ship_wing_cleanup for guarded wings to
74837524 // properly note the destruction of a ship in their wing.
7484- if (cleanup_mode & SHIP_DESTROYED) {
7525+ if (cleanup_mode == SHIP_DESTROYED) {
74857526 ai_ship_destroy(shipnum, Ship::Exit_Flags::Destroyed); // Do AI stuff for destruction of ship.
74867527 } else {
74877528 ai_ship_destroy(shipnum, Ship::Exit_Flags::Departed); // should still do AI cleanup after ship has departed
0 commit comments