@@ -6622,6 +6622,15 @@ bool post_process_mission(mission *pm)
66226622
66236623 // convert all ship name indices to ship indices now that mission has been loaded
66246624 if (Fred_running) {
6625+ // lambda for seeing whether the anchors actually work for arrival/departure
6626+ SCP_string message;
6627+ SCP_set<int > anchors_checked;
6628+ auto check_anchor = [&message, &anchors_checked](int anchor_shipnum, const char *other_name, bool other_is_ship, bool is_arrival) {
6629+ check_anchor_for_hangar_bay (message, anchors_checked, anchor_shipnum, other_name, other_is_ship, is_arrival);
6630+ if (!message.empty ())
6631+ Warning (LOCATION , " %s" , message.c_str ());
6632+ };
6633+
66256634 i = 0 ;
66266635 for (const auto &parse_name: Parse_names) {
66276636 auto ship_entry = ship_registry_get (parse_name);
@@ -6632,21 +6641,32 @@ bool post_process_mission(mission *pm)
66326641 }
66336642
66346643 for (i=0 ; i<MAX_SHIPS ; i++) {
6635- if ((Ships[i].objnum >= 0 ) && (Ships[i].arrival_anchor >= 0 ) && (Ships[i].arrival_anchor < SPECIAL_ARRIVAL_ANCHOR_FLAG ))
6644+ if ((Ships[i].objnum >= 0 ) && (Ships[i].arrival_anchor >= 0 ) && (Ships[i].arrival_anchor < SPECIAL_ARRIVAL_ANCHOR_FLAG )) {
66366645 Ships[i].arrival_anchor = indices[Ships[i].arrival_anchor ];
6646+ if (Ships[i].arrival_location == ArrivalLocation::FROM_DOCK_BAY )
6647+ check_anchor (Ships[i].arrival_anchor , Ships[i].ship_name , true , true );
6648+ }
66376649
6638- if ( (Ships[i].objnum >= 0 ) && (Ships[i].departure_anchor >= 0 ) )
6650+ if ((Ships[i].objnum >= 0 ) && (Ships[i].departure_anchor >= 0 )) {
66396651 Ships[i].departure_anchor = indices[Ships[i].departure_anchor ];
6652+ if (Ships[i].departure_location == DepartureLocation::TO_DOCK_BAY )
6653+ check_anchor (Ships[i].departure_anchor , Ships[i].ship_name , true , false );
6654+ }
66406655 }
66416656
66426657 for (i=0 ; i<MAX_WINGS ; i++) {
6643- if (Wings[i].wave_count && (Wings[i].arrival_anchor >= 0 ) && (Wings[i].arrival_anchor < SPECIAL_ARRIVAL_ANCHOR_FLAG ))
6658+ if (Wings[i].wave_count && (Wings[i].arrival_anchor >= 0 ) && (Wings[i].arrival_anchor < SPECIAL_ARRIVAL_ANCHOR_FLAG )) {
66446659 Wings[i].arrival_anchor = indices[Wings[i].arrival_anchor ];
6660+ if (Wings[i].arrival_location == ArrivalLocation::FROM_DOCK_BAY )
6661+ check_anchor (Wings[i].arrival_anchor , Wings[i].name , false , true );
6662+ }
66456663
6646- if (Wings[i].wave_count && (Wings[i].departure_anchor >= 0 ) )
6664+ if (Wings[i].wave_count && (Wings[i].departure_anchor >= 0 )) {
66476665 Wings[i].departure_anchor = indices[Wings[i].departure_anchor ];
6666+ if (Wings[i].departure_location == DepartureLocation::TO_DOCK_BAY )
6667+ check_anchor (Wings[i].departure_anchor , Wings[i].name , false , false );
6668+ }
66486669 }
6649-
66506670 }
66516671
66526672 // before doing anything else, we must validate all of the sexpressions that were loaded into the mission.
@@ -8673,6 +8693,27 @@ int get_anchor(const char *name)
86738693 return get_parse_name_index (name);
86748694}
86758695
8696+ /* *
8697+ * See if an arrival/departure anchor is missing a hangar bay. If it is, the message parameter will be populated with an appropriate error.
8698+ */
8699+ void check_anchor_for_hangar_bay (SCP_string &message, SCP_set<int > &anchor_shipnums_checked, int anchor_shipnum, const char *other_name, bool other_is_ship, bool is_arrival)
8700+ {
8701+ message.clear ();
8702+
8703+ if (anchor_shipnum < 0 )
8704+ return ;
8705+ if (anchor_shipnums_checked.contains (anchor_shipnum))
8706+ return ;
8707+ anchor_shipnums_checked.insert (anchor_shipnum);
8708+
8709+ if (!ship_has_dock_bay (anchor_shipnum))
8710+ {
8711+ auto shipp = &Ships[anchor_shipnum];
8712+ sprintf (message, " %s (%s) is used as a%s anchor by %s %s (and possibly elsewhere too), but it does not have a hangar bay!" , shipp->ship_name ,
8713+ Ship_info[shipp->ship_info_index ].name , is_arrival ? " n arrival" : " departure" , other_is_ship ? " ship" : " wing" , other_name);
8714+ }
8715+ };
8716+
86768717/* *
86778718 * Fixup the goals/ai references for player objects in the mission
86788719 */
0 commit comments