4141import java .util .Collections ;
4242import java .util .List ;
4343import java .util .Map ;
44+ import java .util .stream .Collectors ;
4445
4546import static com .fs .starfarer .api .util .Misc .MAX_OFFICER_LEVEL ;
4647
@@ -720,10 +721,8 @@ public static MarketAPI addSimpleMarket(
720721 * @param factionId person's faction
721722 * @param rankId rank from campaign.ids.Ranks
722723 * @param postId post from campaign.ids.Ranks
723- * @param isMarketAdmin
724+ * @param isMarketAdmin if the person is the market admin
724725 * @param industrialPlanning_level skill level for market admin
725- * @param spaceOperation_level skill level for market admin
726- * @param groundOperations_level skill level for market admin
727726 * @param commScreenPosition position order in the comm screen, 0 is the admin position
728727 * @return
729728 */
@@ -1433,7 +1432,7 @@ public static SectorEntityToken findSuitableTarget(
14331432 desiredEntities = entities ;
14341433 }
14351434
1436- //lets check the system lists in order by prefered distances
1435+ // lets check the system lists in order by prefered distances
14371436 for (int i = 0 ; i < 3 ; i ++) {
14381437 //check if the system list has anything, and shuffle it to ensure proper randomization
14391438 if (distance_priority .get (i ).isEmpty ()) {
@@ -1442,8 +1441,8 @@ public static SectorEntityToken findSuitableTarget(
14421441 Collections .shuffle (distance_priority .get (i ));
14431442 }
14441443
1445- //now check if any valid system got the required entity in this range band
1446- //starting with unexplored systems if required
1444+ // now check if any valid system got the required entity in this range band
1445+ // starting with unexplored systems if required
14471446 if (prioritizeUnexplored ) {
14481447 for (StarSystemAPI s : distance_priority .get (i )) {
14491448 //skip visited systems
@@ -1562,11 +1561,24 @@ public static SectorEntityToken findSuitableTarget(
15621561 if (verbose ) {
15631562 log .warn ("No valid system found" );
15641563 }
1565- return null ;
1566- }
15671564
1568- ////////////////////////////////////////////////////////////////////////////
1569- //DUMPSTER
1570- ////////////////////////////////////////////////////////////////////////////
1565+ // If no valid systems were found, retry without the hardcoded Tags.THEME_HIDDEN restriction
1566+ // so that bounties that are intended to be in hidden systems will spawn.
1567+ if (avoid_themes != null && avoid_themes .contains (Tags .THEME_HIDDEN )) {
1568+ log .info ("findSuitableTarget did not find a valid system, retrying without " + Tags .THEME_HIDDEN );
1569+ return findSuitableTarget (
1570+ entityIDs ,
1571+ marketFactions ,
1572+ distance ,
1573+ seek_themes ,
1574+ avoid_themes .stream ().filter (t -> !t .equals (Tags .THEME_HIDDEN )).collect (Collectors .toList ()),
1575+ entities ,
1576+ defaultToAnyEntity ,
1577+ prioritizeUnexplored ,
1578+ verbose
1579+ );
1580+ }
15711581
1582+ return null ;
1583+ }
15721584}
0 commit comments