Author Topic: Fix for Mantis 2369  (Read 1322 times)

0 Members and 1 Guest are viewing this topic.

Offline CommanderDJ

  • Software engineer
  • 210
Link is here.

This has been sitting there waiting to be committed for days. It's been reviewed by both niffiwan and Karajorma. So instead of trying to badger people on IRC I figured I'd make a thread!

For completeness, here's the patch (which is also available on the mantis ticket):

Code: [Select]
Index: ship/ship.cpp
===================================================================
--- ship/ship.cpp (revision 7936)
+++ ship/ship.cpp (working copy)
@@ -1296,6 +1296,7 @@
  int i, j, num_allowed;
  int allowed_weapons[MAX_WEAPON_TYPES];
  int pbank_capacity_count, sbank_capacity_count;
+ bool sbank_defaults_specified = false;
  int rtn = 0;
  char name_tmp[NAME_LENGTH];
 
@@ -2315,21 +2316,33 @@
  }
 
  // Get default secondary bank weapons
-
  if(optional_string("$Default SBanks:"))
  {
+ sbank_defaults_specified = true;
  strcat_s(parse_error_text,"'s default secondary banks");
  sip->num_secondary_banks = stuff_int_list(sip->secondary_bank_weapons, MAX_SHIP_SECONDARY_BANKS, WEAPON_LIST_TYPE);
  strcpy_s(parse_error_text, temp_error);
+ }
 
- // Get the capacity of each secondary bank
- required_string("$SBank Capacity:");
+ //Get secondary bank capacities
+ if(optional_string("$SBank Capacity:"))
+ {
  strcat_s(parse_error_text,"'s secondary banks capacities");
  sbank_capacity_count = stuff_int_list(sip->secondary_bank_ammo_capacity, MAX_SHIP_SECONDARY_BANKS, RAW_INTEGER_TYPE);
  strcpy_s(parse_error_text, temp_error);
- if ( sbank_capacity_count != sip->num_secondary_banks )
+
+ //if defaults were specified, use them to double check number of secondary banks
+ if(sbank_defaults_specified)
+ {
+ if(sbank_capacity_count != sip->num_secondary_banks)
+ {
+ Warning(LOCATION, "Number of default secondary banks and number of bank capacities do not match for ship class %s... fix this!!", sip->name);
+ }
+ }
+ //otherwise, set the number of banks using the capacities
+ else
  {
- Warning(LOCATION, "Secondary bank capacities have not been completely specified for ship class %s... fix this!!", sip->name);
+ sip->num_secondary_banks = sbank_capacity_count;
  }
  }
     
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline Iss Mneur

  • 210
  • TODO:
I have posted a question in the ticket.
"I love deadlines. I like the whooshing sound they make as they fly by." -Douglas Adams
wxLauncher 0.9.4 public beta (now with no config file editing for FRED) | wxLauncher 2.0 Request for Comments

  

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Wait, this triggers several red flags.  I'm posting on the ticket.