2 * $Logfile: /Freespace2/code/Fred2/WeaponEditorDlg.cpp $
7 * Weapon editor dialog box handling code
10 * Revision 1.1 2002/05/03 03:28:09 root
14 * 4 4/28/99 11:13p Dave
15 * Temporary checkin of artillery code.
17 * 3 4/23/99 12:01p Johnson
20 * 2 10/07/98 6:28p Dave
21 * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
22 * Fred. Globalized mission and campaign file extensions. Removed Silent
23 * Threat specific code.
25 * 1 10/07/98 3:02p Dave
27 * 1 10/07/98 3:00p Dave
29 * 17 5/14/98 5:31p Hoffoss
30 * Fixed some stupid behaviour in this editor related to ammo counts being
33 * 16 4/22/98 11:27a Hoffoss
34 * Make big weapons available for capital ships as well as big ships (why
35 * the hell a capital ship isn't a big ship is beyond me, though).
37 * 15 4/14/98 11:46a Johnson
38 * Added window enables for spinners, but it seems to be ignored.
40 * 14 2/26/98 10:44a Johnson
41 * Fixed bug with SetRange() not being called on editor first open.
43 * 13 2/22/98 1:32a Hoffoss
44 * Changed editor to use raw ammo counts isntead of percentages, and make
45 * it select first item in list by default.
47 * 12 2/13/98 3:38p Johnson
48 * Fixed bug where multi ship editing won't update player ships.
50 * 11 12/11/97 5:46p Hoffoss
51 * Changed Fred to not display weapons that are not available to various
54 * 10 9/16/97 9:41p Hoffoss
55 * Changed Fred code around to stop using Parse_player structure for
56 * player information, and use actual ships instead.
58 * 9 5/30/97 4:50p Hoffoss
59 * Added code to allow marked ship editing of data in child dialogs of
62 * 8 4/21/97 5:02p Hoffoss
63 * Player/player status editing supported, and both saved and loaded from
66 * 7 4/16/97 2:02p Hoffoss
67 * Fixed bug Mike created by changing code while I had file checked out
70 * 6 4/16/97 1:59p Hoffoss
71 * Weapon editor now fully functional.
73 * 5 4/10/97 3:20p Mike
74 * Change hull damage to be like shields.
76 * 4 4/09/97 11:48a Hoffoss
77 * Initial work to weapon editor.
79 * 3 3/31/97 6:07p Hoffoss
80 * Fixed several errors, including BG editor not graying fields, BG editor
81 * not updating image when changed, Removed obsolete data from Weapon
82 * editor, priority not being saved when missions saved, priority not
83 * editable in initial orders editor.
85 * 2 2/17/97 5:28p Hoffoss
86 * Checked RCS headers, added them were missing, changing description to
87 * something better, etc where needed.
94 #include "weaponeditordlg.h"
96 #include "management.h"
100 #define BLANK_FIELD -99
103 #define new DEBUG_NEW
105 static char THIS_FILE[] = __FILE__;
108 /////////////////////////////////////////////////////////////////////////////
109 // WeaponEditorDlg dialog
111 WeaponEditorDlg::WeaponEditorDlg(CWnd* pParent /*=NULL*/)
112 : CDialog(WeaponEditorDlg::IDD, pParent)
114 //{{AFX_DATA_INIT(WeaponEditorDlg)
133 int save_number(char *str, int *val)
139 sprintf(buf, "%d", num);
140 if (strncmp(str, buf, strlen(buf)))
147 void WeaponEditorDlg::DoDataExchange(CDataExchange* pDX)
151 CDialog::DoDataExchange(pDX);
152 //{{AFX_DATA_MAP(WeaponEditorDlg)
153 DDX_Control(pDX, IDC_SPIN4, m_spin4);
154 DDX_Control(pDX, IDC_SPIN3, m_spin3);
155 DDX_Control(pDX, IDC_SPIN2, m_spin2);
156 DDX_Control(pDX, IDC_SPIN1, m_spin1);
157 DDX_CBIndex(pDX, IDC_AI_CLASS, m_ai_class);
158 DDX_CBIndex(pDX, IDC_GUN1, m_gun1);
159 DDX_CBIndex(pDX, IDC_GUN2, m_gun2);
160 DDX_CBIndex(pDX, IDC_GUN3, m_gun3);
161 DDX_CBIndex(pDX, IDC_MISSILE1, m_missile1);
162 DDX_CBIndex(pDX, IDC_MISSILE2, m_missile2);
163 DDX_CBIndex(pDX, IDC_MISSILE3, m_missile3);
164 DDX_CBIndex(pDX, IDC_MISSILE4, m_missile4);
165 DDX_LBIndex(pDX, IDC_LIST, m_cur_item);
168 if (pDX->m_bSaveAndValidate) {
169 GetDlgItem(IDC_AMMO1)->GetWindowText(str);
170 if (save_number((char *) (LPCSTR) str, &m_ammo1)) {
171 m_ammo_max1 = (m_missile1 <= 0) ? 0 : get_max_ammo_count_for_bank(m_ship_class, 0, m_missile1 + First_secondary_index - 1);
174 if (m_ammo1 > m_ammo_max1)
175 m_ammo1 = m_ammo_max1;
178 GetDlgItem(IDC_AMMO2)->GetWindowText(str);
179 if (save_number((char *) (LPCSTR) str, &m_ammo2)) {
180 m_ammo_max2 = (m_missile2 <= 0) ? 0 : get_max_ammo_count_for_bank(m_ship_class, 1, m_missile2 + First_secondary_index - 1);
183 if (m_ammo2 > m_ammo_max2)
184 m_ammo2 = m_ammo_max2;
187 GetDlgItem(IDC_AMMO3)->GetWindowText(str);
188 if (save_number((char *) (LPCSTR) str, &m_ammo3)) {
189 m_ammo_max3 = (m_missile3 <= 0) ? 0 : get_max_ammo_count_for_bank(m_ship_class, 2, m_missile3 + First_secondary_index - 1);
192 if (m_ammo3 > m_ammo_max3)
193 m_ammo3 = m_ammo_max3;
196 GetDlgItem(IDC_AMMO4)->GetWindowText(str);
197 if (save_number((char *) (LPCSTR) str, &m_ammo4)) {
198 m_ammo_max4 = (m_missile4 <= 0) ? 0 : get_max_ammo_count_for_bank(m_ship_class, 3, m_missile4 + First_secondary_index - 1);
201 if (m_ammo4 > m_ammo_max4)
202 m_ammo4 = m_ammo_max4;
205 m_spin1.SetRange(0, m_ammo_max1);
206 m_spin2.SetRange(0, m_ammo_max2);
207 m_spin3.SetRange(0, m_ammo_max3);
208 m_spin4.SetRange(0, m_ammo_max4);
211 if (m_ammo1 != BLANK_FIELD)
212 DDX_Text(pDX, IDC_AMMO1, m_ammo1);
214 GetDlgItem(IDC_AMMO1)->SetWindowText("");
216 if (m_ammo2 != BLANK_FIELD)
217 DDX_Text(pDX, IDC_AMMO2, m_ammo2);
219 GetDlgItem(IDC_AMMO2)->SetWindowText("");
221 if (m_ammo3 != BLANK_FIELD)
222 DDX_Text(pDX, IDC_AMMO3, m_ammo3);
224 GetDlgItem(IDC_AMMO3)->SetWindowText("");
226 if (m_ammo4 != BLANK_FIELD)
227 DDX_Text(pDX, IDC_AMMO4, m_ammo4);
229 GetDlgItem(IDC_AMMO4)->SetWindowText("");
233 BEGIN_MESSAGE_MAP(WeaponEditorDlg, CDialog)
234 //{{AFX_MSG_MAP(WeaponEditorDlg)
235 ON_LBN_SELCHANGE(IDC_LIST, OnSelchangeList)
237 ON_CBN_SELCHANGE(IDC_MISSILE1, OnSelchangeMissile1)
238 ON_CBN_SELCHANGE(IDC_MISSILE2, OnSelchangeMissile2)
239 ON_CBN_SELCHANGE(IDC_MISSILE3, OnSelchangeMissile3)
240 ON_CBN_SELCHANGE(IDC_MISSILE4, OnSelchangeMissile4)
244 /////////////////////////////////////////////////////////////////////////////
245 // WeaponEditorDlg message handlers
247 BOOL WeaponEditorDlg::OnInitDialog()
249 int i, z, big = 1, end1, end2, inst, flag = 0;
251 model_subsystem *psub;
252 ship_subsys *ssl, *pss;
256 CDialog::OnInitDialog();
259 m_ship = Objects[cur_object_index].instance;
261 end1 = First_secondary_index;
262 end2 = Num_weapon_types;
264 list = (CListBox *) GetDlgItem(IDC_LIST);
266 z = list->AddString("Pilot");
268 list->SetItemDataPtr(z, &pilot);
269 ptr = GET_FIRST(&obj_used_list);
270 while (ptr != END_OF_LIST(&obj_used_list)) {
271 if (((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) && (ptr->flags & OF_MARKED)) {
272 inst = ptr->instance;
273 if (!(ship_get_SIF(inst) & (SIF_BIG_SHIP | SIF_HUGE_SHIP)))
277 pilot = Ships[inst].weapons;
278 m_ship_class = Ships[inst].ship_info_index;
282 Assert(Ships[inst].ship_info_index == m_ship_class);
283 if (pilot.ai_class != Ships[inst].weapons.ai_class)
284 pilot.ai_class = BLANK_FIELD;
286 for (i=0; i<MAX_PRIMARY_BANKS; i++)
287 if (pilot.primary_bank_weapons[i] != Ships[inst].weapons.primary_bank_weapons[i])
288 pilot.primary_bank_weapons[i] = BLANK_FIELD;
290 for (i=0; i<MAX_SECONDARY_BANKS; i++) {
291 if (pilot.secondary_bank_weapons[i] != Ships[inst].weapons.secondary_bank_weapons[i])
292 pilot.secondary_bank_weapons[i] = BLANK_FIELD;
293 if (pilot.secondary_bank_ammo[i] != Ships[inst].weapons.secondary_bank_ammo[i])
294 pilot.secondary_bank_ammo[i] = BLANK_FIELD;
303 if (!(ship_get_SIF(m_ship) & (SIF_BIG_SHIP | SIF_HUGE_SHIP)))
306 m_ship_class = Ships[m_ship].ship_info_index;
307 list->SetItemDataPtr(z, &Ships[m_ship].weapons);
308 ssl = &Ships[m_ship].subsys_list;
309 for (pss = GET_FIRST(ssl); pss != END_OF_LIST(ssl); pss = GET_NEXT(pss)) {
310 psub = pss->system_info;
311 if (psub->type == SUBSYSTEM_TURRET) {
312 z = list->AddString(psub->subobj_name);
313 list->SetItemDataPtr(z, &pss->weapons);
318 box = (CComboBox *) GetDlgItem(IDC_AI_CLASS);
319 for (i=0; i<Num_ai_classes; i++){
320 box->AddString(Ai_class_names[i]);
323 for (i=0; i<end1; i++){
324 if ((Weapon_info[i].wi_flags & WIF_CHILD) || (!big && (Weapon_info[i].wi_flags & WIF_BIG_ONLY))){
329 box = (CComboBox *) GetDlgItem(IDC_GUN1);
330 box->AddString("None");
331 for (i=0; i<end1; i++){
332 box->AddString(Weapon_info[i].name);
335 box = (CComboBox *) GetDlgItem(IDC_GUN2);
336 box->AddString("None");
337 for (i=0; i<end1; i++){
338 box->AddString(Weapon_info[i].name);
341 box = (CComboBox *) GetDlgItem(IDC_GUN3);
342 box->AddString("None");
343 for (i=0; i<end1; i++){
344 box->AddString(Weapon_info[i].name);
347 for (i=First_secondary_index; i<end2; i++){
348 if ((Weapon_info[i].wi_flags & WIF_CHILD) || (!big && (Weapon_info[i].wi_flags & WIF_BIG_ONLY))){
353 box = (CComboBox *) GetDlgItem(IDC_MISSILE1);
354 box->AddString("None");
355 for (i=First_secondary_index; i<end2; i++){
356 box->AddString(Weapon_info[i].name);
359 box = (CComboBox *) GetDlgItem(IDC_MISSILE2);
360 box->AddString("None");
361 for (i=First_secondary_index; i<end2; i++){
362 box->AddString(Weapon_info[i].name);
365 box = (CComboBox *) GetDlgItem(IDC_MISSILE3);
366 box->AddString("None");
367 for (i=First_secondary_index; i<end2; i++){
368 box->AddString(Weapon_info[i].name);
371 box = (CComboBox *) GetDlgItem(IDC_MISSILE4);
372 box->AddString("None");
373 for (i=First_secondary_index; i<end2; i++){
374 box->AddString(Weapon_info[i].name);
384 void WeaponEditorDlg::OnSelchangeList()
391 void WeaponEditorDlg::change_selection()
393 CString a1, a2, a3, a4;
395 GetDlgItem(IDC_AMMO1)->GetWindowText(a1);
396 GetDlgItem(IDC_AMMO2)->GetWindowText(a2);
397 GetDlgItem(IDC_AMMO3)->GetWindowText(a3);
398 GetDlgItem(IDC_AMMO4)->GetWindowText(a4);
400 if (m_last_item >= 0) {
401 cur_weapon->ai_class = m_ai_class;
402 cur_weapon->primary_bank_weapons[0] = m_gun1 - 1;
403 cur_weapon->primary_bank_weapons[1] = m_gun2 - 1;
404 cur_weapon->primary_bank_weapons[2] = m_gun3 - 1;
406 m_missile1 += First_secondary_index;
408 cur_weapon->secondary_bank_weapons[0] = m_missile1 - 1;
410 m_missile2 += First_secondary_index;
412 cur_weapon->secondary_bank_weapons[1] = m_missile2 - 1;
414 m_missile3 += First_secondary_index;
416 cur_weapon->secondary_bank_weapons[2] = m_missile3 - 1;
418 m_missile4 += First_secondary_index;
420 cur_weapon->secondary_bank_weapons[3] = m_missile4 - 1;
421 cur_weapon->secondary_bank_ammo[0] = m_ammo_max1 ? (m_ammo1 * 100 / m_ammo_max1) : 0;
422 cur_weapon->secondary_bank_ammo[1] = m_ammo_max2 ? (m_ammo2 * 100 / m_ammo_max2) : 0;
423 cur_weapon->secondary_bank_ammo[2] = m_ammo_max3 ? (m_ammo3 * 100 / m_ammo_max3) : 0;
424 cur_weapon->secondary_bank_ammo[3] = m_ammo_max4 ? (m_ammo4 * 100 / m_ammo_max4) : 0;
427 cur_weapon->secondary_bank_ammo[0] = BLANK_FIELD;
429 cur_weapon->secondary_bank_ammo[1] = BLANK_FIELD;
431 cur_weapon->secondary_bank_ammo[2] = BLANK_FIELD;
433 cur_weapon->secondary_bank_ammo[3] = BLANK_FIELD;
437 m_gun1 = m_gun2 = m_gun3 = m_missile1 = m_missile2 = m_missile3 = m_missile4 = -1;
438 m_ammo1 = m_ammo2 = m_ammo3 = m_ammo4 = BLANK_FIELD;
439 m_ammo_max1 = m_ammo_max2 = m_ammo_max3 = m_ammo_max4 = 0;
440 if (m_cur_item < 0) {
441 m_last_item = m_cur_item;
442 GetDlgItem(IDC_GUN1)->EnableWindow(FALSE);
443 GetDlgItem(IDC_GUN2)->EnableWindow(FALSE);
444 GetDlgItem(IDC_GUN3)->EnableWindow(FALSE);
445 GetDlgItem(IDC_MISSILE1)->EnableWindow(FALSE);
446 GetDlgItem(IDC_MISSILE2)->EnableWindow(FALSE);
447 GetDlgItem(IDC_MISSILE3)->EnableWindow(FALSE);
448 GetDlgItem(IDC_MISSILE4)->EnableWindow(FALSE);
449 GetDlgItem(IDC_AMMO1)->EnableWindow(FALSE);
450 GetDlgItem(IDC_AMMO2)->EnableWindow(FALSE);
451 GetDlgItem(IDC_AMMO3)->EnableWindow(FALSE);
452 GetDlgItem(IDC_AMMO4)->EnableWindow(FALSE);
453 GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
454 GetDlgItem(IDC_SPIN2)->EnableWindow(FALSE);
455 GetDlgItem(IDC_SPIN3)->EnableWindow(FALSE);
456 GetDlgItem(IDC_SPIN4)->EnableWindow(FALSE);
457 GetDlgItem(IDC_AI_CLASS)->EnableWindow(FALSE);
462 cur_weapon = (ship_weapon *) ((CListBox *) GetDlgItem(IDC_LIST))->GetItemDataPtr(m_cur_item);
463 GetDlgItem(IDC_AI_CLASS)->EnableWindow(TRUE);
464 m_ai_class = cur_weapon->ai_class;
466 if (cur_weapon->num_primary_banks > 0) {
467 m_gun1 = cur_weapon->primary_bank_weapons[0] + 1;
468 GetDlgItem(IDC_GUN1)->EnableWindow(TRUE);
470 GetDlgItem(IDC_GUN1)->EnableWindow(FALSE);
472 if (cur_weapon->num_primary_banks > 1) {
473 m_gun2 = cur_weapon->primary_bank_weapons[1] + 1;
474 GetDlgItem(IDC_GUN2)->EnableWindow(TRUE);
476 GetDlgItem(IDC_GUN2)->EnableWindow(FALSE);
478 if (cur_weapon->num_primary_banks > 2) {
479 m_gun3 = cur_weapon->primary_bank_weapons[2] + 1;
480 GetDlgItem(IDC_GUN3)->EnableWindow(TRUE);
482 GetDlgItem(IDC_GUN3)->EnableWindow(FALSE);
484 if (cur_weapon->num_secondary_banks > 0) {
485 m_missile1 = cur_weapon->secondary_bank_weapons[0] + 1;
486 if (m_missile1 > 0) {
487 m_ammo_max1 = get_max_ammo_count_for_bank(m_ship_class, 0, m_missile1 - 1);
488 if (cur_weapon->secondary_bank_ammo[0] != BLANK_FIELD)
489 m_ammo1 = cur_weapon->secondary_bank_ammo[0] * m_ammo_max1 / 100;
490 m_missile1 -= First_secondary_index;
493 GetDlgItem(IDC_MISSILE1)->EnableWindow(TRUE);
494 GetDlgItem(IDC_AMMO1)->EnableWindow(TRUE);
495 GetDlgItem(IDC_SPIN1)->EnableWindow(TRUE);
498 GetDlgItem(IDC_MISSILE1)->EnableWindow(FALSE);
499 GetDlgItem(IDC_AMMO1)->EnableWindow(FALSE);
500 GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
503 if (cur_weapon->num_secondary_banks > 1) {
504 m_missile2 = cur_weapon->secondary_bank_weapons[1] + 1;
505 if (m_missile2 > 0) {
506 m_ammo_max2 = get_max_ammo_count_for_bank(m_ship_class, 1, m_missile2 - 1);
507 if (cur_weapon->secondary_bank_ammo[1] != BLANK_FIELD)
508 m_ammo2 = cur_weapon->secondary_bank_ammo[1] * m_ammo_max2 / 100;
509 m_missile2 -= First_secondary_index;
512 GetDlgItem(IDC_MISSILE2)->EnableWindow(TRUE);
513 GetDlgItem(IDC_AMMO2)->EnableWindow(TRUE);
514 GetDlgItem(IDC_SPIN2)->EnableWindow(TRUE);
517 GetDlgItem(IDC_MISSILE2)->EnableWindow(FALSE);
518 GetDlgItem(IDC_AMMO2)->EnableWindow(FALSE);
519 GetDlgItem(IDC_SPIN2)->EnableWindow(FALSE);
522 if (cur_weapon->num_secondary_banks > 2) {
523 m_missile3 = cur_weapon->secondary_bank_weapons[2] + 1;
524 if (m_missile3 > 0) {
525 m_ammo_max3 = get_max_ammo_count_for_bank(m_ship_class, 2, m_missile3 - 1);
526 if (cur_weapon->secondary_bank_ammo[2] != BLANK_FIELD)
527 m_ammo3 = cur_weapon->secondary_bank_ammo[2] * m_ammo_max3 / 100;
528 m_missile3 -= First_secondary_index;
531 GetDlgItem(IDC_MISSILE3)->EnableWindow(TRUE);
532 GetDlgItem(IDC_AMMO3)->EnableWindow(TRUE);
533 GetDlgItem(IDC_SPIN3)->EnableWindow(TRUE);
536 GetDlgItem(IDC_MISSILE3)->EnableWindow(FALSE);
537 GetDlgItem(IDC_AMMO3)->EnableWindow(FALSE);
538 GetDlgItem(IDC_SPIN3)->EnableWindow(FALSE);
541 if (cur_weapon->num_secondary_banks > 3) {
542 m_missile4 = cur_weapon->secondary_bank_weapons[3] + 1;
543 if (m_missile4 > 0) {
544 m_ammo_max4 = get_max_ammo_count_for_bank(m_ship_class, 3, m_missile4 - 1);
545 if (cur_weapon->secondary_bank_ammo[3] != BLANK_FIELD)
546 m_ammo4 = cur_weapon->secondary_bank_ammo[3] * m_ammo_max4 / 100;
547 m_missile4 -= First_secondary_index;
550 GetDlgItem(IDC_MISSILE4)->EnableWindow(TRUE);
551 GetDlgItem(IDC_AMMO4)->EnableWindow(TRUE);
552 GetDlgItem(IDC_SPIN4)->EnableWindow(TRUE);
555 GetDlgItem(IDC_MISSILE4)->EnableWindow(FALSE);
556 GetDlgItem(IDC_AMMO4)->EnableWindow(FALSE);
557 GetDlgItem(IDC_SPIN4)->EnableWindow(FALSE);
560 m_last_item = m_cur_item;
563 if (m_ammo1 == BLANK_FIELD)
564 GetDlgItem(IDC_AMMO1)->SetWindowText("");
565 if (m_ammo2 == BLANK_FIELD)
566 GetDlgItem(IDC_AMMO2)->SetWindowText("");
567 if (m_ammo3 == BLANK_FIELD)
568 GetDlgItem(IDC_AMMO3)->SetWindowText("");
569 if (m_ammo4 == BLANK_FIELD)
570 GetDlgItem(IDC_AMMO4)->SetWindowText("");
574 void WeaponEditorDlg::OnOK()
583 void WeaponEditorDlg::OnCancel()
592 void WeaponEditorDlg::OnClose()
601 void WeaponEditorDlg::update_pilot()
608 ptr = GET_FIRST(&obj_used_list);
609 while (ptr != END_OF_LIST(&obj_used_list)) {
610 if (((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) && (ptr->flags & OF_MARKED)) {
611 weapon = &Ships[ptr->instance].weapons;
613 if (pilot.ai_class >= 0)
614 weapon->ai_class = pilot.ai_class;
616 for (i=0; i<MAX_PRIMARY_BANKS; i++)
617 if (pilot.primary_bank_weapons[i] != -2)
618 weapon->primary_bank_weapons[i] = pilot.primary_bank_weapons[i];
620 for (i=0; i<MAX_SECONDARY_BANKS; i++) {
621 if (pilot.secondary_bank_weapons[i] != -2)
622 weapon->secondary_bank_weapons[i] = pilot.secondary_bank_weapons[i];
623 if (pilot.secondary_bank_ammo[i] >= 0)
624 weapon->secondary_bank_ammo[i] = pilot.secondary_bank_ammo[i];
633 void WeaponEditorDlg::OnSelchangeMissile1()
637 m_ammo_max1 = get_max_ammo_count_for_bank(m_ship_class, 0, m_missile1 + First_secondary_index - 1);
638 m_ammo1 = m_ammo_max1 ? (m_ammo_max1) : 0;
642 void WeaponEditorDlg::OnSelchangeMissile2()
646 m_ammo_max2 = get_max_ammo_count_for_bank(m_ship_class, 0, m_missile2 + First_secondary_index - 1);
647 m_ammo2 = m_ammo_max2 ? (m_ammo_max2) : 0;
651 void WeaponEditorDlg::OnSelchangeMissile3()
655 m_ammo_max3 = get_max_ammo_count_for_bank(m_ship_class, 0, m_missile3 + First_secondary_index - 1);
656 m_ammo3 = m_ammo_max3 ? (m_ammo_max3) : 0;
660 void WeaponEditorDlg::OnSelchangeMissile4()
664 m_ammo_max4 = get_max_ammo_count_for_bank(m_ship_class, 0, m_missile4 + First_secondary_index - 1);
665 m_ammo4 = m_ammo_max4 ? (m_ammo_max4) : 0;