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.11 2005/10/02 09:30:10 taylor
17 * sync up rest of big-endian network changes. it should at least be as good as what's in FS2_Open now, only better :)
19 * Revision 1.10 2005/08/12 08:58:41 taylor
20 * fix the strange mouse click issues on briefing, ship select and weapon select screens
22 * Revision 1.9 2004/09/20 01:31:44 theoddone33
25 * Revision 1.8 2004/07/04 11:31:43 taylor
26 * amd64 support, compiler warning fixes, don't use software rendering
28 * Revision 1.7 2003/08/03 16:10:29 taylor
29 * cleanup; compile warning fixes
31 * Revision 1.6 2003/06/11 18:30:33 taylor
34 * Revision 1.5 2003/05/25 02:30:43 taylor
37 * Revision 1.4 2002/06/09 04:41:23 relnev
38 * added copyright header
40 * Revision 1.3 2002/06/01 07:12:33 relnev
41 * a few NDEBUG updates.
43 * removed a few warnings.
45 * Revision 1.2 2002/05/07 03:16:46 theoddone33
46 * The Great Newline Fix
48 * Revision 1.1.1.1 2002/05/03 03:28:10 root
52 * 13 10/14/99 2:51p Jefff
55 * 12 8/05/99 3:40p Jefff
56 * hi-res text adjustments
58 * 11 7/15/99 9:20a Andsager
59 * FS2_DEMO initial checkin
61 * 10 2/01/99 5:55p Dave
62 * Removed the idea of explicit bitmaps for buttons. Fixed text
63 * highlighting for disabled gadgets.
65 * 9 1/30/99 7:33p Neilk
66 * Fixed coords problems for mission briefing screens
68 * 8 1/30/99 5:08p Dave
69 * More new hi-res stuff.Support for nice D3D textures.
71 * 7 1/29/99 4:17p Dave
72 * New interface screens.
74 * 6 1/24/99 11:37p Dave
75 * First full rev of beam weapons. Very customizable. Removed some bogus
76 * Int3()'s in low level net code.
78 * 5 11/30/98 1:07p Dave
79 * 16 bit conversion, first run.
81 * 4 11/17/98 11:12a Dave
82 * Removed player identification by address. Now assign explicit id #'s.
84 * 3 10/16/98 9:40a Andsager
85 * Remove ".h" files from model.h
87 * 2 10/07/98 10:53a Dave
90 * 1 10/07/98 10:50a Dave
92 * 85 6/09/98 10:31a Hoffoss
93 * Created index numbers for all xstr() references. Any new xstr() stuff
94 * added from here on out should be added to the end if the list. The
95 * current list count can be found in FreeSpace.cpp (search for
98 * 84 5/08/98 7:52p Lawrance
99 * fix bug where wing slot icons were not getting loaded
101 * 83 5/08/98 10:17a Lawrance
102 * don't play briefing slide-in animation if detail level is below high
104 * 82 5/06/98 11:50p Lawrance
105 * Clean up help overlay code for loadout screens
107 * 81 5/03/98 1:55a Lawrance
108 * Fix some sound problems with loadout screens
110 * 80 4/30/98 6:03p Lawrance
111 * Make drag and drop work better.
113 * 79 4/22/98 5:52p Dave
114 * Large reworking of endgame sequencing. Updated host options screen for
115 * new artwork. Put in checks to end game if host leaves or if team
116 * captains leave mid-game.
118 * 78 4/07/98 7:51p Hoffoss
119 * Implemented changed to options screen due to artwork changes.
121 * 77 4/07/98 5:42p Dave
122 * Put in support for ui display of voice system status (recording,
123 * playing back, etc). Make sure main hall music is stopped before
124 * entering a multiplayer game via ingame join.
126 * 76 4/02/98 11:40a Lawrance
127 * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
129 * 75 4/01/98 11:19p Dave
130 * Put in auto-loading of xferred pilot pic files. Grey out background
131 * behind pinfo popup. Put a chatbox message in when players are kicked.
132 * Moved mission title down in briefing. Other ui fixes.
134 * 74 4/01/98 9:21p John
135 * Made NDEBUG, optimized build with no warnings or errors.
137 * 73 3/31/98 11:47p Lawrance
138 * Fix some bugs related to wingmen selection when doing a quick mission
141 * 72 3/31/98 5:31p Lawrance
142 * Fix sound bug that happenned when entering briefing
144 * 71 3/30/98 5:16p Lawrance
145 * centralize a check for disabled loadout screens
147 * 70 3/30/98 12:18a Lawrance
148 * change some DEMO_RELEASE code to not compile code rather than return
151 * 69 3/29/98 10:16p Allender
152 * scramble missions need to have ship/weapon selection disabled (this
153 * code was somehow lost)
155 * 68 3/29/98 1:24p Dave
156 * Make chatbox not clear between multiplayer screens. Select player ship
157 * as default in mp team select and weapons select screens. Made create
158 * game mission list use 2 fixed size columns.
160 * 67 3/29/98 12:55a Lawrance
161 * Get demo build working with limited set of data.
163 * 66 3/25/98 8:43p Hoffoss
164 * Changed anim_play() to not be so damn complex when you try and call it.
166 * 65 3/24/98 4:59p Dave
167 * Fixed several ui bugs. Put in pre and post voice stream playback sound
168 * fx. Put in error specific popups for clients getting dropped from games
169 * through actions other than their own.
171 * 64 3/19/98 5:32p Lawrance
172 * Added music to the background of command brief screen.
174 * 63 3/05/98 5:02p Dave
175 * More work on team vs. team support for multiplayer. Need to fix bugs in
178 * 62 3/03/98 8:55p Dave
179 * Finished pre-briefing team vs. team support.
181 * 61 3/03/98 8:12p Lawrance
182 * Double timeout before flashing buttons
184 * 60 3/02/98 3:27p Lawrance
185 * Don't call muti_ts_init() in single player
187 * 59 3/01/98 3:26p Dave
188 * Fixed a few team select bugs. Put in multiplayer intertface sounds.
189 * Corrected how ships are disabled/enabled in team select/weapon select
192 * 58 2/27/98 4:55p Sandeep
193 * Fixed a signed/unsigned bug in the wss packet type
195 * 57 2/26/98 4:59p Allender
196 * groundwork for team vs team briefings. Moved weaponry pool into the
197 * Team_data structure. Added team field into the p_info structure.
198 * Allow for mutliple structures in the briefing code.
200 * 56 2/25/98 10:24a Lawrance
201 * Don't ask for confirmation when ESC is pressed.
203 * 55 2/24/98 12:22a Lawrance
204 * New coords for revamped briefing graphics
206 * 54 2/22/98 4:17p John
207 * More string externalization classification... 190 left to go!
209 * 53 2/22/98 12:19p John
210 * Externalized some strings
212 * 52 2/21/98 2:50p Lawrance
213 * Tell players that their campaign position will get saved if they return
214 * to main hall from loadout screens.
216 * 51 2/19/98 6:26p Dave
217 * Fixed a few file xfer bugs. Tweaked mp team select screen. Put in
218 * initial support for player data uploading.
220 * 50 2/18/98 3:56p Dave
221 * Several bugs fixed for mp team select screen. Put in standalone packet
222 * routing for team select.
224 * 49 2/17/98 6:07p Dave
225 * Tore out old multiplayer team select screen, installed new one.
227 * 48 2/13/98 3:46p Dave
228 * Put in dynamic chatbox sizing. Made multiplayer file lookups use cfile
231 * 47 2/10/98 8:40p Dave
232 * Fixed some debriefing bugs.
234 * 46 2/04/98 11:06p Lawrance
235 * Fix a couple of bugs with save/restore of player weapon loadout.
237 * 45 2/04/98 4:32p Allender
238 * support for multiple briefings and debriefings. Changes to mission
239 * type (now a bitfield). Bitfield defs for multiplayer modes
241 * 44 1/30/98 10:40a Lawrance
242 * remove any binding references to hotkey screen
244 * 43 1/20/98 5:52p Lawrance
245 * prompt user before returning to main hall (in single player)
247 * 42 1/17/98 5:51p Dave
248 * Bug fixes for bugs generated by multiplayer testing.
250 * 41 1/14/98 11:39a Dave
251 * Polished up a bunch of popup support items.
253 * 40 1/13/98 5:35p Lawrance
254 * Show popup when trying to go to weapons loadout without any ships
257 * 39 1/10/98 5:48p Lawrance
258 * Don't allow Tab to go to ship/weapon loadout screen in training, play
259 * negative feedback sounds if user tries to.
261 * 38 1/10/98 12:45a Lawrance
262 * Don't restore loadout if mission was modified.
264 * 37 1/09/98 6:06p Dave
265 * Put in network sound support for multiplayer ship/weapon select
266 * screens. Made clients exit game correctly through warp effect. Fixed
267 * main hall menu help overlay bug.
269 * 36 1/09/98 11:04a Lawrance
270 * Fix bug that prevented buttons from flashing in the loadout screens.
272 * 35 1/07/98 6:45p Lawrance
273 * Play first briefing music if none specified.
275 * 34 1/05/98 4:57p Lawrance
276 * reset flash timers when a button is pressed or a key is pressed
278 * 33 12/30/97 5:46p Lawrance
279 * Rename rnd() to rand_alt().
281 * 32 12/30/97 4:27p Lawrance
282 * Add new rnd() function that doesn't affect rand() sequence.
284 * 31 12/29/97 4:21p Lawrance
285 * Flash buttons on briefing/ship select/weapons loadout when enough time
286 * has elapsed without activity.
288 * 30 12/28/97 5:52p Lawrance
289 * Add support for debriefing success/fail music.
291 * 29 12/24/97 8:54p Lawrance
292 * Integrating new popup code
294 * 28 12/24/97 1:19p Lawrance
295 * fix some bugs with the multiplayer ship/weapons loadout
297 * 27 12/23/97 11:58a Allender
298 * changes to ship/wespon selection for multplayer. added sounds to some
299 * interface screens. Update and modiied end-of-briefing packets -- yet
307 #include "freespace.h"
308 #include "eventmusic.h"
310 #include "missionscreencommon.h"
311 #include "missionshipchoice.h"
312 #include "missionweaponchoice.h"
313 #include "missionbrief.h"
315 #include "multimsgs.h"
318 #include "gamesequence.h"
320 // #include "movie.h"
324 #include "contexthelp.h"
329 #include "linklist.h"
330 #include "staticrand.h" // for rand_alt()
332 #include "multiutil.h"
333 #include "multiteamselect.h"
334 #include "hudwingmanstatus.h"
335 #include "multi_endgame.h"
337 #include "animplay.h"
339 //////////////////////////////////////////////////////////////////
341 //////////////////////////////////////////////////////////////////
343 int Common_select_inited = 0;
345 // Dependent on when mouse button goes up
346 int Drop_icon_mflag, Drop_on_wing_mflag, Brief_mouse_up_flag;
348 int Mouse_down_last_frame = 0;
350 // Timers used to flash buttons after timeouts
351 #define MSC_FLASH_AFTER_TIME 60000 // time before flashing a button
352 #define MSC_FLASH_INTERVAL 200 // time between flashes
353 int Flash_timer; // timestamp used to start flashing
354 int Flash_toggle; // timestamp used to toggle flashing
355 int Flash_bright; // state of button to flash
357 //////////////////////////////////////////////////////////////////
359 //////////////////////////////////////////////////////////////////
362 static int InterfacePaletteBitmap = -1; // PCX file that holds the interface palette
364 //////////////////////////////////////////////////////////////////
366 //////////////////////////////////////////////////////////////////
367 UI_WINDOW *Active_ui_window;
369 brief_common_buttons Common_buttons[3][GR_NUM_RESOLUTIONS][NUM_COMMON_BUTTONS] = {
370 // icons for briefing, ship selection, weapon selection screens
374 brief_common_buttons("CB_00", 0, 0, -1, -1, 0), // briefing
375 brief_common_buttons("CB_01", 0, 19, -1, -1, 1), // ship selection
376 brief_common_buttons("CB_02", 0, 33, -1, -1, 2), // weapons loadout
377 brief_common_buttons("CB_05", 562, 411, -1, -1, 5), // commit
378 brief_common_buttons("CB_06", 469, 424, -1, -1, 6), // help
379 brief_common_buttons("CB_07", 447, 452, -1, -1, 7), // options
381 brief_common_buttons("CB_00", 7, 3, 37, 7, 0),
382 brief_common_buttons("CB_01", 7, 19, 37, 23, 1),
383 brief_common_buttons("CB_02", 7, 35, 37, 39, 2),
384 brief_common_buttons("CB_05", 571, 425, 572, 413, 5),
385 brief_common_buttons("CB_06", 533, 425, 500, 440, 6),
386 brief_common_buttons("CB_07", 533, 455, 479, 464, 7),
390 brief_common_buttons("2_CB_00", 12, 5, 59, 12, 0),
391 brief_common_buttons("2_CB_01", 12, 31, 59, 37, 1),
392 brief_common_buttons("2_CB_02", 12, 56, 59, 62, 2),
393 brief_common_buttons("2_CB_05", 914, 681, 937, 671, 5),
394 brief_common_buttons("2_CB_06", 854, 681, 822, 704, 6),
395 brief_common_buttons("2_CB_07", 854, 724, 800, 743, 7),
401 brief_common_buttons("CB_00", 0, 0, -1, -1, 0), // briefing
402 brief_common_buttons("CB_01", 0, 19, -1, -1, 1), // ship selection
403 brief_common_buttons("CB_02", 0, 33, -1, -1, 2), // weapons loadout
404 brief_common_buttons("CB_05", 562, 411, -1, -1, 5), // commit
405 brief_common_buttons("CB_06", 469, 424, -1, -1, 6), // help
406 brief_common_buttons("CB_07", 447, 452, -1, -1, 7), // options
408 brief_common_buttons("CB_00", 7, 3, 37, 7, 0),
409 brief_common_buttons("CB_01", 7, 19, 37, 23, 1),
410 brief_common_buttons("CB_02", 7, 35, 37, 39, 2),
411 brief_common_buttons("CB_05", 571, 425, 572, 413, 5),
412 brief_common_buttons("CB_06", 533, 425, 500, 440, 6),
413 brief_common_buttons("CB_07", 533, 455, 479, 464, 7),
417 brief_common_buttons("2_CB_00", 12, 5, 59, 12, 0),
418 brief_common_buttons("2_CB_01", 12, 31, 59, 37, 1),
419 brief_common_buttons("2_CB_02", 12, 56, 59, 62, 2),
420 brief_common_buttons("2_CB_05", 914, 681, 937, 671, 5),
421 brief_common_buttons("2_CB_06", 854, 681, 822, 704, 6),
422 brief_common_buttons("2_CB_07", 854, 724, 800, 743, 7),
428 brief_common_buttons("CB_00", 0, 0, -1, -1, 0), // briefing
429 brief_common_buttons("CB_01", 0, 19, -1, -1, 1), // ship selection
430 brief_common_buttons("CB_02", 0, 33, -1, -1, 2), // weapons loadout
431 brief_common_buttons("CB_05", 562, 411, -1, -1, 5), // commit
432 brief_common_buttons("CB_06", 469, 424, -1, -1, 6), // help
433 brief_common_buttons("CB_07", 447, 452, -1, -1, 7), // options
435 brief_common_buttons("CB_00", 7, 3, 37, 7, 0),
436 brief_common_buttons("CB_01", 7, 19, 37, 23, 1),
437 brief_common_buttons("CB_02", 7, 35, 37, 39, 2),
438 brief_common_buttons("CB_05", 571, 425, 572, 413, 5),
439 brief_common_buttons("CB_06", 533, 425, 500, 440, 6),
440 brief_common_buttons("CB_07", 533, 455, 479, 464, 7),
444 brief_common_buttons("2_CB_00", 12, 5, 59, 12, 0),
445 brief_common_buttons("2_CB_01", 12, 31, 59, 37, 1),
446 brief_common_buttons("2_CB_02", 12, 56, 59, 62, 2),
447 brief_common_buttons("2_CB_05", 914, 681, 937, 671, 5),
448 brief_common_buttons("2_CB_06", 854, 681, 822, 704, 6),
449 brief_common_buttons("2_CB_07", 854, 724, 800, 743, 7),
454 #define COMMON_BRIEFING_BUTTON 0
455 #define COMMON_SS_BUTTON 1
456 #define COMMON_WEAPON_BUTTON 2
457 #define COMMON_COMMIT_BUTTON 3
458 #define COMMON_HELP_BUTTON 4
459 #define COMMON_OPTIONS_BUTTON 5
461 int Background_playing; // Flag to indicate background animation is playing
462 static anim *Background_anim; // Ids for the anim data that is loaded
464 // value for which Team_data entry to use
467 // Ids for the instance of the anim that is playing
469 static anim_instance *Background_anim_instance;
472 int Wing_slot_empty_bitmap;
473 int Wing_slot_disabled_bitmap;
476 int wss_slots_all_empty();
478 // Display the no ships selected error
479 void common_show_no_ship_error()
481 popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "At least one ship must be selected before proceeding to weapons loadout", 460));
484 // Check the status of the buttons common to the loadout screens
485 void common_check_buttons()
490 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
491 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
492 if ( b->pressed() ) {
499 // AL 11-23-97: let a joystick button press commit
500 if ( joy_down_count(0) || joy_down_count(1) ) {
507 // -------------------------------------------------------------------
508 // common_redraw_pressed_buttons()
510 // Redraw any common buttons that are pressed down. This function is needed
511 // since we sometimes need to draw pressed buttons last to ensure the entire
512 // button gets drawn (and not overlapped by other buttons)
514 void common_redraw_pressed_buttons()
519 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
520 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
521 if ( b->button_down() ) {
527 void common_buttons_maybe_reload(UI_WINDOW *ui_window)
532 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
533 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
534 b->set_bmaps(Common_buttons[Current_screen-1][gr_screen.res][i].filename);
538 void common_buttons_init(UI_WINDOW *ui_window)
543 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
544 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
545 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);
546 // set up callback for when a mouse first goes over a button
547 b->set_highlight_action( common_play_highlight_sound );
548 b->set_bmaps(Common_buttons[Current_screen-1][gr_screen.res][i].filename);
549 b->link_hotspot(Common_buttons[Current_screen-1][gr_screen.res][i].hotspot);
554 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);
555 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);
556 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);
557 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);
558 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);
559 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);
562 common_reset_buttons();
564 Common_buttons[Current_screen-1][gr_screen.res][COMMON_COMMIT_BUTTON].button.set_hotkey(KEY_CTRLED+SDLK_RETURN);
565 Common_buttons[Current_screen-1][gr_screen.res][COMMON_HELP_BUTTON].button.set_hotkey(SDLK_F1);
566 Common_buttons[Current_screen-1][gr_screen.res][COMMON_OPTIONS_BUTTON].button.set_hotkey(SDLK_F2);
568 // for scramble or training missions, disable the ship/weapon selection regions
569 if ( brief_only_allow_briefing() ) {
570 Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_REGION].button.disable();
571 Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_REGION].button.disable();
574 #ifdef DEMO // allow for FS2_DEMO
575 Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_REGION].button.disable();
576 Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_REGION].button.disable();
580 void set_active_ui(UI_WINDOW *ui_window)
582 Active_ui_window = ui_window;
585 void common_music_init(int score_index)
587 if ( Cmdline_freespace_no_music ) {
591 if ( score_index >= NUM_SCORES ) {
596 if ( Mission_music[score_index] < 0 ) {
597 if ( Num_music_files > 0 ) {
598 Mission_music[score_index] = 0;
599 nprintf(("Sound","No briefing music is selected, so play first briefing track: %s\n",Spooled_music[Mission_music[score_index]].name));
605 briefing_load_music( Spooled_music[Mission_music[score_index]].filename );
606 // Use this id to trigger the start of music playing on the briefing screen
607 Briefing_music_begin_timestamp = timestamp(BRIEFING_MUSIC_DELAY);
610 void common_music_do()
612 if ( Cmdline_freespace_no_music ) {
616 // Use this id to trigger the start of music playing on the briefing screen
617 if ( timestamp_elapsed( Briefing_music_begin_timestamp) ) {
618 Briefing_music_begin_timestamp = 0;
619 briefing_start_music();
623 void common_music_close()
625 if ( Cmdline_freespace_no_music ) {
629 if ( Num_music_files <= 0 )
632 briefing_stop_music();
635 // function that sets the current palette to the interface palette. This function
636 // needs to be followed by common_free_interface_palette() to restore the game palette.
637 void common_set_interface_palette(const char *filename)
639 static char buf[MAX_FILENAME_LEN + 1] = {0};
642 filename = NOX("palette01");
644 SDL_assert(strlen(filename) <= MAX_FILENAME_LEN);
645 if ( (InterfacePaletteBitmap != -1) && !SDL_strcasecmp(filename, buf) )
646 return; // already set to this palette
648 SDL_strlcpy(buf, filename, sizeof(buf));
650 // unload the interface bitmap from memory
651 if (InterfacePaletteBitmap != -1) {
652 bm_unload(InterfacePaletteBitmap);
653 InterfacePaletteBitmap = -1;
656 // ugh - we don't need this anymore
658 InterfacePaletteBitmap = bm_load(filename);
659 if (InterfacePaletteBitmap < 0) {
660 Error(LOCATION, "Could not load in \"%s\"!", filename);
665 // release the interface palette .pcx file, and restore the game palette
666 void common_free_interface_palette()
668 // unload the interface bitmap from memory
669 if (InterfacePaletteBitmap != -1) {
670 bm_unload(InterfacePaletteBitmap);
671 InterfacePaletteBitmap = -1;
674 // restore the normal game palette
675 palette_restore_palette();
678 // Init timers used for flashing buttons
679 void common_flash_button_init()
681 Flash_timer = timestamp(MSC_FLASH_AFTER_TIME);
686 // determine if we should draw a button as bright
687 int common_flash_bright()
689 if ( timestamp_elapsed(Flash_timer) ) {
690 if ( timestamp_elapsed(Flash_toggle) ) {
691 Flash_toggle = timestamp(MSC_FLASH_INTERVAL);
699 // common_select_init() will load in animations and bitmaps that are common to the
700 // briefing/ship select/weapon select screens. The global Common_select_inited is set
701 // after this function is called once, and is only cleared when common_select_close()
702 // is called. This prevents multiple loadings of animations/bitmaps.
704 // This function also sets the palette based on the file palette01.pcx
705 void common_select_init()
707 if ( Common_select_inited ) {
708 nprintf(("Alan","common_select_init() returning without doing anything\n"));
712 nprintf(("Alan","entering common_select_init()\n"));
714 // No anims are playing
715 Background_playing = 0;
716 Background_anim = NULL;
718 #ifndef DEMO // not for FS2_DEMO
721 if ( current_detail_level() >= (NUM_DEFAULT_DETAIL_LEVELS-2) ) {
723 anim_play_struct aps;
725 // Load in the background transition anim
726 if ( Game_mode & GM_MULTIPLAYER )
727 Background_anim = anim_load("BriefTransMulti", 1); // 1 as last parm means file is mem-mapped
729 Background_anim = anim_load("BriefTrans", 1); // 1 as last parm means file is mem-mapped
732 SDL_assert( Background_anim != NULL );
733 anim_play_init(&aps, Background_anim, 0, 0);
734 aps.framerate_independent = 1;
736 Background_anim_instance = anim_play(&aps);
737 Background_playing = 1; // start playing the Background anim
741 Current_screen = Next_screen = ON_BRIEFING_SELECT;
743 // load in the icons for the wing slots
744 load_wing_icons(NOX("iconwing01"));
749 Current_screen = Next_screen = ON_BRIEFING_SELECT;
753 Common_select_inited = 1;
755 // this handles the case where the player played a multiplayer game but now is in single player (in one instance
757 if(!(Game_mode & GM_MULTIPLAYER)){
761 // get the value of the team
762 Common_team = 0; // assume the first team -- we'll change this value if we need to
763 if ( (Game_mode & GM_MULTIPLAYER) && IS_MISSION_MULTI_TEAMS )
764 Common_team = Net_player->p_info.team;
766 ship_select_common_init();
767 weapon_select_common_init();
768 common_flash_button_init();
770 if ( Game_mode & GM_MULTIPLAYER ) {
771 multi_ts_common_init();
774 // restore loadout from Player_loadout if this is the same mission as the one previously played
775 if ( !(Game_mode & GM_MULTIPLAYER) ) {
776 if ( !SDL_strcasecmp(Player_loadout.filename, Game_current_mission_filename) ) {
777 wss_restore_loadout();
778 ss_synch_interface();
779 wl_synch_interface();
784 Drop_on_wing_mflag = 0;
787 void common_reset_buttons()
792 for ( i = 0; i < NUM_COMMON_BUTTONS; i++ ) {
793 b = &Common_buttons[Current_screen-1][gr_screen.res][i].button;
797 switch(Current_screen) {
798 case ON_BRIEFING_SELECT:
799 Common_buttons[Current_screen-1][gr_screen.res][COMMON_BRIEFING_REGION].button.skip_first_highlight_callback();
802 Common_buttons[Current_screen-1][gr_screen.res][COMMON_SS_REGION].button.skip_first_highlight_callback();
804 case ON_WEAPON_SELECT:
805 Common_buttons[Current_screen-1][gr_screen.res][COMMON_WEAPON_REGION].button.skip_first_highlight_callback();
810 // common_select_do() is called once per loop in the interface screens and is used
811 // for drawing and changing the common animations and blitting common bitmaps.
812 int common_select_do(float frametime)
816 if ( help_overlay_active(BR_OVERLAY) || help_overlay_active(SS_OVERLAY) || help_overlay_active(WL_OVERLAY) ) {
817 Common_buttons[0][gr_screen.res][COMMON_HELP_BUTTON].button.reset_status();
818 Common_buttons[1][gr_screen.res][COMMON_HELP_BUTTON].button.reset_status();
819 Common_buttons[2][gr_screen.res][COMMON_HELP_BUTTON].button.reset_status();
820 Active_ui_window->set_ignore_gadgets(1);
822 Active_ui_window->set_ignore_gadgets(0);
825 k = chatbox_process();
826 if ( Game_mode & GM_NORMAL ) {
827 new_k = Active_ui_window->process(k);
829 new_k = Active_ui_window->process(k, 0);
832 if ( (k > 0) || (new_k > 0) || B1_JUST_RELEASED ) {
833 if ( help_overlay_active(BR_OVERLAY) || help_overlay_active(SS_OVERLAY) || help_overlay_active(WL_OVERLAY) ) {
834 help_overlay_set_state(BR_OVERLAY, 0);
835 help_overlay_set_state(SS_OVERLAY, 0);
836 help_overlay_set_state(WL_OVERLAY, 0);
837 Active_ui_window->set_ignore_gadgets(0);
843 // test for mouse buttons, must be done after Active_ui_window->process()
844 // has been called to work properly
847 Drop_on_wing_mflag = 0;
848 Brief_mouse_up_flag = 0;
849 Mouse_down_last_frame = 0;
851 // if the left mouse button was released...
854 Drop_on_wing_mflag = 1;
857 // if the left mouse button was pressed...
859 Mouse_down_last_frame = 1;
862 // basically a "click", only check for the click here to avoid action-on-over on briefing map
863 if ( B1_JUST_PRESSED ) {
864 Brief_mouse_up_flag = 1;
867 // reset timers for flashing buttons if key pressed
868 if ( (k>0) || (new_k>0) ) {
869 common_flash_button_init();
875 if ( Background_playing ) {
877 if ( Background_anim_instance->frame_num == BUTTON_SLIDE_IN_FRAME ) {
878 gamesnd_play_iface(SND_BTN_SLIDE);
881 if ( Background_anim_instance->frame_num == Background_anim_instance->stop_at ) {
882 // Free up the big honking background animation, since we won't be playing it again
883 anim_release_render_instance(Background_anim_instance);
884 anim_free(Background_anim);
886 Background_playing = 0;
887 Current_screen = Next_screen = ON_BRIEFING_SELECT;
892 if ( Current_screen != Next_screen ) {
893 switch( Next_screen ) {
894 case ON_BRIEFING_SELECT:
895 gameseq_post_event( GS_EVENT_START_BRIEFING );
899 // go to the specialized multiplayer team/ship select screen
900 if(Game_mode & GM_MULTIPLAYER){
901 gameseq_post_event(GS_EVENT_TEAM_SELECT);
903 // go to the normal ship select screen
905 gameseq_post_event(GS_EVENT_SHIP_SELECTION);
909 case ON_WEAPON_SELECT:
910 if ( !wss_slots_all_empty() ) {
911 gameseq_post_event(GS_EVENT_WEAPON_SELECTION);
913 common_show_no_ship_error();
922 // -------------------------------------------------------------------------------------
925 void common_render(float frametime)
927 if ( !Background_playing ) {
928 gr_set_bitmap(Brief_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
932 anim_render_all(0, frametime);
933 anim_render_all(ON_SHIP_SELECT, frametime);
936 // -------------------------------------------------------------------------------------
937 // common_render_selected_screen_button()
939 // A very ugly piece of special purpose code. This is used to draw the pressed button
940 // frame for whatever stage of the briefing/ship select/weapons loadout we are on.
942 void common_render_selected_screen_button()
944 Common_buttons[Next_screen-1][gr_screen.res][Next_screen-1].button.draw_forced(2);
947 // -------------------------------------------------------------------------------------
948 // common_button_do() do the button action for the specified pressed button
950 void common_button_do(int i)
952 if ( i == COMMON_COMMIT_BUTTON ) {
957 if ( Background_playing )
962 case COMMON_BRIEFING_BUTTON:
963 if ( Current_screen != ON_BRIEFING_SELECT ) {
964 gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
965 Next_screen = ON_BRIEFING_SELECT;
969 case COMMON_WEAPON_BUTTON:
970 if ( Current_screen != ON_WEAPON_SELECT ) {
971 if ( !wss_slots_all_empty() ) {
972 gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
973 Next_screen = ON_WEAPON_SELECT;
975 common_show_no_ship_error();
980 case COMMON_SS_BUTTON:
981 if ( Current_screen != ON_SHIP_SELECT ) {
982 gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
983 Next_screen = ON_SHIP_SELECT;
987 case COMMON_OPTIONS_BUTTON:
988 gamesnd_play_iface(SND_SWITCH_SCREENS);
989 gameseq_post_event( GS_EVENT_OPTIONS_MENU );
992 case COMMON_HELP_BUTTON:
993 gamesnd_play_iface(SND_HELP_PRESSED);
994 launch_context_help();
1000 // common_check_keys() will check for keypresses common to all the interface screens.
1001 void common_check_keys(int k)
1007 if ( Current_screen == ON_BRIEFING_SELECT ) {
1008 if ( brief_get_closeup_icon() != NULL ) {
1009 brief_turn_off_closeup_icon();
1014 // prompt the host of a multiplayer game
1015 if(Game_mode & GM_MULTIPLAYER){
1016 multi_quit_game(PROMPT_ALL);
1018 // go through the single player quit process
1020 // return to the main menu
1022 int return_to_menu, pf_flags;
1023 pf_flags = PF_USE_AFFIRMATIVE_ICON|PF_USE_NEGATIVE_ICON;
1024 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));
1025 if ( return_to_menu == 1 ) {
1026 gameseq_post_event(GS_EVENT_MAIN_MENU);
1029 gameseq_post_event(GS_EVENT_MAIN_MENU);
1034 case KEY_CTRLED + SDLK_RETURN:
1039 if ( Current_screen != ON_BRIEFING_SELECT && !Background_playing ) {
1040 Next_screen = ON_BRIEFING_SELECT;
1045 if ( brief_only_allow_briefing() ) {
1046 gamesnd_play_iface(SND_GENERAL_FAIL);
1050 #ifndef DEMO // not for FS2_DEMO
1051 if ( Current_screen != ON_WEAPON_SELECT && !Background_playing ) {
1052 if ( !wss_slots_all_empty() ) {
1053 Next_screen = ON_WEAPON_SELECT;
1055 common_show_no_ship_error();
1059 gamesnd_play_iface(SND_GENERAL_FAIL);
1066 if ( brief_only_allow_briefing() ) {
1067 gamesnd_play_iface(SND_GENERAL_FAIL);
1071 #ifndef DEMO // not for FS2_DEMO
1072 if ( Current_screen != ON_SHIP_SELECT && !Background_playing ) {
1073 Next_screen = ON_SHIP_SELECT;
1076 gamesnd_play_iface(SND_GENERAL_FAIL);
1081 case KEY_SHIFTED+SDLK_TAB:
1083 if ( brief_only_allow_briefing() ) {
1084 gamesnd_play_iface(SND_GENERAL_FAIL);
1088 #ifndef DEMO // not for FS2_DEMO
1089 if ( !Background_playing ) {
1090 switch ( Current_screen ) {
1091 case ON_BRIEFING_SELECT:
1092 if ( !wss_slots_all_empty() ) {
1093 Next_screen = ON_WEAPON_SELECT;
1095 common_show_no_ship_error();
1099 case ON_SHIP_SELECT:
1100 Next_screen = ON_BRIEFING_SELECT;
1103 case ON_WEAPON_SELECT:
1104 Next_screen = ON_SHIP_SELECT;
1112 gamesnd_play_iface(SND_GENERAL_FAIL);
1119 if ( brief_only_allow_briefing() ) {
1120 gamesnd_play_iface(SND_GENERAL_FAIL);
1124 #ifndef DEMO // not for FS2_DEMO
1125 if ( !Background_playing ) {
1126 switch ( Current_screen ) {
1127 case ON_BRIEFING_SELECT:
1128 Next_screen = ON_SHIP_SELECT;
1131 case ON_SHIP_SELECT:
1132 if ( !wss_slots_all_empty() ) {
1133 Next_screen = ON_WEAPON_SELECT;
1135 common_show_no_ship_error();
1139 case ON_WEAPON_SELECT:
1140 Next_screen = ON_BRIEFING_SELECT;
1148 gamesnd_play_iface(SND_GENERAL_FAIL);
1162 // common_select_close() will release the memory for animations and bitmaps that
1163 // were loaded in common_select_init(). This function will abort if the Common_select_inited
1164 // flag is not set. The last thing common_select_close() does in clear the Common_select_inited
1167 // weapon_select_close() and ship_select_close() are both called, since common_select_close()
1168 // is the function that is called the interface screens are finally exited.
1169 void common_select_close()
1171 if ( !Common_select_inited ) {
1172 nprintf(("Alan","common_select_close() returning without doing anything\n"));
1176 nprintf(("Alan","entering common_select_close()\n"));
1178 // catch open anims that weapon_select_init_team() opened when not in weapon_select
1179 weapon_select_close_team();
1181 weapon_select_close();
1182 if(Game_mode & GM_MULTIPLAYER){
1185 ship_select_close();
1188 common_free_interface_palette();
1190 // release the bitmpas that were previously extracted from anim files
1191 unload_wing_icons();
1193 // Release any instances that may still exist
1194 anim_release_all_instances();
1196 // free the anim's that were loaded into memory
1198 if ( Background_anim ) {
1199 anim_free(Background_anim);
1200 Background_anim = NULL;
1204 common_music_close();
1205 Common_select_inited = 0;
1208 // ------------------------------------------------------------------------
1209 // load_wing_icons() creates the bitmaps for wing icons
1211 void load_wing_icons(const char *filename)
1213 int first_frame, num_frames;
1215 first_frame = bm_load_animation(filename, &num_frames);
1216 if ( first_frame == -1 ) {
1217 Error(LOCATION, "Could not load icons from %s\n", filename);
1221 Wing_slot_disabled_bitmap = first_frame;
1222 Wing_slot_empty_bitmap = first_frame + 1;
1223 // Wing_slot_player_empty_bitmap = first_frame + 2;
1226 // ------------------------------------------------------------------------
1227 // common_scroll_up_pressed()
1229 int common_scroll_up_pressed(int *start, int size, int max_show)
1231 // check if we even need to scroll at all
1232 if ( size <= max_show ) {
1236 if ( (size - *start) > max_show ) {
1243 // ------------------------------------------------------------------------
1244 // common_scroll_down_pressed()
1246 int common_scroll_down_pressed(int *start, int size, int max_show)
1248 // check if we even need to scroll at all
1249 if ( size <= max_show ) {
1262 loadout_data Player_loadout; // what the ship and weapon loadout is... used since we want to use the
1263 // same loadout if the mission is played again
1265 //wss_unit Wss_slots[MAX_WSS_SLOTS]; // slot data struct
1266 //int Wl_pool[MAX_WEAPON_TYPES]; // weapon pool
1267 //int Ss_pool[MAX_SHIP_TYPES]; // ship pool
1268 //int Wss_num_wings; // number of player wings
1270 wss_unit Wss_slots_teams[MAX_TEAMS][MAX_WSS_SLOTS];
1271 int Wl_pool_teams[MAX_TEAMS][MAX_WEAPON_TYPES];
1272 int Ss_pool_teams[MAX_TEAMS][MAX_SHIP_TYPES];
1273 int Wss_num_wings_teams[MAX_TEAMS];
1275 wss_unit *Wss_slots;
1280 // save ship selection loadout to the Player_loadout struct
1281 void wss_save_loadout()
1285 // save the ship pool
1286 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1287 Player_loadout.ship_pool[i] = Ss_pool[i];
1290 // save the weapons pool
1291 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1292 Player_loadout.weapon_pool[i] = Wl_pool[i];
1295 // save the ship class / weapons for each slot
1296 for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
1297 Player_loadout.unit_data[i].ship_class = Wss_slots[i].ship_class;
1299 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
1300 Player_loadout.unit_data[i].wep[j] = Wss_slots[i].wep[j];
1301 Player_loadout.unit_data[i].wep_count[j] = Wss_slots[i].wep_count[j];
1306 // restore ship/weapons loadout from the Player_loadout struct
1307 void wss_restore_loadout()
1312 // only restore if mission hasn't changed
1313 if ( SDL_strcasecmp(Player_loadout.last_modified, The_mission.modified) ) {
1317 // restore the ship pool
1318 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1319 Ss_pool[i] = Player_loadout.ship_pool[i];
1322 // restore the weapons pool
1323 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1324 Wl_pool[i] = Player_loadout.weapon_pool[i];
1327 // restore the ship class / weapons for each slot
1328 for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
1329 slot = &Player_loadout.unit_data[i];
1330 Wss_slots[i].ship_class = slot->ship_class;
1332 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
1333 Wss_slots[i].wep[j]= slot->wep[j];
1334 Wss_slots[i].wep_count[j] = slot->wep_count[j];
1339 // Do a direct restore of the Player_loadout ship/weapon data to the wings
1340 void wss_direct_restore_loadout()
1346 // only restore if mission hasn't changed
1347 if ( SDL_strcasecmp(Player_loadout.last_modified, The_mission.modified) ) {
1351 for ( i = 0; i < MAX_WING_BLOCKS; i++ ) {
1353 if ( Starting_wings[i] < 0 )
1356 wp = &Wings[Starting_wings[i]];
1358 // If this wing is still on the arrival list, then update the parse objects
1359 if ( wp->ship_index[0] == -1 ) {
1362 for ( p_objp = GET_FIRST(&ship_arrival_list); p_objp != END_OF_LIST(&ship_arrival_list); p_objp = GET_NEXT(p_objp) ) {
1363 slot = &Player_loadout.unit_data[i*4+j];
1364 if ( p_objp->wingnum == WING_INDEX(wp) ) {
1365 p_objp->ship_class = slot->ship_class;
1366 wl_update_parse_object_weapons(p_objp, slot);
1372 int cleanup_ship_index[MAX_WING_SLOTS];
1375 for ( k = 0; k < MAX_WING_SLOTS; k++ ) {
1376 cleanup_ship_index[k] = -1;
1379 // This wing is already created, so directly update the ships
1380 for ( j = 0; j < MAX_WING_SLOTS; j++ ) {
1381 slot = &Player_loadout.unit_data[i*4+j];
1382 shipp = &Ships[wp->ship_index[j]];
1383 if ( shipp->ship_info_index != slot->ship_class ) {
1385 if ( wp->ship_index[j] == -1 ) {
1389 if ( slot->ship_class == -1 ) {
1390 cleanup_ship_index[j] = wp->ship_index[j];
1391 ship_add_exited_ship( shipp, SEF_PLAYER_DELETED );
1392 obj_delete(shipp->objnum);
1393 hud_set_wingman_status_none( shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
1396 change_ship_type(wp->ship_index[j], slot->ship_class);
1399 wl_bash_ship_weapons(&Ships[wp->ship_index[j]].weapons, slot);
1402 for ( k = 0; k < MAX_WING_SLOTS; k++ ) {
1403 if ( cleanup_ship_index[k] != -1 ) {
1404 ship_wing_cleanup( cleanup_ship_index[k], wp );
1411 int wss_slots_all_empty()
1415 for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
1416 if ( Wss_slots[i].ship_class >= 0 )
1420 if ( i == MAX_WSS_SLOTS )
1426 // determine the mode (WSS_...) based on slot/list index values
1427 int wss_get_mode(int from_slot, int from_list, int to_slot, int to_list, int wl_ship_slot)
1429 int mode, to_slot_empty=0;
1431 if ( wl_ship_slot >= 0 ) {
1433 if ( to_slot >= 0 ) {
1434 if ( Wss_slots[wl_ship_slot].wep_count[to_slot] == 0 ) {
1440 if ( to_slot >= 0 ) {
1441 if ( Wss_slots[to_slot].ship_class == -1 ){
1448 if ( from_slot >= 0 && to_slot >= 0 ) {
1449 mode = WSS_SWAP_SLOT_SLOT;
1450 } else if ( from_slot >= 0 && to_list >= 0 ) {
1451 mode = WSS_DUMP_TO_LIST;
1452 } else if ( (from_list >= 0) && (to_slot >= 0) && (to_slot_empty) ) {
1453 mode = WSS_GRAB_FROM_LIST;
1454 } else if ( (from_list >= 0) && (to_slot >= 0) && (!to_slot_empty) ) {
1455 mode = WSS_SWAP_LIST_SLOT;
1457 mode = -1; // no changes required
1463 // store all the unit data and pool data
1464 int store_wss_data(ubyte *block, int max_size, int sound,int player_index)
1470 // this is intended for multi only since it byteswaps
1471 SDL_assert( Game_mode & GM_MULTIPLAYER );
1473 // write the ship pool
1474 for ( i = 0; i < MAX_SHIP_TYPES; i++ ) {
1475 if ( Ss_pool[i] > 0 ) {
1476 block[offset++] = (ubyte)i;
1477 SDL_assert( Ss_pool[i] < UCHAR_MAX );
1479 // take care of sign issues
1480 if(Ss_pool[i] == -1){
1481 block[offset++] = 0xff;
1483 block[offset++] = (ubyte)Ss_pool[i];
1488 block[offset++] = 0xff; // signals start of weapons pool
1490 // write the weapon pool
1491 for ( i = 0; i < MAX_WEAPON_TYPES; i++ ) {
1492 if ( Wl_pool[i] > 0 ) {
1493 block[offset++] = (ubyte)i;
1494 ishort = INTEL_SHORT( (short)Wl_pool[i] );
1495 memcpy(block+offset, &ishort, sizeof(short));
1496 offset += sizeof(short);
1500 // write the unit data
1502 block[offset++] = 0xff; // signals start of unit data
1504 for ( i=0; i<MAX_WSS_SLOTS; i++ ) {
1505 SDL_assert( Wss_slots[i].ship_class < UCHAR_MAX );
1506 if(Wss_slots[i].ship_class == -1){
1507 block[offset++] = 0xff;
1509 block[offset++] = (ubyte)(Wss_slots[i].ship_class);
1511 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
1512 // take care of sign issues
1513 SDL_assert( Wss_slots[i].wep[j] < UCHAR_MAX );
1514 if(Wss_slots[i].wep[j] == -1){
1515 block[offset++] = 0xff;
1517 block[offset++] = (ubyte)(Wss_slots[i].wep[j]);
1520 SDL_assert( Wss_slots[i].wep_count[j] < SHRT_MAX );
1521 ishort = INTEL_SHORT( (short)Wss_slots[i].wep_count[j] );
1523 memcpy(&(block[offset]), &(ishort), sizeof(short) );
1524 offset += sizeof(short);
1527 // mwa -- old way below -- too much space
1528 //memcpy(block+offset, &Wss_slots[i], sizeof(wss_unit));
1529 //offset += sizeof(wss_unit);
1534 block[offset++] = 0xff;
1536 block[offset++] = (ubyte)sound;
1539 // add a netplayer address to identify who should play the sound
1541 if(player_index != -1){
1542 player_id = Net_players[player_index].player_id;
1544 player_id = INTEL_SHORT( player_id );
1545 memcpy(block+offset,&player_id,sizeof(player_id));
1546 offset += sizeof(player_id);
1548 SDL_assert( offset < max_size );
1552 int restore_wss_data(ubyte *block)
1554 int i, j, sanity, offset=0;
1559 // this is intended for multi only since it byteswaps
1560 SDL_assert( Game_mode & GM_MULTIPLAYER );
1562 // restore ship pool
1564 memset(Ss_pool, 0, MAX_SHIP_TYPES*sizeof(int));
1566 if ( sanity++ > MAX_SHIP_TYPES ) {
1571 b1 = block[offset++];
1576 // take care of sign issues
1577 b2 = block[offset++];
1585 // restore weapons pool
1587 memset(Wl_pool, 0, MAX_WEAPON_TYPES*sizeof(int));
1589 if ( sanity++ > MAX_WEAPON_TYPES ) {
1594 b1 = block[offset++];
1599 memcpy(&ishort, block+offset, sizeof(short));
1600 offset += sizeof(short);
1601 Wl_pool[b1] = INTEL_SHORT( ishort );
1604 for ( i=0; i<MAX_WSS_SLOTS; i++ ) {
1605 if(block[offset] == 0xff){
1606 Wss_slots[i].ship_class = -1;
1608 Wss_slots[i].ship_class = block[offset];
1611 for ( j = 0; j < MAX_WL_WEAPONS; j++ ) {
1612 // take care of sign issues
1613 if(block[offset] == 0xff){
1614 Wss_slots[i].wep[j] = -1;
1617 Wss_slots[i].wep[j] = (int)(block[offset++]);
1620 memcpy( &ishort, &(block[offset]), sizeof(short) );
1621 ishort = INTEL_SHORT( ishort );
1622 Wss_slots[i].wep_count[j] = (int)ishort;
1623 offset += sizeof(short);
1626 // mwa -- old way below
1627 //memcpy(&Wss_slots[i], block+offset, sizeof(wss_unit));
1628 //offset += sizeof(wss_unit);
1631 // read in the sound data
1632 sound = block[offset++]; // the sound index
1634 // read in the player address
1635 memcpy(&player_id,block+offset,sizeof(player_id));
1636 player_id = INTEL_SHORT( player_id );
1637 offset += sizeof(short);
1639 // determine if I'm the guy who should be playing the sound
1640 if((Net_player != NULL) && (Net_player->player_id == player_id)){
1643 gamesnd_play_iface((int)sound);
1647 if(!(Game_mode & GM_MULTIPLAYER)){
1648 ss_synch_interface();