@@ -1443,12 +1443,27 @@ int parse_weapon(int subtype, bool replace, const char *filename)
14431443
14441444 if (optional_string (" +Sensors Range:" )) {
14451445 stuff_float (&wip->mine_sensors_range );
1446+ if (wip->mine_sensors_range < 0 .0f ) {
1447+ wip->mine_sensors_range = 0 .0f ;
1448+ Warning (LOCATION , " Mine weapon '%s': +Sensors Range cannot be negative. Setting to 0.\n " , wip->name );
1449+ }
14461450 }
14471451
14481452 if (optional_string (" +Targetable Range:" )) {
14491453 stuff_float (&wip->mine_targetable_range );
1454+ if (wip->mine_targetable_range < 0 .0f ) {
1455+ wip->mine_targetable_range = 0 .0f ;
1456+ Warning (LOCATION , " Mine weapon '%s': +Targetable Range cannot be negative. Setting to 0.\n " , wip->name );
1457+ }
14501458 }
14511459
1460+ // Mines must have finite detection ranges. Defaults scale off proximity_radius so a tiny
1461+ // proximity radius doesn't accidentally produce a galaxy-spanning blip.
1462+ if (wip->mine_sensors_range < 0 .0f )
1463+ wip->mine_sensors_range = wip->proximity_radius * 60 .0f ;
1464+ if (wip->mine_targetable_range < 0 .0f )
1465+ wip->mine_targetable_range = wip->proximity_radius * 30 .0f ;
1466+
14521467 if (optional_string (" +Hitpoints:" )) {
14531468 stuff_int (&wip->weapon_hitpoints );
14541469 } else if (first_time) {
@@ -1481,15 +1496,9 @@ int parse_weapon(int subtype, bool replace, const char *filename)
14811496 }
14821497
14831498 // Warn if targetable range makes sensors range unreachable
1484- bool targetable_infinite = (wip->mine_targetable_range < 0 .0f );
1485- bool sensors_infinite = (wip->mine_sensors_range < 0 .0f );
1486- if (!sensors_infinite) {
1487- if (targetable_infinite) {
1488- Warning (LOCATION , " Mine weapon '%s': +Targetable Range is infinite but +Sensors Range is finite. The distorted blip state will never occur.\n " , wip->name );
1489- } else if (wip->mine_targetable_range >= wip->mine_sensors_range ) {
1490- Warning (LOCATION , " Mine weapon '%s': +Targetable Range (%.1f) >= +Sensors Range (%.1f). The distorted blip state will never occur.\n " ,
1491- wip->name , wip->mine_targetable_range , wip->mine_sensors_range );
1492- }
1499+ if (wip->mine_targetable_range >= wip->mine_sensors_range ) {
1500+ Warning (LOCATION , " Mine weapon '%s': +Targetable Range (%.1f) >= +Sensors Range (%.1f). The distorted blip state will never occur.\n " ,
1501+ wip->name , wip->mine_targetable_range , wip->mine_sensors_range );
14931502 }
14941503 }
14951504
@@ -5120,10 +5129,7 @@ void weapon_post_ship_init()
51205129
51215130 for (const auto & entry : Pending_proximity_type_names) {
51225131 const int wi_index = entry.first ;
5123- if (wi_index < 0 || wi_index >= num_weapons) {
5124- Warning (LOCATION , " Proximity types: stale weapon_info index %d. Entries dropped.\n " , wi_index);
5125- continue ;
5126- }
5132+ Assertion (wi_index >= 0 && wi_index < num_weapons, " Pending proximity type entry has out-of-range weapon_info index %d (num_weapons=%d)." , wi_index, num_weapons);
51275133 weapon_info& wip = Weapon_info[wi_index];
51285134 for (const SCP_string& type_name : entry.second ) {
51295135 int idx = ship_type_name_lookup (type_name.c_str ());
@@ -5136,10 +5142,7 @@ void weapon_post_ship_init()
51365142
51375143 for (const auto & entry : Pending_proximity_class_names) {
51385144 const int wi_index = entry.first ;
5139- if (wi_index < 0 || wi_index >= num_weapons) {
5140- Warning (LOCATION , " Proximity classes: stale weapon_info index %d. Entries dropped.\n " , wi_index);
5141- continue ;
5142- }
5145+ Assertion (wi_index >= 0 && wi_index < num_weapons, " Pending proximity class entry has out-of-range weapon_info index %d (num_weapons=%d)." , wi_index, num_weapons);
51435146 weapon_info& wip = Weapon_info[wi_index];
51445147 for (const SCP_string& class_name : entry.second ) {
51455148 int idx = ship_info_lookup (class_name.c_str ());
0 commit comments