2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/MissionUI/MissionWeaponChoice.cpp $
15 * C module for the weapon loadout screen
18 * Revision 1.5 2003/05/25 02:30:43 taylor
21 * Revision 1.4 2002/06/16 01:43:23 relnev
22 * fixed demo dogfight multiplayer mission
26 * Revision 1.3 2002/06/09 04:41:23 relnev
27 * added copyright header
29 * Revision 1.2 2002/05/07 03:16:46 theoddone33
30 * The Great Newline Fix
32 * Revision 1.1.1.1 2002/05/03 03:28:10 root
36 * 40 11/01/99 11:22a Jefff
37 * some weapon name translations
39 * 39 9/10/99 10:26a Jefff
40 * default weapon anim selection fix
42 * 38 9/06/99 3:30p Mikek
43 * Added system for restricting weapon choices based on ship class for
46 * 37 8/27/99 11:59a Jefff
47 * fixed unnecessary sound playing
49 * 36 8/05/99 3:40p Jefff
50 * hi-res text adjustments
52 * 35 8/05/99 11:32a Jefff
53 * fixed hi-res weapon anims not loading from packfile
55 * 34 7/30/99 4:35p Andsager
56 * Clean up change ship sound
58 * 33 7/30/99 4:22p Andsager
59 * restored ship and weapon anim sounds for demo. Added sound for
60 * changing ship in weapon loadout screen.
62 * 32 7/27/99 7:34p Jefff
63 * Lotsa clean up, moving stuff around, generally making the whole damn
66 * 31 7/27/99 3:01p Jefff
67 * crippled wl_start_slot_animation to prevent loading of overhead ship
68 * .anis. also began modifications for multiplayer interface.
70 * 30 7/25/99 5:49p Jefff
71 * initial weapon ani is now one of the ship's weapons. this will fall
72 * back to the original search if the ship should be weaponless.
74 * 29 7/24/99 6:03p Jefff
75 * Added "lock" text to multiplayer lock button
77 * 28 7/21/99 6:02p Jefff
78 * fixed weapon counts running into weapon icons
80 * 27 7/21/99 3:24p Andsager
81 * Modify demo to use 2 frame ship and weapon select anis and cut sounds
84 * 26 7/20/99 7:07p Jefff
85 * added "reset" text above reset button
87 * 25 7/20/99 1:48p Jefff
88 * Long weapon titles now wrap to next line
90 * 24 7/20/99 10:44a Jefff
91 * increased WEAPON_DESC_MAX_LINES to 6
93 * 23 7/20/99 12:26a Jefff
96 * 22 7/19/99 5:08p Jefff
97 * Added text descriptions for selected weapons, complete with wipe
100 * 21 7/16/99 1:50p Dave
101 * 8 bit aabitmaps. yay.
103 * 20 7/15/99 9:20a Andsager
104 * FS2_DEMO initial checkin
106 * 19 7/11/99 3:20p Kellys
107 * Make sure we load high-res weapon rotations in 1024
109 * 18 7/09/99 5:54p Dave
110 * Seperated cruiser types into individual types. Added tons of new
111 * briefing icons. Campaign screen.
113 * 17 7/09/99 12:21a Dave
114 * Change weapon loop anim frame.
116 * 16 3/25/99 2:45p Neilk
119 * 15 3/23/99 9:23p Neilk
120 * fixed various multiplayer lock button problems
122 * 14 3/10/99 6:21p Neilk
123 * Added new artwork for hires
125 * 13 2/21/99 6:01p Dave
126 * Fixed standalone WSS packets.
128 * 12 2/18/99 11:46a Neilk
129 * hires interface coord support
131 * 11 2/11/99 3:08p Dave
132 * PXO refresh button. Very preliminary squad war support.
134 * 10 2/01/99 5:55p Dave
135 * Removed the idea of explicit bitmaps for buttons. Fixed text
136 * highlighting for disabled gadgets.
138 * 9 1/30/99 1:29a Dave
139 * Fixed nebula thumbnail problem. Full support for 1024x768 choose pilot
140 * screen. Fixed beam weapon death messages.
142 * 8 1/29/99 4:17p Dave
143 * New interface screens.
145 * 7 1/27/99 9:56a Dave
146 * Temporary checkin of beam weapons for Dan to make cool sounds.
148 * 6 12/18/98 1:13a Dave
149 * Rough 1024x768 support for Direct3D. Proper detection and usage through
152 * 5 11/30/98 1:07p Dave
153 * 16 bit conversion, first run.
155 * 4 11/17/98 11:12a Dave
156 * Removed player identification by address. Now assign explicit id #'s.
158 * 3 10/13/98 9:29a Dave
159 * Started neatening up freespace.h. Many variables renamed and
160 * reorganized. Added AlphaColors.[h,cpp]
162 * 2 10/07/98 10:53a Dave
165 * 1 10/07/98 10:50a Dave
167 * 119 6/17/98 11:06a Lawrance
168 * put in weapon description tooltip
170 * 118 6/13/98 6:01p Hoffoss
171 * Externalized all new (or forgot to be added) strings to all the code.
173 * 117 6/01/98 11:43a John
174 * JAS & MK: Classified all strings for localization.
176 * 116 5/19/98 8:35p Dave
177 * Revamp PXO channel listing system. Send campaign goals/events to
178 * clients for evaluation. Made lock button pressable on all screens.
180 * 115 5/18/98 2:49p Lawrance
181 * Put in weapon animation sound hook
183 * 114 5/08/98 7:52p Lawrance
184 * Add code to loop new weapon animations
186 * 113 5/06/98 11:50p Lawrance
187 * Clean up help overlay code for loadout screens
189 * 112 5/04/98 5:27p Johnson
190 * Fixed a team vs. team weapons loadout bug.
192 * 111 5/03/98 1:55a Lawrance
193 * Fix some sound problems with loadout screens
195 * 110 4/30/98 6:03p Lawrance
196 * Make drag and drop work better.
198 * 109 4/27/98 6:02p Dave
199 * Modify how missile scoring works. Fixed a team select ui bug. Speed up
200 * multi_lag system. Put in new main hall.
202 * 108 4/24/98 2:17a Lawrance
203 * repositioin ship name in weapons loadout
205 * 107 4/22/98 7:24p Dave
206 * Made sure the "player/ships" locked button for multiplayer appears on
207 * all briefing screens.
209 * 106 4/21/98 6:45p Dave
210 * AL: Fix bug with replacement weapons on ships
212 * 105 4/17/98 5:27p Dave
213 * More work on the multi options screen. Fixed many minor ui todo bugs.
215 * 104 4/16/98 8:05p Lawrance
216 * fix some bugs with numbers over-writing weapon icons
218 * 103 4/10/98 4:51p Hoffoss
219 * Made several changes related to tooltips.
221 * 102 4/08/98 1:18a Lawrance
222 * Fix bug that could occur when picking alternate weapons (ie count could
223 * have been wrong due to missile size)
225 * 101 4/07/98 5:42p Dave
226 * Put in support for ui display of voice system status (recording,
227 * playing back, etc). Make sure main hall music is stopped before
228 * entering a multiplayer game via ingame join.
230 * 100 4/02/98 11:40a Lawrance
231 * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
233 * 99 3/31/98 1:50p Duncan
234 * ALAN: fix bugs with selecting alternate weapons
236 * 98 3/30/98 12:18a Lawrance
237 * change some DEMO_RELEASE code to not compile code rather than return
240 * 97 3/29/98 1:24p Dave
241 * Make chatbox not clear between multiplayer screens. Select player ship
242 * as default in mp team select and weapons select screens. Made create
243 * game mission list use 2 fixed size columns.
245 * 96 3/29/98 12:55a Lawrance
246 * Get demo build working with limited set of data.
248 * 95 3/26/98 5:47p Lawrance
249 * Implement default weapon picking if default weapons not available in
252 * 94 3/25/98 8:43p Hoffoss
253 * Changed anim_play() to not be so damn complex when you try and call it.
255 * 93 3/25/98 11:23a Mike
256 * Fix stack overwrite due to async between MAX_SECONDARY_WEAPONS and
259 * 92 3/21/98 2:47p Dave
260 * Fixed chat packet routing problem on standalone. Fixed wss_request
261 * packet routing on standalone.
263 * 91 3/19/98 5:34p Lawrance
264 * Tweak drag/drop behavior in weapons loadout
266 * 90 3/14/98 2:48p Dave
267 * Cleaned up observer joining code. Put in support for file xfers to
268 * ingame joiners (observers or not). Revamped and reinstalled pseudo
271 * 89 3/12/98 4:03p Lawrance
272 * don't press buttons when icon dropped on them
274 * 88 3/10/98 1:35p Lawrance
275 * Fix default selected weapon bug
277 * 87 3/09/98 9:55p Lawrance
278 * Move secondary icons to the right to avoid overlap with numbers
280 * 86 3/09/98 11:13a Lawrance
281 * Fix up drop sound effects used in loadout screens.
283 * 85 3/06/98 5:36p Dave
284 * Finished up first rev of team vs team. Probably needs to be debugged
287 * 84 3/05/98 5:03p Dave
288 * More work on team vs. team support for multiplayer. Need to fix bugs in
291 * 83 3/01/98 3:26p Dave
292 * Fixed a few team select bugs. Put in multiplayer intertface sounds.
293 * Corrected how ships are disabled/enabled in team select/weapon select
296 * 82 2/28/98 7:04p Lawrance
297 * Don't show reset button in multiplayer
299 * 81 2/27/98 11:32a Andsager
300 * AL: Fix bug with showing valid weapon slots for ships that arrive late.
302 * 80 2/26/98 4:59p Allender
303 * groundwork for team vs team briefings. Moved weaponry pool into the
304 * Team_data structure. Added team field into the p_info structure.
305 * Allow for mutliple structures in the briefing code.
307 * 79 2/24/98 6:21p Lawrance
308 * Integrate new reset button into loadout screens
310 * 78 2/22/98 4:17p John
311 * More string externalization classification... 190 left to go!
313 * 77 2/22/98 12:19p John
314 * Externalized some strings
316 * 76 2/19/98 6:26p Dave
317 * Fixed a few file xfer bugs. Tweaked mp team select screen. Put in
318 * initial support for player data uploading.
320 * 75 2/18/98 10:37p Dave
321 * Fixed a mp team select bug which allowed players to commit at
322 * inappropriate times.
324 * 74 2/18/98 3:56p Dave
325 * Several bugs fixed for mp team select screen. Put in standalone packet
326 * routing for team select.
328 * 73 2/16/98 10:27a Lawrance
329 * Fix bug in wl_cull_illegal_weapons()
331 * 72 2/15/98 11:28p Allender
332 * allow increase in MAX_WEAPON_TYPES by chaning all bitfield references
334 * 71 2/13/98 5:15p Lawrance
335 * Fix help overlay bug in weapons loadout.
337 * 70 2/13/98 3:46p Dave
338 * Put in dynamic chatbox sizing. Made multiplayer file lookups use cfile
341 * 69 2/09/98 11:24p Lawrance
342 * Allow player to click on disallowed weapons, but don't let them drag
343 * them away from the list.
345 * 68 2/07/98 5:47p Lawrance
346 * reset flashing if a button gets highlighted
348 * 67 2/06/98 5:15p Jasen
349 * AL: Allow up to 10000 of any given missile in the pool
351 * 66 2/05/98 11:21p Lawrance
352 * When flashing buttons, use highlight frame
354 * 65 2/02/98 3:36p Jasen
355 * AL: remove weapon debug name, and allow for 2 frame weapon anis
357 * 64 2/02/98 3:21p Jasen
358 * Updated coords for weapon anim location.
360 * 63 1/20/98 5:52p Lawrance
361 * account for no player ship when moving to weapons loadout
363 * 62 1/20/98 2:23p Dave
364 * Removed optimized build warnings. 99% done with ingame join fixes.
366 * 61 1/20/98 11:08a Lawrance
367 * Fix sound error when clicking on a weapon.
369 * 60 1/19/98 2:17p Lawrance
370 * Fix bug that was not recognizing non-default weapons on late-arriving
373 * 59 1/15/98 4:09p Lawrance
374 * fix weapon scrolling bug
376 * 58 1/14/98 6:44p Lawrance
377 * Take out unnecessary instance checking when freeing anims.
379 * 57 1/12/98 5:17p Dave
380 * Put in a bunch of multiplayer sequencing code. Made weapon/ship select
381 * work through the standalone.
383 * 56 1/10/98 12:47a Lawrance
384 * update some comments
386 * 55 1/09/98 6:06p Dave
387 * Put in network sound support for multiplayer ship/weapon select
388 * screens. Made clients exit game correctly through warp effect. Fixed
389 * main hall menu help overlay bug.
391 * 54 1/09/98 4:08p John
392 * Fixed a bug loading too many icon frames
394 * 53 1/08/98 10:55p Lawrance
395 * Fix bug where forbidden weapons were not updated when a ship was
396 * changed before weapons loadout is entered.
398 * 52 1/08/98 5:19p Sandeep
399 * Alan made a change which fixed missions with more than 4 types of
402 * 51 1/08/98 11:38a Lawrance
405 * 50 1/08/98 11:36a Lawrance
406 * Get ship select and weapons loadout icon dropping sound effects working
407 * for single and multiplayer
409 * 49 1/02/98 9:10p Lawrance
410 * Big changes to how colors get set on the HUD.
412 * 48 12/30/97 6:08p Lawrance
413 * Fix bug where player discarded ship before entering weapon select
415 * 47 12/29/97 4:21p Lawrance
416 * Flash buttons on briefing/ship select/weapons loadout when enough time
417 * has elapsed without activity.
419 * 46 12/29/97 10:11a Lawrance
420 * Don't play drop sound when a weapon is clicked on in a slot.
422 * 45 12/24/97 8:54p Lawrance
423 * Integrating new popup code
425 * 44 12/24/97 1:19p Lawrance
426 * fix some bugs with the multiplayer ship/weapons loadout
428 * 43 12/23/97 5:25p Allender
429 * more fixes to multiplayer ship selection. Fixed strange reentrant
430 * problem with cf_callback when loading freespace data
432 * 42 12/23/97 11:59a Allender
433 * changes to ship/wespon selection for multplayer. added sounds to some
434 * interface screens. Update and modiied end-of-briefing packets -- yet
437 * 41 12/23/97 11:48a Lawrance
438 * fix bug that could cause assert when swapping secondary weapons
440 * 40 12/22/97 6:18p Lawrance
441 * Get save/restore of player loadout working with new code
443 * 39 12/22/97 1:40a Lawrance
444 * Re-write ship select/weapons loadout to be multiplayer friendly
446 * 38 12/19/97 1:23p Dave
447 * Put in multiplayer groundwork for new weapon/ship select screens.
449 * 37 12/19/97 12:44p Dave
450 * Put in final touches on ship/weapon select. However, this is all going
456 #include "missionscreencommon.h"
457 #include "missionweaponchoice.h"
458 #include "missionshipchoice.h"
464 #include "snazzyui.h"
465 #include "animplay.h"
466 #include "freespace.h"
467 #include "gamesequence.h"
469 #include "missionbrief.h"
472 #include "animplay.h"
473 #include "contexthelp.h"
475 #include "linklist.h"
476 #include "multimsgs.h"
478 #include "multiteamselect.h"
480 #include "alphacolors.h"
481 #include "localize.h"
483 //#define MAX_PRIMARY_BANKS 3
484 //#define MAX_SECONDARY_BANKS 3 // Lowered from 5 to 3 by MK on 3/25/98. This needs to be <= MAX_WL_SECONDARY or you'll get stack overwrites.
486 #define IS_BANK_PRIMARY(x) (x<3?1:0)
487 #define IS_BANK_SECONDARY(x) (x>2?1:0)
489 #define IS_LIST_PRIMARY(x) (Weapon_info[x].subtype==WP_MISSILE?0:1)
490 #define IS_LIST_SECONDARY(x) (Weapon_info[x].subtype==WP_MISSILE?1:0)
493 #if (MAX_PRIMARY_BANKS > MAX_WL_PRIMARY)
494 #error "Illegal: MAX_PRIMARY_BANKS greater than MAX_WL_PRIMARY"
497 #if (MAX_SECONDARY_BANKS > MAX_WL_SECONDARY)
498 #error "Illegal: MAX_SECONDARY_BANKS greater than MAX_WL_SECONDARY"
502 //////////////////////////////////////////////////////////////////
504 //////////////////////////////////////////////////////////////////
506 // This game-wide global flag is set to 1 to indicate that the weapon
507 // select screen has been opened and memory allocated. This flag
508 // is needed so we can know if weapon_select_close() needs to called if
509 // restoring a game from the Options screen invoked from weapon select
510 int Weapon_select_open = 0;
512 //////////////////////////////////////////////////////////////////
514 //////////////////////////////////////////////////////////////////
516 typedef struct wl_bitmap_group
522 #if defined(FS2_DEMO) || defined(FS1_DEMO)
523 #define WEAPON_ANIM_LOOP_FRAME 1
525 #define WEAPON_ANIM_LOOP_FRAME 32
527 #define WEAPON_ANIM_LOOP_FRAME 52 // frame (from 0) to loop weapon anim
530 #define WEAPON_ICON_FRAME_NORMAL 0
531 #define WEAPON_ICON_FRAME_HOT 1
532 #define WEAPON_ICON_FRAME_SELECTED 2
533 #define WEAPON_ICON_FRAME_DISABLED 3
535 // Weapn loadout specific buttons
536 #define NUM_WEAPON_BUTTONS 7
537 #define WL_BUTTON_SCROLL_PRIMARY_UP 0
538 #define WL_BUTTON_SCROLL_PRIMARY_DOWN 1
539 #define WL_BUTTON_SCROLL_SECONDARY_UP 2
540 #define WL_BUTTON_SCROLL_SECONDARY_DOWN 3
541 #define WL_BUTTON_RESET 4
542 #define WL_BUTTON_DUMMY 5
543 #define WL_BUTTON_MULTI_LOCK 6
544 UI_WINDOW Weapon_ui_window;
545 //UI_BUTTON Weapon_buttons[NUM_WEAPON_BUTTONS];
547 static char *Wl_mask_single[GR_NUM_RESOLUTIONS] = {
552 static char *Wl_mask_multi[GR_NUM_RESOLUTIONS] = {
553 "weaponloadoutmulti-m",
554 "2_weaponloadoutmulti-m"
557 static char *Wl_loadout_select_mask[GR_NUM_RESOLUTIONS] = {
563 static char *Weapon_select_background_fname[GR_NUM_RESOLUTIONS] = {
573 static char *Weapon_select_multi_background_fname[GR_NUM_RESOLUTIONS] = {
578 "WeaponLoadoutMulti",
579 "2_WeaponLoadoutMulti"
583 int Weapon_select_background_bitmap; // bitmap for weapon select brackground
585 static MENU_REGION Weapon_select_region[NUM_WEAPON_REGIONS];
586 static int Num_weapon_select_regions;
588 // Mask bitmap pointer and Mask bitmap_id
589 static bitmap* WeaponSelectMaskPtr; // bitmap pointer to the weapon select mask bitmap
590 static ubyte* WeaponSelectMaskData; // pointer to actual bitmap data
591 static int Weaponselect_mask_w, Weaponselect_mask_h;
592 static int WeaponSelectMaskBitmap; // bitmap id of the weapon select mask bitmap
595 // convenient struct for handling all button controls
600 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
602 wl_buttons(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {}
605 static wl_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_WEAPON_BUTTONS] = {
608 wl_buttons("WLB_26", 0, 123, -1, -1, 26),
609 wl_buttons("WLB_27", 0, 272, -1, -1, 27),
610 wl_buttons("WLB_26", 0, 302, -1, -1, 8),
611 wl_buttons("WLB_27", 0, 452, -1, -1, 9),
612 wl_buttons("ssb_39", 566, 317, -1, -1, 39),
613 wl_buttons("ssb_39", 0, 0, -1, -1, 99),
614 wl_buttons("TSB_34", 601, 344, -1, -1, 50)
616 wl_buttons("WLB_26", 24, 125, -1, -1, 26),
617 wl_buttons("WLB_27", 24, 276, -1, -1, 27),
618 wl_buttons("WLB_08", 24, 303, -1, -1, 8),
619 wl_buttons("WLB_09", 24, 454, -1, -1, 9),
620 wl_buttons("ssb_39", 571, 347, -1, -1, 39),
621 wl_buttons("ssb_39", 0, 0, -1, -1, 99),
622 wl_buttons("TSB_34", 603, 374, -1, -1, 34)
626 wl_buttons("2_WLB_26", 39, 200, -1, -1, 26),
627 wl_buttons("2_WLB_27", 39, 442, -1, -1, 27),
628 wl_buttons("2_WLB_08", 39, 485, -1, -1, 8),
629 wl_buttons("2_WLB_09", 39, 727, -1, -1, 9),
630 wl_buttons("2_ssb_39", 913, 556, -1, -1, 39),
631 wl_buttons("2_ssb_39", 0, 0, -1, -1, 99),
632 wl_buttons("2_TSB_34", 966, 599, -1, -1, 34)
636 //static wl_bitmap_group wl_button_bitmaps[NUM_WEAPON_BUTTONS];
638 static int Weapon_button_scrollable[NUM_WEAPON_BUTTONS] = {0, 0, 0, 0, 0, 0, 0};
640 #define MAX_WEAPON_ICONS_ON_SCREEN 8
642 // X and Y locations of the weapon icons in the scrollable lists
643 //int Weapon_icon_x[MAX_WEAPON_ICONS_ON_SCREEN] = {27, 27, 27, 27, 36, 36, 36, 36};
644 //int Weapon_icon_y[MAX_WEAPON_ICONS_ON_SCREEN] = {152, 182, 212, 242, 331, 361, 391, 421};
645 static int Wl_weapon_icon_coords[GR_NUM_RESOLUTIONS][MAX_WEAPON_ICONS_ON_SCREEN][2] = {
669 static int Wl_bank_coords[GR_NUM_RESOLUTIONS][MAX_WL_WEAPONS][2] = {
700 static int Wl_bank_count_draw_flags[MAX_WL_WEAPONS] = {
701 0, 0, 0, // primaries -- dont draw counts
702 1, 1, 1, 1 // secondaries -- do draw counts
706 static int Weapon_anim_class = -1;
707 static int Last_wl_ship_class;
709 static int Wl_overhead_coords[GR_NUM_RESOLUTIONS][2] = {
724 static int Wl_weapon_ani_coords[GR_NUM_RESOLUTIONS][2] = {
737 static int Wl_weapon_ani_coords_multi[GR_NUM_RESOLUTIONS][2] = {
751 static int Wl_weapon_desc_coords[GR_NUM_RESOLUTIONS][2] = {
760 static int Wl_delta_x, Wl_delta_y;
762 static int Wl_ship_name_coords[GR_NUM_RESOLUTIONS][2] = {
772 ///////////////////////////////////////////////////////////////////////
774 ///////////////////////////////////////////////////////////////////////
775 typedef struct wl_ship_class_info
779 anim_instance_t *anim_instance;
780 } wl_ship_class_info;
782 wl_ship_class_info Wl_ships[MAX_SHIP_TYPES];
784 typedef struct wl_icon_info
786 int icon_bmaps[NUM_ICON_FRAMES];
787 int current_icon_bmap;
790 anim_instance_t *anim_instance;
793 wl_icon_info Wl_icons_teams[MAX_TEAMS][MAX_WEAPON_TYPES];
794 wl_icon_info *Wl_icons;
796 int Plist[MAX_WEAPON_TYPES]; // used to track scrolling of primary icon list
797 int Plist_start, Plist_size;
799 int Slist[MAX_WEAPON_TYPES]; // used to track scrolling of primary icon list
800 int Slist_start, Slist_size;
802 static int Selected_wl_slot = -1; // Currently selected ship slot
803 static int Selected_wl_class = -1; // Class of weapon that is selected
804 static int Hot_wl_slot = -1; // Ship slot that mouse is over (0..11)
805 static int Hot_weapon_icon = -1; // Icon number (0-7) which has mouse over it
806 static int Hot_weapon_bank = -1; // index (0-7) for weapon slot on ship that has a droppable icon over it
807 static int Hot_weapon_bank_icon = -1;
809 static int Wl_mouse_down_on_region = -1;
814 #define WEAPON_DESC_WIPE_TIME 1.5f // time in seconds for wipe to occur (over WEAPON_DESC_MAX_LENGTH number of chars)
815 #define WEAPON_DESC_MAX_LINES 7 // max lines in the description incl. title
816 #define WEAPON_DESC_MAX_LENGTH 50 // max chars per line of description text
817 static int Weapon_desc_wipe_done = 0;
818 static float Weapon_desc_wipe_time_elapsed = 0.0f;
819 static char Weapon_desc_lines[WEAPON_DESC_MAX_LINES][WEAPON_DESC_MAX_LENGTH]; // 1st 2 lines are title, rest are desc
821 // maximum width the weapon title can be -- used in the line breaking
822 int Weapon_title_max_width[GR_NUM_RESOLUTIONS] = { 200, 320 };
824 static int Wl_new_weapon_title_coords[GR_NUM_RESOLUTIONS][2] = {
833 static int Wl_new_weapon_title_coords_multi[GR_NUM_RESOLUTIONS][2] = {
842 static int Wl_new_weapon_desc_coords[GR_NUM_RESOLUTIONS][2] = {
851 static int Wl_new_weapon_desc_coords_multi[GR_NUM_RESOLUTIONS][2] = {
863 #define WEAPON_SELECT_NUM_TEXT 0
865 #define WEAPON_SELECT_NUM_TEXT 2
867 UI_XSTR Weapon_select_text[GR_NUM_RESOLUTIONS][WEAPON_SELECT_NUM_TEXT] = {
872 { "Reset", 1337, 580, 337, UI_XSTR_COLOR_GREEN, -1, &Buttons[0][WL_BUTTON_RESET].button },
873 { "Lock", 1270, 602, 364, UI_XSTR_COLOR_GREEN, -1, &Buttons[0][WL_BUTTON_MULTI_LOCK].button }
880 { "Reset", 1337, 938, 546, UI_XSTR_COLOR_GREEN, -1, &Buttons[1][WL_BUTTON_RESET].button },
881 { "Lock", 1270, 964, 584, UI_XSTR_COLOR_GREEN, -1, &Buttons[1][WL_BUTTON_MULTI_LOCK].button }
887 ///////////////////////////////////////////////////////////////////////
889 ///////////////////////////////////////////////////////////////////////
890 typedef struct carried_icon
892 int weapon_class; // index Wl_icons[] for carried icon (-1 if carried from bank)
893 int num; // number of units of weapon
894 int from_bank; // bank index that icon came from (0..2 primary, 3..6 secondary). -1 if from list
895 int from_slot; // ship slot that weapon is part of
899 static carried_icon Carried_wl_icon;
901 // forward declarations
902 void draw_wl_icons();
903 void wl_draw_ship_weapons(int index);
904 void wl_pick_icon_from_list(int index);
905 void pick_from_ship_slot(int num);
906 void start_weapon_animation(int weapon_class);
907 void stop_weapon_animation();
908 void wl_start_slot_animation(int n);
909 int wl_get_pilot_subsys_index(p_object *pobjp);
911 void wl_reset_to_defaults();
913 void wl_set_selected_slot(int slot_num);
914 void wl_maybe_reset_selected_slot();
915 void wl_maybe_reset_selected_weapon_class();
917 void wl_render_icon_count(int num, int x, int y);
918 void wl_render_weapon_desc();
922 // carry icon functions
923 void wl_reset_carried_icon();
924 int wl_icon_being_carried();
925 void wl_set_carried_icon(int from_bank, int from_slot, int weapon_class);
928 // Determine hack offset for how to draw fury missile icon.
929 int wl_fury_missile_offset_hack(int weapon_class, int num_missiles)
931 if ( weapon_class < 0 ) {
935 if ( num_missiles < 100 ) {
939 if ( !strnicmp(Weapon_info[weapon_class].name, NOX("fury"), 4) ) {
946 char *wl_tooltip_handler(char *str)
948 if (Selected_wl_class < 0)
951 if (!stricmp(str, "@weapon_desc")) {
955 str = Weapon_info[Selected_wl_class].desc;
956 gr_get_string_size(&w, &h, str);
957 x = Wl_weapon_desc_coords[gr_screen.res][0] - w / 2;
958 y = Wl_weapon_desc_coords[gr_screen.res][1] - h / 2;
960 gr_set_color_fast(&Color_black);
961 gr_rect(x - 5, y - 5, w + 10, h + 10);
963 gr_set_color_fast(&Color_bright_white);
964 gr_string(x, y, str);
971 // reset the data inside the Carried_wl_icon
972 void wl_reset_carried_icon()
974 Carried_wl_icon.weapon_class = -1;
975 Carried_wl_icon.num = 0;
976 Carried_wl_icon.from_bank = -1;
977 Carried_wl_icon.from_slot = -1;
980 // Is an icon being carried?
981 int wl_icon_being_carried()
983 if ( Carried_wl_icon.weapon_class >= 0 ) {
990 // Set carried icon data
991 void wl_set_carried_icon(int from_bank, int from_slot, int weapon_class)
995 Carried_wl_icon.from_bank = from_bank;
996 Carried_wl_icon.from_slot = from_slot;
997 Carried_wl_icon.weapon_class = weapon_class;
999 mouse_get_pos( &mx, &my );
1000 Carried_wl_icon.from_x=mx;
1001 Carried_wl_icon.from_y=my;
1003 Buttons[gr_screen.res][WL_BUTTON_DUMMY].button.capture_mouse();
1006 // determine if the carried icon has moved
1007 int wl_carried_icon_moved()
1010 mouse_get_pos( &mx, &my );
1011 if ( Carried_wl_icon.from_x != mx || Carried_wl_icon.from_y != my) {
1018 // return the index for the pilot subsystem in the parse object
1019 int wl_get_pilot_subsys_index(p_object *pobjp)
1021 int pilot_index, start_index, end_index, i;
1023 // see if there is a PILOT subystem
1024 start_index = pobjp->subsys_index;
1025 end_index = start_index + pobjp->subsys_count;
1027 for ( i = start_index; i < end_index; i++ ) {
1028 if ( !stricmp(Subsys_status[i].name, NOX("pilot") ) ) {
1034 if ( pilot_index == -1 ) {
1035 Error(LOCATION,"Parse object doesn't have a pilot subsystem\n");
1042 // Pause the current weapon animation
1043 void wl_pause_anim()
1045 if ( Weapon_anim_class >= 0 && Wl_icons[Weapon_anim_class].anim_instance ) {
1046 anim_pause(Wl_icons[Weapon_anim_class].anim_instance);
1050 // Unpause the current weapon animation
1051 void wl_unpause_anim()
1053 if ( Weapon_anim_class >= 0 && Wl_icons[Weapon_anim_class].anim_instance ) {
1054 anim_unpause(Wl_icons[Weapon_anim_class].anim_instance);
1058 // ---------------------------------------------------------------------------------
1059 // weapon_button_do()
1061 void weapon_button_do(int i)
1064 case PRIMARY_SCROLL_UP:
1065 if ( common_scroll_up_pressed(&Plist_start, Plist_size, 4) ) {
1066 gamesnd_play_iface(SND_SCROLL);
1068 gamesnd_play_iface(SND_GENERAL_FAIL);
1072 case PRIMARY_SCROLL_DOWN:
1073 if ( common_scroll_down_pressed(&Plist_start, Plist_size, 4) ) {
1074 gamesnd_play_iface(SND_SCROLL);
1076 gamesnd_play_iface(SND_GENERAL_FAIL);
1080 case SECONDARY_SCROLL_UP:
1081 if ( common_scroll_up_pressed(&Slist_start, Slist_size, 4) ) {
1082 gamesnd_play_iface(SND_SCROLL);
1084 gamesnd_play_iface(SND_GENERAL_FAIL);
1088 case SECONDARY_SCROLL_DOWN:
1089 if ( common_scroll_down_pressed(&Slist_start, Slist_size, 4) ) {
1090 gamesnd_play_iface(SND_SCROLL);
1092 gamesnd_play_iface(SND_GENERAL_FAIL);
1096 case WL_RESET_BUTTON_MASK:
1097 wl_reset_to_defaults();
1100 case WL_BUTTON_MULTI_LOCK:
1101 Assert(Game_mode & GM_MULTIPLAYER);
1102 // the "lock" button has been pressed
1103 multi_ts_lock_pressed();
1105 // disable the button if it is now locked
1106 if(multi_ts_is_locked()){
1107 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.disable();
1116 // -------------------------------------------------------------------
1117 // weapon_check_buttons()
1119 // Check if any weapons loadout screen buttons have been pressed, and
1120 // call weapon_button_do() if they have.
1122 void weapon_check_buttons()
1127 for ( i = 0; i < NUM_WEAPON_BUTTONS; i++ ) {
1128 b = &Buttons[gr_screen.res][i];
1130 if ( b->button.pressed() ) {
1131 if(i == WL_BUTTON_MULTI_LOCK){
1132 weapon_button_do(i);
1134 weapon_button_do(b->hotspot);
1140 // -------------------------------------------------------------------
1141 // wl_redraw_pressed_buttons()
1143 // Redraw any weapon loadout buttons that are pressed down. This function is needed
1144 // since we sometimes need to draw pressed buttons last to ensure the entire
1145 // button gets drawn (and not overlapped by other buttons)
1147 void wl_redraw_pressed_buttons()
1152 common_redraw_pressed_buttons();
1154 for ( i = 0; i < NUM_WEAPON_BUTTONS; i++ ) {
1155 b = &Buttons[gr_screen.res][i];
1156 if ( b->button.button_down() ) {
1157 b->button.draw_forced(2);
1162 // ---------------------------------------------------------------------------------
1163 // weapon_buttons_init()
1165 void weapon_buttons_init()
1170 for ( i = 0; i < NUM_WEAPON_BUTTONS; i++ ) {
1171 b = &Buttons[gr_screen.res][i];
1172 b->button.create( &Weapon_ui_window, "", Buttons[gr_screen.res][i].x, Buttons[gr_screen.res][i].y, 60, 30, Weapon_button_scrollable[i]);
1173 // set up callback for when a mouse first goes over a button
1174 b->button.set_highlight_action( common_play_highlight_sound );
1175 b->button.set_bmaps(Buttons[gr_screen.res][i].filename);
1176 b->button.link_hotspot(Buttons[gr_screen.res][i].hotspot);
1179 if ( Game_mode & GM_MULTIPLAYER ) {
1180 Buttons[gr_screen.res][WL_BUTTON_RESET].button.hide();
1181 Buttons[gr_screen.res][WL_BUTTON_RESET].button.disable();
1183 // if we're not the host of the game (or a team captain in team vs. team mode), disable the lock button
1184 if(Netgame.type_flags & NG_TYPE_TEAM){
1185 if(!(Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN)){
1186 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.disable();
1189 if(!(Net_player->flags & NETINFO_FLAG_GAME_HOST)){
1190 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.disable();
1194 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.hide();
1195 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.disable();
1199 for(i=0; i<WEAPON_SELECT_NUM_TEXT; i++) {
1200 Weapon_ui_window.add_XSTR(&Weapon_select_text[gr_screen.res][i]);
1203 Buttons[gr_screen.res][WL_BUTTON_DUMMY].button.hide();
1204 Buttons[gr_screen.res][WL_BUTTON_DUMMY].button.disable();
1207 // ---------------------------------------------------------------------------------
1208 // wl_render_overhead_view()
1210 void wl_render_overhead_view(float frametime)
1212 char name[NAME_LENGTH + CALLSIGN_LEN];
1213 wl_ship_class_info *wl_ship;
1216 if ( Selected_wl_slot == -1 ) {
1220 ship_class = Wss_slots[Selected_wl_slot].ship_class;
1222 // check if ship class has changed and maybe play sound
1223 if (Last_wl_ship_class != ship_class) {
1224 if (Last_wl_ship_class != -1) {
1225 gamesnd_play_iface(SND_ICON_DROP);
1227 Last_wl_ship_class = ship_class;
1230 wl_ship = &Wl_ships[ship_class];
1232 if ( wl_ship->anim_instance == NULL ) {
1233 if ( wl_ship->overhead_bitmap < 0 ) {
1235 if (gr_screen.res == GR_640)
1238 wl_ship->overhead_bitmap = bm_load(Ship_info[ship_class].overhead_filename);
1241 char filename[NAME_LENGTH+2] = "2_";
1242 strcat(filename, Ship_info[ship_class].overhead_filename);
1243 wl_ship->overhead_bitmap = bm_load(filename);
1245 if ( wl_ship->overhead_bitmap < 0 ) {
1246 Int3(); // bad things happened
1250 gr_set_bitmap(wl_ship->overhead_bitmap);
1251 gr_bitmap(Wl_overhead_coords[gr_screen.res][0], Wl_overhead_coords[gr_screen.res][1]);
1254 ss_return_name(Selected_wl_slot/4, Selected_wl_slot%4, name);
1255 gr_set_color_fast(&Color_normal);
1256 gr_string(Wl_ship_name_coords[gr_screen.res][0], Wl_ship_name_coords[gr_screen.res][1], name);
1259 // ---------------------------------------------------------------------------------
1260 // wl_get_ship_class()
1263 int wl_get_ship_class(int wl_slot)
1265 return Wss_slots[wl_slot].ship_class;
1268 // Return true if weapon_flags indicates a weapon that is legal for use in current game type.
1269 // Function added by MK on 9/6/99 to support separate legal loadouts for dogfight missions.
1270 int weapon_allowed_for_game_type(int weapon_flags)
1274 /* disable check for demo since it doesn't have "$Allowed Dogfight PBanks" */
1275 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
1276 if ((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT)) {
1277 if (weapon_flags & (1 << 1))
1281 if (weapon_flags & (1 << 0))
1287 // go through the possible weapons to choose from, and flag some as disabled since
1288 // that ship class cannot use that kind of weapon. The weapon filter is specified
1289 // in ships.tbl, where each ship has a list of all the possible weapons it can use.
1290 void wl_set_disabled_weapons(int ship_class)
1295 if ( ship_class == - 1 )
1298 Assert(ship_class >= 0 && ship_class < MAX_SHIP_TYPES);
1300 sip = &Ship_info[ship_class];
1302 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1303 // Determine whether weapon #i is allowed on this ship class in the current type of mission.
1304 // As of 9/6/99, the only difference is dogfight missions have a different list of legal weapons.
1305 Wl_icons[i].can_use = weapon_allowed_for_game_type(sip->allowed_weapons[i]);
1309 // ---------------------------------------------------------------------------------
1310 // maybe_select_wl_slot()
1312 // A slot index was clicked on, mabye change Selected_wl_slot
1313 void maybe_select_wl_slot(int block, int slot)
1317 if ( Wss_num_wings <= 0 )
1320 sidx = block*4 + slot;
1321 if ( Wss_slots[sidx].ship_class < 0 ) {
1325 wl_set_selected_slot(sidx);
1328 // ---------------------------------------------------------------------------------
1329 // maybe_select_new_weapon()
1331 // Change to the weapon that corresponds to index in the weapon list
1333 // input: index => weapon icon index (0-7)
1335 void maybe_select_new_weapon(int index)
1339 // if a weapon is being carried, do nothing
1340 if ( wl_icon_being_carried() ) {
1344 int region_index = ICON_PRIMARY_0+index;
1346 region_index = ICON_SECONDARY_0 + (index - 4);
1349 if ( Wl_mouse_down_on_region != region_index ) {
1354 weapon_class = Plist[Plist_start+index];
1356 weapon_class = Slist[Slist_start+index-4];
1359 if ( weapon_class >= 0 ) {
1360 Selected_wl_class = weapon_class;
1361 wl_pick_icon_from_list(index);
1365 // ---------------------------------------------------------------------------------
1366 // maybe_select_new_ship_weapon()
1368 // Change to the weapon that corresponds to the ship weapon slot
1370 // input: index -> index of bank (0..2 primary, 0..6 secondary)
1371 void maybe_select_new_ship_weapon(int index)
1373 int *wep, *wep_count;
1375 if ( Selected_wl_slot == -1 )
1378 if ( wl_icon_being_carried() ) {
1382 wep = Wss_slots[Selected_wl_slot].wep;
1383 wep_count = Wss_slots[Selected_wl_slot].wep_count;
1385 if ( wep[index] < 0 || wep_count[index] <= 0 ) {
1389 if ( Wl_mouse_down_on_region != (ICON_SHIP_PRIMARY_0+index) ) {
1394 Selected_wl_class = wep[index];
1397 // Initialize Wl_pool[] to mission deafult
1398 void wl_init_pool(team_data *td)
1402 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1406 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1407 Wl_pool[i] = td->weaponry_pool[i]; // read from mission
1411 // load the icons for a specific ship class
1412 void wl_load_icons(int weapon_class)
1415 int first_frame, num_frames, i;
1417 icon = &Wl_icons[weapon_class];
1419 first_frame = bm_load_animation(Weapon_info[weapon_class].icon_filename, &num_frames);
1420 if ( first_frame == -1 ) {
1421 Int3(); // Could not load in icon frames.. get Alan
1425 for ( i = 0; i < num_frames ; i++ ) {
1426 icon->icon_bmaps[i] = first_frame+i;
1430 // Load in a specific weapon animation. The data is loaded as a memory-mapped file since these animations
1432 void wl_load_anim(int weapon_class)
1434 char animation_filename[CF_MAX_FILENAME_LENGTH+4];
1437 icon = &Wl_icons[weapon_class];
1438 Assert( icon->anim == NULL );
1441 // If we are in 1024x768, we first want to append "2_" in front of the filename
1442 if (gr_screen.res == GR_1024) {
1443 Assert(strlen(Weapon_info[weapon_class].anim_filename) <= 30);
1444 strcpy(animation_filename, "2_");
1445 strcat(animation_filename, Weapon_info[weapon_class].anim_filename);
1447 // now check if file exists
1448 // GRR must add a .ANI at the end for detection
1449 strcat(animation_filename,".ani");
1450 icon->anim = anim_load(animation_filename, 1);
1452 if (icon->anim == NULL) {
1453 mprintf(("Weapon ANI: Can not find %s, using lowres version instead.\n",animation_filename));
1454 strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
1455 icon->anim = anim_load(animation_filename, 1);
1459 if (!cf_exist(animation_filename, CF_TYPE_INTERFACE)) {
1460 // file does not exist, use original low res version
1461 mprintf(("Weapon ANI: Can not find %s, using lowres version instead.\n",animation_filename));
1462 strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
1464 animation_filename[strlen(animation_filename) - 4] = '\0';
1465 mprintf(("Weapon ANI: Found hires version of %s\n",animation_filename));
1469 strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
1470 // load the compressed ship animation into memory
1471 // NOTE: if last parm of load_anim is 1, the anim file is mapped to memory
1472 icon->anim = anim_load(animation_filename, 1);
1475 if ( icon->anim == NULL ) {
1476 Int3(); // couldn't load anim filename.. get Alan
1480 // Load in any weapon animations. This function assumes that Wl_pool has been inited.
1481 void wl_load_all_anims()
1483 #ifndef DEMO // not for FS2_DEMO
1487 // init anim members for weapon animations
1488 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1489 Wl_icons[i].anim = NULL;
1490 Wl_icons[i].anim_instance = NULL;
1493 // init anim member for overhead ship animations
1494 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1495 Wl_ships[i].anim = NULL;
1496 Wl_ships[i].anim_instance = NULL;
1499 // load up the animations used for weapons (they are memory-mapped)
1500 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1501 if ( Wl_pool[i] > 0 ) {
1509 // release any anim instances
1510 void wl_unload_all_anim_instances()
1512 // stop any weapon anim instances
1513 for ( int i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1514 if ( Wl_icons[i].anim_instance ) {
1515 anim_release_render_instance(Wl_icons[i].anim_instance);
1516 Wl_icons[i].anim_instance = NULL;
1520 // stop any overhead anim instances
1521 for (int i = 0; i < MAX_SHIP_TYPES; i++ ) {
1522 if ( Wl_ships[i].anim_instance ) {
1523 anim_release_render_instance(Wl_ships[i].anim_instance);
1524 Wl_ships[i].anim_instance = NULL;
1529 // free source anim data if allocated
1530 void wl_unload_all_anims()
1534 // unload overhead anim instances
1535 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1536 if ( Wl_ships[i].anim ) {
1537 anim_free(Wl_ships[i].anim);
1538 Wl_ships[i].anim = NULL;
1542 // unload weapon anim instances
1543 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1544 if ( Wl_icons[i].anim ) {
1545 anim_free(Wl_icons[i].anim);
1546 Wl_icons[i].anim = NULL;
1551 // load all the icons for weapons in the pool
1552 void wl_load_all_icons()
1554 #ifndef DEMO // not for FS2_DEMO
1558 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1560 Wl_icons[i].anim = NULL;
1561 Wl_icons[i].anim_instance = NULL;
1562 for ( j = 0; j < NUM_ICON_FRAMES; j++ ) {
1563 Wl_icons[i].icon_bmaps[j] = -1;
1566 if ( Wl_pool[i] > 0 ) {
1574 // wl_unload_icons() frees the bitmaps used for weapon icons
1575 void wl_unload_icons()
1580 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1581 icon = &Wl_icons[i];
1583 for ( j = 0; j < NUM_ICON_FRAMES; j++ ) {
1584 if ( icon->icon_bmaps[j] >= 0 ) {
1585 bm_release(icon->icon_bmaps[j]);
1586 icon->icon_bmaps[j] = -1;
1592 // init ship-class specific data
1593 void wl_init_ship_class_data()
1596 wl_ship_class_info *wl_ship;
1598 for ( i=0; i<MAX_SHIP_TYPES; i++ ) {
1599 wl_ship = &Wl_ships[i];
1600 wl_ship->overhead_bitmap = -1;
1601 wl_ship->anim = NULL;
1602 wl_ship->anim_instance = NULL;
1606 // free any allocated ship-class specific data
1607 void wl_free_ship_class_data()
1610 wl_ship_class_info *wl_ship;
1612 for ( i=0; i<MAX_SHIP_TYPES; i++ ) {
1613 wl_ship = &Wl_ships[i];
1615 if ( wl_ship->overhead_bitmap != -1 ) {
1616 bm_release(wl_ship->overhead_bitmap);
1617 wl_ship->overhead_bitmap = -1;
1620 if ( wl_ship->anim != NULL ) {
1621 wl_ship->anim = NULL;
1624 if ( wl_ship->anim_instance != NULL ) {
1625 wl_ship->anim_instance = NULL;
1630 // Set selected slot to first placed ship
1631 void wl_reset_selected_slot()
1634 Selected_wl_slot = -1;
1636 // in multiplayer, select the slot of the player's ship by default
1637 if((Game_mode & GM_MULTIPLAYER) && !MULTI_PERM_OBSERVER(Net_players[MY_NET_PLAYER_NUM]) && (Wss_slots[Net_player->p_info.ship_index].ship_class >= 0)){
1638 wl_set_selected_slot(Net_player->p_info.ship_index);
1642 for ( i=0; i<MAX_WSS_SLOTS; i++ ) {
1643 if ( !ss_disabled_slot(i) ) {
1644 if ( ss_wing_slot_is_console_player(i) && (Wss_slots[i].ship_class >= 0) ) {
1645 wl_set_selected_slot(i);
1651 // Didn't locate player ship, so just select the first ship we find
1652 for ( i=0; i<MAX_WSS_SLOTS; i++ ) {
1653 if ( Wss_slots[i].ship_class >= 0 ) {
1654 wl_set_selected_slot(i);
1660 // called whenever it is possible that the current selected slot has had it's ship disappear
1661 void wl_maybe_reset_selected_slot()
1665 if ( Selected_wl_slot == -1 ) {
1669 if ( Wss_slots[Selected_wl_slot].ship_class < 0 ) {
1674 wl_reset_selected_slot();
1678 // If Selected_wl_class is -1, choose the first weapon available from the pool for an animation
1679 // - on second thought, choose the first weapon that is oin the ship, then go to the pools
1680 void wl_maybe_reset_selected_weapon_class()
1684 if ( Selected_wl_class >= 0 )
1687 // try to locate a weapon class to show animation for
1688 // first check for a weapon on the ship
1689 for (i=0; i<MAX_WL_WEAPONS; i++) {
1690 // if alpha 1 has a weapon in bank i, set it as the selected type
1691 if (Wss_slots[0].wep_count[i] >= 0) {
1692 Selected_wl_class = Wss_slots[0].wep[i];
1697 // then check for a primary weapon in the pool
1698 for ( i = 0; i < Plist_size; i++ ) {
1699 if ( Plist[i] >= 0 ) {
1700 Selected_wl_class = Plist[i];
1705 // finally, if no others found yet, check for a secondary weapon in the pool
1706 for ( i = 0; i < Slist_size; i++ ) {
1707 if ( Slist[i] >= 0 ) {
1708 Selected_wl_class = Slist[i];
1714 // start an overhead animation, since selected slot has changed
1715 void wl_start_slot_animation(int n)
1717 #ifndef DEMO // not for FS2_DEMO
1720 // fallback code in wl_render_overhead_view() will
1721 // use the .pcx files
1722 // should prolly scrub out the 1e06 lines of dead code this leaves
1727 wl_ship_class_info *wl_ship;
1728 anim_play_struct aps;
1734 ship_class = Wss_slots[n].ship_class;
1736 if ( ship_class < 0 ) {
1741 wl_ship = &Wl_ships[ship_class];
1743 // maybe this animation is already playing?
1744 if ( wl_ship->anim_instance ) {
1745 anim_stop_playing(wl_ship->anim_instance);
1746 wl_ship->anim_instance = NULL;
1749 // maybe we have to load this animation
1750 if ( wl_ship->anim == NULL ) {
1751 wl_ship->anim = anim_load(Ship_info[ship_class].overhead_filename, 1);
1752 if ( wl_ship->anim == NULL ) {
1753 Int3(); // couldn't load anim filename.. get Alan
1758 anim_play_init(&aps, wl_ship->anim, Wl_overhead_coords[gr_screen.res][0], Wl_overhead_coords[gr_screen.res][1]);
1759 aps.screen_id = ON_WEAPON_SELECT;
1760 aps.framerate_independent = 1;
1761 aps.skip_frames = 0;
1762 wl_ship->anim_instance = anim_play(&aps);
1767 // Call when Selected_wl_slot needs to be changed
1768 void wl_set_selected_slot(int slot_num)
1770 if ( (slot_num >= 0) && (slot_num != Selected_wl_slot) ) {
1771 // slot has changed.... start an animation
1772 wl_start_slot_animation(slot_num);
1774 if ( Current_screen == ON_WEAPON_SELECT ) {
1775 gamesnd_play_iface(SND_OVERHEAD_SHIP_ANIM);
1780 Selected_wl_slot = slot_num;
1781 if ( Selected_wl_slot >= 0 ) {
1782 wl_set_disabled_weapons(Wss_slots[slot_num].ship_class);
1786 // determine how many missiles of type 'wi_index' will fit into capacity
1787 int wl_calc_missile_fit(int wi_index, int capacity)
1789 if ( wi_index < 0 ) {
1793 Assert(Weapon_info[wi_index].subtype == WP_MISSILE);
1794 return fl2i( capacity / Weapon_info[wi_index].cargo_size + 0.5f );
1797 // fill out the weapons for this ship_class
1798 void wl_get_ship_class_weapons(int ship_class, int *wep, int *wep_count)
1803 Assert(ship_class >= 0 && ship_class < MAX_SHIP_TYPES);
1804 sip = &Ship_info[ship_class];
1806 // reset weapons arrays
1807 for ( i=0; i < MAX_WL_WEAPONS; i++ ) {
1809 wep_count[i] = -1; // -1 means weapon bank doesn't exist.. 0 just means it is empty
1812 for ( i = 0; i < sip->num_primary_banks; i++ ) {
1813 wep[i] = sip->primary_bank_weapons[i];
1817 for ( i = 0; i < sip->num_secondary_banks; i++ ) {
1818 wep[i+MAX_WL_PRIMARY] = sip->secondary_bank_weapons[i];
1819 wep_count[i+MAX_WL_PRIMARY] = wl_calc_missile_fit(sip->secondary_bank_weapons[i], sip->secondary_bank_ammo_capacity[i]);
1823 // fill out the wep[] and wep_count[] arrays for a ship
1824 void wl_get_ship_weapons(int ship_index, int *wep, int *wep_count)
1830 Assert(ship_index >= 0);
1832 Assert(Ships[ship_index].wingnum >= 0);
1833 wp = &Wings[Ships[ship_index].wingnum];
1834 swp = &Ships[ship_index].weapons;
1836 for ( i = 0; i < swp->num_primary_banks; i++ ) {
1837 wep[i] = swp->primary_bank_weapons[i];
1839 if ( wep[i] == -1 ) {
1844 for ( i = 0; i < swp->num_secondary_banks; i++ ) {
1845 wep[i+MAX_WL_PRIMARY] = swp->secondary_bank_weapons[i];
1846 wep_count[i+MAX_WL_PRIMARY] = swp->secondary_bank_ammo[i];
1847 if ( wep[i+MAX_WL_PRIMARY] == -1 ) {
1848 wep_count[i+MAX_WL_PRIMARY] = 0;
1853 // set wep and wep_count from a ship which sits in the ship_arrivals[] list at index sa_index
1854 void wl_get_parseobj_weapons(int sa_index, int ship_class, int *wep, int *wep_count)
1861 pobjp = &ship_arrivals[sa_index];
1862 sip = &Ship_info[ship_class];
1864 pilot_index = wl_get_pilot_subsys_index(pobjp);
1866 if ( pilot_index == -1 )
1869 ss = &Subsys_status[pilot_index];
1871 if ( ss->primary_banks[0] != SUBSYS_STATUS_NO_CHANGE ) {
1872 for ( i=0; i < MAX_PRIMARY_BANKS; i++ ) {
1873 wep[i] = ss->primary_banks[i];
1877 if ( ss->secondary_banks[0] != SUBSYS_STATUS_NO_CHANGE ) {
1878 for ( i=0; i < MAX_SECONDARY_BANKS; i++ ) {
1879 wep[i+MAX_WL_PRIMARY] = ss->secondary_banks[i];
1883 // ammo counts could still be modified
1884 for ( i=0; i < MAX_SECONDARY_BANKS; i++ ) {
1885 if ( wep[i+MAX_WL_PRIMARY] >= 0 ) {
1886 wep_count[i+MAX_WL_PRIMARY] = wl_calc_missile_fit(wep[i+MAX_WL_PRIMARY], fl2i(ss->secondary_ammo[i]/100.0f * sip->secondary_bank_ammo_capacity[i] + 0.5f));
1891 // ensure that there aren't any bogus weapons assigned by default
1892 void wl_cull_illegal_weapons(int ship_class, int *wep, int *wep_count)
1895 for ( i=0; i < MAX_WL_WEAPONS; i++ ) {
1900 if ( !weapon_allowed_for_game_type(Ship_info[ship_class].allowed_weapons[wep[i]]) ) {
1907 // get the weapons info that should be on ship by default
1908 void wl_get_default_weapons(int ship_class, int slot_num, int *wep, int *wep_count)
1910 int original_ship_class, i;
1912 Assert(slot_num >= 0 && slot_num < MAX_WSS_SLOTS);
1914 // clear out wep and wep_count
1915 for ( i = 0; i < MAX_WL_WEAPONS; i++ ) {
1920 if ( ship_class < 0 )
1923 original_ship_class = ss_return_original_ship_class(slot_num);
1925 if ( original_ship_class != ship_class ) {
1926 wl_get_ship_class_weapons(ship_class, wep, wep_count);
1928 int sa_index; // ship arrival index
1929 sa_index = ss_return_saindex(slot_num);
1931 if ( sa_index >= 0 ) {
1932 // still a parse object
1933 wl_get_ship_class_weapons(ship_class, wep, wep_count);
1934 wl_get_parseobj_weapons(sa_index, ship_class, wep, wep_count);
1936 // ship has been created
1937 // wl_get_ship_weapons(slot_num/4, slot_num%4, wep, wep_count);
1938 int ship_index = -1;
1940 ss_return_ship(slot_num/4, slot_num%4, &ship_index, &pobjp);
1941 Assert(ship_index != -1);
1942 wl_get_ship_weapons(ship_index, wep, wep_count);
1946 // ensure that there aren't any bogus weapons assigned by default
1947 wl_cull_illegal_weapons(ship_class, wep, wep_count);
1950 // function to add a weapon_class to ui lists
1951 void wl_add_index_to_list(int wi_index)
1954 if ( Weapon_info[wi_index].subtype == WP_MISSILE ) {
1956 for ( i=0; i<Slist_size; i++ ) {
1957 if ( Slist[i] == wi_index )
1961 if ( i == Slist_size )
1962 Slist[Slist_size++] = wi_index;
1965 for ( i=0; i<Plist_size; i++ ) {
1966 if ( Plist[i] == wi_index )
1970 if ( i == Plist_size )
1971 Plist[Plist_size++] = wi_index;
1975 // remove the weapons specificed by wep[] and wep_count[] from Wl_pool[].
1976 void wl_remove_weps_from_pool(int *wep, int *wep_count, int ship_class)
1980 for ( i = 0; i < MAX_WL_WEAPONS; i++ ) {
1982 if ( wi_index >= 0 ) {
1983 if ( (wep_count[i] > 0) && ((Wl_pool[wi_index] - wep_count[i]) >= 0) ) {
1984 Wl_pool[wi_index] -= wep_count[i];
1986 // not enough weapons in pool
1987 // TEMP HACK: FRED doesn't fill in a weapons pool if there are no starting wings... so
1988 // add to the pool. This should be fixed.
1989 if ( Wss_num_wings <= 0 ) {
1990 wl_add_index_to_list(wi_index);
1993 if ( (Wl_pool[wi_index] <= 0) || (wep_count[i] == 0) ) {
1994 // fresh out of this weapon, pick an alternate pool weapon if we can
1995 int wep_pool_index, wep_precedence_index, new_wi_index = -1;
1996 for ( wep_pool_index = 0; wep_pool_index < MAX_WEAPON_TYPES; wep_pool_index++ ) {
1998 if ( Wl_pool[wep_pool_index] <= 0 ) {
2002 // AL 3-31-98: Only pick another primary if primary, etc
2003 if ( Weapon_info[wi_index].subtype != Weapon_info[wep_pool_index].subtype ) {
2007 if ( !weapon_allowed_for_game_type(Ship_info[ship_class].allowed_weapons[wep_pool_index]) ) {
2012 for ( wep_precedence_index = 0; wep_precedence_index < Num_player_weapon_precedence; wep_precedence_index++ ) {
2013 if ( wep_pool_index == Player_weapon_precedence[wep_precedence_index] ) {
2014 new_wi_index = wep_pool_index;
2019 if ( new_wi_index >= 0 ) {
2024 if ( new_wi_index >= 0 ) {
2025 wep[i] = new_wi_index;
2026 wi_index = new_wi_index;
2030 int new_wep_count = wep_count[i];
2031 if ( Weapon_info[wi_index].subtype == WP_MISSILE ) {
2032 int secondary_bank_index;
2033 secondary_bank_index = i-3;
2034 if ( secondary_bank_index < 0 ) {
2036 secondary_bank_index = 0;
2038 new_wep_count = wl_calc_missile_fit(wi_index, Ship_info[ship_class].secondary_bank_ammo_capacity[secondary_bank_index]);
2041 wep_count[i] = min(new_wep_count, Wl_pool[wi_index]);
2042 Assert(wep_count[i] >= 0);
2043 Wl_pool[wi_index] -= wep_count[i];
2044 if ( wep_count[i] <= 0 ) {
2053 // Init the weapons portion of Wss_slots[] and the ui data in Wl_slots[]
2054 // NOTE: it is assumed that Wl_pool[] has been initialized, and Wss_slots[].ship_class is correctly set
2055 void wl_fill_slots()
2058 int wep[MAX_WL_WEAPONS];
2059 int wep_count[MAX_WL_WEAPONS];
2061 for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
2062 if ( Wss_slots[i].ship_class < 0 ){
2066 // get the weapons info that should be on ship by default
2067 wl_get_default_weapons(Wss_slots[i].ship_class, i, wep, wep_count);
2068 wl_remove_weps_from_pool(wep, wep_count, Wss_slots[i].ship_class);
2070 // copy to Wss_slots[]
2071 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
2072 Wss_slots[i].wep[j] = wep[j];
2073 Wss_slots[i].wep_count[j] = wep_count[j];
2078 // set up the primary and secondary icons lists that hold the weapons the player can choose from
2079 void wl_init_icon_lists()
2083 Plist_start = 0; // offset into Plist[]
2086 Plist_size = 0; // number of active elements in Plist[]
2089 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
2094 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
2095 if ( Wl_pool[i] > 0 ) {
2096 if ( Weapon_info[i].subtype == WP_MISSILE ) {
2097 Slist[Slist_size++] = i;
2099 Plist[Plist_size++] = i;
2105 // initialize team specific weapon select data structures
2106 void weapon_select_init_team(int team_num)
2108 Wl_icons = Wl_icons_teams[team_num];
2109 ss_set_team_pointers(team_num);
2111 wl_init_pool(&Team_data[team_num]);
2112 wl_init_icon_lists();
2113 wl_init_ship_class_data();
2115 wl_load_all_icons();
2116 wl_load_all_anims();
2121 // This init is called even before the weapons loadout screen is entered. It is called when the
2122 // briefing state is entered.
2123 void weapon_select_common_init()
2127 if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){
2128 // initialize for all teams
2129 for(idx=0;idx<MULTI_TS_MAX_TEAMS;idx++){
2130 weapon_select_init_team(idx);
2133 // re-initialize for me specifically
2134 weapon_select_init_team(Common_team);
2136 // initialize for my own team
2137 weapon_select_init_team(Common_team);
2140 wl_reset_selected_slot();
2141 wl_reset_carried_icon();
2142 wl_maybe_reset_selected_weapon_class();
2145 // ---------------------------------------------------------------------------------
2146 // weapon_select_init() is called to load the bitmaps and set up the mask regions for
2147 // the weapon loadout screen. common_select_init() is called to load the animations
2148 // and bitmaps which are in common with the ship select and briefing screens.
2150 // The Weapon_select_open flag is set to 1 when weapon_select_init() completes successfully
2152 void weapon_select_init()
2154 common_set_interface_palette("WeaponPalette");
2155 common_flash_button_init();
2157 // for multiplayer, change the state in my netplayer structure
2158 if ( Game_mode & GM_MULTIPLAYER )
2159 Net_player->state = NETPLAYER_STATE_WEAPON_SELECT;
2161 ship_stop_animation();
2162 stop_weapon_animation();
2163 Weapon_anim_class = -1;
2165 set_active_ui(&Weapon_ui_window);
2166 Current_screen = ON_WEAPON_SELECT;
2167 Last_wl_ship_class = -1;
2169 wl_maybe_reset_selected_slot();
2170 wl_set_disabled_weapons(Wss_slots[Selected_wl_slot].ship_class);
2172 help_overlay_set_state(WL_OVERLAY,0);
2174 if ( Weapon_select_open ) {
2175 wl_maybe_reset_selected_weapon_class();
2176 wl_start_slot_animation(Selected_wl_slot);
2177 common_buttons_maybe_reload(&Weapon_ui_window); // AL 11-21-97: this is necessary since we may returning from the hotkey
2178 // screen, which can release common button bitmaps.
2179 common_reset_buttons();
2180 nprintf(("Alan","weapon_select_init() returning without doing anything\n"));
2182 // if we're in multiplayer always select the player's ship
2183 wl_reset_selected_slot();
2188 nprintf(("Alan","entering weapon_select_init()\n"));
2189 common_select_init();
2191 WeaponSelectMaskBitmap = bm_load(Wl_loadout_select_mask[gr_screen.res]);
2192 if (WeaponSelectMaskBitmap < 0) {
2193 if (gr_screen.res == GR_640) {
2194 Error(LOCATION,"Could not load in 'weaponloadout-m'!");
2195 } else if (gr_screen.res == GR_1024) {
2196 Error(LOCATION,"Could not load in '2_weaponloadout-m'!");
2198 Error(LOCATION,"Could not load in 'weaponloadout-m'!");
2202 Weaponselect_mask_w = -1;
2203 Weaponselect_mask_h = -1;
2205 // get a pointer to bitmap by using bm_lock()
2206 WeaponSelectMaskPtr = bm_lock(WeaponSelectMaskBitmap, 8, BMP_AABITMAP);
2207 WeaponSelectMaskData = (ubyte*)WeaponSelectMaskPtr->data;
2208 Assert(WeaponSelectMaskData != NULL);
2209 bm_get_info(WeaponSelectMaskBitmap, &Weaponselect_mask_w, &Weaponselect_mask_h);
2212 // Set up the mask regions
2213 // initialize the different regions of the menu that will react when the mouse moves over it
2214 Num_weapon_select_regions = 0;
2216 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_BRIEFING_REGION, 0);
2217 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_SS_REGION, 0);
2218 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_WEAPON_REGION, 0);
2219 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_COMMIT_REGION, 0);
2220 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_HELP_REGION, 0);
2221 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_OPTIONS_REGION, 0);
2223 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_0_SHIP_0, 0);
2224 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_0_SHIP_1, 0);
2225 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_0_SHIP_2, 0);
2226 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_0_SHIP_3, 0);
2227 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_1_SHIP_0, 0);
2228 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_1_SHIP_1, 0);
2229 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_1_SHIP_2, 0);
2230 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_1_SHIP_3, 0);
2231 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_2_SHIP_0, 0);
2232 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_2_SHIP_1, 0);
2233 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_2_SHIP_2, 0);
2234 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_2_SHIP_3, 0);
2236 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_PRIMARY_0, 0);
2237 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_PRIMARY_1, 0);
2238 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_PRIMARY_2, 0);
2239 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_PRIMARY_3, 0);
2240 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SECONDARY_0, 0);
2241 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SECONDARY_1, 0);
2242 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SECONDARY_2, 0);
2243 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SECONDARY_3, 0);
2245 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_PRIMARY_0, 0);
2246 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_PRIMARY_1, 0);
2247 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_PRIMARY_2, 0);
2248 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_SECONDARY_0, 0);
2249 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_SECONDARY_1, 0);
2250 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_SECONDARY_2, 0);
2251 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_SECONDARY_3, 0);
2254 Weapon_ui_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
2256 if(Game_mode & GM_MULTIPLAYER){
2257 Weapon_ui_window.set_mask_bmap(Wl_mask_multi[gr_screen.res]);
2259 Weapon_ui_window.set_mask_bmap(Wl_mask_single[gr_screen.res]);
2262 // initialize background bitmap
2263 if(Game_mode & GM_MULTIPLAYER) {
2264 Weapon_select_background_bitmap = bm_load(Weapon_select_multi_background_fname[gr_screen.res]);
2266 Weapon_select_background_bitmap = bm_load(Weapon_select_background_fname[gr_screen.res]);
2269 Weapon_ui_window.tooltip_handler = wl_tooltip_handler;
2270 common_buttons_init(&Weapon_ui_window);
2271 weapon_buttons_init();
2272 Weapon_select_open = 1;
2274 // if we're in multiplayer always select the player's ship
2275 wl_reset_selected_slot();
2278 // ----------------------------------------------------------------
2279 // wl_dump_carried_icon()
2280 void wl_dump_carried_icon()
2282 if ( wl_icon_being_carried() ) {
2283 // Add back into the weapon pool
2284 if ( Carried_wl_icon.from_bank >= 0 ) {
2286 wl_drop(Carried_wl_icon.from_bank, -1, -1, Carried_wl_icon.weapon_class, Carried_wl_icon.from_slot);
2288 if ( wl_carried_icon_moved() ) {
2289 gamesnd_play_iface(SND_ICON_DROP);
2293 wl_reset_carried_icon();
2297 // ----------------------------------------------------------------
2298 // drop_icon_on_slot()
2300 // Drop the Carried_wl_icon onto the specified slot. The slot numbering is:
2302 // 0->2: primary weapons
2303 // 3-6: secondary weapons
2305 // These are the slots that exist beside the overhead view of the ship.
2306 // on the weapons loadout screen.
2308 int drop_icon_on_slot(int bank_num)
2310 if ( Selected_wl_slot == -1 ) {
2314 if(Game_mode & GM_MULTIPLAYER){
2315 if(multi_ts_disabled_slot(Selected_wl_slot)){
2319 if ( ss_disabled_slot( Selected_wl_slot ) ){
2324 // check if slot exists
2325 if ( Wss_slots[Selected_wl_slot].wep_count[bank_num] < 0 ) {
2329 if ( !wl_carried_icon_moved() ) {
2330 wl_reset_carried_icon();
2334 wl_drop(Carried_wl_icon.from_bank, Carried_wl_icon.weapon_class, bank_num, -1, Selected_wl_slot);
2338 // ----------------------------------------------------------------
2339 // maybe_drop_icon_on_slot()
2341 void maybe_drop_icon_on_slot(int bank_num)
2344 if ( !mouse_down(MOUSE_LEFT_BUTTON) ) {
2345 if ( wl_icon_being_carried() )
2346 dropped = drop_icon_on_slot(bank_num);
2349 wl_reset_carried_icon();
2354 // ----------------------------------------------------------------
2355 // wl_check_for_stopped_ship_anims()
2357 void wl_check_for_stopped_ship_anims()
2361 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
2362 ai = Wl_ships[i].anim_instance;
2364 if ( !anim_playing(ai) ) {
2365 Wl_ships[i].anim_instance = NULL;
2371 // ---------------------------------------------------------------------------------
2372 // do_mouse_over_list_weapon()
2374 void do_mouse_over_list_weapon(int index)
2376 Hot_weapon_icon = index;
2378 int region_index = ICON_PRIMARY_0+index;
2380 region_index = ICON_SECONDARY_0 + (index - 4);
2383 if ( Wl_mouse_down_on_region != region_index ){
2387 if ( mouse_down(MOUSE_LEFT_BUTTON) )
2388 wl_pick_icon_from_list(index);
2391 // ---------------------------------------------------------------------------------
2392 // do_mouse_over_ship_weapon()
2395 // input: index -> bank index on ship (0..6)
2398 // 0 -> icon was not dropped on a slot
2399 // 1 -> icon was dropped on a slot
2400 int do_mouse_over_ship_weapon(int index)
2402 int dropped_on_slot, is_moved, mx, my;
2404 dropped_on_slot = 0;
2405 Assert(Selected_wl_slot >= 0);
2407 if ( ss_disabled_slot( Selected_wl_slot ) )
2410 Hot_weapon_bank_icon = index; // bank icon will be drawn highlighted
2412 if ( mouse_down(MOUSE_LEFT_BUTTON) ) {
2413 if ( Wl_mouse_down_on_region == (ICON_SHIP_PRIMARY_0+index) ){
2414 pick_from_ship_slot(index);
2417 int was_carried = wl_icon_being_carried();
2418 maybe_drop_icon_on_slot(index);
2419 if ( was_carried && !wl_icon_being_carried() ) {
2420 mouse_get_pos( &mx, &my );
2421 if ( Carried_wl_icon.from_x != mx || Carried_wl_icon.from_y != my) {
2422 dropped_on_slot = 1;
2427 // set Hot_weapon_bank if a droppable icon is being held over a slot that
2428 // can accept that icon
2430 mouse_get_pos( &mx, &my );
2431 if ( Carried_wl_icon.from_x != mx || Carried_wl_icon.from_y != my) {
2435 if ( wl_icon_being_carried() && is_moved ) {
2436 if ( Weapon_info[Carried_wl_icon.weapon_class].subtype != WP_MISSILE ) {
2437 if ( (index < 3) && (Wss_slots[Selected_wl_slot].wep_count[index] >= 0) )
2438 Hot_weapon_bank = index;
2440 if ( index >= 3 && ( Wss_slots[Selected_wl_slot].wep_count[index] >= 0) )
2441 Hot_weapon_bank = index;
2445 return dropped_on_slot;
2449 // maybe flash a button if player hasn't done anything for a while
2450 void wl_maybe_flash_button()
2452 if ( common_flash_bright() ) {
2454 if ( Common_buttons[Current_screen-1][gr_screen.res][3].button.button_hilighted() ) {
2455 common_flash_button_init();
2457 Common_buttons[Current_screen-1][gr_screen.res][3].button.draw_forced(1);
2463 void weapon_select_render(float frametime)
2465 if ( !Background_playing ) {
2466 gr_set_bitmap(Weapon_select_background_bitmap);
2470 anim_render_all(0, frametime);
2471 anim_render_all(ON_SHIP_SELECT, frametime);
2474 // draw the weapon description text
2476 void wl_render_weapon_desc(float frametime)
2479 int *weapon_desc_coords;
2480 int *weapon_title_coords;
2482 // retrieve the correct set of text coordinates
2483 if (Game_mode & GM_MULTIPLAYER) {
2484 weapon_desc_coords = Wl_new_weapon_desc_coords_multi[gr_screen.res];
2485 weapon_title_coords = Wl_new_weapon_title_coords_multi[gr_screen.res];
2487 weapon_desc_coords = Wl_new_weapon_desc_coords[gr_screen.res];
2488 weapon_title_coords = Wl_new_weapon_title_coords[gr_screen.res];
2491 // render the normal version of the weapom desc
2492 char bright_char[WEAPON_DESC_MAX_LINES]; // one bright char per line
2493 if (!Weapon_desc_wipe_done) {
2494 // draw mid-wipe version
2495 // decide which char is last (and bright)
2496 int bright_char_index = (int)(Weapon_desc_wipe_time_elapsed * WEAPON_DESC_MAX_LENGTH / WEAPON_DESC_WIPE_TIME);
2497 int i, w, h, curr_len;
2499 // draw weapon title (above weapon anim)
2500 for (i=0; i<2; i++) {
2501 curr_len = strlen(Weapon_desc_lines[i]);
2503 if (bright_char_index < curr_len) {
2504 // save bright char and plunk in some nulls to shorten string
2505 bright_char[i] = Weapon_desc_lines[i][bright_char_index];
2506 Weapon_desc_lines[i][bright_char_index] = '\0';
2509 gr_set_color_fast(&Color_white);
2510 gr_string(weapon_title_coords[0], weapon_title_coords[1]+(10*i), Weapon_desc_lines[i]);
2512 // draw the bright letters
2513 gr_set_color_fast(&Color_bright_white);
2514 gr_get_string_size(&w, &h, Weapon_desc_lines[i], curr_len);
2515 gr_printf(weapon_title_coords[0]+w, weapon_title_coords[1]+(10*i), "%c", bright_char[i]);
2517 // restore the bright char to the string
2518 Weapon_desc_lines[i][bright_char_index] = bright_char[i];
2522 gr_set_color_fast(&Color_white);
2523 gr_string(weapon_title_coords[0], weapon_title_coords[1]+(10*i), Weapon_desc_lines[i]);
2527 // draw weapon desc (below weapon anim)
2528 for (i=2; i<WEAPON_DESC_MAX_LINES; i++) {
2529 curr_len = strlen(Weapon_desc_lines[i]);
2531 if (bright_char_index < curr_len) {
2532 // save bright char and plunk in some nulls to shorten string
2533 bright_char[i] = Weapon_desc_lines[i][bright_char_index];
2534 Weapon_desc_lines[i][bright_char_index] = '\0';
2537 gr_set_color_fast(&Color_white);
2538 gr_string(weapon_desc_coords[0], weapon_desc_coords[1]+(10*(i-2)), Weapon_desc_lines[i]);
2540 // draw the bright letters
2541 gr_set_color_fast(&Color_bright_white);
2542 gr_get_string_size(&w, &h, Weapon_desc_lines[i], curr_len);
2543 gr_printf(weapon_desc_coords[0]+w, weapon_desc_coords[1]+(10*(i-2)), "%c", bright_char[i]);
2545 // restore the bright char to the string
2546 Weapon_desc_lines[i][bright_char_index] = bright_char[i];
2550 gr_set_color_fast(&Color_white);
2551 gr_string(weapon_desc_coords[0], weapon_desc_coords[1]+(10*(i-2)), Weapon_desc_lines[i]);
2556 Weapon_desc_wipe_time_elapsed += frametime;
2557 if (Weapon_desc_wipe_time_elapsed >= WEAPON_DESC_WIPE_TIME) {
2558 // wipe is done,set flag and stop sound
2559 Weapon_desc_wipe_done = 1;
2564 // draw full version
2565 // FIXME - change to use a for loop
2566 gr_set_color_fast(&Color_white);
2567 gr_string(weapon_title_coords[0], weapon_title_coords[1], Weapon_desc_lines[0]);
2568 gr_string(weapon_title_coords[0], weapon_title_coords[1] + 10, Weapon_desc_lines[1]);
2569 gr_string(weapon_desc_coords[0], weapon_desc_coords[1], Weapon_desc_lines[2]);
2570 gr_string(weapon_desc_coords[0], weapon_desc_coords[1] + 10, Weapon_desc_lines[3]);
2571 gr_string(weapon_desc_coords[0], weapon_desc_coords[1] + 20, Weapon_desc_lines[4]);
2572 gr_string(weapon_desc_coords[0], weapon_desc_coords[1] + 30, Weapon_desc_lines[5]);
2579 // re-inits wiping vars and causes the current text to wipe in again
2580 void wl_weapon_desc_start_wipe()
2583 int currchar_src = 0, currline_dest = 2, currchar_dest = 0, i;
2585 int title_len = strlen(Weapon_info[Selected_wl_class].title);
2588 Weapon_desc_wipe_time_elapsed = 0.0f;
2589 Weapon_desc_wipe_done = 0;
2591 // break title into two lines if too long
2592 strcpy(Weapon_desc_lines[0], Weapon_info[Selected_wl_class].title);
2593 gr_get_string_size(&w, &h, Weapon_info[Selected_wl_class].title, title_len);
2594 if (w > Weapon_title_max_width[gr_screen.res]) {
2596 currchar_src = (int)(((float)title_len / (float)w) * Weapon_title_max_width[gr_screen.res]); // char to start space search at
2597 while (Weapon_desc_lines[0][currchar_src] != ' ') {
2599 if (currchar_src <= 0) {
2600 currchar_src = title_len;
2605 Weapon_desc_lines[0][currchar_src] = '\0'; // shorten line 0
2606 strcpy(Weapon_desc_lines[1], &(Weapon_desc_lines[0][currchar_src+1])); // copy remainder into line 1
2608 // entire title in line 0, thus line 1 is empty
2609 Weapon_desc_lines[1][0] = '\0';
2612 // break current description into lines (break at the /n's)
2614 while (Weapon_info[Selected_wl_class].desc[currchar_src] != '\0') {
2615 if (Weapon_info[Selected_wl_class].desc[currchar_src] == '\n') {
2617 if (currchar_src != 0) { // protect against leading /n's
2618 Weapon_desc_lines[currline_dest][currchar_dest] = '\0';
2624 Weapon_desc_lines[currline_dest][currchar_dest] = Weapon_info[Selected_wl_class].desc[currchar_src];
2630 Assert(currline_dest < WEAPON_DESC_MAX_LINES);
2631 Assert(currchar_dest < WEAPON_DESC_MAX_LENGTH);
2634 // wrap up the line processing
2635 Weapon_desc_lines[currline_dest][currchar_dest] = '\0';
2636 for (i=currline_dest+1; i<WEAPON_DESC_MAX_LINES; i++) {
2637 Weapon_desc_lines[i][0] = '\0';
2644 // ---------------------------------------------------------------------------------
2645 // weapon_select_do() is called once per frame while in the weapon loadout screen.
2647 // Calls to common_ functions are made for those functions which are common to the
2648 // ship select and briefing screens.
2650 void weapon_select_do(float frametime)
2652 int k, wl_choice, snazzy_action;
2655 if ( !Weapon_select_open )
2656 weapon_select_init();
2658 wl_choice = snazzy_menu_do(WeaponSelectMaskData, Weaponselect_mask_w, Weaponselect_mask_h, Num_weapon_select_regions, Weapon_select_region, &snazzy_action, 0);
2660 if ( wl_choice >= 0 ) {
2661 if ( snazzy_action == SNAZZY_CLICKED ) {
2662 nprintf(("Alan","got one\n"));
2667 Hot_weapon_icon = -1;
2668 Hot_weapon_bank = -1;
2669 Hot_weapon_bank_icon = -1;
2671 k = common_select_do(frametime);
2673 if ( help_overlay_active(WL_OVERLAY) ) {
2674 if ( Weapon_anim_class >= 0 && Wl_icons[Weapon_anim_class].anim_instance ) {
2675 anim_pause(Wl_icons[Weapon_anim_class].anim_instance);
2679 if ( Weapon_anim_class >= 0 && Wl_icons[Weapon_anim_class].anim_instance ) {
2680 anim_unpause(Wl_icons[Weapon_anim_class].anim_instance);
2684 // Check common keypresses
2685 common_check_keys(k);
2687 if ( Mouse_down_last_frame ) {
2688 Wl_mouse_down_on_region = wl_choice;
2691 if ( wl_choice > -1 ) {
2693 case ICON_PRIMARY_0:
2694 do_mouse_over_list_weapon(0);
2696 case ICON_PRIMARY_1:
2697 do_mouse_over_list_weapon(1);
2699 case ICON_PRIMARY_2:
2700 do_mouse_over_list_weapon(2);
2702 case ICON_PRIMARY_3:
2703 do_mouse_over_list_weapon(3);
2705 case ICON_SECONDARY_0:
2706 do_mouse_over_list_weapon(4);
2708 case ICON_SECONDARY_1:
2709 do_mouse_over_list_weapon(5);
2711 case ICON_SECONDARY_2:
2712 do_mouse_over_list_weapon(6);
2714 case ICON_SECONDARY_3:
2715 do_mouse_over_list_weapon(7);
2717 case ICON_SHIP_PRIMARY_0:
2718 if ( do_mouse_over_ship_weapon(0) )
2721 case ICON_SHIP_PRIMARY_1:
2722 if ( do_mouse_over_ship_weapon(1) )
2725 case ICON_SHIP_PRIMARY_2:
2726 if ( do_mouse_over_ship_weapon(2) )
2729 case ICON_SHIP_SECONDARY_0:
2730 if ( do_mouse_over_ship_weapon(3) )
2733 case ICON_SHIP_SECONDARY_1:
2734 if ( do_mouse_over_ship_weapon(4) )
2737 case ICON_SHIP_SECONDARY_2:
2738 if ( do_mouse_over_ship_weapon(5) )
2741 case ICON_SHIP_SECONDARY_3:
2742 if ( do_mouse_over_ship_weapon(6) )
2787 if ( !mouse_down(MOUSE_LEFT_BUTTON) ) {
2788 wl_dump_carried_icon();
2791 // Check for a mouse click on buttons
2792 common_check_buttons();
2793 weapon_check_buttons();
2795 // Check for the mouse clicks over a region
2796 if ( wl_choice > -1 && snazzy_action == SNAZZY_CLICKED ) {
2797 switch (wl_choice) {
2798 case ICON_PRIMARY_0:
2799 maybe_select_new_weapon(0);
2801 case ICON_PRIMARY_1:
2802 maybe_select_new_weapon(1);
2804 case ICON_PRIMARY_2:
2805 maybe_select_new_weapon(2);
2807 case ICON_PRIMARY_3:
2808 maybe_select_new_weapon(3);
2810 case ICON_SECONDARY_0:
2811 maybe_select_new_weapon(4);
2813 case ICON_SECONDARY_1:
2814 maybe_select_new_weapon(5);
2816 case ICON_SECONDARY_2:
2817 maybe_select_new_weapon(6);
2819 case ICON_SECONDARY_3:
2820 maybe_select_new_weapon(7);
2822 case ICON_SHIP_PRIMARY_0:
2823 maybe_select_new_ship_weapon(0);
2825 case ICON_SHIP_PRIMARY_1:
2826 maybe_select_new_ship_weapon(1);
2828 case ICON_SHIP_PRIMARY_2:
2829 maybe_select_new_ship_weapon(2);
2831 case ICON_SHIP_SECONDARY_0:
2832 maybe_select_new_ship_weapon(3);
2834 case ICON_SHIP_SECONDARY_1:
2835 maybe_select_new_ship_weapon(4);
2837 case ICON_SHIP_SECONDARY_2:
2838 maybe_select_new_ship_weapon(5);
2840 case ICON_SHIP_SECONDARY_3:
2841 maybe_select_new_ship_weapon(6);
2844 maybe_select_wl_slot(0,0);
2847 maybe_select_wl_slot(0,1);
2850 maybe_select_wl_slot(0,2);
2853 maybe_select_wl_slot(0,3);
2856 maybe_select_wl_slot(1,0);
2859 maybe_select_wl_slot(1,1);
2862 maybe_select_wl_slot(1,2);
2865 maybe_select_wl_slot(1,3);
2868 maybe_select_wl_slot(2,0);
2871 maybe_select_wl_slot(2,1);
2874 maybe_select_wl_slot(2,2);
2877 maybe_select_wl_slot(2,3);
2888 if ( Weapon_anim_class != -1 && ( Selected_wl_class == Weapon_anim_class ) ) {
2890 Assert(Selected_wl_class >= 0 && Selected_wl_class < MAX_WEAPON_TYPES );
2891 if ( Weapon_anim_class != Selected_wl_class )
2892 start_weapon_animation(Selected_wl_class);
2894 Assert(Weapon_anim_class == Selected_wl_class);
2895 icon = &Wl_icons[Selected_wl_class];
2896 if ( icon->anim_instance ) {
2897 if ( icon->anim_instance->frame_num == icon->anim_instance->stop_at ) {
2898 anim_play_struct aps;
2899 int *weapon_ani_coords;
2901 // get the correct weapon animations coords
2902 if (Game_mode & GM_MULTIPLAYER) {
2903 weapon_ani_coords = Wl_weapon_ani_coords_multi[gr_screen.res];
2905 weapon_ani_coords = Wl_weapon_ani_coords[gr_screen.res];
2908 anim_release_render_instance(icon->anim_instance);
2909 anim_play_init(&aps, icon->anim, weapon_ani_coords[0], weapon_ani_coords[1]);
2910 aps.start_at = WEAPON_ANIM_LOOP_FRAME-1;
2911 aps.screen_id = ON_WEAPON_SELECT;
2912 aps.framerate_independent = 1;
2913 aps.skip_frames = 0;
2914 icon->anim_instance = anim_play(&aps);
2919 weapon_select_render(frametime);
2920 if ( !Background_playing ) {
2921 Weapon_ui_window.draw();
2922 wl_redraw_pressed_buttons();
2924 anim_render_all(ON_WEAPON_SELECT, frametime);
2925 wl_check_for_stopped_ship_anims();
2926 wl_render_overhead_view(frametime);
2927 wl_draw_ship_weapons(Selected_wl_slot);
2928 for ( int i = 0; i < MAX_WING_BLOCKS; i++ ) {
2929 draw_wing_block(i, Hot_wl_slot, Selected_wl_slot, -1);
2931 common_render_selected_screen_button();
2934 // maybe blit the multiplayer "locked" button
2935 if((Game_mode & GM_MULTIPLAYER) && multi_ts_is_locked()){
2936 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.draw_forced(2);
2940 if ( wl_icon_being_carried() ) {
2942 Assert(Carried_wl_icon.weapon_class < MAX_WEAPON_TYPES);
2943 mouse_get_pos( &mx, &my );
2944 sx = mx + Wl_delta_x;
2945 sy = my + Wl_delta_y;
2948 if ( Wl_icons[Carried_wl_icon.weapon_class].can_use > 0) {
2949 gr_set_color_fast(&Color_blue);
2950 gr_set_bitmap(Wl_icons[Carried_wl_icon.weapon_class].icon_bmaps[WEAPON_ICON_FRAME_SELECTED]);
2954 // draw number to prevent it from disappearing on clicks
2955 if ( Carried_wl_icon.from_bank >= MAX_WL_PRIMARY ) {
2956 if ( mx == Carried_wl_icon.from_x && my == Carried_wl_icon.from_y ) {
2957 int num_missiles = Wss_slots[Carried_wl_icon.from_slot].wep_count[Carried_wl_icon.from_bank];
2958 //sprintf(buf, "%d", num_missiles);
2959 //gr_set_color_fast(&Color_white);
2961 //int x_offset = wl_fury_missile_offset_hack(Carried_wl_icon.weapon_class, num_missiles);
2962 //gr_string(sx-19-x_offset, sy+8, buf);
2965 wl_render_icon_count(num_missiles, Wl_bank_coords[gr_screen.res][Carried_wl_icon.from_bank][0], Wl_bank_coords[gr_screen.res][Carried_wl_icon.from_bank][1]);
2969 // check so see if this is really a legal weapon to carry away
2970 if ( !Wl_icons[Carried_wl_icon.weapon_class].can_use ) {
2972 diffx = abs(Carried_wl_icon.from_x-mx);
2973 diffy = abs(Carried_wl_icon.from_y-my);
2974 if ( (diffx > 2) || (diffy > 2) ) {
2975 int ship_class = Wss_slots[Selected_wl_slot].ship_class;
2978 // might have to get weapon name translation
2979 char display_name[128];
2980 strncpy(display_name, Weapon_info[Carried_wl_icon.weapon_class].name, 128);
2981 lcl_translate_wep_name(display_name);
2982 popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "A %s is unable to carry %s weaponry", 633), Ship_info[ship_class].name, display_name);
2984 popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "A %s is unable to carry %s weaponry", 633), Ship_info[ship_class].name, Weapon_info[Carried_wl_icon.weapon_class].name);
2987 wl_dump_carried_icon();
2992 if ( Weapon_anim_class != Selected_wl_class ) {
2993 start_weapon_animation(Selected_wl_class);
2996 // render weapon description text
2997 wl_render_weapon_desc(frametime);
2999 wl_maybe_flash_button();
3001 // should render the chatbox as close to the end as possible so it overlaps all controls
3002 if(!Background_playing){
3004 // render some extra stuff in multiplayer
3005 if(Game_mode & GM_MULTIPLAYER){
3006 // render the chatbox
3010 Weapon_ui_window.draw_tooltip();
3012 // render the status indicator for the voice system
3013 multi_common_voice_display_status();
3015 // blit the "ships/players" locked button
3016 // multi_ts_blit_locked_button();
3020 // blit help overlay if active
3021 help_overlay_maybe_blit(WL_OVERLAY);
3024 // If the commit button was pressed, do the commit button actions. Done at the end of the
3025 // loop so there isn't a skip in the animation (since ship_create() can take a long time if
3026 // the ship model is not in memory
3027 if ( Commit_pressed ) {
3028 if(Game_mode & GM_MULTIPLAYER){
3029 multi_ts_commit_pressed();
3037 // -------------------------------------------------------------------------------
3038 // weapon_select_close() will free the bitmap slot and memory that was allocated
3039 // to store the mask bitmap.
3041 // Weapon_select_open is cleared when this function completes.
3043 void weapon_select_close()
3045 if ( !Weapon_select_open ) {
3046 nprintf(("Alan","weapon_select_close() returning without doing anything\n"));
3050 nprintf(("Alan", "Entering weapon_select_close()\n"));
3052 stop_weapon_animation();
3054 // done with the bitmaps, so unlock it
3055 bm_unlock(WeaponSelectMaskBitmap);
3057 Weapon_ui_window.destroy();
3060 common_free_interface_palette();
3064 help_overlay_unload(WL_OVERLAY);
3066 bm_unload(WeaponSelectMaskBitmap);
3069 wl_unload_all_anim_instances();
3070 wl_unload_all_anims();
3072 Selected_wl_class = -1;
3073 Weapon_select_open = 0;
3077 // ------------------------------------------------------------------------
3078 // wl_render_icon_count()
3079 // renders the number next to the weapon icon
3081 // input: x,y => x,y screen position OF THE ICON (NOT where u want the text,
3082 // this is calculated to prevent overlapping)
3083 // num => the actual count to be printed
3085 void wl_render_icon_count(int num, int x, int y)
3089 int number_to_draw = (num > 1000) ? 999 : num; // cap count @ 999
3090 Assert(number_to_draw >= 0);
3092 sprintf(buf, "%d", number_to_draw);
3093 gr_get_string_size(&num_w, &num_h, buf, strlen(buf));
3096 gr_set_color_fast(&Color_white);
3098 // strict left align
3099 gr_string(x-21, y+8, buf);
3101 gr_string(x-num_w-4, y+8, buf);
3106 // ------------------------------------------------------------------------
3109 // input: index => index into Wl_icons[], identifying which weapon to draw
3110 // x,y => x,y screen position to draw icon at
3111 // num => count for weapon
3112 // draw_num_flag => 0 if not to draw count for weapon, nonzero otherwise
3113 // hot_mask => value that should match Hot_weapon_icon to show mouse is over
3114 // hot_bank_mask => value that should match Hot_weapon_bank_icon to show mouse is over
3115 // select_mask => value that should match Selected_wl_class to show icon is selected
3117 void wl_render_icon(int index, int x, int y, int num, int draw_num_flag, int hot_mask, int hot_bank_mask, int select_mask)
3122 if ( Selected_wl_slot == -1 )
3125 icon = &Wl_icons[index];
3127 if ( icon->icon_bmaps[0] == -1 ) {
3128 wl_load_icons(index);
3131 // assume default bitmap is to be used
3132 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_NORMAL]; // normal frame
3134 if ( bitmap_id < 0 ) {
3139 // next check if ship has mouse over it
3140 if ( !wl_icon_being_carried() ) {
3141 if ( Hot_weapon_icon > -1 && Hot_weapon_icon == hot_mask )
3142 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_HOT];
3144 if ( Hot_weapon_bank_icon > -1 && Hot_weapon_bank_icon == hot_bank_mask )
3145 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_HOT];
3148 // if icon is selected
3149 if ( Selected_wl_class > -1 ) {
3150 if ( Selected_wl_class == select_mask)
3151 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_SELECTED]; // selected icon
3154 // if icon is disabled
3155 if ( !icon->can_use ) {
3156 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_DISABLED]; // disabled icon
3159 gr_set_color_fast(&Color_blue);
3160 gr_set_bitmap(bitmap_id);
3163 // draw the number of the item
3164 // now, right justified
3165 if ( draw_num_flag != 0 ) {
3167 // add a little extra text padding for secondary weapons
3168 if ( hot_mask > 3 ) {
3169 wl_render_icon_count(num, x-9, y);
3171 wl_render_icon_count(num, x, y);
3174 wl_render_icon_count(num, x, y);
3179 // ------------------------------------------------------------------------
3180 // wl_draw_ship_weapons()
3182 // Draw the icons for the weapons that are currently on the selected ship
3184 // input: slot_num => Slot to draw weapons for
3186 void wl_draw_ship_weapons(int index)
3189 int *wep, *wep_count;
3194 Assert(index >= 0 && index < MAX_WSS_SLOTS);
3195 wep = Wss_slots[index].wep;
3196 wep_count = Wss_slots[index].wep_count;
3198 for ( i = 0; i < MAX_WL_WEAPONS; i++ ) {
3200 if ( Carried_wl_icon.from_bank == i && Carried_wl_icon.from_slot == index ) {
3204 if ( (wep[i] != -1) && (wep_count[i] > 0) ) {
3205 int x_offset = wl_fury_missile_offset_hack(wep[i], wep_count[i]);
3207 wl_render_icon( wep[i], Wl_bank_coords[gr_screen.res][i][0]+x_offset, Wl_bank_coords[gr_screen.res][i][1], wep_count[i], Wl_bank_count_draw_flags[i], -1, i, wep[i]);
3212 // ------------------------------------------------------------------------
3213 // draw_wl_icon_with_number()
3215 // input: list_count => list position on screen (0-7)
3216 // weapon_class => class of weapon
3218 void draw_wl_icon_with_number(int list_count, int weapon_class)
3220 Assert( list_count >= 0 && list_count < 8 );
3222 wl_render_icon(weapon_class, Wl_weapon_icon_coords[gr_screen.res][list_count][0], Wl_weapon_icon_coords[gr_screen.res][list_count][1],
3223 Wl_pool[weapon_class], 1, list_count, -1, weapon_class);
3226 // ------------------------------------------------------------------------
3229 // Draw the weapon icons that are available
3230 void draw_wl_icons()
3235 for ( i = Plist_start; i < Plist_size; i++ ) {
3236 draw_wl_icon_with_number(count, Plist[i]);
3242 for ( i = Slist_start; i < Slist_size; i++ ) {
3243 draw_wl_icon_with_number(count+4, Slist[i]);
3249 // ------------------------------------------------------------------------
3250 // wl_pick_icon_from_list()
3252 // determine if an icon from the scrollable weapon list can be picked up
3253 // (for drag and drop). It calculates the difference in x & y between the icon
3254 // and the mouse, so we can move the icon with the mouse in a realistic way
3255 // input: index (0..7)
3256 void wl_pick_icon_from_list(int index)
3258 int weapon_class, mx, my;
3260 // if this is a multiplayer game and the player is an observer, he can never pick any weapons up
3261 if((Game_mode & GM_MULTIPLAYER) && (Net_player->flags & NETINFO_FLAG_OBSERVER)){
3265 // if a weapon is being carried, do nothing
3266 if ( wl_icon_being_carried() ) {
3271 weapon_class = Plist[Plist_start+index];
3273 weapon_class = Slist[Slist_start+index-4];
3276 // there isn't a weapon there at all!
3277 if ( weapon_class < 0 )
3280 // no weapons left of that class
3281 if ( Wl_pool[weapon_class] <= 0 ) {
3286 // some are available, but weapon cannot be used on current ship class
3287 if ( !Wl_icons[weapon_class].can_use ) {
3290 int ship_class = Wss_slots[Selected_wl_slot].ship_class;
3291 popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, "A %s is unable to carry %s weaponry", Ship_info[ship_class].name, Weapon_info[weapon_class].name);
3298 wl_set_carried_icon(-1, -1, weapon_class);
3299 common_flash_button_init();
3301 mouse_get_pos( &mx, &my );
3302 Wl_delta_x = Wl_weapon_icon_coords[gr_screen.res][index][0] - mx;
3303 Wl_delta_y = Wl_weapon_icon_coords[gr_screen.res][index][1] - my;
3306 // ------------------------------------------------------------------------
3307 // pick_from_ship_slot()
3309 // input: num -> index into shipb banks (0..2 primary, 3..6 secondary)
3310 void pick_from_ship_slot(int num)
3312 int mx, my, *wep, *wep_count;
3316 if ( Selected_wl_slot == -1 )
3319 if ( wl_icon_being_carried() )
3322 if ( ss_disabled_slot( Selected_wl_slot ) )
3325 wep = Wss_slots[Selected_wl_slot].wep;
3326 wep_count = Wss_slots[Selected_wl_slot].wep_count;
3328 // check if a weapon even exists in that slot
3329 if ( (wep[num] < 0) || (wep_count[num] <= 0) ) {
3333 Assert(Wl_icons[wep[num]].can_use);
3335 wl_set_carried_icon(num, Selected_wl_slot, wep[num]);
3336 common_flash_button_init();
3338 mouse_get_pos( &mx, &my );
3340 int x_offset = wl_fury_missile_offset_hack(wep[num], wep_count[num]);
3341 Wl_delta_x = Wl_bank_coords[gr_screen.res][num][0] - mx + x_offset;
3342 Wl_delta_y = Wl_bank_coords[gr_screen.res][num][1] - my;
3344 Carried_wl_icon.from_x = mx;
3345 Carried_wl_icon.from_y = my;
3348 // determine if this slot has no weapons
3349 int wl_slots_all_empty(wss_unit *slot)
3353 for ( i = 0; i < MAX_WL_WEAPONS; i++ ) {
3354 if ( (slot->wep_count[i] > 0) && (slot->wep[i] >= 0) )
3361 // ------------------------------------------------------------------------
3362 // wl_update_ship_weapons()
3364 // Change a ship's weapons based on the information contained in the
3365 // Weapon_data[] structure that is filled in during weapon loadout
3367 // returns: -1 => if the playre ship has no weapons
3368 // 0 => function finished without errors
3369 int wl_update_ship_weapons(int objnum, wss_unit *slot )
3371 // AL 11-15-97: Ensure that the player ship hasn't removed all
3372 // weapons from their ship. This will cause a warning to appear.
3373 if ( objnum == OBJ_INDEX(Player_obj) && Weapon_select_open ) {
3374 if ( wl_slots_all_empty(slot) ) {
3379 wl_bash_ship_weapons(&Ships[Objects[objnum].instance].weapons, slot);
3384 // ------------------------------------------------------------------------
3385 // wl_update_parse_object_weapons()
3387 // Set the Pilot subsystem of a parse_object to the weapons that are setup
3388 // for the wing_block,wing_slot ship
3390 // input: pobjp => pointer to parse object that references Pilot subsystem
3392 void wl_update_parse_object_weapons(p_object *pobjp, wss_unit *slot)
3394 int i, j, sidx, pilot_index, max_count;
3398 Assert(slot->ship_class >= 0);
3399 sip = &Ship_info[slot->ship_class];
3401 pilot_index = wl_get_pilot_subsys_index(pobjp);
3403 if ( pilot_index == -1 )
3406 ss = &Subsys_status[pilot_index];
3408 for ( i = 0; i < MAX_PRIMARY_BANKS; i++ ) {
3409 ss->primary_banks[i] = -1;
3412 for ( i = 0; i < MAX_SECONDARY_BANKS; i++ ) {
3413 ss->secondary_banks[i] = -1;
3417 for ( i = 0; i < MAX_WL_PRIMARY; i++ ) {
3418 if ( (slot->wep_count[i] > 0) && (slot->wep[i] >= 0) ) {
3419 ss->primary_banks[j] = slot->wep[i];
3425 for ( i = 0; i < MAX_WL_SECONDARY; i++ ) {
3426 sidx = i+MAX_WL_PRIMARY;
3427 if ( (slot->wep_count[sidx] > 0) && (slot->wep[sidx] >= 0) ) {
3428 ss->secondary_banks[j] = slot->wep[sidx];
3429 // Important: the secondary_ammo[] value is a percentage of max capacity!
3430 max_count = wl_calc_missile_fit(slot->wep[sidx], Ship_info[slot->ship_class].secondary_bank_ammo_capacity[j]);
3431 ss->secondary_ammo[j] = fl2i( i2fl(slot->wep_count[sidx]) / max_count * 100.0f + 0.5f);
3437 // ------------------------------------------------------------------------
3438 // stop_weapon_animation()
3440 // Stop the current weapon animation from playing.
3442 void stop_weapon_animation()
3444 if ( Weapon_anim_class < 0 )
3447 if ( anim_playing(Wl_icons[Weapon_anim_class].anim_instance) )
3448 anim_release_render_instance(Wl_icons[Weapon_anim_class].anim_instance);
3450 Wl_icons[Weapon_anim_class].anim_instance = NULL;
3451 Weapon_anim_class = -1;
3454 // ------------------------------------------------------------------------
3455 // start_weapon_animation()
3457 // Start the current weapon animation from playing.
3459 void start_weapon_animation(int weapon_class)
3462 int *weapon_ani_coords;
3464 if ( weapon_class < 0 )
3467 if ( weapon_class == Weapon_anim_class )
3470 // get the correct weapon animations coords
3471 if (Game_mode & GM_MULTIPLAYER) {
3472 weapon_ani_coords = Wl_weapon_ani_coords_multi[gr_screen.res];
3474 weapon_ani_coords = Wl_weapon_ani_coords[gr_screen.res];
3477 icon = &Wl_icons[weapon_class];
3479 // stop current animation playing
3480 stop_weapon_animation();
3482 // see if we need to load in the animation from disk
3483 if ( icon->anim == NULL ) {
3484 wl_load_anim(weapon_class);
3486 icon->anim = anim_load(Weapon_info[weapon_class].anim_filename, 1);
3487 if ( icon->anim == NULL ) {
3488 Int3(); // could not open the weapon animation
3494 // see if we need to get an instance
3495 if ( icon->anim_instance == NULL ) {
3496 anim_play_struct aps;
3498 anim_play_init(&aps, icon->anim, weapon_ani_coords[0], weapon_ani_coords[1]);
3499 aps.screen_id = ON_WEAPON_SELECT;
3500 aps.framerate_independent = 1;
3501 aps.skip_frames = 0;
3502 icon->anim_instance = anim_play(&aps);
3503 gamesnd_play_iface(SND_WEAPON_ANIM_START);
3506 Weapon_anim_class = weapon_class;
3508 // start the text wipe
3509 wl_weapon_desc_start_wipe();
3512 // reset the weapons loadout to the defaults in the mission
3513 void wl_reset_to_defaults()
3515 // don't reset of weapons pool in multiplayer
3516 if(Game_mode & GM_MULTIPLAYER){
3520 wl_init_pool(&Team_data[Common_team]);
3521 wl_init_icon_lists();
3523 wl_reset_selected_slot();
3524 wl_reset_carried_icon();
3525 wl_maybe_reset_selected_weapon_class();
3528 // Bash ship weapons, based on what is stored in the stored weapons loadout
3529 // NOTE: Wss_slots[] is assumed to be correctly set
3530 void wl_bash_ship_weapons(ship_weapon *swp, wss_unit *slot)
3534 for ( i = 0; i < MAX_PRIMARY_BANKS; i++ ) {
3535 swp->primary_bank_weapons[i] = -1;
3538 for ( i = 0; i < MAX_SECONDARY_BANKS; i++ ) {
3539 swp->secondary_bank_weapons[i] = -1;
3543 for ( i = 0; i < MAX_WL_PRIMARY; i++ ) {
3544 if ( (slot->wep_count[i] > 0) && (slot->wep[i] >= 0) ) {
3545 swp->primary_bank_weapons[j] = slot->wep[i];
3549 swp->num_primary_banks = j;
3552 for ( i = 0; i < MAX_WL_SECONDARY; i++ ) {
3553 sidx = i+MAX_WL_PRIMARY;
3554 if ( (slot->wep_count[sidx] > 0) && (slot->wep[sidx] >= 0) ) {
3555 swp->secondary_bank_weapons[j] = slot->wep[sidx];
3556 swp->secondary_bank_ammo[j] = slot->wep_count[sidx];
3560 swp->num_secondary_banks = j;
3563 // utility function for swapping two banks
3564 void wl_swap_weapons(int ship_slot, int from_bank, int to_bank)
3568 slot = &Wss_slots[ship_slot];
3570 if ( from_bank == to_bank ) {
3575 tmp = slot->wep[from_bank];
3576 slot->wep[from_bank] = slot->wep[to_bank];
3577 slot->wep[to_bank] = tmp;
3579 // swap weapon count
3580 tmp = slot->wep_count[from_bank];
3581 slot->wep_count[from_bank] = slot->wep_count[to_bank];
3582 slot->wep_count[to_bank] = tmp;
3585 // utility function used to put back overflow into the weapons pool
3586 void wl_saturate_bank(int ship_slot, int bank)
3589 int max_count, overflow;
3591 slot = &Wss_slots[ship_slot];
3593 if ( (slot->wep[bank] < 0) || (slot->wep_count <= 0) ) {
3597 max_count = wl_calc_missile_fit(slot->wep[bank], Ship_info[slot->ship_class].secondary_bank_ammo_capacity[bank-3]);
3598 overflow = slot->wep_count[bank] - max_count;
3599 if ( overflow > 0 ) {
3600 slot->wep_count[bank] -= overflow;
3601 // add overflow back to pool
3602 Wl_pool[slot->wep[bank]] += overflow;
3606 // exit: 0 -> no data changed
3607 // 1 -> data changed
3608 // sound => gets filled with sound id to play
3609 int wl_swap_slot_slot(int from_bank, int to_bank, int ship_slot, int *sound)
3612 slot = &Wss_slots[ship_slot];
3614 if ( slot->ship_class == -1 ) {
3615 Int3(); // should not be possible
3619 // do nothing if swapping with self
3620 if ( from_bank == to_bank ) {
3621 *sound=SND_ICON_DROP_ON_WING;
3622 return 0; // no update
3625 // ensure that source bank exists and has something to pick from
3626 if ( slot->wep[from_bank] == -1 || slot->wep_count[from_bank] <= 0 ) {
3630 // ensure that the dest bank exists
3631 if ( slot->wep_count[to_bank] < 0 ) {
3635 // ensure that the banks are both of the same class
3636 if ( (IS_BANK_PRIMARY(from_bank) && IS_BANK_SECONDARY(to_bank)) || (IS_BANK_SECONDARY(from_bank) && IS_BANK_PRIMARY(to_bank)) ) {
3637 // put from_bank back into list
3638 Wl_pool[slot->wep[from_bank]] += slot->wep_count[from_bank];; // return to list
3639 slot->wep[from_bank] = -1; // remove from slot
3640 slot->wep_count[from_bank] = 0;
3641 *sound=SND_ICON_DROP;
3645 // case 1: primaries (easy)
3646 if ( IS_BANK_PRIMARY(from_bank) && IS_BANK_PRIMARY(to_bank) ) {
3647 wl_swap_weapons(ship_slot, from_bank, to_bank);
3648 *sound=SND_ICON_DROP_ON_WING;
3652 // case 2: secondaries (harder)
3653 if ( IS_BANK_SECONDARY(from_bank) && IS_BANK_SECONDARY(to_bank) ) {
3655 // case 2a: secondaries are the same type
3656 if ( slot->wep[from_bank] == slot->wep[to_bank] ) {
3657 int dest_max, dest_can_fit, source_can_give;
3658 dest_max = wl_calc_missile_fit(slot->wep[to_bank], Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-3]);
3660 dest_can_fit = dest_max - slot->wep_count[to_bank];
3662 if ( dest_can_fit <= 0 ) {
3663 // dest bank is already full.. nothing to do here
3667 // see how much source can give
3668 source_can_give = min(dest_can_fit, slot->wep_count[from_bank]);
3670 if ( source_can_give > 0 ) {
3671 slot->wep_count[to_bank] += source_can_give; // add to dest
3672 slot->wep_count[from_bank] -= source_can_give; // take from source
3673 *sound=SND_ICON_DROP_ON_WING;
3680 // case 2b: secondaries are different types
3681 if ( slot->wep[from_bank] != slot->wep[to_bank] ) {
3684 wl_swap_weapons(ship_slot, from_bank, to_bank);
3686 // put back some on list if required
3687 wl_saturate_bank(ship_slot, from_bank);
3688 wl_saturate_bank(ship_slot, to_bank);
3689 *sound=SND_ICON_DROP_ON_WING;
3694 Int3(); // should never get here
3698 // exit: 0 -> no data changed
3699 // 1 -> data changed
3700 // sound => gets filled with sound id to play
3701 int wl_dump_to_list(int from_bank, int to_list, int ship_slot, int *sound)
3704 slot = &Wss_slots[ship_slot];
3706 // ensure that source bank exists and has something to pick from
3707 if ( slot->wep[from_bank] == -1 || slot->wep_count[from_bank] <= 0 ) {
3711 // put weapon bank to the list
3712 Wl_pool[to_list] += slot->wep_count[from_bank]; // return to list
3713 slot->wep[from_bank] = -1; // remove from slot
3714 slot->wep_count[from_bank] = 0;
3715 *sound=SND_ICON_DROP;
3720 // exit: 0 -> no data changed
3721 // 1 -> data changed
3722 // sound => gets filled with sound id to play
3723 int wl_grab_from_list(int from_list, int to_bank, int ship_slot, int *sound)
3726 slot = &Wss_slots[ship_slot];
3729 // ensure that the banks are both of the same class
3730 if ( (IS_LIST_PRIMARY(from_list) && IS_BANK_SECONDARY(to_bank)) || (IS_LIST_SECONDARY(from_list) && IS_BANK_PRIMARY(to_bank)) ) {
3732 *sound=SND_ICON_DROP;
3736 // ensure that dest bank exists
3737 if ( slot->wep_count[to_bank] < 0 ) {
3738 *sound=SND_ICON_DROP;
3742 // bank should be empty:
3743 Assert(slot->wep_count[to_bank] == 0);
3744 Assert(slot->wep[to_bank] < 0);
3746 // ensure that pool has weapon
3747 if ( Wl_pool[from_list] <= 0 ) {
3751 // find how much dest bank can fit
3752 if ( to_bank < MAX_WL_PRIMARY ) {
3755 max_fit = wl_calc_missile_fit(from_list, Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-MAX_WL_PRIMARY]);
3758 // take weapon from list
3759 if ( Wl_pool[from_list] < max_fit ) {
3760 max_fit = Wl_pool[from_list];
3762 Wl_pool[from_list] -= max_fit;
3765 slot->wep[to_bank] = from_list;
3766 slot->wep_count[to_bank] = max_fit;
3768 *sound=SND_ICON_DROP_ON_WING;
3772 // exit: 0 -> no data changed
3773 // 1 -> data changed
3774 // sound => gets filled with sound id to play
3775 int wl_swap_list_slot(int from_list, int to_bank, int ship_slot, int *sound)
3778 slot = &Wss_slots[ship_slot];
3781 // ensure that the banks are both of the same class
3782 if ( (IS_LIST_PRIMARY(from_list) && IS_BANK_SECONDARY(to_bank)) || (IS_LIST_SECONDARY(from_list) && IS_BANK_PRIMARY(to_bank)) ) {
3784 *sound=SND_ICON_DROP;
3788 // ensure that dest bank exists
3789 if ( slot->wep_count[to_bank] < 0 ) {
3793 // bank should have something in it
3794 Assert(slot->wep_count[to_bank] > 0);
3795 Assert(slot->wep[to_bank] >= 0);
3797 // ensure that pool has weapon
3798 if ( Wl_pool[from_list] <= 0 ) {
3802 // dump slot weapon back into list
3803 Wl_pool[slot->wep[to_bank]] += slot->wep_count[to_bank];
3804 slot->wep_count[to_bank] = 0;
3805 slot->wep[to_bank] = -1;
3807 // put weapon on ship from list
3809 // find how much dest bank can fit
3810 if ( to_bank < MAX_WL_PRIMARY ) {
3813 max_fit = wl_calc_missile_fit(from_list, Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-MAX_WL_PRIMARY]);
3816 // take weapon from list
3817 if ( Wl_pool[from_list] < max_fit ) {
3818 max_fit = Wl_pool[from_list];
3820 Wl_pool[from_list] -= max_fit;
3823 slot->wep[to_bank] = from_list;
3824 slot->wep_count[to_bank] = max_fit;
3826 *sound=SND_ICON_DROP_ON_WING;
3830 // update any interface data that may be dependent on Wss_slots[]
3831 void wl_synch_interface()
3835 void wl_apply(int mode,int from_bank,int from_list,int to_bank,int to_list,int ship_slot,int player_index)
3841 // get the appropriate net player
3842 if(Game_mode & GM_MULTIPLAYER){
3843 if(player_index == -1){
3846 pl = &Net_players[player_index];
3853 case WSS_SWAP_SLOT_SLOT:
3854 update = wl_swap_slot_slot(from_bank, to_bank, ship_slot, &sound);
3856 case WSS_DUMP_TO_LIST:
3857 update = wl_dump_to_list(from_bank, to_list, ship_slot, &sound);
3859 case WSS_GRAB_FROM_LIST:
3860 update = wl_grab_from_list(from_list, to_bank, ship_slot, &sound);
3862 case WSS_SWAP_LIST_SLOT:
3863 update = wl_swap_list_slot(from_list, to_bank, ship_slot, &sound);
3867 // only play this sound if the move was done locally (by the host in other words)
3868 if ( (sound >= 0) && (player_index == -1) ) {
3869 gamesnd_play_iface(sound);
3873 if ( MULTIPLAYER_HOST ) {
3875 ubyte wss_data[MAX_PACKET_SIZE-20];
3877 size = store_wss_data(wss_data, MAX_PACKET_SIZE-20,sound,player_index);
3879 send_wss_update_packet(pl->p_info.team,wss_data, size);
3882 if(Game_mode & GM_MULTIPLAYER){
3885 // if the pool we're using has changed, synch stuff up
3886 if(pl->p_info.team == Net_player->p_info.team){
3887 wl_synch_interface();
3890 wl_synch_interface();
3895 void wl_drop(int from_bank,int from_list,int to_bank,int to_list, int ship_slot, int player_index)
3900 // get the appropriate net player
3901 if(Game_mode & GM_MULTIPLAYER){
3902 if(player_index == -1){
3905 pl = &Net_players[player_index];
3911 common_flash_button_init();
3912 if ( !(Game_mode & GM_MULTIPLAYER) || MULTIPLAYER_HOST ) {
3913 if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){
3914 // set the global pointers to the right pools
3915 ss_set_team_pointers(pl->p_info.team);
3919 mode = wss_get_mode(from_bank, from_list, to_bank, to_list, ship_slot);
3921 wl_apply(mode, from_bank, from_list, to_bank, to_list, ship_slot, player_index);
3924 if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){
3925 // set the global pointers to the right pools
3926 ss_set_team_pointers(Net_player->p_info.team);
3929 send_wss_request_packet(Net_player->player_id, from_bank, from_list, to_bank, to_list, ship_slot, -1, WSS_WEAPON_SELECT);