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/MissionScreenCommon.cpp $
16 * Revision 1.10 2005/08/12 08:58:41 taylor
17 * fix the strange mouse click issues on briefing, ship select and weapon select screens
19 * Revision 1.9 2004/09/20 01:31:44 theoddone33
22 * Revision 1.8 2004/07/04 11:31:43 taylor
23 * amd64 support, compiler warning fixes, don't use software rendering
25 * Revision 1.7 2003/08/03 16:10:29 taylor
26 * cleanup; compile warning fixes
28 * Revision 1.6 2003/06/11 18:30:33 taylor
31 * Revision 1.5 2003/05/25 02:30:43 taylor
34 * Revision 1.4 2002/06/09 04:41:23 relnev
35 * added copyright header
37 * Revision 1.3 2002/06/01 07:12:33 relnev
38 * a few NDEBUG updates.
40 * removed a few warnings.
42 * Revision 1.2 2002/05/07 03:16:46 theoddone33
43 * The Great Newline Fix
45 * Revision 1.1.1.1 2002/05/03 03:28:10 root
49 * 13 10/14/99 2:51p Jefff
52 * 12 8/05/99 3:40p Jefff
53 * hi-res text adjustments
55 * 11 7/15/99 9:20a Andsager
56 * FS2_DEMO initial checkin
58 * 10 2/01/99 5:55p Dave
59 * Removed the idea of explicit bitmaps for buttons. Fixed text
60 * highlighting for disabled gadgets.
62 * 9 1/30/99 7:33p Neilk
63 * Fixed coords problems for mission briefing screens
65 * 8 1/30/99 5:08p Dave
66 * More new hi-res stuff.Support for nice D3D textures.
68 * 7 1/29/99 4:17p Dave
69 * New interface screens.
71 * 6 1/24/99 11:37p Dave
72 * First full rev of beam weapons. Very customizable. Removed some bogus
73 * Int3()'s in low level net code.
75 * 5 11/30/98 1:07p Dave
76 * 16 bit conversion, first run.
78 * 4 11/17/98 11:12a Dave
79 * Removed player identification by address. Now assign explicit id #'s.
81 * 3 10/16/98 9:40a Andsager
82 * Remove ".h" files from model.h
84 * 2 10/07/98 10:53a Dave
87 * 1 10/07/98 10:50a Dave
89 * 85 6/09/98 10:31a Hoffoss
90 * Created index numbers for all xstr() references. Any new xstr() stuff
91 * added from here on out should be added to the end if the list. The
92 * current list count can be found in FreeSpace.cpp (search for
95 * 84 5/08/98 7:52p Lawrance
96 * fix bug where wing slot icons were not getting loaded
98 * 83 5/08/98 10:17a Lawrance
99 * don't play briefing slide-in animation if detail level is below high
101 * 82 5/06/98 11:50p Lawrance
102 * Clean up help overlay code for loadout screens
104 * 81 5/03/98 1:55a Lawrance
105 * Fix some sound problems with loadout screens
107 * 80 4/30/98 6:03p Lawrance
108 * Make drag and drop work better.
110 * 79 4/22/98 5:52p Dave
111 * Large reworking of endgame sequencing. Updated host options screen for
112 * new artwork. Put in checks to end game if host leaves or if team
113 * captains leave mid-game.
115 * 78 4/07/98 7:51p Hoffoss
116 * Implemented changed to options screen due to artwork changes.
118 * 77 4/07/98 5:42p Dave
119 * Put in support for ui display of voice system status (recording,
120 * playing back, etc). Make sure main hall music is stopped before
121 * entering a multiplayer game via ingame join.
123 * 76 4/02/98 11:40a Lawrance
124 * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
126 * 75 4/01/98 11:19p Dave
127 * Put in auto-loading of xferred pilot pic files. Grey out background
128 * behind pinfo popup. Put a chatbox message in when players are kicked.
129 * Moved mission title down in briefing. Other ui fixes.
131 * 74 4/01/98 9:21p John
132 * Made NDEBUG, optimized build with no warnings or errors.
134 * 73 3/31/98 11:47p Lawrance
135 * Fix some bugs related to wingmen selection when doing a quick mission
138 * 72 3/31/98 5:31p Lawrance
139 * Fix sound bug that happenned when entering briefing
141 * 71 3/30/98 5:16p Lawrance
142 * centralize a check for disabled loadout screens
144 * 70 3/30/98 12:18a Lawrance
145 * change some DEMO_RELEASE code to not compile code rather than return
148 * 69 3/29/98 10:16p Allender
149 * scramble missions need to have ship/weapon selection disabled (this
150 * code was somehow lost)
152 * 68 3/29/98 1:24p Dave
153 * Make chatbox not clear between multiplayer screens. Select player ship
154 * as default in mp team select and weapons select screens. Made create
155 * game mission list use 2 fixed size columns.
157 * 67 3/29/98 12:55a Lawrance
158 * Get demo build working with limited set of data.
160 * 66 3/25/98 8:43p Hoffoss
161 * Changed anim_play() to not be so damn complex when you try and call it.
163 * 65 3/24/98 4:59p Dave
164 * Fixed several ui bugs. Put in pre and post voice stream playback sound
165 * fx. Put in error specific popups for clients getting dropped from games
166 * through actions other than their own.
168 * 64 3/19/98 5:32p Lawrance
169 * Added music to the background of command brief screen.
171 * 63 3/05/98 5:02p Dave
172 * More work on team vs. team support for multiplayer. Need to fix bugs in
175 * 62 3/03/98 8:55p Dave
176 * Finished pre-briefing team vs. team support.
178 * 61 3/03/98 8:12p Lawrance
179 * Double timeout before flashing buttons
181 * 60 3/02/98 3:27p Lawrance
182 * Don't call muti_ts_init() in single player
184 * 59 3/01/98 3:26p Dave
185 * Fixed a few team select bugs. Put in multiplayer intertface sounds.
186 * Corrected how ships are disabled/enabled in team select/weapon select
189 * 58 2/27/98 4:55p Sandeep
190 * Fixed a signed/unsigned bug in the wss packet type
192 * 57 2/26/98 4:59p Allender
193 * groundwork for team vs team briefings. Moved weaponry pool into the
194 * Team_data structure. Added team field into the p_info structure.
195 * Allow for mutliple structures in the briefing code.
197 * 56 2/25/98 10:24a Lawrance
198 * Don't ask for confirmation when ESC is pressed.
200 * 55 2/24/98 12:22a Lawrance
201 * New coords for revamped briefing graphics
203 * 54 2/22/98 4:17p John
204 * More string externalization classification... 190 left to go!
206 * 53 2/22/98 12:19p John
207 * Externalized some strings
209 * 52 2/21/98 2:50p Lawrance
210 * Tell players that their campaign position will get saved if they return
211 * to main hall from loadout screens.
213 * 51 2/19/98 6:26p Dave
214 * Fixed a few file xfer bugs. Tweaked mp team select screen. Put in
215 * initial support for player data uploading.
217 * 50 2/18/98 3:56p Dave
218 * Several bugs fixed for mp team select screen. Put in standalone packet
219 * routing for team select.
221 * 49 2/17/98 6:07p Dave
222 * Tore out old multiplayer team select screen, installed new one.
224 * 48 2/13/98 3:46p Dave
225 * Put in dynamic chatbox sizing. Made multiplayer file lookups use cfile
228 * 47 2/10/98 8:40p Dave
229 * Fixed some debriefing bugs.
231 * 46 2/04/98 11:06p Lawrance
232 * Fix a couple of bugs with save/restore of player weapon loadout.
234 * 45 2/04/98 4:32p Allender
235 * support for multiple briefings and debriefings. Changes to mission
236 * type (now a bitfield). Bitfield defs for multiplayer modes
238 * 44 1/30/98 10:40a Lawrance
239 * remove any binding references to hotkey screen
241 * 43 1/20/98 5:52p Lawrance
242 * prompt user before returning to main hall (in single player)
244 * 42 1/17/98 5:51p Dave
245 * Bug fixes for bugs generated by multiplayer testing.
247 * 41 1/14/98 11:39a Dave
248 * Polished up a bunch of popup support items.
250 * 40 1/13/98 5:35p Lawrance
251 * Show popup when trying to go to weapons loadout without any ships
254 * 39 1/10/98 5:48p Lawrance
255 * Don't allow Tab to go to ship/weapon loadout screen in training, play
256 * negative feedback sounds if user tries to.
258 * 38 1/10/98 12:45a Lawrance
259 * Don't restore loadout if mission was modified.
261 * 37 1/09/98 6:06p Dave
262 * Put in network sound support for multiplayer ship/weapon select
263 * screens. Made clients exit game correctly through warp effect. Fixed
264 * main hall menu help overlay bug.
266 * 36 1/09/98 11:04a Lawrance
267 * Fix bug that prevented buttons from flashing in the loadout screens.
269 * 35 1/07/98 6:45p Lawrance
270 * Play first briefing music if none specified.
272 * 34 1/05/98 4:57p Lawrance
273 * reset flash timers when a button is pressed or a key is pressed
275 * 33 12/30/97 5:46p Lawrance
276 * Rename rnd() to rand_alt().
278 * 32 12/30/97 4:27p Lawrance
279 * Add new rnd() function that doesn't affect rand() sequence.
281 * 31 12/29/97 4:21p Lawrance
282 * Flash buttons on briefing/ship select/weapons loadout when enough time
283 * has elapsed without activity.
285 * 30 12/28/97 5:52p Lawrance
286 * Add support for debriefing success/fail music.
288 * 29 12/24/97 8:54p Lawrance
289 * Integrating new popup code
291 * 28 12/24/97 1:19p Lawrance
292 * fix some bugs with the multiplayer ship/weapons loadout
294 * 27 12/23/97 11:58a Allender
295 * changes to ship/wespon selection for multplayer. added sounds to some
296 * interface screens. Update and modiied end-of-briefing packets -- yet
304 #include "freespace.h"
305 #include "eventmusic.h"
307 #include "missionscreencommon.h"
308 #include "missionshipchoice.h"
309 #include "missionweaponchoice.h"
310 #include "missionbrief.h"
312 #include "multimsgs.h"
315 #include "gamesequence.h"
317 // #include "movie.h"
321 #include "contexthelp.h"
326 #include "linklist.h"
327 #include "staticrand.h" // for rand_alt()
329 #include "multiutil.h"
330 #include "multiteamselect.h"
331 #include "hudwingmanstatus.h"
332 #include "multi_endgame.h"
334 #include "animplay.h"
336 //////////////////////////////////////////////////////////////////
338 //////////////////////////////////////////////////////////////////
340 int Common_select_inited = 0;
342 // Dependent on when mouse button goes up
343 int Drop_icon_mflag, Drop_on_wing_mflag, Brief_mouse_up_flag;
345 int Mouse_down_last_frame = 0;
347 // Timers used to flash buttons after timeouts
348 #define MSC_FLASH_AFTER_TIME 60000 // time before flashing a button
349 #define MSC_FLASH_INTERVAL 200 // time between flashes
350 int Flash_timer; // timestamp used to start flashing
351 int Flash_toggle; // timestamp used to toggle flashing
352 int Flash_bright; // state of button to flash
354 //////////////////////////////////////////////////////////////////
356 //////////////////////////////////////////////////////////////////
359 static int InterfacePaletteBitmap = -1; // PCX file that holds the interface palette
361 //////////////////////////////////////////////////////////////////
363 //////////////////////////////////////////////////////////////////
364 UI_WINDOW *Active_ui_window;
366 brief_common_buttons Common_buttons[3][GR_NUM_RESOLUTIONS][NUM_COMMON_BUTTONS] = {
367 // icons for briefing, ship selection, weapon selection screens
371 brief_common_buttons("CB_00", 0, 0, -1, -1, 0), // briefing
372 brief_common_buttons("CB_01", 0, 19, -1, -1, 1), // ship selection
373 brief_common_buttons("CB_02", 0, 33, -1, -1, 2), // weapons loadout
374 brief_common_buttons("CB_05", 562, 411, -1, -1, 5), // commit
375 brief_common_buttons("CB_06", 469, 424, -1, -1, 6), // help
376 brief_common_buttons("CB_07", 447, 452, -1, -1, 7), // options
378 brief_common_buttons("CB_00", 7, 3, 37, 7, 0),
379 brief_common_buttons("CB_01", 7, 19, 37, 23, 1),
380 brief_common_buttons("CB_02", 7, 35, 37, 39, 2),
381 brief_common_buttons("CB_05", 571, 425, 572, 413, 5),
382 brief_common_buttons("CB_06", 533, 425, 500, 440, 6),
383 brief_common_buttons("CB_07", 533, 455, 479, 464, 7),
387 brief_common_buttons("2_CB_00", 12, 5, 59, 12, 0),
388 brief_common_buttons("2_CB_01", 12, 31, 59, 37, 1),
389 brief_common_buttons("2_CB_02", 12, 56, 59, 62, 2),
390 brief_common_buttons("2_CB_05", 914, 681, 937, 671, 5),
391 brief_common_buttons("2_CB_06", 854, 681, 822, 704, 6),
392 brief_common_buttons("2_CB_07", 854, 724, 800, 743, 7),
398 brief_common_buttons("CB_00", 0, 0, -1, -1, 0), // briefing
399 brief_common_buttons("CB_01", 0, 19, -1, -1, 1), // ship selection
400 brief_common_buttons("CB_02", 0, 33, -1, -1, 2), // weapons loadout
401 brief_common_buttons("CB_05", 562, 411, -1, -1, 5), // commit
402 brief_common_buttons("CB_06", 469, 424, -1, -1, 6), // help
403 brief_common_buttons("CB_07", 447, 452, -1, -1, 7), // options
405 brief_common_buttons("CB_00", 7, 3, 37, 7, 0),
406 brief_common_buttons("CB_01", 7, 19, 37, 23, 1),
407 brief_common_buttons("CB_02", 7, 35, 37, 39, 2),
408 brief_common_buttons("CB_05", 571, 425, 572, 413, 5),
409 brief_common_buttons("CB_06", 533, 425, 500, 440, 6),
410 brief_common_buttons("CB_07", 533, 455, 479, 464, 7),
414 brief_common_buttons("2_CB_00", 12, 5, 59, 12, 0),
415 brief_common_buttons("2_CB_01", 12, 31, 59, 37, 1),
416 brief_common_buttons("2_CB_02", 12, 56, 59, 62, 2),
417 brief_common_buttons("2_CB_05", 914, 681, 937, 671, 5),
418 brief_common_buttons("2_CB_06", 854, 681, 822, 704, 6),
419 brief_common_buttons("2_CB_07", 854, 724, 800, 743, 7),
425 brief_common_buttons("CB_00", 0, 0, -1, -1, 0), // briefing
426 brief_common_buttons("CB_01", 0, 19, -1, -1, 1), // ship selection
427 brief_common_buttons("CB_02", 0, 33, -1, -1, 2), // weapons loadout
428 brief_common_buttons("CB_05", 562, 411, -1, -1, 5), // commit
429 brief_common_buttons("CB_06", 469, 424, -1, -1, 6), // help
430 brief_common_buttons("CB_07", 447, 452, -1, -1, 7), // options
432 brief_common_buttons("CB_00", 7, 3, 37, 7, 0),
433 brief_common_buttons("CB_01", 7, 19, 37, 23, 1),
434 brief_common_buttons("CB_02", 7, 35, 37, 39, 2),
435 brief_common_buttons("CB_05", 571, 425, 572, 413, 5),
436 brief_common_buttons("CB_06", 533, 425, 500, 440, 6),
437 brief_common_buttons("CB_07", 533, 455, 479, 464, 7),
441 brief_common_buttons("2_CB_00", 12, 5, 59, 12, 0),
442 brief_common_buttons("2_CB_01", 12, 31, 59, 37, 1),
443 brief_common_buttons("2_CB_02", 12, 56, 59, 62, 2),
444 brief_common_buttons("2_CB_05", 914, 681, 937, 671, 5),
445 brief_common_buttons("2_CB_06", 854, 681, 822, 704, 6),
446 brief_common_buttons("2_CB_07", 854, 724, 800, 743, 7),
451 #define COMMON_BRIEFING_BUTTON 0
452 #define COMMON_SS_BUTTON 1
453 #define COMMON_WEAPON_BUTTON 2
454 #define COMMON_COMMIT_BUTTON 3
455 #define COMMON_HELP_BUTTON 4
456 #define COMMON_OPTIONS_BUTTON 5
458 int Background_playing; // Flag to indicate background animation is playing
459 static anim *Background_anim; // Ids for the anim data that is loaded
461 // value for which Team_data entry to use
464 // Ids for the instance of the anim that is playing
466 static anim_instance *Background_anim_instance;
469 int Wing_slot_empty_bitmap;
470 int Wing_slot_disabled_bitmap;
473 int wss_slots_all_empty();
475 // Display the no ships selected error
476 void common_show_no_ship_error()
478 popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "At least one ship must be selected before proceeding to weapons loadout", 460));
481 // Check the status of the buttons common to the loadout screens
482 void common_check_buttons()
487 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
488 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
489 if ( b->pressed() ) {
496 // AL 11-23-97: let a joystick button press commit
497 if ( joy_down_count(0) || joy_down_count(1) ) {
504 // -------------------------------------------------------------------
505 // common_redraw_pressed_buttons()
507 // Redraw any common buttons that are pressed down. This function is needed
508 // since we sometimes need to draw pressed buttons last to ensure the entire
509 // button gets drawn (and not overlapped by other buttons)
511 void common_redraw_pressed_buttons()
516 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
517 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
518 if ( b->button_down() ) {
524 void common_buttons_maybe_reload(UI_WINDOW *ui_window)
529 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
530 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
531 b->set_bmaps(Common_buttons[Current_screen-1][gr_screen.res][i].filename);
535 void common_buttons_init(UI_WINDOW *ui_window)
540 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
541 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
542 b->create( ui_window, "", Common_buttons[Current_screen-1][gr_screen.res][i].x, Common_buttons[Current_screen-1][gr_screen.res][i].y, 60, 30, 0, 1);
543 // set up callback for when a mouse first goes over a button
544 b->set_highlight_action( common_play_highlight_sound );
545 b->set_bmaps(Common_buttons[Current_screen-1][gr_screen.res][i].filename);
546 b->link_hotspot(Common_buttons[Current_screen-1][gr_screen.res][i].hotspot);
551 ui_window->add_XSTR("Briefing", 1504, Common_buttons[Current_screen-1][gr_screen.res][COMMON_BRIEFING_BUTTON].xt, Common_buttons[Current_screen-1][gr_screen.res][COMMON_BRIEFING_BUTTON].yt, &Common_buttons[Current_screen-1][gr_screen.res][COMMON_BRIEFING_BUTTON].button, UI_XSTR_COLOR_GREEN);
552 ui_window->add_XSTR("Ship Selection", 1067, Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_BUTTON].xt, Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_BUTTON].yt, &Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_BUTTON].button, UI_XSTR_COLOR_GREEN);
553 ui_window->add_XSTR("Weapon Loadout", 1068, Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_BUTTON].xt, Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_BUTTON].yt, &Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_BUTTON].button, UI_XSTR_COLOR_GREEN);
554 ui_window->add_XSTR("Commit", 1062, Common_buttons[Current_screen-1][gr_screen.res][COMMON_COMMIT_BUTTON].xt, Common_buttons[Current_screen-1][gr_screen.res][COMMON_COMMIT_BUTTON].yt, &Common_buttons[Current_screen-1][gr_screen.res][COMMON_COMMIT_BUTTON].button, UI_XSTR_COLOR_PINK);
555 ui_window->add_XSTR("Help", 928, Common_buttons[Current_screen-1][gr_screen.res][COMMON_HELP_BUTTON].xt, Common_buttons[Current_screen-1][gr_screen.res][COMMON_HELP_BUTTON].yt, &Common_buttons[Current_screen-1][gr_screen.res][COMMON_HELP_BUTTON].button, UI_XSTR_COLOR_GREEN);
556 ui_window->add_XSTR("Options", 1036, Common_buttons[Current_screen-1][gr_screen.res][COMMON_OPTIONS_BUTTON].xt, Common_buttons[Current_screen-1][gr_screen.res][COMMON_OPTIONS_BUTTON].yt, &Common_buttons[Current_screen-1][gr_screen.res][COMMON_OPTIONS_BUTTON].button, UI_XSTR_COLOR_GREEN);
559 common_reset_buttons();
561 Common_buttons[Current_screen-1][gr_screen.res][COMMON_COMMIT_BUTTON].button.set_hotkey(KEY_CTRLED+KEY_ENTER);
562 Common_buttons[Current_screen-1][gr_screen.res][COMMON_HELP_BUTTON].button.set_hotkey(KEY_F1);
563 Common_buttons[Current_screen-1][gr_screen.res][COMMON_OPTIONS_BUTTON].button.set_hotkey(KEY_F2);
565 // for scramble or training missions, disable the ship/weapon selection regions
566 if ( brief_only_allow_briefing() ) {
567 Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_REGION].button.disable();
568 Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_REGION].button.disable();
571 #ifdef DEMO // allow for FS2_DEMO
572 Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_REGION].button.disable();
573 Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_REGION].button.disable();
577 void set_active_ui(UI_WINDOW *ui_window)
579 Active_ui_window = ui_window;
582 void common_music_init(int score_index)
584 if ( Cmdline_freespace_no_music ) {
588 if ( score_index >= NUM_SCORES ) {
593 if ( Mission_music[score_index] < 0 ) {
594 if ( Num_music_files > 0 ) {
595 Mission_music[score_index] = 0;
596 nprintf(("Sound","No briefing music is selected, so play first briefing track: %s\n",Spooled_music[Mission_music[score_index]].name));
602 briefing_load_music( Spooled_music[Mission_music[score_index]].filename );
603 // Use this id to trigger the start of music playing on the briefing screen
604 Briefing_music_begin_timestamp = timestamp(BRIEFING_MUSIC_DELAY);
607 void common_music_do()
609 if ( Cmdline_freespace_no_music ) {
613 // Use this id to trigger the start of music playing on the briefing screen
614 if ( timestamp_elapsed( Briefing_music_begin_timestamp) ) {
615 Briefing_music_begin_timestamp = 0;
616 briefing_start_music();
620 void common_music_close()
622 if ( Cmdline_freespace_no_music ) {
626 if ( Num_music_files <= 0 )
629 briefing_stop_music();
632 // function that sets the current palette to the interface palette. This function
633 // needs to be followed by common_free_interface_palette() to restore the game palette.
634 void common_set_interface_palette(char *filename)
636 static char buf[MAX_FILENAME_LEN + 1] = {0};
639 filename = NOX("palette01");
641 Assert(strlen(filename) <= MAX_FILENAME_LEN);
642 if ( (InterfacePaletteBitmap != -1) && !stricmp(filename, buf) )
643 return; // already set to this palette
645 strcpy(buf, filename);
647 // unload the interface bitmap from memory
648 if (InterfacePaletteBitmap != -1) {
649 bm_unload(InterfacePaletteBitmap);
650 InterfacePaletteBitmap = -1;
653 // ugh - we don't need this anymore
655 InterfacePaletteBitmap = bm_load(filename);
656 if (InterfacePaletteBitmap < 0) {
657 Error(LOCATION, "Could not load in \"%s\"!", filename);
661 #ifndef HARDWARE_ONLY
662 palette_use_bm_palette(InterfacePaletteBitmap);
666 // release the interface palette .pcx file, and restore the game palette
667 void common_free_interface_palette()
669 // unload the interface bitmap from memory
670 if (InterfacePaletteBitmap != -1) {
671 bm_unload(InterfacePaletteBitmap);
672 InterfacePaletteBitmap = -1;
675 // restore the normal game palette
676 palette_restore_palette();
679 // Init timers used for flashing buttons
680 void common_flash_button_init()
682 Flash_timer = timestamp(MSC_FLASH_AFTER_TIME);
687 // determine if we should draw a button as bright
688 int common_flash_bright()
690 if ( timestamp_elapsed(Flash_timer) ) {
691 if ( timestamp_elapsed(Flash_toggle) ) {
692 Flash_toggle = timestamp(MSC_FLASH_INTERVAL);
700 // common_select_init() will load in animations and bitmaps that are common to the
701 // briefing/ship select/weapon select screens. The global Common_select_inited is set
702 // after this function is called once, and is only cleared when common_select_close()
703 // is called. This prevents multiple loadings of animations/bitmaps.
705 // This function also sets the palette based on the file palette01.pcx
706 void common_select_init()
708 if ( Common_select_inited ) {
709 nprintf(("Alan","common_select_init() returning without doing anything\n"));
713 nprintf(("Alan","entering common_select_init()\n"));
715 // No anims are playing
716 Background_playing = 0;
717 Background_anim = NULL;
719 #ifndef DEMO // not for FS2_DEMO
722 if ( current_detail_level() >= (NUM_DEFAULT_DETAIL_LEVELS-2) ) {
724 anim_play_struct aps;
726 // Load in the background transition anim
727 if ( Game_mode & GM_MULTIPLAYER )
728 Background_anim = anim_load("BriefTransMulti", 1); // 1 as last parm means file is mem-mapped
730 Background_anim = anim_load("BriefTrans", 1); // 1 as last parm means file is mem-mapped
733 Assert( Background_anim != NULL );
734 anim_play_init(&aps, Background_anim, 0, 0);
735 aps.framerate_independent = 1;
737 Background_anim_instance = anim_play(&aps);
738 Background_playing = 1; // start playing the Background anim
742 Current_screen = Next_screen = ON_BRIEFING_SELECT;
744 // load in the icons for the wing slots
745 load_wing_icons(NOX("iconwing01"));
750 Current_screen = Next_screen = ON_BRIEFING_SELECT;
754 Common_select_inited = 1;
756 // this handles the case where the player played a multiplayer game but now is in single player (in one instance
758 if(!(Game_mode & GM_MULTIPLAYER)){
762 // get the value of the team
763 Common_team = 0; // assume the first team -- we'll change this value if we need to
764 if ( (Game_mode & GM_MULTIPLAYER) && IS_MISSION_MULTI_TEAMS )
765 Common_team = Net_player->p_info.team;
767 ship_select_common_init();
768 weapon_select_common_init();
769 common_flash_button_init();
771 if ( Game_mode & GM_MULTIPLAYER ) {
772 multi_ts_common_init();
775 // restore loadout from Player_loadout if this is the same mission as the one previously played
776 if ( !(Game_mode & GM_MULTIPLAYER) ) {
777 if ( !stricmp(Player_loadout.filename, Game_current_mission_filename) ) {
778 wss_restore_loadout();
779 ss_synch_interface();
780 wl_synch_interface();
785 Drop_on_wing_mflag = 0;
788 void common_reset_buttons()
793 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
794 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
798 switch(Current_screen) {
799 case ON_BRIEFING_SELECT:
800 Common_buttons[Current_screen-1][gr_screen.res][COMMON_BRIEFING_REGION].button.skip_first_highlight_callback();
803 Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_REGION].button.skip_first_highlight_callback();
805 case ON_WEAPON_SELECT:
806 Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_REGION].button.skip_first_highlight_callback();
811 // common_select_do() is called once per loop in the interface screens and is used
812 // for drawing and changing the common animations and blitting common bitmaps.
813 int common_select_do(float frametime)
817 if ( help_overlay_active(BR_OVERLAY) || help_overlay_active(SS_OVERLAY) || help_overlay_active(WL_OVERLAY) ) {
818 Common_buttons[0][gr_screen.res][COMMON_HELP_BUTTON].button.reset_status();
819 Common_buttons[1][gr_screen.res][COMMON_HELP_BUTTON].button.reset_status();
820 Common_buttons[2][gr_screen.res][COMMON_HELP_BUTTON].button.reset_status();
821 Active_ui_window->set_ignore_gadgets(1);
823 Active_ui_window->set_ignore_gadgets(0);
826 k = chatbox_process();
827 if ( Game_mode & GM_NORMAL ) {
828 new_k = Active_ui_window->process(k);
830 new_k = Active_ui_window->process(k, 0);
833 if ( (k > 0) || (new_k > 0) || B1_JUST_RELEASED ) {
834 if ( help_overlay_active(BR_OVERLAY) || help_overlay_active(SS_OVERLAY) || help_overlay_active(WL_OVERLAY) ) {
835 help_overlay_set_state(BR_OVERLAY, 0);
836 help_overlay_set_state(SS_OVERLAY, 0);
837 help_overlay_set_state(WL_OVERLAY, 0);
838 Active_ui_window->set_ignore_gadgets(0);
844 // test for mouse buttons, must be done after Active_ui_window->process()
845 // has been called to work properly
848 Drop_on_wing_mflag = 0;
849 Brief_mouse_up_flag = 0;
850 Mouse_down_last_frame = 0;
852 // if the left mouse button was released...
855 Drop_on_wing_mflag = 1;
858 // if the left mouse button was pressed...
860 Mouse_down_last_frame = 1;
863 // basically a "click", only check for the click here to avoid action-on-over on briefing map
864 if ( B1_JUST_PRESSED ) {
865 Brief_mouse_up_flag = 1;
868 // reset timers for flashing buttons if key pressed
869 if ( (k>0) || (new_k>0) ) {
870 common_flash_button_init();
876 if ( Background_playing ) {
878 if ( Background_anim_instance->frame_num == BUTTON_SLIDE_IN_FRAME ) {
879 gamesnd_play_iface(SND_BTN_SLIDE);
882 if ( Background_anim_instance->frame_num == Background_anim_instance->stop_at ) {
883 // Free up the big honking background animation, since we won't be playing it again
884 anim_release_render_instance(Background_anim_instance);
885 anim_free(Background_anim);
887 Background_playing = 0;
888 Current_screen = Next_screen = ON_BRIEFING_SELECT;
893 if ( Current_screen != Next_screen ) {
894 switch( Next_screen ) {
895 case ON_BRIEFING_SELECT:
896 gameseq_post_event( GS_EVENT_START_BRIEFING );
900 // go to the specialized multiplayer team/ship select screen
901 if(Game_mode & GM_MULTIPLAYER){
902 gameseq_post_event(GS_EVENT_TEAM_SELECT);
904 // go to the normal ship select screen
906 gameseq_post_event(GS_EVENT_SHIP_SELECTION);
910 case ON_WEAPON_SELECT:
911 if ( !wss_slots_all_empty() ) {
912 gameseq_post_event(GS_EVENT_WEAPON_SELECTION);
914 common_show_no_ship_error();
923 // -------------------------------------------------------------------------------------
926 void common_render(float frametime)
928 if ( !Background_playing ) {
929 gr_set_bitmap(Brief_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
933 anim_render_all(0, frametime);
934 anim_render_all(ON_SHIP_SELECT, frametime);
937 // -------------------------------------------------------------------------------------
938 // common_render_selected_screen_button()
940 // A very ugly piece of special purpose code. This is used to draw the pressed button
941 // frame for whatever stage of the briefing/ship select/weapons loadout we are on.
943 void common_render_selected_screen_button()
945 Common_buttons[Next_screen-1][gr_screen.res][Next_screen-1].button.draw_forced(2);
948 // -------------------------------------------------------------------------------------
949 // common_button_do() do the button action for the specified pressed button
951 void common_button_do(int i)
953 if ( i == COMMON_COMMIT_BUTTON ) {
958 if ( Background_playing )
963 case COMMON_BRIEFING_BUTTON:
964 if ( Current_screen != ON_BRIEFING_SELECT ) {
965 gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
966 Next_screen = ON_BRIEFING_SELECT;
970 case COMMON_WEAPON_BUTTON:
971 if ( Current_screen != ON_WEAPON_SELECT ) {
972 if ( !wss_slots_all_empty() ) {
973 gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
974 Next_screen = ON_WEAPON_SELECT;
976 common_show_no_ship_error();
981 case COMMON_SS_BUTTON:
982 if ( Current_screen != ON_SHIP_SELECT ) {
983 gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
984 Next_screen = ON_SHIP_SELECT;
988 case COMMON_OPTIONS_BUTTON:
989 gamesnd_play_iface(SND_SWITCH_SCREENS);
990 gameseq_post_event( GS_EVENT_OPTIONS_MENU );
993 case COMMON_HELP_BUTTON:
994 gamesnd_play_iface(SND_HELP_PRESSED);
995 launch_context_help();
1001 // common_check_keys() will check for keypresses common to all the interface screens.
1002 void common_check_keys(int k)
1008 if ( Current_screen == ON_BRIEFING_SELECT ) {
1009 if ( brief_get_closeup_icon() != NULL ) {
1010 brief_turn_off_closeup_icon();
1015 // prompt the host of a multiplayer game
1016 if(Game_mode & GM_MULTIPLAYER){
1017 multi_quit_game(PROMPT_ALL);
1019 // go through the single player quit process
1021 // return to the main menu
1023 int return_to_menu, pf_flags;
1024 pf_flags = PF_USE_AFFIRMATIVE_ICON|PF_USE_NEGATIVE_ICON;
1025 return_to_menu = popup(pf_flags, 2, POPUP_NO, POPUP_YES, XSTR( "Do you want to return to the Main Hall?\n(Your campaign position will be saved)", -1));
1026 if ( return_to_menu == 1 ) {
1027 gameseq_post_event(GS_EVENT_MAIN_MENU);
1030 gameseq_post_event(GS_EVENT_MAIN_MENU);
1035 case KEY_CTRLED + KEY_ENTER:
1040 if ( Current_screen != ON_BRIEFING_SELECT && !Background_playing ) {
1041 Next_screen = ON_BRIEFING_SELECT;
1046 if ( brief_only_allow_briefing() ) {
1047 gamesnd_play_iface(SND_GENERAL_FAIL);
1051 #ifndef DEMO // not for FS2_DEMO
1052 if ( Current_screen != ON_WEAPON_SELECT && !Background_playing ) {
1053 if ( !wss_slots_all_empty() ) {
1054 Next_screen = ON_WEAPON_SELECT;
1056 common_show_no_ship_error();
1060 gamesnd_play_iface(SND_GENERAL_FAIL);
1067 if ( brief_only_allow_briefing() ) {
1068 gamesnd_play_iface(SND_GENERAL_FAIL);
1072 #ifndef DEMO // not for FS2_DEMO
1073 if ( Current_screen != ON_SHIP_SELECT && !Background_playing ) {
1074 Next_screen = ON_SHIP_SELECT;
1077 gamesnd_play_iface(SND_GENERAL_FAIL);
1082 case KEY_SHIFTED+KEY_TAB:
1084 if ( brief_only_allow_briefing() ) {
1085 gamesnd_play_iface(SND_GENERAL_FAIL);
1089 #ifndef DEMO // not for FS2_DEMO
1090 if ( !Background_playing ) {
1091 switch ( Current_screen ) {
1092 case ON_BRIEFING_SELECT:
1093 if ( !wss_slots_all_empty() ) {
1094 Next_screen = ON_WEAPON_SELECT;
1096 common_show_no_ship_error();
1100 case ON_SHIP_SELECT:
1101 Next_screen = ON_BRIEFING_SELECT;
1104 case ON_WEAPON_SELECT:
1105 Next_screen = ON_SHIP_SELECT;
1113 gamesnd_play_iface(SND_GENERAL_FAIL);
1120 if ( brief_only_allow_briefing() ) {
1121 gamesnd_play_iface(SND_GENERAL_FAIL);
1125 #ifndef DEMO // not for FS2_DEMO
1126 if ( !Background_playing ) {
1127 switch ( Current_screen ) {
1128 case ON_BRIEFING_SELECT:
1129 Next_screen = ON_SHIP_SELECT;
1132 case ON_SHIP_SELECT:
1133 if ( !wss_slots_all_empty() ) {
1134 Next_screen = ON_WEAPON_SELECT;
1136 common_show_no_ship_error();
1140 case ON_WEAPON_SELECT:
1141 Next_screen = ON_BRIEFING_SELECT;
1149 gamesnd_play_iface(SND_GENERAL_FAIL);
1163 // common_select_close() will release the memory for animations and bitmaps that
1164 // were loaded in common_select_init(). This function will abort if the Common_select_inited
1165 // flag is not set. The last thing common_select_close() does in clear the Common_select_inited
1168 // weapon_select_close() and ship_select_close() are both called, since common_select_close()
1169 // is the function that is called the interface screens are finally exited.
1170 void common_select_close()
1172 if ( !Common_select_inited ) {
1173 nprintf(("Alan","common_select_close() returning without doing anything\n"));
1177 nprintf(("Alan","entering common_select_close()\n"));
1179 // catch open anims that weapon_select_init_team() opened when not in weapon_select
1180 weapon_select_close_team();
1182 weapon_select_close();
1183 if(Game_mode & GM_MULTIPLAYER){
1186 ship_select_close();
1189 common_free_interface_palette();
1191 // release the bitmpas that were previously extracted from anim files
1192 unload_wing_icons();
1194 // Release any instances that may still exist
1195 anim_release_all_instances();
1197 // free the anim's that were loaded into memory
1199 if ( Background_anim ) {
1200 anim_free(Background_anim);
1201 Background_anim = NULL;
1205 common_music_close();
1206 Common_select_inited = 0;
1209 // ------------------------------------------------------------------------
1210 // load_wing_icons() creates the bitmaps for wing icons
1212 void load_wing_icons(char *filename)
1214 int first_frame, num_frames;
1216 first_frame = bm_load_animation(filename, &num_frames);
1217 if ( first_frame == -1 ) {
1218 Error(LOCATION, "Could not load icons from %s\n", filename);
1222 Wing_slot_disabled_bitmap = first_frame;
1223 Wing_slot_empty_bitmap = first_frame + 1;
1224 // Wing_slot_player_empty_bitmap = first_frame + 2;
1227 // ------------------------------------------------------------------------
1228 // common_scroll_up_pressed()
1230 int common_scroll_up_pressed(int *start, int size, int max_show)
1232 // check if we even need to scroll at all
1233 if ( size <= max_show ) {
1237 if ( (size - *start) > max_show ) {
1244 // ------------------------------------------------------------------------
1245 // common_scroll_down_pressed()
1247 int common_scroll_down_pressed(int *start, int size, int max_show)
1249 // check if we even need to scroll at all
1250 if ( size <= max_show ) {
1263 loadout_data Player_loadout; // what the ship and weapon loadout is... used since we want to use the
1264 // same loadout if the mission is played again
1266 //wss_unit Wss_slots[MAX_WSS_SLOTS]; // slot data struct
1267 //int Wl_pool[MAX_WEAPON_TYPES]; // weapon pool
1268 //int Ss_pool[MAX_SHIP_TYPES]; // ship pool
1269 //int Wss_num_wings; // number of player wings
1271 wss_unit Wss_slots_teams[MAX_TEAMS][MAX_WSS_SLOTS];
1272 int Wl_pool_teams[MAX_TEAMS][MAX_WEAPON_TYPES];
1273 int Ss_pool_teams[MAX_TEAMS][MAX_SHIP_TYPES];
1274 int Wss_num_wings_teams[MAX_TEAMS];
1276 wss_unit *Wss_slots;
1281 // save ship selection loadout to the Player_loadout struct
1282 void wss_save_loadout()
1286 // save the ship pool
1287 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1288 Player_loadout.ship_pool[i] = Ss_pool[i];
1291 // save the weapons pool
1292 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1293 Player_loadout.weapon_pool[i] = Wl_pool[i];
1296 // save the ship class / weapons for each slot
1297 for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
1298 Player_loadout.unit_data[i].ship_class = Wss_slots[i].ship_class;
1300 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
1301 Player_loadout.unit_data[i].wep[j] = Wss_slots[i].wep[j];
1302 Player_loadout.unit_data[i].wep_count[j] = Wss_slots[i].wep_count[j];
1307 // restore ship/weapons loadout from the Player_loadout struct
1308 void wss_restore_loadout()
1313 // only restore if mission hasn't changed
1314 if ( stricmp(Player_loadout.last_modified, The_mission.modified) ) {
1318 // restore the ship pool
1319 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1320 Ss_pool[i] = Player_loadout.ship_pool[i];
1323 // restore the weapons pool
1324 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1325 Wl_pool[i] = Player_loadout.weapon_pool[i];
1328 // restore the ship class / weapons for each slot
1329 for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
1330 slot = &Player_loadout.unit_data[i];
1331 Wss_slots[i].ship_class = slot->ship_class;
1333 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
1334 Wss_slots[i].wep[j]= slot->wep[j];
1335 Wss_slots[i].wep_count[j] = slot->wep_count[j];
1340 // Do a direct restore of the Player_loadout ship/weapon data to the wings
1341 void wss_direct_restore_loadout()
1347 // only restore if mission hasn't changed
1348 if ( stricmp(Player_loadout.last_modified, The_mission.modified) ) {
1352 for ( i = 0; i < MAX_WING_BLOCKS; i++ ) {
1354 if ( Starting_wings[i] < 0 )
1357 wp = &Wings[Starting_wings[i]];
1359 // If this wing is still on the arrival list, then update the parse objects
1360 if ( wp->ship_index[0] == -1 ) {
1363 for ( p_objp = GET_FIRST(&ship_arrival_list); p_objp != END_OF_LIST(&ship_arrival_list); p_objp = GET_NEXT(p_objp) ) {
1364 slot = &Player_loadout.unit_data[i*4+j];
1365 if ( p_objp->wingnum == WING_INDEX(wp) ) {
1366 p_objp->ship_class = slot->ship_class;
1367 wl_update_parse_object_weapons(p_objp, slot);
1373 int cleanup_ship_index[MAX_WING_SLOTS];
1376 for ( k = 0; k < MAX_WING_SLOTS; k++ ) {
1377 cleanup_ship_index[k] = -1;
1380 // This wing is already created, so directly update the ships
1381 for ( j = 0; j < MAX_WING_SLOTS; j++ ) {
1382 slot = &Player_loadout.unit_data[i*4+j];
1383 shipp = &Ships[wp->ship_index[j]];
1384 if ( shipp->ship_info_index != slot->ship_class ) {
1386 if ( wp->ship_index[j] == -1 ) {
1390 if ( slot->ship_class == -1 ) {
1391 cleanup_ship_index[j] = wp->ship_index[j];
1392 ship_add_exited_ship( shipp, SEF_PLAYER_DELETED );
1393 obj_delete(shipp->objnum);
1394 hud_set_wingman_status_none( shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
1397 change_ship_type(wp->ship_index[j], slot->ship_class);
1400 wl_bash_ship_weapons(&Ships[wp->ship_index[j]].weapons, slot);
1403 for ( k = 0; k < MAX_WING_SLOTS; k++ ) {
1404 if ( cleanup_ship_index[k] != -1 ) {
1405 ship_wing_cleanup( cleanup_ship_index[k], wp );
1412 int wss_slots_all_empty()
1416 for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
1417 if ( Wss_slots[i].ship_class >= 0 )
1421 if ( i == MAX_WSS_SLOTS )
1427 // determine the mode (WSS_...) based on slot/list index values
1428 int wss_get_mode(int from_slot, int from_list, int to_slot, int to_list, int wl_ship_slot)
1430 int mode, to_slot_empty=0;
1432 if ( wl_ship_slot >= 0 ) {
1434 if ( to_slot >= 0 ) {
1435 if ( Wss_slots[wl_ship_slot].wep_count[to_slot] == 0 ) {
1441 if ( to_slot >= 0 ) {
1442 if ( Wss_slots[to_slot].ship_class == -1 ){
1449 if ( from_slot >= 0 && to_slot >= 0 ) {
1450 mode = WSS_SWAP_SLOT_SLOT;
1451 } else if ( from_slot >= 0 && to_list >= 0 ) {
1452 mode = WSS_DUMP_TO_LIST;
1453 } else if ( (from_list >= 0) && (to_slot >= 0) && (to_slot_empty) ) {
1454 mode = WSS_GRAB_FROM_LIST;
1455 } else if ( (from_list >= 0) && (to_slot >= 0) && (!to_slot_empty) ) {
1456 mode = WSS_SWAP_LIST_SLOT;
1458 mode = -1; // no changes required
1464 // store all the unit data and pool data
1465 int store_wss_data(ubyte *block, int max_size, int sound,int player_index)
1471 // write the ship pool
1472 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1473 if ( Ss_pool[i] > 0 ) {
1474 block[offset++] = (ubyte)i;
1475 Assert( Ss_pool[i] < UCHAR_MAX );
1477 // take care of sign issues
1478 if(Ss_pool[i] == -1){
1479 block[offset++] = 0xff;
1481 block[offset++] = (ubyte)Ss_pool[i];
1486 block[offset++] = 0xff; // signals start of weapons pool
1488 // write the weapon pool
1489 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1490 if ( Wl_pool[i] > 0 ) {
1491 block[offset++] = (ubyte)i;
1492 ishort = (short)Wl_pool[i];
1493 memcpy(block+offset, &ishort, sizeof(short));
1494 offset += sizeof(short);
1498 // write the unit data
1500 block[offset++] = 0xff; // signals start of unit data
1502 for ( i=0; i<MAX_WSS_SLOTS; i++ ) {
1503 Assert( Wss_slots[i].ship_class < UCHAR_MAX );
1504 if(Wss_slots[i].ship_class == -1){
1505 block[offset++] = 0xff;
1507 block[offset++] = (ubyte)(Wss_slots[i].ship_class);
1509 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
1510 // take care of sign issues
1511 Assert( Wss_slots[i].wep[j] < UCHAR_MAX );
1512 if(Wss_slots[i].wep[j] == -1){
1513 block[offset++] = 0xff;
1515 block[offset++] = (ubyte)(Wss_slots[i].wep[j]);
1518 Assert( Wss_slots[i].wep_count[j] < SHRT_MAX );
1519 ishort = short(Wss_slots[i].wep_count[j]);
1521 memcpy(&(block[offset]), &(ishort), sizeof(short) );
1522 offset += sizeof(short);
1525 // mwa -- old way below -- too much space
1526 //memcpy(block+offset, &Wss_slots[i], sizeof(wss_unit));
1527 //offset += sizeof(wss_unit);
1532 block[offset++] = 0xff;
1534 block[offset++] = (ubyte)sound;
1537 // add a netplayer address to identify who should play the sound
1539 if(player_index != -1){
1540 player_id = Net_players[player_index].player_id;
1542 memcpy(block+offset,&player_id,sizeof(player_id));
1543 offset += sizeof(player_id);
1545 Assert( offset < max_size );
1549 int restore_wss_data(ubyte *block)
1551 int i, j, sanity, offset=0;
1556 // restore ship pool
1558 memset(Ss_pool, 0, MAX_SHIP_TYPES*sizeof(int));
1560 if ( sanity++ > MAX_SHIP_TYPES ) {
1565 b1 = block[offset++];
1570 // take care of sign issues
1571 b2 = block[offset++];
1579 // restore weapons pool
1581 memset(Wl_pool, 0, MAX_WEAPON_TYPES*sizeof(int));
1583 if ( sanity++ > MAX_WEAPON_TYPES ) {
1588 b1 = block[offset++];
1593 memcpy(&ishort, block+offset, sizeof(short));
1594 offset += sizeof(short);
1595 Wl_pool[b1] = ishort;
1598 for ( i=0; i<MAX_WSS_SLOTS; i++ ) {
1599 if(block[offset] == 0xff){
1600 Wss_slots[i].ship_class = -1;
1602 Wss_slots[i].ship_class = block[offset];
1605 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
1606 // take care of sign issues
1607 if(block[offset] == 0xff){
1608 Wss_slots[i].wep[j] = -1;
1611 Wss_slots[i].wep[j] = (int)(block[offset++]);
1614 memcpy( &ishort, &(block[offset]), sizeof(short) );
1615 Wss_slots[i].wep_count[j] = (int)ishort;
1616 offset += sizeof(short);
1619 // mwa -- old way below
1620 //memcpy(&Wss_slots[i], block+offset, sizeof(wss_unit));
1621 //offset += sizeof(wss_unit);
1624 // read in the sound data
1625 sound = block[offset++]; // the sound index
1627 // read in the player address
1628 memcpy(&player_id,block+offset,sizeof(player_id));
1629 offset += sizeof(short);
1631 // determine if I'm the guy who should be playing the sound
1632 if((Net_player != NULL) && (Net_player->player_id == player_id)){
1635 gamesnd_play_iface((int)sound);
1639 if(!(Game_mode & GM_MULTIPLAYER)){
1640 ss_synch_interface();