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.7 2004/09/20 01:31:44 theoddone33
21 * Revision 1.6 2003/06/11 18:30:33 taylor
24 * Revision 1.5 2003/05/25 02:30:43 taylor
27 * Revision 1.4 2002/06/16 01:43:23 relnev
28 * fixed demo dogfight multiplayer mission
32 * Revision 1.3 2002/06/09 04:41:23 relnev
33 * added copyright header
35 * Revision 1.2 2002/05/07 03:16:46 theoddone33
36 * The Great Newline Fix
38 * Revision 1.1.1.1 2002/05/03 03:28:10 root
42 * 40 11/01/99 11:22a Jefff
43 * some weapon name translations
45 * 39 9/10/99 10:26a Jefff
46 * default weapon anim selection fix
48 * 38 9/06/99 3:30p Mikek
49 * Added system for restricting weapon choices based on ship class for
52 * 37 8/27/99 11:59a Jefff
53 * fixed unnecessary sound playing
55 * 36 8/05/99 3:40p Jefff
56 * hi-res text adjustments
58 * 35 8/05/99 11:32a Jefff
59 * fixed hi-res weapon anims not loading from packfile
61 * 34 7/30/99 4:35p Andsager
62 * Clean up change ship sound
64 * 33 7/30/99 4:22p Andsager
65 * restored ship and weapon anim sounds for demo. Added sound for
66 * changing ship in weapon loadout screen.
68 * 32 7/27/99 7:34p Jefff
69 * Lotsa clean up, moving stuff around, generally making the whole damn
72 * 31 7/27/99 3:01p Jefff
73 * crippled wl_start_slot_animation to prevent loading of overhead ship
74 * .anis. also began modifications for multiplayer interface.
76 * 30 7/25/99 5:49p Jefff
77 * initial weapon ani is now one of the ship's weapons. this will fall
78 * back to the original search if the ship should be weaponless.
80 * 29 7/24/99 6:03p Jefff
81 * Added "lock" text to multiplayer lock button
83 * 28 7/21/99 6:02p Jefff
84 * fixed weapon counts running into weapon icons
86 * 27 7/21/99 3:24p Andsager
87 * Modify demo to use 2 frame ship and weapon select anis and cut sounds
90 * 26 7/20/99 7:07p Jefff
91 * added "reset" text above reset button
93 * 25 7/20/99 1:48p Jefff
94 * Long weapon titles now wrap to next line
96 * 24 7/20/99 10:44a Jefff
97 * increased WEAPON_DESC_MAX_LINES to 6
99 * 23 7/20/99 12:26a Jefff
102 * 22 7/19/99 5:08p Jefff
103 * Added text descriptions for selected weapons, complete with wipe
106 * 21 7/16/99 1:50p Dave
107 * 8 bit aabitmaps. yay.
109 * 20 7/15/99 9:20a Andsager
110 * FS2_DEMO initial checkin
112 * 19 7/11/99 3:20p Kellys
113 * Make sure we load high-res weapon rotations in 1024
115 * 18 7/09/99 5:54p Dave
116 * Seperated cruiser types into individual types. Added tons of new
117 * briefing icons. Campaign screen.
119 * 17 7/09/99 12:21a Dave
120 * Change weapon loop anim frame.
122 * 16 3/25/99 2:45p Neilk
125 * 15 3/23/99 9:23p Neilk
126 * fixed various multiplayer lock button problems
128 * 14 3/10/99 6:21p Neilk
129 * Added new artwork for hires
131 * 13 2/21/99 6:01p Dave
132 * Fixed standalone WSS packets.
134 * 12 2/18/99 11:46a Neilk
135 * hires interface coord support
137 * 11 2/11/99 3:08p Dave
138 * PXO refresh button. Very preliminary squad war support.
140 * 10 2/01/99 5:55p Dave
141 * Removed the idea of explicit bitmaps for buttons. Fixed text
142 * highlighting for disabled gadgets.
144 * 9 1/30/99 1:29a Dave
145 * Fixed nebula thumbnail problem. Full support for 1024x768 choose pilot
146 * screen. Fixed beam weapon death messages.
148 * 8 1/29/99 4:17p Dave
149 * New interface screens.
151 * 7 1/27/99 9:56a Dave
152 * Temporary checkin of beam weapons for Dan to make cool sounds.
154 * 6 12/18/98 1:13a Dave
155 * Rough 1024x768 support for Direct3D. Proper detection and usage through
158 * 5 11/30/98 1:07p Dave
159 * 16 bit conversion, first run.
161 * 4 11/17/98 11:12a Dave
162 * Removed player identification by address. Now assign explicit id #'s.
164 * 3 10/13/98 9:29a Dave
165 * Started neatening up freespace.h. Many variables renamed and
166 * reorganized. Added AlphaColors.[h,cpp]
168 * 2 10/07/98 10:53a Dave
171 * 1 10/07/98 10:50a Dave
173 * 119 6/17/98 11:06a Lawrance
174 * put in weapon description tooltip
176 * 118 6/13/98 6:01p Hoffoss
177 * Externalized all new (or forgot to be added) strings to all the code.
179 * 117 6/01/98 11:43a John
180 * JAS & MK: Classified all strings for localization.
182 * 116 5/19/98 8:35p Dave
183 * Revamp PXO channel listing system. Send campaign goals/events to
184 * clients for evaluation. Made lock button pressable on all screens.
186 * 115 5/18/98 2:49p Lawrance
187 * Put in weapon animation sound hook
189 * 114 5/08/98 7:52p Lawrance
190 * Add code to loop new weapon animations
192 * 113 5/06/98 11:50p Lawrance
193 * Clean up help overlay code for loadout screens
195 * 112 5/04/98 5:27p Johnson
196 * Fixed a team vs. team weapons loadout bug.
198 * 111 5/03/98 1:55a Lawrance
199 * Fix some sound problems with loadout screens
201 * 110 4/30/98 6:03p Lawrance
202 * Make drag and drop work better.
204 * 109 4/27/98 6:02p Dave
205 * Modify how missile scoring works. Fixed a team select ui bug. Speed up
206 * multi_lag system. Put in new main hall.
208 * 108 4/24/98 2:17a Lawrance
209 * repositioin ship name in weapons loadout
211 * 107 4/22/98 7:24p Dave
212 * Made sure the "player/ships" locked button for multiplayer appears on
213 * all briefing screens.
215 * 106 4/21/98 6:45p Dave
216 * AL: Fix bug with replacement weapons on ships
218 * 105 4/17/98 5:27p Dave
219 * More work on the multi options screen. Fixed many minor ui todo bugs.
221 * 104 4/16/98 8:05p Lawrance
222 * fix some bugs with numbers over-writing weapon icons
224 * 103 4/10/98 4:51p Hoffoss
225 * Made several changes related to tooltips.
227 * 102 4/08/98 1:18a Lawrance
228 * Fix bug that could occur when picking alternate weapons (ie count could
229 * have been wrong due to missile size)
231 * 101 4/07/98 5:42p Dave
232 * Put in support for ui display of voice system status (recording,
233 * playing back, etc). Make sure main hall music is stopped before
234 * entering a multiplayer game via ingame join.
236 * 100 4/02/98 11:40a Lawrance
237 * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
239 * 99 3/31/98 1:50p Duncan
240 * ALAN: fix bugs with selecting alternate weapons
242 * 98 3/30/98 12:18a Lawrance
243 * change some DEMO_RELEASE code to not compile code rather than return
246 * 97 3/29/98 1:24p Dave
247 * Make chatbox not clear between multiplayer screens. Select player ship
248 * as default in mp team select and weapons select screens. Made create
249 * game mission list use 2 fixed size columns.
251 * 96 3/29/98 12:55a Lawrance
252 * Get demo build working with limited set of data.
254 * 95 3/26/98 5:47p Lawrance
255 * Implement default weapon picking if default weapons not available in
258 * 94 3/25/98 8:43p Hoffoss
259 * Changed anim_play() to not be so damn complex when you try and call it.
261 * 93 3/25/98 11:23a Mike
262 * Fix stack overwrite due to async between MAX_SECONDARY_WEAPONS and
265 * 92 3/21/98 2:47p Dave
266 * Fixed chat packet routing problem on standalone. Fixed wss_request
267 * packet routing on standalone.
269 * 91 3/19/98 5:34p Lawrance
270 * Tweak drag/drop behavior in weapons loadout
272 * 90 3/14/98 2:48p Dave
273 * Cleaned up observer joining code. Put in support for file xfers to
274 * ingame joiners (observers or not). Revamped and reinstalled pseudo
277 * 89 3/12/98 4:03p Lawrance
278 * don't press buttons when icon dropped on them
280 * 88 3/10/98 1:35p Lawrance
281 * Fix default selected weapon bug
283 * 87 3/09/98 9:55p Lawrance
284 * Move secondary icons to the right to avoid overlap with numbers
286 * 86 3/09/98 11:13a Lawrance
287 * Fix up drop sound effects used in loadout screens.
289 * 85 3/06/98 5:36p Dave
290 * Finished up first rev of team vs team. Probably needs to be debugged
293 * 84 3/05/98 5:03p Dave
294 * More work on team vs. team support for multiplayer. Need to fix bugs in
297 * 83 3/01/98 3:26p Dave
298 * Fixed a few team select bugs. Put in multiplayer intertface sounds.
299 * Corrected how ships are disabled/enabled in team select/weapon select
302 * 82 2/28/98 7:04p Lawrance
303 * Don't show reset button in multiplayer
305 * 81 2/27/98 11:32a Andsager
306 * AL: Fix bug with showing valid weapon slots for ships that arrive late.
308 * 80 2/26/98 4:59p Allender
309 * groundwork for team vs team briefings. Moved weaponry pool into the
310 * Team_data structure. Added team field into the p_info structure.
311 * Allow for mutliple structures in the briefing code.
313 * 79 2/24/98 6:21p Lawrance
314 * Integrate new reset button into loadout screens
316 * 78 2/22/98 4:17p John
317 * More string externalization classification... 190 left to go!
319 * 77 2/22/98 12:19p John
320 * Externalized some strings
322 * 76 2/19/98 6:26p Dave
323 * Fixed a few file xfer bugs. Tweaked mp team select screen. Put in
324 * initial support for player data uploading.
326 * 75 2/18/98 10:37p Dave
327 * Fixed a mp team select bug which allowed players to commit at
328 * inappropriate times.
330 * 74 2/18/98 3:56p Dave
331 * Several bugs fixed for mp team select screen. Put in standalone packet
332 * routing for team select.
334 * 73 2/16/98 10:27a Lawrance
335 * Fix bug in wl_cull_illegal_weapons()
337 * 72 2/15/98 11:28p Allender
338 * allow increase in MAX_WEAPON_TYPES by chaning all bitfield references
340 * 71 2/13/98 5:15p Lawrance
341 * Fix help overlay bug in weapons loadout.
343 * 70 2/13/98 3:46p Dave
344 * Put in dynamic chatbox sizing. Made multiplayer file lookups use cfile
347 * 69 2/09/98 11:24p Lawrance
348 * Allow player to click on disallowed weapons, but don't let them drag
349 * them away from the list.
351 * 68 2/07/98 5:47p Lawrance
352 * reset flashing if a button gets highlighted
354 * 67 2/06/98 5:15p Jasen
355 * AL: Allow up to 10000 of any given missile in the pool
357 * 66 2/05/98 11:21p Lawrance
358 * When flashing buttons, use highlight frame
360 * 65 2/02/98 3:36p Jasen
361 * AL: remove weapon debug name, and allow for 2 frame weapon anis
363 * 64 2/02/98 3:21p Jasen
364 * Updated coords for weapon anim location.
366 * 63 1/20/98 5:52p Lawrance
367 * account for no player ship when moving to weapons loadout
369 * 62 1/20/98 2:23p Dave
370 * Removed optimized build warnings. 99% done with ingame join fixes.
372 * 61 1/20/98 11:08a Lawrance
373 * Fix sound error when clicking on a weapon.
375 * 60 1/19/98 2:17p Lawrance
376 * Fix bug that was not recognizing non-default weapons on late-arriving
379 * 59 1/15/98 4:09p Lawrance
380 * fix weapon scrolling bug
382 * 58 1/14/98 6:44p Lawrance
383 * Take out unnecessary instance checking when freeing anims.
385 * 57 1/12/98 5:17p Dave
386 * Put in a bunch of multiplayer sequencing code. Made weapon/ship select
387 * work through the standalone.
389 * 56 1/10/98 12:47a Lawrance
390 * update some comments
392 * 55 1/09/98 6:06p Dave
393 * Put in network sound support for multiplayer ship/weapon select
394 * screens. Made clients exit game correctly through warp effect. Fixed
395 * main hall menu help overlay bug.
397 * 54 1/09/98 4:08p John
398 * Fixed a bug loading too many icon frames
400 * 53 1/08/98 10:55p Lawrance
401 * Fix bug where forbidden weapons were not updated when a ship was
402 * changed before weapons loadout is entered.
404 * 52 1/08/98 5:19p Sandeep
405 * Alan made a change which fixed missions with more than 4 types of
408 * 51 1/08/98 11:38a Lawrance
411 * 50 1/08/98 11:36a Lawrance
412 * Get ship select and weapons loadout icon dropping sound effects working
413 * for single and multiplayer
415 * 49 1/02/98 9:10p Lawrance
416 * Big changes to how colors get set on the HUD.
418 * 48 12/30/97 6:08p Lawrance
419 * Fix bug where player discarded ship before entering weapon select
421 * 47 12/29/97 4:21p Lawrance
422 * Flash buttons on briefing/ship select/weapons loadout when enough time
423 * has elapsed without activity.
425 * 46 12/29/97 10:11a Lawrance
426 * Don't play drop sound when a weapon is clicked on in a slot.
428 * 45 12/24/97 8:54p Lawrance
429 * Integrating new popup code
431 * 44 12/24/97 1:19p Lawrance
432 * fix some bugs with the multiplayer ship/weapons loadout
434 * 43 12/23/97 5:25p Allender
435 * more fixes to multiplayer ship selection. Fixed strange reentrant
436 * problem with cf_callback when loading freespace data
438 * 42 12/23/97 11:59a Allender
439 * changes to ship/wespon selection for multplayer. added sounds to some
440 * interface screens. Update and modiied end-of-briefing packets -- yet
443 * 41 12/23/97 11:48a Lawrance
444 * fix bug that could cause assert when swapping secondary weapons
446 * 40 12/22/97 6:18p Lawrance
447 * Get save/restore of player loadout working with new code
449 * 39 12/22/97 1:40a Lawrance
450 * Re-write ship select/weapons loadout to be multiplayer friendly
452 * 38 12/19/97 1:23p Dave
453 * Put in multiplayer groundwork for new weapon/ship select screens.
455 * 37 12/19/97 12:44p Dave
456 * Put in final touches on ship/weapon select. However, this is all going
462 #include "missionscreencommon.h"
463 #include "missionweaponchoice.h"
464 #include "missionshipchoice.h"
470 #include "snazzyui.h"
471 #include "animplay.h"
472 #include "freespace.h"
473 #include "gamesequence.h"
475 #include "missionbrief.h"
478 #include "animplay.h"
479 #include "contexthelp.h"
481 #include "linklist.h"
482 #include "multimsgs.h"
484 #include "multiteamselect.h"
486 #include "alphacolors.h"
487 #include "localize.h"
489 //#define MAX_PRIMARY_BANKS 3
490 //#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.
492 #define IS_BANK_PRIMARY(x) (x<3?1:0)
493 #define IS_BANK_SECONDARY(x) (x>2?1:0)
495 #define IS_LIST_PRIMARY(x) (Weapon_info[x].subtype==WP_MISSILE?0:1)
496 #define IS_LIST_SECONDARY(x) (Weapon_info[x].subtype==WP_MISSILE?1:0)
499 #if (MAX_PRIMARY_BANKS > MAX_WL_PRIMARY)
500 #error "Illegal: MAX_PRIMARY_BANKS greater than MAX_WL_PRIMARY"
503 #if (MAX_SECONDARY_BANKS > MAX_WL_SECONDARY)
504 #error "Illegal: MAX_SECONDARY_BANKS greater than MAX_WL_SECONDARY"
508 //////////////////////////////////////////////////////////////////
510 //////////////////////////////////////////////////////////////////
512 // This game-wide global flag is set to 1 to indicate that the weapon
513 // select screen has been opened and memory allocated. This flag
514 // is needed so we can know if weapon_select_close() needs to called if
515 // restoring a game from the Options screen invoked from weapon select
516 int Weapon_select_open = 0;
518 //////////////////////////////////////////////////////////////////
520 //////////////////////////////////////////////////////////////////
522 typedef struct wl_bitmap_group
528 #if defined(FS2_DEMO) || defined(FS1_DEMO)
529 #define WEAPON_ANIM_LOOP_FRAME 1
531 #define WEAPON_ANIM_LOOP_FRAME 32
533 #define WEAPON_ANIM_LOOP_FRAME 52 // frame (from 0) to loop weapon anim
536 #define WEAPON_ICON_FRAME_NORMAL 0
537 #define WEAPON_ICON_FRAME_HOT 1
538 #define WEAPON_ICON_FRAME_SELECTED 2
539 #define WEAPON_ICON_FRAME_DISABLED 3
541 // Weapn loadout specific buttons
542 #define NUM_WEAPON_BUTTONS 7
543 #define WL_BUTTON_SCROLL_PRIMARY_UP 0
544 #define WL_BUTTON_SCROLL_PRIMARY_DOWN 1
545 #define WL_BUTTON_SCROLL_SECONDARY_UP 2
546 #define WL_BUTTON_SCROLL_SECONDARY_DOWN 3
547 #define WL_BUTTON_RESET 4
548 #define WL_BUTTON_DUMMY 5
549 #define WL_BUTTON_MULTI_LOCK 6
550 UI_WINDOW Weapon_ui_window;
551 //UI_BUTTON Weapon_buttons[NUM_WEAPON_BUTTONS];
553 static char *Wl_mask_single[GR_NUM_RESOLUTIONS] = {
558 static char *Wl_mask_multi[GR_NUM_RESOLUTIONS] = {
559 "weaponloadoutmulti-m",
560 "2_weaponloadoutmulti-m"
563 static char *Wl_loadout_select_mask[GR_NUM_RESOLUTIONS] = {
569 static char *Weapon_select_background_fname[GR_NUM_RESOLUTIONS] = {
579 static char *Weapon_select_multi_background_fname[GR_NUM_RESOLUTIONS] = {
584 "WeaponLoadoutMulti",
585 "2_WeaponLoadoutMulti"
589 int Weapon_select_background_bitmap; // bitmap for weapon select brackground
591 static MENU_REGION Weapon_select_region[NUM_WEAPON_REGIONS];
592 static int Num_weapon_select_regions;
594 // Mask bitmap pointer and Mask bitmap_id
595 static bitmap* WeaponSelectMaskPtr; // bitmap pointer to the weapon select mask bitmap
596 static ubyte* WeaponSelectMaskData; // pointer to actual bitmap data
597 static int Weaponselect_mask_w, Weaponselect_mask_h;
598 static int WeaponSelectMaskBitmap; // bitmap id of the weapon select mask bitmap
601 // convenient struct for handling all button controls
606 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
608 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) {}
611 static wl_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_WEAPON_BUTTONS] = {
614 wl_buttons("WLB_26", 0, 123, -1, -1, 26),
615 wl_buttons("WLB_27", 0, 272, -1, -1, 27),
616 wl_buttons("WLB_26", 0, 302, -1, -1, 8),
617 wl_buttons("WLB_27", 0, 452, -1, -1, 9),
618 wl_buttons("ssb_39", 566, 317, -1, -1, 39),
619 wl_buttons("ssb_39", 0, 0, -1, -1, 99),
620 wl_buttons("TSB_34", 601, 344, -1, -1, 50)
622 wl_buttons("WLB_26", 24, 125, -1, -1, 26),
623 wl_buttons("WLB_27", 24, 276, -1, -1, 27),
624 wl_buttons("WLB_08", 24, 303, -1, -1, 8),
625 wl_buttons("WLB_09", 24, 454, -1, -1, 9),
626 wl_buttons("ssb_39", 571, 347, -1, -1, 39),
627 wl_buttons("ssb_39", 0, 0, -1, -1, 99),
628 wl_buttons("TSB_34", 603, 374, -1, -1, 34)
632 wl_buttons("2_WLB_26", 39, 200, -1, -1, 26),
633 wl_buttons("2_WLB_27", 39, 442, -1, -1, 27),
634 wl_buttons("2_WLB_08", 39, 485, -1, -1, 8),
635 wl_buttons("2_WLB_09", 39, 727, -1, -1, 9),
636 wl_buttons("2_ssb_39", 913, 556, -1, -1, 39),
637 wl_buttons("2_ssb_39", 0, 0, -1, -1, 99),
638 wl_buttons("2_TSB_34", 966, 599, -1, -1, 34)
642 //static wl_bitmap_group wl_button_bitmaps[NUM_WEAPON_BUTTONS];
644 static int Weapon_button_scrollable[NUM_WEAPON_BUTTONS] = {0, 0, 0, 0, 0, 0, 0};
646 #define MAX_WEAPON_ICONS_ON_SCREEN 8
648 // X and Y locations of the weapon icons in the scrollable lists
649 //int Weapon_icon_x[MAX_WEAPON_ICONS_ON_SCREEN] = {27, 27, 27, 27, 36, 36, 36, 36};
650 //int Weapon_icon_y[MAX_WEAPON_ICONS_ON_SCREEN] = {152, 182, 212, 242, 331, 361, 391, 421};
651 static int Wl_weapon_icon_coords[GR_NUM_RESOLUTIONS][MAX_WEAPON_ICONS_ON_SCREEN][2] = {
675 static int Wl_bank_coords[GR_NUM_RESOLUTIONS][MAX_WL_WEAPONS][2] = {
706 static int Wl_bank_count_draw_flags[MAX_WL_WEAPONS] = {
707 0, 0, 0, // primaries -- dont draw counts
708 1, 1, 1, 1 // secondaries -- do draw counts
712 static int Weapon_anim_class = -1;
713 static int Last_wl_ship_class;
715 static int Wl_overhead_coords[GR_NUM_RESOLUTIONS][2] = {
730 static int Wl_weapon_ani_coords[GR_NUM_RESOLUTIONS][2] = {
743 static int Wl_weapon_ani_coords_multi[GR_NUM_RESOLUTIONS][2] = {
757 static int Wl_weapon_desc_coords[GR_NUM_RESOLUTIONS][2] = {
766 static int Wl_delta_x, Wl_delta_y;
768 static int Wl_ship_name_coords[GR_NUM_RESOLUTIONS][2] = {
778 ///////////////////////////////////////////////////////////////////////
780 ///////////////////////////////////////////////////////////////////////
781 typedef struct wl_ship_class_info
785 anim_instance_t *anim_instance;
786 } wl_ship_class_info;
788 wl_ship_class_info Wl_ships[MAX_SHIP_TYPES];
790 typedef struct wl_icon_info
792 int icon_bmaps[NUM_ICON_FRAMES];
793 int current_icon_bmap;
796 anim_instance_t *anim_instance;
799 wl_icon_info Wl_icons_teams[MAX_TEAMS][MAX_WEAPON_TYPES];
800 wl_icon_info *Wl_icons;
802 int Plist[MAX_WEAPON_TYPES]; // used to track scrolling of primary icon list
803 int Plist_start, Plist_size;
805 int Slist[MAX_WEAPON_TYPES]; // used to track scrolling of primary icon list
806 int Slist_start, Slist_size;
808 static int Selected_wl_slot = -1; // Currently selected ship slot
809 static int Selected_wl_class = -1; // Class of weapon that is selected
810 static int Hot_wl_slot = -1; // Ship slot that mouse is over (0..11)
811 static int Hot_weapon_icon = -1; // Icon number (0-7) which has mouse over it
812 static int Hot_weapon_bank = -1; // index (0-7) for weapon slot on ship that has a droppable icon over it
813 static int Hot_weapon_bank_icon = -1;
815 static int Wl_mouse_down_on_region = -1;
820 #define WEAPON_DESC_WIPE_TIME 1.5f // time in seconds for wipe to occur (over WEAPON_DESC_MAX_LENGTH number of chars)
821 #define WEAPON_DESC_MAX_LINES 7 // max lines in the description incl. title
822 #define WEAPON_DESC_MAX_LENGTH 50 // max chars per line of description text
823 static int Weapon_desc_wipe_done = 0;
824 static float Weapon_desc_wipe_time_elapsed = 0.0f;
825 static char Weapon_desc_lines[WEAPON_DESC_MAX_LINES][WEAPON_DESC_MAX_LENGTH]; // 1st 2 lines are title, rest are desc
827 // maximum width the weapon title can be -- used in the line breaking
828 int Weapon_title_max_width[GR_NUM_RESOLUTIONS] = { 200, 320 };
830 static int Wl_new_weapon_title_coords[GR_NUM_RESOLUTIONS][2] = {
839 static int Wl_new_weapon_title_coords_multi[GR_NUM_RESOLUTIONS][2] = {
848 static int Wl_new_weapon_desc_coords[GR_NUM_RESOLUTIONS][2] = {
857 static int Wl_new_weapon_desc_coords_multi[GR_NUM_RESOLUTIONS][2] = {
869 #define WEAPON_SELECT_NUM_TEXT 0
871 #define WEAPON_SELECT_NUM_TEXT 2
873 UI_XSTR Weapon_select_text[GR_NUM_RESOLUTIONS][WEAPON_SELECT_NUM_TEXT] = {
878 { "Reset", 1337, 580, 337, UI_XSTR_COLOR_GREEN, -1, &Buttons[0][WL_BUTTON_RESET].button },
879 { "Lock", 1270, 602, 364, UI_XSTR_COLOR_GREEN, -1, &Buttons[0][WL_BUTTON_MULTI_LOCK].button }
886 { "Reset", 1337, 938, 546, UI_XSTR_COLOR_GREEN, -1, &Buttons[1][WL_BUTTON_RESET].button },
887 { "Lock", 1270, 964, 584, UI_XSTR_COLOR_GREEN, -1, &Buttons[1][WL_BUTTON_MULTI_LOCK].button }
893 ///////////////////////////////////////////////////////////////////////
895 ///////////////////////////////////////////////////////////////////////
896 typedef struct carried_icon
898 int weapon_class; // index Wl_icons[] for carried icon (-1 if carried from bank)
899 int num; // number of units of weapon
900 int from_bank; // bank index that icon came from (0..2 primary, 3..6 secondary). -1 if from list
901 int from_slot; // ship slot that weapon is part of
905 static carried_icon Carried_wl_icon;
907 // forward declarations
908 void draw_wl_icons();
909 void wl_draw_ship_weapons(int index);
910 void wl_pick_icon_from_list(int index);
911 void pick_from_ship_slot(int num);
912 void start_weapon_animation(int weapon_class);
913 void stop_weapon_animation();
914 void wl_start_slot_animation(int n);
915 int wl_get_pilot_subsys_index(p_object *pobjp);
917 void wl_reset_to_defaults();
919 void wl_set_selected_slot(int slot_num);
920 void wl_maybe_reset_selected_slot();
921 void wl_maybe_reset_selected_weapon_class();
923 void wl_render_icon_count(int num, int x, int y);
924 void wl_render_weapon_desc();
928 // carry icon functions
929 void wl_reset_carried_icon();
930 int wl_icon_being_carried();
931 void wl_set_carried_icon(int from_bank, int from_slot, int weapon_class);
934 // Determine hack offset for how to draw fury missile icon.
935 int wl_fury_missile_offset_hack(int weapon_class, int num_missiles)
937 if ( weapon_class < 0 ) {
941 if ( num_missiles < 100 ) {
945 if ( !strnicmp(Weapon_info[weapon_class].name, NOX("fury"), 4) ) {
952 char *wl_tooltip_handler(char *str)
954 if (Selected_wl_class < 0)
957 if (!stricmp(str, "@weapon_desc")) {
961 str = Weapon_info[Selected_wl_class].desc;
962 gr_get_string_size(&w, &h, str);
963 x = Wl_weapon_desc_coords[gr_screen.res][0] - w / 2;
964 y = Wl_weapon_desc_coords[gr_screen.res][1] - h / 2;
966 gr_set_color_fast(&Color_black);
967 gr_rect(x - 5, y - 5, w + 10, h + 10);
969 gr_set_color_fast(&Color_bright_white);
970 gr_string(x, y, str);
977 // reset the data inside the Carried_wl_icon
978 void wl_reset_carried_icon()
980 Carried_wl_icon.weapon_class = -1;
981 Carried_wl_icon.num = 0;
982 Carried_wl_icon.from_bank = -1;
983 Carried_wl_icon.from_slot = -1;
986 // Is an icon being carried?
987 int wl_icon_being_carried()
989 if ( Carried_wl_icon.weapon_class >= 0 ) {
996 // Set carried icon data
997 void wl_set_carried_icon(int from_bank, int from_slot, int weapon_class)
1001 Carried_wl_icon.from_bank = from_bank;
1002 Carried_wl_icon.from_slot = from_slot;
1003 Carried_wl_icon.weapon_class = weapon_class;
1005 mouse_get_pos( &mx, &my );
1006 Carried_wl_icon.from_x=mx;
1007 Carried_wl_icon.from_y=my;
1009 Buttons[gr_screen.res][WL_BUTTON_DUMMY].button.capture_mouse();
1012 // determine if the carried icon has moved
1013 int wl_carried_icon_moved()
1016 mouse_get_pos( &mx, &my );
1017 if ( Carried_wl_icon.from_x != mx || Carried_wl_icon.from_y != my) {
1024 // return the index for the pilot subsystem in the parse object
1025 int wl_get_pilot_subsys_index(p_object *pobjp)
1027 int pilot_index, start_index, end_index, i;
1029 // see if there is a PILOT subystem
1030 start_index = pobjp->subsys_index;
1031 end_index = start_index + pobjp->subsys_count;
1033 for ( i = start_index; i < end_index; i++ ) {
1034 if ( !stricmp(Subsys_status[i].name, NOX("pilot") ) ) {
1040 if ( pilot_index == -1 ) {
1041 Error(LOCATION,"Parse object doesn't have a pilot subsystem\n");
1048 // Pause the current weapon animation
1049 void wl_pause_anim()
1051 if ( Weapon_anim_class >= 0 && Wl_icons[Weapon_anim_class].anim_instance ) {
1052 anim_pause(Wl_icons[Weapon_anim_class].anim_instance);
1056 // Unpause the current weapon animation
1057 void wl_unpause_anim()
1059 if ( Weapon_anim_class >= 0 && Wl_icons[Weapon_anim_class].anim_instance ) {
1060 anim_unpause(Wl_icons[Weapon_anim_class].anim_instance);
1064 // ---------------------------------------------------------------------------------
1065 // weapon_button_do()
1067 void weapon_button_do(int i)
1070 case PRIMARY_SCROLL_UP:
1071 if ( common_scroll_up_pressed(&Plist_start, Plist_size, 4) ) {
1072 gamesnd_play_iface(SND_SCROLL);
1074 gamesnd_play_iface(SND_GENERAL_FAIL);
1078 case PRIMARY_SCROLL_DOWN:
1079 if ( common_scroll_down_pressed(&Plist_start, Plist_size, 4) ) {
1080 gamesnd_play_iface(SND_SCROLL);
1082 gamesnd_play_iface(SND_GENERAL_FAIL);
1086 case SECONDARY_SCROLL_UP:
1087 if ( common_scroll_up_pressed(&Slist_start, Slist_size, 4) ) {
1088 gamesnd_play_iface(SND_SCROLL);
1090 gamesnd_play_iface(SND_GENERAL_FAIL);
1094 case SECONDARY_SCROLL_DOWN:
1095 if ( common_scroll_down_pressed(&Slist_start, Slist_size, 4) ) {
1096 gamesnd_play_iface(SND_SCROLL);
1098 gamesnd_play_iface(SND_GENERAL_FAIL);
1102 case WL_RESET_BUTTON_MASK:
1103 wl_reset_to_defaults();
1106 case WL_BUTTON_MULTI_LOCK:
1107 Assert(Game_mode & GM_MULTIPLAYER);
1108 // the "lock" button has been pressed
1109 multi_ts_lock_pressed();
1111 // disable the button if it is now locked
1112 if(multi_ts_is_locked()){
1113 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.disable();
1122 // -------------------------------------------------------------------
1123 // weapon_check_buttons()
1125 // Check if any weapons loadout screen buttons have been pressed, and
1126 // call weapon_button_do() if they have.
1128 void weapon_check_buttons()
1133 for ( i = 0; i < NUM_WEAPON_BUTTONS; i++ ) {
1134 b = &Buttons[gr_screen.res][i];
1136 if ( b->button.pressed() ) {
1137 if(i == WL_BUTTON_MULTI_LOCK){
1138 weapon_button_do(i);
1140 weapon_button_do(b->hotspot);
1146 // -------------------------------------------------------------------
1147 // wl_redraw_pressed_buttons()
1149 // Redraw any weapon loadout buttons that are pressed down. This function is needed
1150 // since we sometimes need to draw pressed buttons last to ensure the entire
1151 // button gets drawn (and not overlapped by other buttons)
1153 void wl_redraw_pressed_buttons()
1158 common_redraw_pressed_buttons();
1160 for ( i = 0; i < NUM_WEAPON_BUTTONS; i++ ) {
1161 b = &Buttons[gr_screen.res][i];
1162 if ( b->button.button_down() ) {
1163 b->button.draw_forced(2);
1168 // ---------------------------------------------------------------------------------
1169 // weapon_buttons_init()
1171 void weapon_buttons_init()
1176 for ( i = 0; i < NUM_WEAPON_BUTTONS; i++ ) {
1177 b = &Buttons[gr_screen.res][i];
1178 b->button.create( &Weapon_ui_window, "", Buttons[gr_screen.res][i].x, Buttons[gr_screen.res][i].y, 60, 30, Weapon_button_scrollable[i]);
1179 // set up callback for when a mouse first goes over a button
1180 b->button.set_highlight_action( common_play_highlight_sound );
1181 b->button.set_bmaps(Buttons[gr_screen.res][i].filename);
1182 b->button.link_hotspot(Buttons[gr_screen.res][i].hotspot);
1185 if ( Game_mode & GM_MULTIPLAYER ) {
1186 Buttons[gr_screen.res][WL_BUTTON_RESET].button.hide();
1187 Buttons[gr_screen.res][WL_BUTTON_RESET].button.disable();
1189 // if we're not the host of the game (or a team captain in team vs. team mode), disable the lock button
1190 if(Netgame.type_flags & NG_TYPE_TEAM){
1191 if(!(Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN)){
1192 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.disable();
1195 if(!(Net_player->flags & NETINFO_FLAG_GAME_HOST)){
1196 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.disable();
1200 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.hide();
1201 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.disable();
1205 for(i=0; i<WEAPON_SELECT_NUM_TEXT; i++) {
1206 Weapon_ui_window.add_XSTR(&Weapon_select_text[gr_screen.res][i]);
1209 Buttons[gr_screen.res][WL_BUTTON_DUMMY].button.hide();
1210 Buttons[gr_screen.res][WL_BUTTON_DUMMY].button.disable();
1213 // ---------------------------------------------------------------------------------
1214 // wl_render_overhead_view()
1216 void wl_render_overhead_view(float frametime)
1218 char name[NAME_LENGTH + CALLSIGN_LEN];
1219 wl_ship_class_info *wl_ship;
1222 if ( Selected_wl_slot == -1 ) {
1226 ship_class = Wss_slots[Selected_wl_slot].ship_class;
1228 // check if ship class has changed and maybe play sound
1229 if (Last_wl_ship_class != ship_class) {
1230 if (Last_wl_ship_class != -1) {
1231 gamesnd_play_iface(SND_ICON_DROP);
1233 Last_wl_ship_class = ship_class;
1236 wl_ship = &Wl_ships[ship_class];
1238 if ( wl_ship->anim_instance == NULL ) {
1239 if ( wl_ship->overhead_bitmap < 0 ) {
1241 if (gr_screen.res == GR_640)
1244 wl_ship->overhead_bitmap = bm_load(Ship_info[ship_class].overhead_filename);
1247 char filename[NAME_LENGTH+2] = "2_";
1248 strcat(filename, Ship_info[ship_class].overhead_filename);
1249 wl_ship->overhead_bitmap = bm_load(filename);
1251 if ( wl_ship->overhead_bitmap < 0 ) {
1252 Int3(); // bad things happened
1256 gr_set_bitmap(wl_ship->overhead_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1257 gr_bitmap(Wl_overhead_coords[gr_screen.res][0], Wl_overhead_coords[gr_screen.res][1]);
1260 ss_return_name(Selected_wl_slot/4, Selected_wl_slot%4, name);
1261 gr_set_color_fast(&Color_normal);
1262 gr_string(Wl_ship_name_coords[gr_screen.res][0], Wl_ship_name_coords[gr_screen.res][1], name);
1265 // ---------------------------------------------------------------------------------
1266 // wl_get_ship_class()
1269 int wl_get_ship_class(int wl_slot)
1271 return Wss_slots[wl_slot].ship_class;
1274 // Return true if weapon_flags indicates a weapon that is legal for use in current game type.
1275 // Function added by MK on 9/6/99 to support separate legal loadouts for dogfight missions.
1276 int weapon_allowed_for_game_type(int weapon_flags)
1280 /* disable check for demo since it doesn't have "$Allowed Dogfight PBanks" */
1281 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
1282 if ((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT)) {
1283 if (weapon_flags & (1 << 1))
1287 if (weapon_flags & (1 << 0))
1293 // go through the possible weapons to choose from, and flag some as disabled since
1294 // that ship class cannot use that kind of weapon. The weapon filter is specified
1295 // in ships.tbl, where each ship has a list of all the possible weapons it can use.
1296 void wl_set_disabled_weapons(int ship_class)
1301 if ( ship_class == - 1 )
1304 Assert(ship_class >= 0 && ship_class < MAX_SHIP_TYPES);
1306 sip = &Ship_info[ship_class];
1308 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1309 // Determine whether weapon #i is allowed on this ship class in the current type of mission.
1310 // As of 9/6/99, the only difference is dogfight missions have a different list of legal weapons.
1311 Wl_icons[i].can_use = weapon_allowed_for_game_type(sip->allowed_weapons[i]);
1315 // ---------------------------------------------------------------------------------
1316 // maybe_select_wl_slot()
1318 // A slot index was clicked on, mabye change Selected_wl_slot
1319 void maybe_select_wl_slot(int block, int slot)
1323 if ( Wss_num_wings <= 0 )
1326 sidx = block*4 + slot;
1327 if ( Wss_slots[sidx].ship_class < 0 ) {
1331 wl_set_selected_slot(sidx);
1334 // ---------------------------------------------------------------------------------
1335 // maybe_select_new_weapon()
1337 // Change to the weapon that corresponds to index in the weapon list
1339 // input: index => weapon icon index (0-7)
1341 void maybe_select_new_weapon(int index)
1345 // if a weapon is being carried, do nothing
1346 if ( wl_icon_being_carried() ) {
1350 int region_index = ICON_PRIMARY_0+index;
1352 region_index = ICON_SECONDARY_0 + (index - 4);
1355 if ( Wl_mouse_down_on_region != region_index ) {
1360 weapon_class = Plist[Plist_start+index];
1362 weapon_class = Slist[Slist_start+index-4];
1365 if ( weapon_class >= 0 ) {
1366 Selected_wl_class = weapon_class;
1367 wl_pick_icon_from_list(index);
1371 // ---------------------------------------------------------------------------------
1372 // maybe_select_new_ship_weapon()
1374 // Change to the weapon that corresponds to the ship weapon slot
1376 // input: index -> index of bank (0..2 primary, 0..6 secondary)
1377 void maybe_select_new_ship_weapon(int index)
1379 int *wep, *wep_count;
1381 if ( Selected_wl_slot == -1 )
1384 if ( wl_icon_being_carried() ) {
1388 wep = Wss_slots[Selected_wl_slot].wep;
1389 wep_count = Wss_slots[Selected_wl_slot].wep_count;
1391 if ( wep[index] < 0 || wep_count[index] <= 0 ) {
1395 if ( Wl_mouse_down_on_region != (ICON_SHIP_PRIMARY_0+index) ) {
1400 Selected_wl_class = wep[index];
1403 // Initialize Wl_pool[] to mission deafult
1404 void wl_init_pool(team_data *td)
1408 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1412 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1413 Wl_pool[i] = td->weaponry_pool[i]; // read from mission
1417 // load the icons for a specific ship class
1418 void wl_load_icons(int weapon_class)
1421 int first_frame, num_frames, i;
1423 icon = &Wl_icons[weapon_class];
1425 first_frame = bm_load_animation(Weapon_info[weapon_class].icon_filename, &num_frames);
1426 if ( first_frame == -1 ) {
1427 Int3(); // Could not load in icon frames.. get Alan
1431 for ( i = 0; i < num_frames ; i++ ) {
1432 icon->icon_bmaps[i] = first_frame+i;
1436 // Load in a specific weapon animation. The data is loaded as a memory-mapped file since these animations
1438 void wl_load_anim(int weapon_class)
1440 char animation_filename[CF_MAX_FILENAME_LENGTH+4];
1443 icon = &Wl_icons[weapon_class];
1444 Assert( icon->anim == NULL );
1447 // If we are in 1024x768, we first want to append "2_" in front of the filename
1448 if (gr_screen.res == GR_1024) {
1449 Assert(strlen(Weapon_info[weapon_class].anim_filename) <= 30);
1450 strcpy(animation_filename, "2_");
1451 strcat(animation_filename, Weapon_info[weapon_class].anim_filename);
1453 // now check if file exists
1454 // GRR must add a .ANI at the end for detection
1455 strcat(animation_filename,".ani");
1456 icon->anim = anim_load(animation_filename, 1);
1458 if (icon->anim == NULL) {
1459 mprintf(("Weapon ANI: Can not find %s, using lowres version instead.\n",animation_filename));
1460 strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
1461 icon->anim = anim_load(animation_filename, 1);
1465 if (!cf_exist(animation_filename, CF_TYPE_INTERFACE)) {
1466 // file does not exist, use original low res version
1467 mprintf(("Weapon ANI: Can not find %s, using lowres version instead.\n",animation_filename));
1468 strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
1470 animation_filename[strlen(animation_filename) - 4] = '\0';
1471 mprintf(("Weapon ANI: Found hires version of %s\n",animation_filename));
1475 strcpy(animation_filename, Weapon_info[weapon_class].anim_filename);
1476 // load the compressed ship animation into memory
1477 // NOTE: if last parm of load_anim is 1, the anim file is mapped to memory
1478 icon->anim = anim_load(animation_filename, 1);
1481 if ( icon->anim == NULL ) {
1482 Int3(); // couldn't load anim filename.. get Alan
1486 // Load in any weapon animations. This function assumes that Wl_pool has been inited.
1487 void wl_load_all_anims()
1489 #ifndef DEMO // not for FS2_DEMO
1493 // init anim members for weapon animations
1494 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1495 Wl_icons[i].anim = NULL;
1496 Wl_icons[i].anim_instance = NULL;
1499 // init anim member for overhead ship animations
1500 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1501 Wl_ships[i].anim = NULL;
1502 Wl_ships[i].anim_instance = NULL;
1505 // load up the animations used for weapons (they are memory-mapped)
1506 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1507 if ( Wl_pool[i] > 0 ) {
1515 // release any anim instances
1516 void wl_unload_all_anim_instances()
1518 // stop any weapon anim instances
1519 for ( int i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1520 if ( Wl_icons[i].anim_instance ) {
1521 anim_release_render_instance(Wl_icons[i].anim_instance);
1522 Wl_icons[i].anim_instance = NULL;
1526 // stop any overhead anim instances
1527 for (int i = 0; i < MAX_SHIP_TYPES; i++ ) {
1528 if ( Wl_ships[i].anim_instance ) {
1529 anim_release_render_instance(Wl_ships[i].anim_instance);
1530 Wl_ships[i].anim_instance = NULL;
1535 // free source anim data if allocated
1536 void wl_unload_all_anims()
1540 // unload overhead anim instances
1541 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1542 if ( Wl_ships[i].anim ) {
1543 anim_free(Wl_ships[i].anim);
1544 Wl_ships[i].anim = NULL;
1548 // unload weapon anim instances
1549 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1550 if ( Wl_icons[i].anim ) {
1551 anim_free(Wl_icons[i].anim);
1552 Wl_icons[i].anim = NULL;
1557 // load all the icons for weapons in the pool
1558 void wl_load_all_icons()
1560 #ifndef DEMO // not for FS2_DEMO
1564 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1566 Wl_icons[i].anim = NULL;
1567 Wl_icons[i].anim_instance = NULL;
1568 for ( j = 0; j < NUM_ICON_FRAMES; j++ ) {
1569 Wl_icons[i].icon_bmaps[j] = -1;
1572 if ( Wl_pool[i] > 0 ) {
1580 // wl_unload_icons() frees the bitmaps used for weapon icons
1581 void wl_unload_icons()
1586 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1587 icon = &Wl_icons[i];
1589 for ( j = 0; j < NUM_ICON_FRAMES; j++ ) {
1590 if ( icon->icon_bmaps[j] >= 0 ) {
1591 bm_release(icon->icon_bmaps[j]);
1592 icon->icon_bmaps[j] = -1;
1598 // init ship-class specific data
1599 void wl_init_ship_class_data()
1602 wl_ship_class_info *wl_ship;
1604 for ( i=0; i<MAX_SHIP_TYPES; i++ ) {
1605 wl_ship = &Wl_ships[i];
1606 wl_ship->overhead_bitmap = -1;
1607 wl_ship->anim = NULL;
1608 wl_ship->anim_instance = NULL;
1612 // free any allocated ship-class specific data
1613 void wl_free_ship_class_data()
1616 wl_ship_class_info *wl_ship;
1618 for ( i=0; i<MAX_SHIP_TYPES; i++ ) {
1619 wl_ship = &Wl_ships[i];
1621 if ( wl_ship->overhead_bitmap != -1 ) {
1622 bm_release(wl_ship->overhead_bitmap);
1623 wl_ship->overhead_bitmap = -1;
1626 if ( wl_ship->anim != NULL ) {
1627 wl_ship->anim = NULL;
1630 if ( wl_ship->anim_instance != NULL ) {
1631 wl_ship->anim_instance = NULL;
1636 // Set selected slot to first placed ship
1637 void wl_reset_selected_slot()
1640 Selected_wl_slot = -1;
1642 // in multiplayer, select the slot of the player's ship by default
1643 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)){
1644 wl_set_selected_slot(Net_player->p_info.ship_index);
1648 for ( i=0; i<MAX_WSS_SLOTS; i++ ) {
1649 if ( !ss_disabled_slot(i) ) {
1650 if ( ss_wing_slot_is_console_player(i) && (Wss_slots[i].ship_class >= 0) ) {
1651 wl_set_selected_slot(i);
1657 // Didn't locate player ship, so just select the first ship we find
1658 for ( i=0; i<MAX_WSS_SLOTS; i++ ) {
1659 if ( Wss_slots[i].ship_class >= 0 ) {
1660 wl_set_selected_slot(i);
1666 // called whenever it is possible that the current selected slot has had it's ship disappear
1667 void wl_maybe_reset_selected_slot()
1671 if ( Selected_wl_slot == -1 ) {
1675 if ( Wss_slots[Selected_wl_slot].ship_class < 0 ) {
1680 wl_reset_selected_slot();
1684 // If Selected_wl_class is -1, choose the first weapon available from the pool for an animation
1685 // - on second thought, choose the first weapon that is oin the ship, then go to the pools
1686 void wl_maybe_reset_selected_weapon_class()
1690 if ( Selected_wl_class >= 0 )
1693 // try to locate a weapon class to show animation for
1694 // first check for a weapon on the ship
1695 for (i=0; i<MAX_WL_WEAPONS; i++) {
1696 // if alpha 1 has a weapon in bank i, set it as the selected type
1697 if (Wss_slots[0].wep_count[i] >= 0) {
1698 Selected_wl_class = Wss_slots[0].wep[i];
1703 // then check for a primary weapon in the pool
1704 for ( i = 0; i < Plist_size; i++ ) {
1705 if ( Plist[i] >= 0 ) {
1706 Selected_wl_class = Plist[i];
1711 // finally, if no others found yet, check for a secondary weapon in the pool
1712 for ( i = 0; i < Slist_size; i++ ) {
1713 if ( Slist[i] >= 0 ) {
1714 Selected_wl_class = Slist[i];
1720 // start an overhead animation, since selected slot has changed
1721 void wl_start_slot_animation(int n)
1723 #ifndef DEMO // not for FS2_DEMO
1726 // fallback code in wl_render_overhead_view() will
1727 // use the .pcx files
1728 // should prolly scrub out the 1e06 lines of dead code this leaves
1733 wl_ship_class_info *wl_ship;
1734 anim_play_struct aps;
1740 ship_class = Wss_slots[n].ship_class;
1742 if ( ship_class < 0 ) {
1747 wl_ship = &Wl_ships[ship_class];
1749 // maybe this animation is already playing?
1750 if ( wl_ship->anim_instance ) {
1751 anim_stop_playing(wl_ship->anim_instance);
1752 wl_ship->anim_instance = NULL;
1755 // maybe we have to load this animation
1756 if ( wl_ship->anim == NULL ) {
1757 wl_ship->anim = anim_load(Ship_info[ship_class].overhead_filename, 1);
1758 if ( wl_ship->anim == NULL ) {
1759 Int3(); // couldn't load anim filename.. get Alan
1764 anim_play_init(&aps, wl_ship->anim, Wl_overhead_coords[gr_screen.res][0], Wl_overhead_coords[gr_screen.res][1]);
1765 aps.screen_id = ON_WEAPON_SELECT;
1766 aps.framerate_independent = 1;
1767 aps.skip_frames = 0;
1768 wl_ship->anim_instance = anim_play(&aps);
1773 // Call when Selected_wl_slot needs to be changed
1774 void wl_set_selected_slot(int slot_num)
1776 if ( (slot_num >= 0) && (slot_num != Selected_wl_slot) ) {
1777 // slot has changed.... start an animation
1778 wl_start_slot_animation(slot_num);
1780 if ( Current_screen == ON_WEAPON_SELECT ) {
1781 gamesnd_play_iface(SND_OVERHEAD_SHIP_ANIM);
1786 Selected_wl_slot = slot_num;
1787 if ( Selected_wl_slot >= 0 ) {
1788 wl_set_disabled_weapons(Wss_slots[slot_num].ship_class);
1792 // determine how many missiles of type 'wi_index' will fit into capacity
1793 int wl_calc_missile_fit(int wi_index, int capacity)
1795 if ( wi_index < 0 ) {
1799 Assert(Weapon_info[wi_index].subtype == WP_MISSILE);
1800 return fl2i( capacity / Weapon_info[wi_index].cargo_size + 0.5f );
1803 // fill out the weapons for this ship_class
1804 void wl_get_ship_class_weapons(int ship_class, int *wep, int *wep_count)
1809 Assert(ship_class >= 0 && ship_class < MAX_SHIP_TYPES);
1810 sip = &Ship_info[ship_class];
1812 // reset weapons arrays
1813 for ( i=0; i < MAX_WL_WEAPONS; i++ ) {
1815 wep_count[i] = -1; // -1 means weapon bank doesn't exist.. 0 just means it is empty
1818 for ( i = 0; i < sip->num_primary_banks; i++ ) {
1819 wep[i] = sip->primary_bank_weapons[i];
1823 for ( i = 0; i < sip->num_secondary_banks; i++ ) {
1824 wep[i+MAX_WL_PRIMARY] = sip->secondary_bank_weapons[i];
1825 wep_count[i+MAX_WL_PRIMARY] = wl_calc_missile_fit(sip->secondary_bank_weapons[i], sip->secondary_bank_ammo_capacity[i]);
1829 // fill out the wep[] and wep_count[] arrays for a ship
1830 void wl_get_ship_weapons(int ship_index, int *wep, int *wep_count)
1836 Assert(ship_index >= 0);
1838 Assert(Ships[ship_index].wingnum >= 0);
1839 wp = &Wings[Ships[ship_index].wingnum];
1840 swp = &Ships[ship_index].weapons;
1842 for ( i = 0; i < swp->num_primary_banks; i++ ) {
1843 wep[i] = swp->primary_bank_weapons[i];
1845 if ( wep[i] == -1 ) {
1850 for ( i = 0; i < swp->num_secondary_banks; i++ ) {
1851 wep[i+MAX_WL_PRIMARY] = swp->secondary_bank_weapons[i];
1852 wep_count[i+MAX_WL_PRIMARY] = swp->secondary_bank_ammo[i];
1853 if ( wep[i+MAX_WL_PRIMARY] == -1 ) {
1854 wep_count[i+MAX_WL_PRIMARY] = 0;
1859 // set wep and wep_count from a ship which sits in the ship_arrivals[] list at index sa_index
1860 void wl_get_parseobj_weapons(int sa_index, int ship_class, int *wep, int *wep_count)
1867 pobjp = &ship_arrivals[sa_index];
1868 sip = &Ship_info[ship_class];
1870 pilot_index = wl_get_pilot_subsys_index(pobjp);
1872 if ( pilot_index == -1 )
1875 ss = &Subsys_status[pilot_index];
1877 if ( ss->primary_banks[0] != SUBSYS_STATUS_NO_CHANGE ) {
1878 for ( i=0; i < MAX_PRIMARY_BANKS; i++ ) {
1879 wep[i] = ss->primary_banks[i];
1883 if ( ss->secondary_banks[0] != SUBSYS_STATUS_NO_CHANGE ) {
1884 for ( i=0; i < MAX_SECONDARY_BANKS; i++ ) {
1885 wep[i+MAX_WL_PRIMARY] = ss->secondary_banks[i];
1889 // ammo counts could still be modified
1890 for ( i=0; i < MAX_SECONDARY_BANKS; i++ ) {
1891 if ( wep[i+MAX_WL_PRIMARY] >= 0 ) {
1892 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));
1897 // ensure that there aren't any bogus weapons assigned by default
1898 void wl_cull_illegal_weapons(int ship_class, int *wep, int *wep_count)
1901 for ( i=0; i < MAX_WL_WEAPONS; i++ ) {
1906 if ( !weapon_allowed_for_game_type(Ship_info[ship_class].allowed_weapons[wep[i]]) ) {
1913 // get the weapons info that should be on ship by default
1914 void wl_get_default_weapons(int ship_class, int slot_num, int *wep, int *wep_count)
1916 int original_ship_class, i;
1918 Assert(slot_num >= 0 && slot_num < MAX_WSS_SLOTS);
1920 // clear out wep and wep_count
1921 for ( i = 0; i < MAX_WL_WEAPONS; i++ ) {
1926 if ( ship_class < 0 )
1929 original_ship_class = ss_return_original_ship_class(slot_num);
1931 if ( original_ship_class != ship_class ) {
1932 wl_get_ship_class_weapons(ship_class, wep, wep_count);
1934 int sa_index; // ship arrival index
1935 sa_index = ss_return_saindex(slot_num);
1937 if ( sa_index >= 0 ) {
1938 // still a parse object
1939 wl_get_ship_class_weapons(ship_class, wep, wep_count);
1940 wl_get_parseobj_weapons(sa_index, ship_class, wep, wep_count);
1942 // ship has been created
1943 // wl_get_ship_weapons(slot_num/4, slot_num%4, wep, wep_count);
1944 int ship_index = -1;
1946 ss_return_ship(slot_num/4, slot_num%4, &ship_index, &pobjp);
1947 Assert(ship_index != -1);
1948 wl_get_ship_weapons(ship_index, wep, wep_count);
1952 // ensure that there aren't any bogus weapons assigned by default
1953 wl_cull_illegal_weapons(ship_class, wep, wep_count);
1956 // function to add a weapon_class to ui lists
1957 void wl_add_index_to_list(int wi_index)
1960 if ( Weapon_info[wi_index].subtype == WP_MISSILE ) {
1962 for ( i=0; i<Slist_size; i++ ) {
1963 if ( Slist[i] == wi_index )
1967 if ( i == Slist_size )
1968 Slist[Slist_size++] = wi_index;
1971 for ( i=0; i<Plist_size; i++ ) {
1972 if ( Plist[i] == wi_index )
1976 if ( i == Plist_size )
1977 Plist[Plist_size++] = wi_index;
1981 // remove the weapons specificed by wep[] and wep_count[] from Wl_pool[].
1982 void wl_remove_weps_from_pool(int *wep, int *wep_count, int ship_class)
1986 for ( i = 0; i < MAX_WL_WEAPONS; i++ ) {
1988 if ( wi_index >= 0 ) {
1989 if ( (wep_count[i] > 0) && ((Wl_pool[wi_index] - wep_count[i]) >= 0) ) {
1990 Wl_pool[wi_index] -= wep_count[i];
1992 // not enough weapons in pool
1993 // TEMP HACK: FRED doesn't fill in a weapons pool if there are no starting wings... so
1994 // add to the pool. This should be fixed.
1995 if ( Wss_num_wings <= 0 ) {
1996 wl_add_index_to_list(wi_index);
1999 if ( (Wl_pool[wi_index] <= 0) || (wep_count[i] == 0) ) {
2000 // fresh out of this weapon, pick an alternate pool weapon if we can
2001 int wep_pool_index, wep_precedence_index, new_wi_index = -1;
2002 for ( wep_pool_index = 0; wep_pool_index < MAX_WEAPON_TYPES; wep_pool_index++ ) {
2004 if ( Wl_pool[wep_pool_index] <= 0 ) {
2008 // AL 3-31-98: Only pick another primary if primary, etc
2009 if ( Weapon_info[wi_index].subtype != Weapon_info[wep_pool_index].subtype ) {
2013 if ( !weapon_allowed_for_game_type(Ship_info[ship_class].allowed_weapons[wep_pool_index]) ) {
2018 for ( wep_precedence_index = 0; wep_precedence_index < Num_player_weapon_precedence; wep_precedence_index++ ) {
2019 if ( wep_pool_index == Player_weapon_precedence[wep_precedence_index] ) {
2020 new_wi_index = wep_pool_index;
2025 if ( new_wi_index >= 0 ) {
2030 if ( new_wi_index >= 0 ) {
2031 wep[i] = new_wi_index;
2032 wi_index = new_wi_index;
2036 int new_wep_count = wep_count[i];
2037 if ( Weapon_info[wi_index].subtype == WP_MISSILE ) {
2038 int secondary_bank_index;
2039 secondary_bank_index = i-3;
2040 if ( secondary_bank_index < 0 ) {
2042 secondary_bank_index = 0;
2044 new_wep_count = wl_calc_missile_fit(wi_index, Ship_info[ship_class].secondary_bank_ammo_capacity[secondary_bank_index]);
2047 wep_count[i] = min(new_wep_count, Wl_pool[wi_index]);
2048 Assert(wep_count[i] >= 0);
2049 Wl_pool[wi_index] -= wep_count[i];
2050 if ( wep_count[i] <= 0 ) {
2059 // Init the weapons portion of Wss_slots[] and the ui data in Wl_slots[]
2060 // NOTE: it is assumed that Wl_pool[] has been initialized, and Wss_slots[].ship_class is correctly set
2061 void wl_fill_slots()
2064 int wep[MAX_WL_WEAPONS];
2065 int wep_count[MAX_WL_WEAPONS];
2067 for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
2068 if ( Wss_slots[i].ship_class < 0 ){
2072 // get the weapons info that should be on ship by default
2073 wl_get_default_weapons(Wss_slots[i].ship_class, i, wep, wep_count);
2074 wl_remove_weps_from_pool(wep, wep_count, Wss_slots[i].ship_class);
2076 // copy to Wss_slots[]
2077 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
2078 Wss_slots[i].wep[j] = wep[j];
2079 Wss_slots[i].wep_count[j] = wep_count[j];
2084 // set up the primary and secondary icons lists that hold the weapons the player can choose from
2085 void wl_init_icon_lists()
2089 Plist_start = 0; // offset into Plist[]
2092 Plist_size = 0; // number of active elements in Plist[]
2095 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
2100 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
2101 if ( Wl_pool[i] > 0 ) {
2102 if ( Weapon_info[i].subtype == WP_MISSILE ) {
2103 Slist[Slist_size++] = i;
2105 Plist[Plist_size++] = i;
2111 // initialize team specific weapon select data structures
2112 void weapon_select_init_team(int team_num)
2114 Wl_icons = Wl_icons_teams[team_num];
2115 ss_set_team_pointers(team_num);
2117 wl_init_pool(&Team_data[team_num]);
2118 wl_init_icon_lists();
2119 wl_init_ship_class_data();
2121 wl_load_all_icons();
2122 wl_load_all_anims();
2127 // close out what weapon_select_init_team() set up but only when we are not acutally
2128 // in the weapon select screen
2129 void weapon_select_close_team()
2131 if (Weapon_select_open)
2134 wl_unload_all_anim_instances();
2135 wl_unload_all_anims();
2138 // This init is called even before the weapons loadout screen is entered. It is called when the
2139 // briefing state is entered.
2140 void weapon_select_common_init()
2144 if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){
2145 // initialize for all teams
2146 for(idx=0;idx<MULTI_TS_MAX_TEAMS;idx++){
2147 weapon_select_init_team(idx);
2150 // re-initialize for me specifically
2151 weapon_select_init_team(Common_team);
2153 // initialize for my own team
2154 weapon_select_init_team(Common_team);
2157 wl_reset_selected_slot();
2158 wl_reset_carried_icon();
2159 wl_maybe_reset_selected_weapon_class();
2162 // ---------------------------------------------------------------------------------
2163 // weapon_select_init() is called to load the bitmaps and set up the mask regions for
2164 // the weapon loadout screen. common_select_init() is called to load the animations
2165 // and bitmaps which are in common with the ship select and briefing screens.
2167 // The Weapon_select_open flag is set to 1 when weapon_select_init() completes successfully
2169 void weapon_select_init()
2171 common_set_interface_palette("WeaponPalette");
2172 common_flash_button_init();
2174 // for multiplayer, change the state in my netplayer structure
2175 if ( Game_mode & GM_MULTIPLAYER )
2176 Net_player->state = NETPLAYER_STATE_WEAPON_SELECT;
2178 ship_stop_animation();
2179 stop_weapon_animation();
2180 Weapon_anim_class = -1;
2182 set_active_ui(&Weapon_ui_window);
2183 Current_screen = ON_WEAPON_SELECT;
2184 Last_wl_ship_class = -1;
2186 wl_maybe_reset_selected_slot();
2187 wl_set_disabled_weapons(Wss_slots[Selected_wl_slot].ship_class);
2189 help_overlay_set_state(WL_OVERLAY,0);
2191 if ( Weapon_select_open ) {
2192 wl_maybe_reset_selected_weapon_class();
2193 wl_start_slot_animation(Selected_wl_slot);
2194 common_buttons_maybe_reload(&Weapon_ui_window); // AL 11-21-97: this is necessary since we may returning from the hotkey
2195 // screen, which can release common button bitmaps.
2196 common_reset_buttons();
2197 nprintf(("Alan","weapon_select_init() returning without doing anything\n"));
2199 // if we're in multiplayer always select the player's ship
2200 wl_reset_selected_slot();
2205 nprintf(("Alan","entering weapon_select_init()\n"));
2206 common_select_init();
2208 WeaponSelectMaskBitmap = bm_load(Wl_loadout_select_mask[gr_screen.res]);
2209 if (WeaponSelectMaskBitmap < 0) {
2210 if (gr_screen.res == GR_640) {
2211 Error(LOCATION,"Could not load in 'weaponloadout-m'!");
2212 } else if (gr_screen.res == GR_1024) {
2213 Error(LOCATION,"Could not load in '2_weaponloadout-m'!");
2215 Error(LOCATION,"Could not load in 'weaponloadout-m'!");
2219 Weaponselect_mask_w = -1;
2220 Weaponselect_mask_h = -1;
2222 // get a pointer to bitmap by using bm_lock()
2223 WeaponSelectMaskPtr = bm_lock(WeaponSelectMaskBitmap, 8, BMP_AABITMAP);
2224 WeaponSelectMaskData = (ubyte*)WeaponSelectMaskPtr->data;
2225 Assert(WeaponSelectMaskData != NULL);
2226 bm_get_info(WeaponSelectMaskBitmap, &Weaponselect_mask_w, &Weaponselect_mask_h);
2229 // Set up the mask regions
2230 // initialize the different regions of the menu that will react when the mouse moves over it
2231 Num_weapon_select_regions = 0;
2233 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_BRIEFING_REGION, 0);
2234 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_SS_REGION, 0);
2235 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_WEAPON_REGION, 0);
2236 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_COMMIT_REGION, 0);
2237 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_HELP_REGION, 0);
2238 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", COMMON_OPTIONS_REGION, 0);
2240 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_0_SHIP_0, 0);
2241 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_0_SHIP_1, 0);
2242 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_0_SHIP_2, 0);
2243 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_0_SHIP_3, 0);
2244 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_1_SHIP_0, 0);
2245 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_1_SHIP_1, 0);
2246 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_1_SHIP_2, 0);
2247 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_1_SHIP_3, 0);
2248 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_2_SHIP_0, 0);
2249 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_2_SHIP_1, 0);
2250 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_2_SHIP_2, 0);
2251 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", WING_2_SHIP_3, 0);
2253 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_PRIMARY_0, 0);
2254 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_PRIMARY_1, 0);
2255 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_PRIMARY_2, 0);
2256 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_PRIMARY_3, 0);
2257 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SECONDARY_0, 0);
2258 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SECONDARY_1, 0);
2259 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SECONDARY_2, 0);
2260 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SECONDARY_3, 0);
2262 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_PRIMARY_0, 0);
2263 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_PRIMARY_1, 0);
2264 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_PRIMARY_2, 0);
2265 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_SECONDARY_0, 0);
2266 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_SECONDARY_1, 0);
2267 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_SECONDARY_2, 0);
2268 snazzy_menu_add_region(&Weapon_select_region[Num_weapon_select_regions++], "", ICON_SHIP_SECONDARY_3, 0);
2271 Weapon_ui_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
2273 if(Game_mode & GM_MULTIPLAYER){
2274 Weapon_ui_window.set_mask_bmap(Wl_mask_multi[gr_screen.res]);
2276 Weapon_ui_window.set_mask_bmap(Wl_mask_single[gr_screen.res]);
2279 // initialize background bitmap
2280 if(Game_mode & GM_MULTIPLAYER) {
2281 Weapon_select_background_bitmap = bm_load(Weapon_select_multi_background_fname[gr_screen.res]);
2283 Weapon_select_background_bitmap = bm_load(Weapon_select_background_fname[gr_screen.res]);
2286 Weapon_ui_window.tooltip_handler = wl_tooltip_handler;
2287 common_buttons_init(&Weapon_ui_window);
2288 weapon_buttons_init();
2289 Weapon_select_open = 1;
2291 // if we're in multiplayer always select the player's ship
2292 wl_reset_selected_slot();
2295 // ----------------------------------------------------------------
2296 // wl_dump_carried_icon()
2297 void wl_dump_carried_icon()
2299 if ( wl_icon_being_carried() ) {
2300 // Add back into the weapon pool
2301 if ( Carried_wl_icon.from_bank >= 0 ) {
2303 wl_drop(Carried_wl_icon.from_bank, -1, -1, Carried_wl_icon.weapon_class, Carried_wl_icon.from_slot);
2305 if ( wl_carried_icon_moved() ) {
2306 gamesnd_play_iface(SND_ICON_DROP);
2310 wl_reset_carried_icon();
2314 // ----------------------------------------------------------------
2315 // drop_icon_on_slot()
2317 // Drop the Carried_wl_icon onto the specified slot. The slot numbering is:
2319 // 0->2: primary weapons
2320 // 3-6: secondary weapons
2322 // These are the slots that exist beside the overhead view of the ship.
2323 // on the weapons loadout screen.
2325 int drop_icon_on_slot(int bank_num)
2327 if ( Selected_wl_slot == -1 ) {
2331 if(Game_mode & GM_MULTIPLAYER){
2332 if(multi_ts_disabled_slot(Selected_wl_slot)){
2336 if ( ss_disabled_slot( Selected_wl_slot ) ){
2341 // check if slot exists
2342 if ( Wss_slots[Selected_wl_slot].wep_count[bank_num] < 0 ) {
2346 if ( !wl_carried_icon_moved() ) {
2347 wl_reset_carried_icon();
2351 wl_drop(Carried_wl_icon.from_bank, Carried_wl_icon.weapon_class, bank_num, -1, Selected_wl_slot);
2355 // ----------------------------------------------------------------
2356 // maybe_drop_icon_on_slot()
2358 void maybe_drop_icon_on_slot(int bank_num)
2361 if ( !mouse_down(MOUSE_LEFT_BUTTON) ) {
2362 if ( wl_icon_being_carried() )
2363 dropped = drop_icon_on_slot(bank_num);
2366 wl_reset_carried_icon();
2371 // ----------------------------------------------------------------
2372 // wl_check_for_stopped_ship_anims()
2374 void wl_check_for_stopped_ship_anims()
2378 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
2379 ai = Wl_ships[i].anim_instance;
2381 if ( !anim_playing(ai) ) {
2382 Wl_ships[i].anim_instance = NULL;
2388 // ---------------------------------------------------------------------------------
2389 // do_mouse_over_list_weapon()
2391 void do_mouse_over_list_weapon(int index)
2393 Hot_weapon_icon = index;
2395 int region_index = ICON_PRIMARY_0+index;
2397 region_index = ICON_SECONDARY_0 + (index - 4);
2400 if ( Wl_mouse_down_on_region != region_index ){
2404 if ( mouse_down(MOUSE_LEFT_BUTTON) )
2405 wl_pick_icon_from_list(index);
2408 // ---------------------------------------------------------------------------------
2409 // do_mouse_over_ship_weapon()
2412 // input: index -> bank index on ship (0..6)
2415 // 0 -> icon was not dropped on a slot
2416 // 1 -> icon was dropped on a slot
2417 int do_mouse_over_ship_weapon(int index)
2419 int dropped_on_slot, is_moved, mx, my;
2421 dropped_on_slot = 0;
2422 Assert(Selected_wl_slot >= 0);
2424 if ( ss_disabled_slot( Selected_wl_slot ) )
2427 Hot_weapon_bank_icon = index; // bank icon will be drawn highlighted
2429 if ( mouse_down(MOUSE_LEFT_BUTTON) ) {
2430 if ( Wl_mouse_down_on_region == (ICON_SHIP_PRIMARY_0+index) ){
2431 pick_from_ship_slot(index);
2434 int was_carried = wl_icon_being_carried();
2435 maybe_drop_icon_on_slot(index);
2436 if ( was_carried && !wl_icon_being_carried() ) {
2437 mouse_get_pos( &mx, &my );
2438 if ( Carried_wl_icon.from_x != mx || Carried_wl_icon.from_y != my) {
2439 dropped_on_slot = 1;
2444 // set Hot_weapon_bank if a droppable icon is being held over a slot that
2445 // can accept that icon
2447 mouse_get_pos( &mx, &my );
2448 if ( Carried_wl_icon.from_x != mx || Carried_wl_icon.from_y != my) {
2452 if ( wl_icon_being_carried() && is_moved ) {
2453 if ( Weapon_info[Carried_wl_icon.weapon_class].subtype != WP_MISSILE ) {
2454 if ( (index < 3) && (Wss_slots[Selected_wl_slot].wep_count[index] >= 0) )
2455 Hot_weapon_bank = index;
2457 if ( index >= 3 && ( Wss_slots[Selected_wl_slot].wep_count[index] >= 0) )
2458 Hot_weapon_bank = index;
2462 return dropped_on_slot;
2466 // maybe flash a button if player hasn't done anything for a while
2467 void wl_maybe_flash_button()
2469 if ( common_flash_bright() ) {
2471 if ( Common_buttons[Current_screen-1][gr_screen.res][3].button.button_hilighted() ) {
2472 common_flash_button_init();
2474 Common_buttons[Current_screen-1][gr_screen.res][3].button.draw_forced(1);
2480 void weapon_select_render(float frametime)
2482 if ( !Background_playing ) {
2483 gr_set_bitmap(Weapon_select_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2487 anim_render_all(0, frametime);
2488 anim_render_all(ON_SHIP_SELECT, frametime);
2491 // draw the weapon description text
2493 void wl_render_weapon_desc(float frametime)
2496 int *weapon_desc_coords;
2497 int *weapon_title_coords;
2499 // retrieve the correct set of text coordinates
2500 if (Game_mode & GM_MULTIPLAYER) {
2501 weapon_desc_coords = Wl_new_weapon_desc_coords_multi[gr_screen.res];
2502 weapon_title_coords = Wl_new_weapon_title_coords_multi[gr_screen.res];
2504 weapon_desc_coords = Wl_new_weapon_desc_coords[gr_screen.res];
2505 weapon_title_coords = Wl_new_weapon_title_coords[gr_screen.res];
2508 // render the normal version of the weapom desc
2509 char bright_char[WEAPON_DESC_MAX_LINES]; // one bright char per line
2510 if (!Weapon_desc_wipe_done) {
2511 // draw mid-wipe version
2512 // decide which char is last (and bright)
2513 int bright_char_index = (int)(Weapon_desc_wipe_time_elapsed * WEAPON_DESC_MAX_LENGTH / WEAPON_DESC_WIPE_TIME);
2514 int i, w, h, curr_len;
2516 // draw weapon title (above weapon anim)
2517 for (i=0; i<2; i++) {
2518 curr_len = strlen(Weapon_desc_lines[i]);
2520 if (bright_char_index < curr_len) {
2521 // save bright char and plunk in some nulls to shorten string
2522 bright_char[i] = Weapon_desc_lines[i][bright_char_index];
2523 Weapon_desc_lines[i][bright_char_index] = '\0';
2526 gr_set_color_fast(&Color_white);
2527 gr_string(weapon_title_coords[0], weapon_title_coords[1]+(10*i), Weapon_desc_lines[i]);
2529 // draw the bright letters
2530 gr_set_color_fast(&Color_bright_white);
2531 gr_get_string_size(&w, &h, Weapon_desc_lines[i], curr_len);
2532 gr_printf(weapon_title_coords[0]+w, weapon_title_coords[1]+(10*i), "%c", bright_char[i]);
2534 // restore the bright char to the string
2535 Weapon_desc_lines[i][bright_char_index] = bright_char[i];
2539 gr_set_color_fast(&Color_white);
2540 gr_string(weapon_title_coords[0], weapon_title_coords[1]+(10*i), Weapon_desc_lines[i]);
2544 // draw weapon desc (below weapon anim)
2545 for (i=2; i<WEAPON_DESC_MAX_LINES; i++) {
2546 curr_len = strlen(Weapon_desc_lines[i]);
2548 if (bright_char_index < curr_len) {
2549 // save bright char and plunk in some nulls to shorten string
2550 bright_char[i] = Weapon_desc_lines[i][bright_char_index];
2551 Weapon_desc_lines[i][bright_char_index] = '\0';
2554 gr_set_color_fast(&Color_white);
2555 gr_string(weapon_desc_coords[0], weapon_desc_coords[1]+(10*(i-2)), Weapon_desc_lines[i]);
2557 // draw the bright letters
2558 gr_set_color_fast(&Color_bright_white);
2559 gr_get_string_size(&w, &h, Weapon_desc_lines[i], curr_len);
2560 gr_printf(weapon_desc_coords[0]+w, weapon_desc_coords[1]+(10*(i-2)), "%c", bright_char[i]);
2562 // restore the bright char to the string
2563 Weapon_desc_lines[i][bright_char_index] = bright_char[i];
2567 gr_set_color_fast(&Color_white);
2568 gr_string(weapon_desc_coords[0], weapon_desc_coords[1]+(10*(i-2)), Weapon_desc_lines[i]);
2573 Weapon_desc_wipe_time_elapsed += frametime;
2574 if (Weapon_desc_wipe_time_elapsed >= WEAPON_DESC_WIPE_TIME) {
2575 // wipe is done,set flag and stop sound
2576 Weapon_desc_wipe_done = 1;
2581 // draw full version
2582 // FIXME - change to use a for loop
2583 gr_set_color_fast(&Color_white);
2584 gr_string(weapon_title_coords[0], weapon_title_coords[1], Weapon_desc_lines[0]);
2585 gr_string(weapon_title_coords[0], weapon_title_coords[1] + 10, Weapon_desc_lines[1]);
2586 gr_string(weapon_desc_coords[0], weapon_desc_coords[1], Weapon_desc_lines[2]);
2587 gr_string(weapon_desc_coords[0], weapon_desc_coords[1] + 10, Weapon_desc_lines[3]);
2588 gr_string(weapon_desc_coords[0], weapon_desc_coords[1] + 20, Weapon_desc_lines[4]);
2589 gr_string(weapon_desc_coords[0], weapon_desc_coords[1] + 30, Weapon_desc_lines[5]);
2596 // re-inits wiping vars and causes the current text to wipe in again
2597 void wl_weapon_desc_start_wipe()
2600 int currchar_src = 0, currline_dest = 2, currchar_dest = 0, i;
2602 int title_len = strlen(Weapon_info[Selected_wl_class].title);
2605 Weapon_desc_wipe_time_elapsed = 0.0f;
2606 Weapon_desc_wipe_done = 0;
2608 // break title into two lines if too long
2609 strcpy(Weapon_desc_lines[0], Weapon_info[Selected_wl_class].title);
2610 gr_get_string_size(&w, &h, Weapon_info[Selected_wl_class].title, title_len);
2611 if (w > Weapon_title_max_width[gr_screen.res]) {
2613 currchar_src = (int)(((float)title_len / (float)w) * Weapon_title_max_width[gr_screen.res]); // char to start space search at
2614 while (Weapon_desc_lines[0][currchar_src] != ' ') {
2616 if (currchar_src <= 0) {
2617 currchar_src = title_len;
2622 Weapon_desc_lines[0][currchar_src] = '\0'; // shorten line 0
2623 strcpy(Weapon_desc_lines[1], &(Weapon_desc_lines[0][currchar_src+1])); // copy remainder into line 1
2625 // entire title in line 0, thus line 1 is empty
2626 Weapon_desc_lines[1][0] = '\0';
2629 // break current description into lines (break at the /n's)
2631 while (Weapon_info[Selected_wl_class].desc[currchar_src] != '\0') {
2632 if (Weapon_info[Selected_wl_class].desc[currchar_src] == '\n') {
2634 if (currchar_src != 0) { // protect against leading /n's
2635 Weapon_desc_lines[currline_dest][currchar_dest] = '\0';
2641 Weapon_desc_lines[currline_dest][currchar_dest] = Weapon_info[Selected_wl_class].desc[currchar_src];
2647 Assert(currline_dest < WEAPON_DESC_MAX_LINES);
2648 Assert(currchar_dest < WEAPON_DESC_MAX_LENGTH);
2651 // wrap up the line processing
2652 Weapon_desc_lines[currline_dest][currchar_dest] = '\0';
2653 for (i=currline_dest+1; i<WEAPON_DESC_MAX_LINES; i++) {
2654 Weapon_desc_lines[i][0] = '\0';
2661 // ---------------------------------------------------------------------------------
2662 // weapon_select_do() is called once per frame while in the weapon loadout screen.
2664 // Calls to common_ functions are made for those functions which are common to the
2665 // ship select and briefing screens.
2667 void weapon_select_do(float frametime)
2669 int k, wl_choice, snazzy_action;
2672 if ( !Weapon_select_open )
2673 weapon_select_init();
2675 wl_choice = snazzy_menu_do(WeaponSelectMaskData, Weaponselect_mask_w, Weaponselect_mask_h, Num_weapon_select_regions, Weapon_select_region, &snazzy_action, 0);
2677 if ( wl_choice >= 0 ) {
2678 if ( snazzy_action == SNAZZY_CLICKED ) {
2679 nprintf(("Alan","got one\n"));
2684 Hot_weapon_icon = -1;
2685 Hot_weapon_bank = -1;
2686 Hot_weapon_bank_icon = -1;
2688 k = common_select_do(frametime);
2690 if ( help_overlay_active(WL_OVERLAY) ) {
2691 if ( Weapon_anim_class >= 0 && Wl_icons[Weapon_anim_class].anim_instance ) {
2692 anim_pause(Wl_icons[Weapon_anim_class].anim_instance);
2696 if ( Weapon_anim_class >= 0 && Wl_icons[Weapon_anim_class].anim_instance ) {
2697 anim_unpause(Wl_icons[Weapon_anim_class].anim_instance);
2701 // Check common keypresses
2702 common_check_keys(k);
2704 if ( Mouse_down_last_frame ) {
2705 Wl_mouse_down_on_region = wl_choice;
2708 if ( wl_choice > -1 ) {
2710 case ICON_PRIMARY_0:
2711 do_mouse_over_list_weapon(0);
2713 case ICON_PRIMARY_1:
2714 do_mouse_over_list_weapon(1);
2716 case ICON_PRIMARY_2:
2717 do_mouse_over_list_weapon(2);
2719 case ICON_PRIMARY_3:
2720 do_mouse_over_list_weapon(3);
2722 case ICON_SECONDARY_0:
2723 do_mouse_over_list_weapon(4);
2725 case ICON_SECONDARY_1:
2726 do_mouse_over_list_weapon(5);
2728 case ICON_SECONDARY_2:
2729 do_mouse_over_list_weapon(6);
2731 case ICON_SECONDARY_3:
2732 do_mouse_over_list_weapon(7);
2734 case ICON_SHIP_PRIMARY_0:
2735 if ( do_mouse_over_ship_weapon(0) )
2738 case ICON_SHIP_PRIMARY_1:
2739 if ( do_mouse_over_ship_weapon(1) )
2742 case ICON_SHIP_PRIMARY_2:
2743 if ( do_mouse_over_ship_weapon(2) )
2746 case ICON_SHIP_SECONDARY_0:
2747 if ( do_mouse_over_ship_weapon(3) )
2750 case ICON_SHIP_SECONDARY_1:
2751 if ( do_mouse_over_ship_weapon(4) )
2754 case ICON_SHIP_SECONDARY_2:
2755 if ( do_mouse_over_ship_weapon(5) )
2758 case ICON_SHIP_SECONDARY_3:
2759 if ( do_mouse_over_ship_weapon(6) )
2804 if ( !mouse_down(MOUSE_LEFT_BUTTON) ) {
2805 wl_dump_carried_icon();
2808 // Check for a mouse click on buttons
2809 common_check_buttons();
2810 weapon_check_buttons();
2812 // Check for the mouse clicks over a region
2813 if ( wl_choice > -1 && snazzy_action == SNAZZY_CLICKED ) {
2814 switch (wl_choice) {
2815 case ICON_PRIMARY_0:
2816 maybe_select_new_weapon(0);
2818 case ICON_PRIMARY_1:
2819 maybe_select_new_weapon(1);
2821 case ICON_PRIMARY_2:
2822 maybe_select_new_weapon(2);
2824 case ICON_PRIMARY_3:
2825 maybe_select_new_weapon(3);
2827 case ICON_SECONDARY_0:
2828 maybe_select_new_weapon(4);
2830 case ICON_SECONDARY_1:
2831 maybe_select_new_weapon(5);
2833 case ICON_SECONDARY_2:
2834 maybe_select_new_weapon(6);
2836 case ICON_SECONDARY_3:
2837 maybe_select_new_weapon(7);
2839 case ICON_SHIP_PRIMARY_0:
2840 maybe_select_new_ship_weapon(0);
2842 case ICON_SHIP_PRIMARY_1:
2843 maybe_select_new_ship_weapon(1);
2845 case ICON_SHIP_PRIMARY_2:
2846 maybe_select_new_ship_weapon(2);
2848 case ICON_SHIP_SECONDARY_0:
2849 maybe_select_new_ship_weapon(3);
2851 case ICON_SHIP_SECONDARY_1:
2852 maybe_select_new_ship_weapon(4);
2854 case ICON_SHIP_SECONDARY_2:
2855 maybe_select_new_ship_weapon(5);
2857 case ICON_SHIP_SECONDARY_3:
2858 maybe_select_new_ship_weapon(6);
2861 maybe_select_wl_slot(0,0);
2864 maybe_select_wl_slot(0,1);
2867 maybe_select_wl_slot(0,2);
2870 maybe_select_wl_slot(0,3);
2873 maybe_select_wl_slot(1,0);
2876 maybe_select_wl_slot(1,1);
2879 maybe_select_wl_slot(1,2);
2882 maybe_select_wl_slot(1,3);
2885 maybe_select_wl_slot(2,0);
2888 maybe_select_wl_slot(2,1);
2891 maybe_select_wl_slot(2,2);
2894 maybe_select_wl_slot(2,3);
2905 if ( Weapon_anim_class != -1 && ( Selected_wl_class == Weapon_anim_class ) ) {
2907 Assert(Selected_wl_class >= 0 && Selected_wl_class < MAX_WEAPON_TYPES );
2908 if ( Weapon_anim_class != Selected_wl_class )
2909 start_weapon_animation(Selected_wl_class);
2911 Assert(Weapon_anim_class == Selected_wl_class);
2912 icon = &Wl_icons[Selected_wl_class];
2913 if ( icon->anim_instance ) {
2914 if ( icon->anim_instance->frame_num == icon->anim_instance->stop_at ) {
2915 anim_play_struct aps;
2916 int *weapon_ani_coords;
2918 // get the correct weapon animations coords
2919 if (Game_mode & GM_MULTIPLAYER) {
2920 weapon_ani_coords = Wl_weapon_ani_coords_multi[gr_screen.res];
2922 weapon_ani_coords = Wl_weapon_ani_coords[gr_screen.res];
2925 anim_release_render_instance(icon->anim_instance);
2926 anim_play_init(&aps, icon->anim, weapon_ani_coords[0], weapon_ani_coords[1]);
2927 aps.start_at = WEAPON_ANIM_LOOP_FRAME-1;
2928 aps.screen_id = ON_WEAPON_SELECT;
2929 aps.framerate_independent = 1;
2930 aps.skip_frames = 0;
2931 icon->anim_instance = anim_play(&aps);
2936 weapon_select_render(frametime);
2937 if ( !Background_playing ) {
2938 Weapon_ui_window.draw();
2939 wl_redraw_pressed_buttons();
2941 anim_render_all(ON_WEAPON_SELECT, frametime);
2942 wl_check_for_stopped_ship_anims();
2943 wl_render_overhead_view(frametime);
2944 wl_draw_ship_weapons(Selected_wl_slot);
2945 for ( int i = 0; i < MAX_WING_BLOCKS; i++ ) {
2946 draw_wing_block(i, Hot_wl_slot, Selected_wl_slot, -1);
2948 common_render_selected_screen_button();
2951 // maybe blit the multiplayer "locked" button
2952 if((Game_mode & GM_MULTIPLAYER) && multi_ts_is_locked()){
2953 Buttons[gr_screen.res][WL_BUTTON_MULTI_LOCK].button.draw_forced(2);
2957 if ( wl_icon_being_carried() ) {
2959 Assert(Carried_wl_icon.weapon_class < MAX_WEAPON_TYPES);
2960 mouse_get_pos( &mx, &my );
2961 sx = mx + Wl_delta_x;
2962 sy = my + Wl_delta_y;
2965 if ( Wl_icons[Carried_wl_icon.weapon_class].can_use > 0) {
2966 gr_set_color_fast(&Color_blue);
2967 gr_set_bitmap(Wl_icons[Carried_wl_icon.weapon_class].icon_bmaps[WEAPON_ICON_FRAME_SELECTED], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2971 // draw number to prevent it from disappearing on clicks
2972 if ( Carried_wl_icon.from_bank >= MAX_WL_PRIMARY ) {
2973 if ( mx == Carried_wl_icon.from_x && my == Carried_wl_icon.from_y ) {
2974 int num_missiles = Wss_slots[Carried_wl_icon.from_slot].wep_count[Carried_wl_icon.from_bank];
2975 //sprintf(buf, "%d", num_missiles);
2976 //gr_set_color_fast(&Color_white);
2978 //int x_offset = wl_fury_missile_offset_hack(Carried_wl_icon.weapon_class, num_missiles);
2979 //gr_string(sx-19-x_offset, sy+8, buf);
2982 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]);
2986 // check so see if this is really a legal weapon to carry away
2987 if ( !Wl_icons[Carried_wl_icon.weapon_class].can_use ) {
2989 diffx = abs(Carried_wl_icon.from_x-mx);
2990 diffy = abs(Carried_wl_icon.from_y-my);
2991 if ( (diffx > 2) || (diffy > 2) ) {
2992 int ship_class = Wss_slots[Selected_wl_slot].ship_class;
2995 // might have to get weapon name translation
2996 char display_name[128];
2997 strncpy(display_name, Weapon_info[Carried_wl_icon.weapon_class].name, 128);
2998 lcl_translate_wep_name(display_name);
2999 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);
3001 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);
3004 wl_dump_carried_icon();
3009 if ( Weapon_anim_class != Selected_wl_class ) {
3010 start_weapon_animation(Selected_wl_class);
3013 // render weapon description text
3014 wl_render_weapon_desc(frametime);
3016 wl_maybe_flash_button();
3018 // should render the chatbox as close to the end as possible so it overlaps all controls
3019 if(!Background_playing){
3021 // render some extra stuff in multiplayer
3022 if(Game_mode & GM_MULTIPLAYER){
3023 // render the chatbox
3027 Weapon_ui_window.draw_tooltip();
3029 // render the status indicator for the voice system
3030 multi_common_voice_display_status();
3032 // blit the "ships/players" locked button
3033 // multi_ts_blit_locked_button();
3037 // blit help overlay if active
3038 help_overlay_maybe_blit(WL_OVERLAY);
3041 // If the commit button was pressed, do the commit button actions. Done at the end of the
3042 // loop so there isn't a skip in the animation (since ship_create() can take a long time if
3043 // the ship model is not in memory
3044 if ( Commit_pressed ) {
3045 if(Game_mode & GM_MULTIPLAYER){
3046 multi_ts_commit_pressed();
3054 // -------------------------------------------------------------------------------
3055 // weapon_select_close() will free the bitmap slot and memory that was allocated
3056 // to store the mask bitmap.
3058 // Weapon_select_open is cleared when this function completes.
3060 void weapon_select_close()
3062 if ( !Weapon_select_open ) {
3063 nprintf(("Alan","weapon_select_close() returning without doing anything\n"));
3067 nprintf(("Alan", "Entering weapon_select_close()\n"));
3069 stop_weapon_animation();
3071 // done with the bitmaps, so unlock it
3072 bm_unlock(WeaponSelectMaskBitmap);
3074 Weapon_ui_window.destroy();
3077 common_free_interface_palette();
3081 help_overlay_unload(WL_OVERLAY);
3083 bm_unload(WeaponSelectMaskBitmap);
3086 wl_unload_all_anim_instances();
3087 wl_unload_all_anims();
3089 Selected_wl_class = -1;
3090 Weapon_select_open = 0;
3094 // ------------------------------------------------------------------------
3095 // wl_render_icon_count()
3096 // renders the number next to the weapon icon
3098 // input: x,y => x,y screen position OF THE ICON (NOT where u want the text,
3099 // this is calculated to prevent overlapping)
3100 // num => the actual count to be printed
3102 void wl_render_icon_count(int num, int x, int y)
3106 int number_to_draw = (num > 1000) ? 999 : num; // cap count @ 999
3107 Assert(number_to_draw >= 0);
3109 sprintf(buf, "%d", number_to_draw);
3110 gr_get_string_size(&num_w, &num_h, buf, strlen(buf));
3113 gr_set_color_fast(&Color_white);
3115 // strict left align
3116 gr_string(x-21, y+8, buf);
3118 gr_string(x-num_w-4, y+8, buf);
3123 // ------------------------------------------------------------------------
3126 // input: index => index into Wl_icons[], identifying which weapon to draw
3127 // x,y => x,y screen position to draw icon at
3128 // num => count for weapon
3129 // draw_num_flag => 0 if not to draw count for weapon, nonzero otherwise
3130 // hot_mask => value that should match Hot_weapon_icon to show mouse is over
3131 // hot_bank_mask => value that should match Hot_weapon_bank_icon to show mouse is over
3132 // select_mask => value that should match Selected_wl_class to show icon is selected
3134 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)
3139 if ( Selected_wl_slot == -1 )
3142 icon = &Wl_icons[index];
3144 if ( icon->icon_bmaps[0] == -1 ) {
3145 wl_load_icons(index);
3148 // assume default bitmap is to be used
3149 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_NORMAL]; // normal frame
3151 if ( bitmap_id < 0 ) {
3156 // next check if ship has mouse over it
3157 if ( !wl_icon_being_carried() ) {
3158 if ( Hot_weapon_icon > -1 && Hot_weapon_icon == hot_mask )
3159 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_HOT];
3161 if ( Hot_weapon_bank_icon > -1 && Hot_weapon_bank_icon == hot_bank_mask )
3162 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_HOT];
3165 // if icon is selected
3166 if ( Selected_wl_class > -1 ) {
3167 if ( Selected_wl_class == select_mask)
3168 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_SELECTED]; // selected icon
3171 // if icon is disabled
3172 if ( !icon->can_use ) {
3173 bitmap_id = icon->icon_bmaps[WEAPON_ICON_FRAME_DISABLED]; // disabled icon
3176 gr_set_color_fast(&Color_blue);
3177 gr_set_bitmap(bitmap_id, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
3180 // draw the number of the item
3181 // now, right justified
3182 if ( draw_num_flag != 0 ) {
3184 // add a little extra text padding for secondary weapons
3185 if ( hot_mask > 3 ) {
3186 wl_render_icon_count(num, x-9, y);
3188 wl_render_icon_count(num, x, y);
3191 wl_render_icon_count(num, x, y);
3196 // ------------------------------------------------------------------------
3197 // wl_draw_ship_weapons()
3199 // Draw the icons for the weapons that are currently on the selected ship
3201 // input: slot_num => Slot to draw weapons for
3203 void wl_draw_ship_weapons(int index)
3206 int *wep, *wep_count;
3211 Assert(index >= 0 && index < MAX_WSS_SLOTS);
3212 wep = Wss_slots[index].wep;
3213 wep_count = Wss_slots[index].wep_count;
3215 for ( i = 0; i < MAX_WL_WEAPONS; i++ ) {
3217 if ( Carried_wl_icon.from_bank == i && Carried_wl_icon.from_slot == index ) {
3221 if ( (wep[i] != -1) && (wep_count[i] > 0) ) {
3222 int x_offset = wl_fury_missile_offset_hack(wep[i], wep_count[i]);
3224 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]);
3229 // ------------------------------------------------------------------------
3230 // draw_wl_icon_with_number()
3232 // input: list_count => list position on screen (0-7)
3233 // weapon_class => class of weapon
3235 void draw_wl_icon_with_number(int list_count, int weapon_class)
3237 Assert( list_count >= 0 && list_count < 8 );
3239 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],
3240 Wl_pool[weapon_class], 1, list_count, -1, weapon_class);
3243 // ------------------------------------------------------------------------
3246 // Draw the weapon icons that are available
3247 void draw_wl_icons()
3252 for ( i = Plist_start; i < Plist_size; i++ ) {
3253 draw_wl_icon_with_number(count, Plist[i]);
3259 for ( i = Slist_start; i < Slist_size; i++ ) {
3260 draw_wl_icon_with_number(count+4, Slist[i]);
3266 // ------------------------------------------------------------------------
3267 // wl_pick_icon_from_list()
3269 // determine if an icon from the scrollable weapon list can be picked up
3270 // (for drag and drop). It calculates the difference in x & y between the icon
3271 // and the mouse, so we can move the icon with the mouse in a realistic way
3272 // input: index (0..7)
3273 void wl_pick_icon_from_list(int index)
3275 int weapon_class, mx, my;
3277 // if this is a multiplayer game and the player is an observer, he can never pick any weapons up
3278 if((Game_mode & GM_MULTIPLAYER) && (Net_player->flags & NETINFO_FLAG_OBSERVER)){
3282 // if a weapon is being carried, do nothing
3283 if ( wl_icon_being_carried() ) {
3288 weapon_class = Plist[Plist_start+index];
3290 weapon_class = Slist[Slist_start+index-4];
3293 // there isn't a weapon there at all!
3294 if ( weapon_class < 0 )
3297 // no weapons left of that class
3298 if ( Wl_pool[weapon_class] <= 0 ) {
3303 // some are available, but weapon cannot be used on current ship class
3304 if ( !Wl_icons[weapon_class].can_use ) {
3307 int ship_class = Wss_slots[Selected_wl_slot].ship_class;
3308 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);
3315 wl_set_carried_icon(-1, -1, weapon_class);
3316 common_flash_button_init();
3318 mouse_get_pos( &mx, &my );
3319 Wl_delta_x = Wl_weapon_icon_coords[gr_screen.res][index][0] - mx;
3320 Wl_delta_y = Wl_weapon_icon_coords[gr_screen.res][index][1] - my;
3323 // ------------------------------------------------------------------------
3324 // pick_from_ship_slot()
3326 // input: num -> index into shipb banks (0..2 primary, 3..6 secondary)
3327 void pick_from_ship_slot(int num)
3329 int mx, my, *wep, *wep_count;
3333 if ( Selected_wl_slot == -1 )
3336 if ( wl_icon_being_carried() )
3339 if ( ss_disabled_slot( Selected_wl_slot ) )
3342 wep = Wss_slots[Selected_wl_slot].wep;
3343 wep_count = Wss_slots[Selected_wl_slot].wep_count;
3345 // check if a weapon even exists in that slot
3346 if ( (wep[num] < 0) || (wep_count[num] <= 0) ) {
3350 Assert(Wl_icons[wep[num]].can_use);
3352 wl_set_carried_icon(num, Selected_wl_slot, wep[num]);
3353 common_flash_button_init();
3355 mouse_get_pos( &mx, &my );
3357 int x_offset = wl_fury_missile_offset_hack(wep[num], wep_count[num]);
3358 Wl_delta_x = Wl_bank_coords[gr_screen.res][num][0] - mx + x_offset;
3359 Wl_delta_y = Wl_bank_coords[gr_screen.res][num][1] - my;
3361 Carried_wl_icon.from_x = mx;
3362 Carried_wl_icon.from_y = my;
3365 // determine if this slot has no weapons
3366 int wl_slots_all_empty(wss_unit *slot)
3370 for ( i = 0; i < MAX_WL_WEAPONS; i++ ) {
3371 if ( (slot->wep_count[i] > 0) && (slot->wep[i] >= 0) )
3378 // ------------------------------------------------------------------------
3379 // wl_update_ship_weapons()
3381 // Change a ship's weapons based on the information contained in the
3382 // Weapon_data[] structure that is filled in during weapon loadout
3384 // returns: -1 => if the playre ship has no weapons
3385 // 0 => function finished without errors
3386 int wl_update_ship_weapons(int objnum, wss_unit *slot )
3388 // AL 11-15-97: Ensure that the player ship hasn't removed all
3389 // weapons from their ship. This will cause a warning to appear.
3390 if ( objnum == OBJ_INDEX(Player_obj) && Weapon_select_open ) {
3391 if ( wl_slots_all_empty(slot) ) {
3396 wl_bash_ship_weapons(&Ships[Objects[objnum].instance].weapons, slot);
3401 // ------------------------------------------------------------------------
3402 // wl_update_parse_object_weapons()
3404 // Set the Pilot subsystem of a parse_object to the weapons that are setup
3405 // for the wing_block,wing_slot ship
3407 // input: pobjp => pointer to parse object that references Pilot subsystem
3409 void wl_update_parse_object_weapons(p_object *pobjp, wss_unit *slot)
3411 int i, j, sidx, pilot_index, max_count;
3415 Assert(slot->ship_class >= 0);
3416 sip = &Ship_info[slot->ship_class];
3418 pilot_index = wl_get_pilot_subsys_index(pobjp);
3420 if ( pilot_index == -1 )
3423 ss = &Subsys_status[pilot_index];
3425 for ( i = 0; i < MAX_PRIMARY_BANKS; i++ ) {
3426 ss->primary_banks[i] = -1;
3429 for ( i = 0; i < MAX_SECONDARY_BANKS; i++ ) {
3430 ss->secondary_banks[i] = -1;
3434 for ( i = 0; i < MAX_WL_PRIMARY; i++ ) {
3435 if ( (slot->wep_count[i] > 0) && (slot->wep[i] >= 0) ) {
3436 ss->primary_banks[j] = slot->wep[i];
3442 for ( i = 0; i < MAX_WL_SECONDARY; i++ ) {
3443 sidx = i+MAX_WL_PRIMARY;
3444 if ( (slot->wep_count[sidx] > 0) && (slot->wep[sidx] >= 0) ) {
3445 ss->secondary_banks[j] = slot->wep[sidx];
3446 // Important: the secondary_ammo[] value is a percentage of max capacity!
3447 max_count = wl_calc_missile_fit(slot->wep[sidx], Ship_info[slot->ship_class].secondary_bank_ammo_capacity[j]);
3448 ss->secondary_ammo[j] = fl2i( i2fl(slot->wep_count[sidx]) / max_count * 100.0f + 0.5f);
3454 // ------------------------------------------------------------------------
3455 // stop_weapon_animation()
3457 // Stop the current weapon animation from playing.
3459 void stop_weapon_animation()
3461 if ( Weapon_anim_class < 0 )
3464 if ( anim_playing(Wl_icons[Weapon_anim_class].anim_instance) )
3465 anim_release_render_instance(Wl_icons[Weapon_anim_class].anim_instance);
3467 Wl_icons[Weapon_anim_class].anim_instance = NULL;
3468 Weapon_anim_class = -1;
3471 // ------------------------------------------------------------------------
3472 // start_weapon_animation()
3474 // Start the current weapon animation from playing.
3476 void start_weapon_animation(int weapon_class)
3479 int *weapon_ani_coords;
3481 if ( weapon_class < 0 )
3484 if ( weapon_class == Weapon_anim_class )
3487 // get the correct weapon animations coords
3488 if (Game_mode & GM_MULTIPLAYER) {
3489 weapon_ani_coords = Wl_weapon_ani_coords_multi[gr_screen.res];
3491 weapon_ani_coords = Wl_weapon_ani_coords[gr_screen.res];
3494 icon = &Wl_icons[weapon_class];
3496 // stop current animation playing
3497 stop_weapon_animation();
3499 // see if we need to load in the animation from disk
3500 if ( icon->anim == NULL ) {
3501 wl_load_anim(weapon_class);
3503 icon->anim = anim_load(Weapon_info[weapon_class].anim_filename, 1);
3504 if ( icon->anim == NULL ) {
3505 Int3(); // could not open the weapon animation
3511 // see if we need to get an instance
3512 if ( icon->anim_instance == NULL ) {
3513 anim_play_struct aps;
3515 anim_play_init(&aps, icon->anim, weapon_ani_coords[0], weapon_ani_coords[1]);
3516 aps.screen_id = ON_WEAPON_SELECT;
3517 aps.framerate_independent = 1;
3518 aps.skip_frames = 0;
3519 icon->anim_instance = anim_play(&aps);
3520 gamesnd_play_iface(SND_WEAPON_ANIM_START);
3523 Weapon_anim_class = weapon_class;
3525 // start the text wipe
3526 wl_weapon_desc_start_wipe();
3529 // reset the weapons loadout to the defaults in the mission
3530 void wl_reset_to_defaults()
3532 // don't reset of weapons pool in multiplayer
3533 if(Game_mode & GM_MULTIPLAYER){
3537 wl_init_pool(&Team_data[Common_team]);
3538 wl_init_icon_lists();
3540 wl_reset_selected_slot();
3541 wl_reset_carried_icon();
3542 wl_maybe_reset_selected_weapon_class();
3545 // Bash ship weapons, based on what is stored in the stored weapons loadout
3546 // NOTE: Wss_slots[] is assumed to be correctly set
3547 void wl_bash_ship_weapons(ship_weapon *swp, wss_unit *slot)
3551 for ( i = 0; i < MAX_PRIMARY_BANKS; i++ ) {
3552 swp->primary_bank_weapons[i] = -1;
3555 for ( i = 0; i < MAX_SECONDARY_BANKS; i++ ) {
3556 swp->secondary_bank_weapons[i] = -1;
3560 for ( i = 0; i < MAX_WL_PRIMARY; i++ ) {
3561 if ( (slot->wep_count[i] > 0) && (slot->wep[i] >= 0) ) {
3562 swp->primary_bank_weapons[j] = slot->wep[i];
3566 swp->num_primary_banks = j;
3569 for ( i = 0; i < MAX_WL_SECONDARY; i++ ) {
3570 sidx = i+MAX_WL_PRIMARY;
3571 if ( (slot->wep_count[sidx] > 0) && (slot->wep[sidx] >= 0) ) {
3572 swp->secondary_bank_weapons[j] = slot->wep[sidx];
3573 swp->secondary_bank_ammo[j] = slot->wep_count[sidx];
3577 swp->num_secondary_banks = j;
3580 // utility function for swapping two banks
3581 void wl_swap_weapons(int ship_slot, int from_bank, int to_bank)
3585 slot = &Wss_slots[ship_slot];
3587 if ( from_bank == to_bank ) {
3592 tmp = slot->wep[from_bank];
3593 slot->wep[from_bank] = slot->wep[to_bank];
3594 slot->wep[to_bank] = tmp;
3596 // swap weapon count
3597 tmp = slot->wep_count[from_bank];
3598 slot->wep_count[from_bank] = slot->wep_count[to_bank];
3599 slot->wep_count[to_bank] = tmp;
3602 // utility function used to put back overflow into the weapons pool
3603 void wl_saturate_bank(int ship_slot, int bank)
3606 int max_count, overflow;
3608 slot = &Wss_slots[ship_slot];
3610 if ( (slot->wep[bank] < 0) || (slot->wep_count <= 0) ) {
3614 max_count = wl_calc_missile_fit(slot->wep[bank], Ship_info[slot->ship_class].secondary_bank_ammo_capacity[bank-3]);
3615 overflow = slot->wep_count[bank] - max_count;
3616 if ( overflow > 0 ) {
3617 slot->wep_count[bank] -= overflow;
3618 // add overflow back to pool
3619 Wl_pool[slot->wep[bank]] += overflow;
3623 // exit: 0 -> no data changed
3624 // 1 -> data changed
3625 // sound => gets filled with sound id to play
3626 int wl_swap_slot_slot(int from_bank, int to_bank, int ship_slot, int *sound)
3629 slot = &Wss_slots[ship_slot];
3631 if ( slot->ship_class == -1 ) {
3632 Int3(); // should not be possible
3636 // do nothing if swapping with self
3637 if ( from_bank == to_bank ) {
3638 *sound=SND_ICON_DROP_ON_WING;
3639 return 0; // no update
3642 // ensure that source bank exists and has something to pick from
3643 if ( slot->wep[from_bank] == -1 || slot->wep_count[from_bank] <= 0 ) {
3647 // ensure that the dest bank exists
3648 if ( slot->wep_count[to_bank] < 0 ) {
3652 // ensure that the banks are both of the same class
3653 if ( (IS_BANK_PRIMARY(from_bank) && IS_BANK_SECONDARY(to_bank)) || (IS_BANK_SECONDARY(from_bank) && IS_BANK_PRIMARY(to_bank)) ) {
3654 // put from_bank back into list
3655 Wl_pool[slot->wep[from_bank]] += slot->wep_count[from_bank];; // return to list
3656 slot->wep[from_bank] = -1; // remove from slot
3657 slot->wep_count[from_bank] = 0;
3658 *sound=SND_ICON_DROP;
3662 // case 1: primaries (easy)
3663 if ( IS_BANK_PRIMARY(from_bank) && IS_BANK_PRIMARY(to_bank) ) {
3664 wl_swap_weapons(ship_slot, from_bank, to_bank);
3665 *sound=SND_ICON_DROP_ON_WING;
3669 // case 2: secondaries (harder)
3670 if ( IS_BANK_SECONDARY(from_bank) && IS_BANK_SECONDARY(to_bank) ) {
3672 // case 2a: secondaries are the same type
3673 if ( slot->wep[from_bank] == slot->wep[to_bank] ) {
3674 int dest_max, dest_can_fit, source_can_give;
3675 dest_max = wl_calc_missile_fit(slot->wep[to_bank], Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-3]);
3677 dest_can_fit = dest_max - slot->wep_count[to_bank];
3679 if ( dest_can_fit <= 0 ) {
3680 // dest bank is already full.. nothing to do here
3684 // see how much source can give
3685 source_can_give = min(dest_can_fit, slot->wep_count[from_bank]);
3687 if ( source_can_give > 0 ) {
3688 slot->wep_count[to_bank] += source_can_give; // add to dest
3689 slot->wep_count[from_bank] -= source_can_give; // take from source
3690 *sound=SND_ICON_DROP_ON_WING;
3697 // case 2b: secondaries are different types
3698 if ( slot->wep[from_bank] != slot->wep[to_bank] ) {
3701 wl_swap_weapons(ship_slot, from_bank, to_bank);
3703 // put back some on list if required
3704 wl_saturate_bank(ship_slot, from_bank);
3705 wl_saturate_bank(ship_slot, to_bank);
3706 *sound=SND_ICON_DROP_ON_WING;
3711 Int3(); // should never get here
3715 // exit: 0 -> no data changed
3716 // 1 -> data changed
3717 // sound => gets filled with sound id to play
3718 int wl_dump_to_list(int from_bank, int to_list, int ship_slot, int *sound)
3721 slot = &Wss_slots[ship_slot];
3723 // ensure that source bank exists and has something to pick from
3724 if ( slot->wep[from_bank] == -1 || slot->wep_count[from_bank] <= 0 ) {
3728 // put weapon bank to the list
3729 Wl_pool[to_list] += slot->wep_count[from_bank]; // return to list
3730 slot->wep[from_bank] = -1; // remove from slot
3731 slot->wep_count[from_bank] = 0;
3732 *sound=SND_ICON_DROP;
3737 // exit: 0 -> no data changed
3738 // 1 -> data changed
3739 // sound => gets filled with sound id to play
3740 int wl_grab_from_list(int from_list, int to_bank, int ship_slot, int *sound)
3743 slot = &Wss_slots[ship_slot];
3746 // ensure that the banks are both of the same class
3747 if ( (IS_LIST_PRIMARY(from_list) && IS_BANK_SECONDARY(to_bank)) || (IS_LIST_SECONDARY(from_list) && IS_BANK_PRIMARY(to_bank)) ) {
3749 *sound=SND_ICON_DROP;
3753 // ensure that dest bank exists
3754 if ( slot->wep_count[to_bank] < 0 ) {
3755 *sound=SND_ICON_DROP;
3759 // bank should be empty:
3760 Assert(slot->wep_count[to_bank] == 0);
3761 Assert(slot->wep[to_bank] < 0);
3763 // ensure that pool has weapon
3764 if ( Wl_pool[from_list] <= 0 ) {
3768 // find how much dest bank can fit
3769 if ( to_bank < MAX_WL_PRIMARY ) {
3772 max_fit = wl_calc_missile_fit(from_list, Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-MAX_WL_PRIMARY]);
3775 // take weapon from list
3776 if ( Wl_pool[from_list] < max_fit ) {
3777 max_fit = Wl_pool[from_list];
3779 Wl_pool[from_list] -= max_fit;
3782 slot->wep[to_bank] = from_list;
3783 slot->wep_count[to_bank] = max_fit;
3785 *sound=SND_ICON_DROP_ON_WING;
3789 // exit: 0 -> no data changed
3790 // 1 -> data changed
3791 // sound => gets filled with sound id to play
3792 int wl_swap_list_slot(int from_list, int to_bank, int ship_slot, int *sound)
3795 slot = &Wss_slots[ship_slot];
3798 // ensure that the banks are both of the same class
3799 if ( (IS_LIST_PRIMARY(from_list) && IS_BANK_SECONDARY(to_bank)) || (IS_LIST_SECONDARY(from_list) && IS_BANK_PRIMARY(to_bank)) ) {
3801 *sound=SND_ICON_DROP;
3805 // ensure that dest bank exists
3806 if ( slot->wep_count[to_bank] < 0 ) {
3810 // bank should have something in it
3811 Assert(slot->wep_count[to_bank] > 0);
3812 Assert(slot->wep[to_bank] >= 0);
3814 // ensure that pool has weapon
3815 if ( Wl_pool[from_list] <= 0 ) {
3819 // dump slot weapon back into list
3820 Wl_pool[slot->wep[to_bank]] += slot->wep_count[to_bank];
3821 slot->wep_count[to_bank] = 0;
3822 slot->wep[to_bank] = -1;
3824 // put weapon on ship from list
3826 // find how much dest bank can fit
3827 if ( to_bank < MAX_WL_PRIMARY ) {
3830 max_fit = wl_calc_missile_fit(from_list, Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-MAX_WL_PRIMARY]);
3833 // take weapon from list
3834 if ( Wl_pool[from_list] < max_fit ) {
3835 max_fit = Wl_pool[from_list];
3837 Wl_pool[from_list] -= max_fit;
3840 slot->wep[to_bank] = from_list;
3841 slot->wep_count[to_bank] = max_fit;
3843 *sound=SND_ICON_DROP_ON_WING;
3847 // update any interface data that may be dependent on Wss_slots[]
3848 void wl_synch_interface()
3852 void wl_apply(int mode,int from_bank,int from_list,int to_bank,int to_list,int ship_slot,int player_index)
3858 // get the appropriate net player
3859 if(Game_mode & GM_MULTIPLAYER){
3860 if(player_index == -1){
3863 pl = &Net_players[player_index];
3870 case WSS_SWAP_SLOT_SLOT:
3871 update = wl_swap_slot_slot(from_bank, to_bank, ship_slot, &sound);
3873 case WSS_DUMP_TO_LIST:
3874 update = wl_dump_to_list(from_bank, to_list, ship_slot, &sound);
3876 case WSS_GRAB_FROM_LIST:
3877 update = wl_grab_from_list(from_list, to_bank, ship_slot, &sound);
3879 case WSS_SWAP_LIST_SLOT:
3880 update = wl_swap_list_slot(from_list, to_bank, ship_slot, &sound);
3884 // only play this sound if the move was done locally (by the host in other words)
3885 if ( (sound >= 0) && (player_index == -1) ) {
3886 gamesnd_play_iface(sound);
3890 if ( MULTIPLAYER_HOST ) {
3892 ubyte wss_data[MAX_PACKET_SIZE-20];
3894 size = store_wss_data(wss_data, MAX_PACKET_SIZE-20,sound,player_index);
3896 send_wss_update_packet(pl->p_info.team,wss_data, size);
3899 if(Game_mode & GM_MULTIPLAYER){
3902 // if the pool we're using has changed, synch stuff up
3903 if(pl->p_info.team == Net_player->p_info.team){
3904 wl_synch_interface();
3907 wl_synch_interface();
3912 void wl_drop(int from_bank,int from_list,int to_bank,int to_list, int ship_slot, int player_index)
3917 // get the appropriate net player
3918 if(Game_mode & GM_MULTIPLAYER){
3919 if(player_index == -1){
3922 pl = &Net_players[player_index];
3928 common_flash_button_init();
3929 if ( !(Game_mode & GM_MULTIPLAYER) || MULTIPLAYER_HOST ) {
3930 if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){
3931 // set the global pointers to the right pools
3932 ss_set_team_pointers(pl->p_info.team);
3936 mode = wss_get_mode(from_bank, from_list, to_bank, to_list, ship_slot);
3938 wl_apply(mode, from_bank, from_list, to_bank, to_list, ship_slot, player_index);
3941 if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){
3942 // set the global pointers to the right pools
3943 ss_set_team_pointers(Net_player->p_info.team);
3946 send_wss_request_packet(Net_player->player_id, from_bank, from_list, to_bank, to_list, ship_slot, -1, WSS_WEAPON_SELECT);