@@ -53,11 +53,11 @@ struct ship_registry_entry;
5353// PURGE_GOALS_ONE_SHIP for goals which should only purge other goals in the one ship.
5454// Goober5000 - note that the new disable and disarm goals (AI_GOAL_DISABLE_SHIP_TACTICAL and
5555// AI_GOAL_DISARM_SHIP_TACTICAL) do not purge ANY goals, not even the ones in the one ship
56- inline bool purge_goals_all_ships (ai_goal_mode ai_mode)
56+ [[nodiscard]] bool purge_goals_all_ships (ai_goal_mode ai_mode)
5757{
5858 return ai_mode == AI_GOAL_IGNORE || ai_mode == AI_GOAL_DISABLE_SHIP || ai_mode == AI_GOAL_DISARM_SHIP ;
5959}
60- inline bool purge_goals_one_ship (ai_goal_mode ai_mode)
60+ [[nodiscard]] bool purge_goals_one_ship (ai_goal_mode ai_mode)
6161{
6262 return ai_mode == AI_GOAL_IGNORE_NEW ;
6363}
@@ -195,12 +195,10 @@ void ai_maybe_add_form_goal(wing* wingp)
195195 return ;
196196 }
197197
198- int j;
199-
200198 // iterate through the ship_index list of this wing and check for orders. We will do
201199 // this for all ships in the wing instead of on a wing only basis in case some ships
202200 // in the wing actually have different orders than others
203- for (j = 0 ; j < wingp->current_count ; j++) {
201+ for (int j = 0 ; j < wingp->current_count ; j++) {
204202 ai_info* aip;
205203
206204 Assert (wingp->ship_index [j] != -1 ); // get Allender
@@ -938,11 +936,9 @@ void ai_add_goal_sub_sexp( int sexp, ai_goal_type type, ai_info *aip, ai_goal *a
938936 // for achievability.
939937 aigp->target_name = ai_get_goal_target_name (CTEXT (CDR (node)), &aigp->target_name_index ); // waypoint path name;
940938
941-
942939 aigp->priority = eval_num (CDDR (node), priority_is_nan, priority_is_nan_forever);
943- aigp->ai_mode = AI_GOAL_WAYPOINTS ;
944- if ( op == OP_AI_WAYPOINTS_ONCE )
945- aigp->ai_mode = AI_GOAL_WAYPOINTS_ONCE ;
940+ aigp->ai_mode = (op == OP_AI_WAYPOINTS_ONCE ) ? AI_GOAL_WAYPOINTS_ONCE : AI_GOAL_WAYPOINTS ;
941+
946942 if (CDDDDR (node) < 0 )
947943 aigp->int_data = 0 ; // handle optional node separately because we don't subtract 1 here
948944 else
@@ -1042,13 +1038,9 @@ void ai_add_goal_sub_sexp( int sexp, ai_goal_type type, ai_info *aip, ai_goal *a
10421038 break ;
10431039
10441040 case OP_AI_PLAY_DEAD :
1045- aigp->priority = eval_num (CDR (node), priority_is_nan, priority_is_nan_forever);
1046- aigp->ai_mode = AI_GOAL_PLAY_DEAD ;
1047- break ;
1048-
10491041 case OP_AI_PLAY_DEAD_PERSISTENT :
10501042 aigp->priority = eval_num (CDR (node), priority_is_nan, priority_is_nan_forever);
1051- aigp->ai_mode = AI_GOAL_PLAY_DEAD_PERSISTENT ;
1043+ aigp->ai_mode = (op == OP_AI_PLAY_DEAD ) ? AI_GOAL_PLAY_DEAD : AI_GOAL_PLAY_DEAD_PERSISTENT ;
10521044 break ;
10531045
10541046 case OP_AI_KEEP_SAFE_DISTANCE :
@@ -1295,12 +1287,9 @@ int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp, bool &remove_more )
12951287 /* We now need to determine what the mode and submode values are*/
12961288 switch ( op )
12971289 {
1298- case OP_AI_WAYPOINTS_ONCE :
1299- goalmode = AI_GOAL_WAYPOINTS_ONCE ;
1300- priority = eval_priority_et_seq (CDDR (node));
1301- break ;
13021290 case OP_AI_WAYPOINTS :
1303- goalmode = AI_GOAL_WAYPOINTS ;
1291+ case OP_AI_WAYPOINTS_ONCE :
1292+ goalmode = (op == OP_AI_WAYPOINTS_ONCE ) ? AI_GOAL_WAYPOINTS_ONCE : AI_GOAL_WAYPOINTS ;
13041293 priority = eval_priority_et_seq (CDDR (node));
13051294 break ;
13061295 case OP_AI_DESTROY_SUBSYS :
@@ -2548,16 +2537,14 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
25482537 break ;
25492538
25502539 case AI_GOAL_PLAY_DEAD :
2551- // if a ship is playing dead, MWA says that it shouldn't try to do anything else.
2552- // clearing out goals is okay here since we are now what mode to set this AI object to.
2553- ai_clear_ship_goals ( aip );
2554- aip->mode = AIM_PLAY_DEAD ;
2555- aip->submode = -1 ;
2556- aip->submode_start_time = Missiontime;
2557- break ;
2558-
25592540 case AI_GOAL_PLAY_DEAD_PERSISTENT :
2560- // same as above, but we don't clear out ship goals
2541+ // we don't clear out ship goals for the "persistent" goal variant
2542+ if (current_goal->ai_mode == AI_GOAL_PLAY_DEAD )
2543+ {
2544+ // if a ship is playing dead, MWA says that it shouldn't try to do anything else.
2545+ // clearing out goals is okay here since we are now what mode to set this AI object to.
2546+ ai_clear_ship_goals (aip);
2547+ }
25612548 aip->mode = AIM_PLAY_DEAD ;
25622549 aip->submode = -1 ;
25632550 aip->submode_start_time = Missiontime;
0 commit comments