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/Mission/MissionBriefCommon.cpp $
15 * C module for briefing code common to FreeSpace and FRED
18 * Revision 1.5 2002/06/09 04:41:22 relnev
19 * added copyright header
21 * Revision 1.4 2002/06/02 04:26:34 relnev
24 * Revision 1.3 2002/06/01 07:12:33 relnev
25 * a few NDEBUG updates.
27 * removed a few warnings.
29 * Revision 1.2 2002/05/07 03:16:46 theoddone33
30 * The Great Newline Fix
32 * Revision 1.1.1.1 2002/05/03 03:28:10 root
36 * 19 11/02/99 3:23p Jefff
37 * translate briefing icon names
39 * 18 9/09/99 9:44a Jefff
40 * doh, fixed reversed brief text color thingy. i am stoopid.
42 * 17 9/08/99 11:14a Jefff
43 * toned down hostile/friendly colors in briefing text
45 * 16 9/07/99 12:20p Mikeb
46 * return pos of briefing icon even it does not fit on screen.
48 * 15 9/03/99 1:32a Dave
49 * CD checking by act. Added support to play 2 cutscenes in a row
50 * seamlessly. Fixed super low level cfile bug related to files in the
51 * root directory of a CD. Added cheat code to set campaign mission # in
54 * 14 8/10/99 7:28p Jefff
55 * shuffled some text around
57 * 13 7/30/99 3:05p Jefff
58 * Fixed briefing icon fades -- in and out were reversed.
60 * 12 7/26/99 1:52p Mikeb
61 * Fixed strange briefing bug where a NULL wasn't being checked for when
62 * copying briefing stage text. Odd.
64 * 11 7/24/99 6:15p Jefff
65 * moved "stage x of y" text in multiplayer mode so its not covered by the
68 * 10 7/20/99 7:09p Jefff
69 * briefing text occupies full window in 1024x768
71 * 9 7/09/99 5:54p Dave
72 * Seperated cruiser types into individual types. Added tons of new
73 * briefing icons. Campaign screen.
75 * 8 6/29/99 7:39p Dave
76 * Lots of small bug fixes.
78 * 7 2/05/99 7:19p Neilk
79 * Removed black part from mission screen, fixed info text coords
81 * 6 1/29/99 4:17p Dave
82 * New interface screens.
84 * 5 12/18/98 1:13a Dave
85 * Rough 1024x768 support for Direct3D. Proper detection and usage through
88 * 4 10/23/98 3:51p Dave
89 * Full support for tstrings.tbl and foreign languages. All that remains
90 * is to make it active in Fred.
92 * 3 10/13/98 9:28a Dave
93 * Started neatening up freespace.h. Many variables renamed and
94 * reorganized. Added AlphaColors.[h,cpp]
96 * 2 10/07/98 10:53a Dave
99 * 1 10/07/98 10:49a Dave
101 * 122 6/09/98 10:31a Hoffoss
102 * Created index numbers for all xstr() references. Any new xstr() stuff
103 * added from here on out should be added to the end if the list. The
104 * current list count can be found in FreeSpace.cpp (search for
107 * 121 6/05/98 9:54a Lawrance
110 * 120 6/01/98 11:43a John
111 * JAS & MK: Classified all strings for localization.
113 * 119 5/23/98 10:38p Lawrance
114 * Avoid doing a cfile refresh when running debug
116 * 118 5/23/98 6:49p Lawrance
117 * Fix problems with refreshing the file list when a CD is inserted
119 * 117 5/21/98 6:57p Lawrance
120 * Don't prompt for the CD if voice not found
122 * 116 5/21/98 12:35a Lawrance
123 * Tweak how CD is checked for
125 * 115 5/12/98 11:46a John
126 * Changed the way the "glowing movement" type text draw. Use Hoffoss's
127 * gr_get_string_size optional length parameter to determine length of
128 * string which accounts for kerning on the last character and then I only
129 * draw each character only once.
131 * 114 5/08/98 5:32p Lawrance
132 * prompt for CD if can't load animations or voice
134 * 113 5/06/98 5:30p John
135 * Removed unused cfilearchiver. Removed/replaced some unused/little used
136 * graphics functions, namely gradient_h and _v and pixel_sp. Put in new
137 * DirectX header files and libs that fixed the Direct3D alpha blending
140 * 112 4/27/98 9:08p Allender
141 * fix the debriefing stage problems when clients get to screen long after
144 * 111 4/25/98 3:49p Lawrance
145 * Save briefing auto-advance pref
147 * 110 4/20/98 3:53p Lawrance
148 * Fix various bugs with auto-advancing through briefings.
153 #include "freespace.h"
161 #include "linklist.h"
168 #include "missionbrief.h"
169 #include "missiongrid.h"
170 #include "missionbriefcommon.h"
171 #include "animplay.h"
177 #include "audiostr.h"
178 #include "missioncmdbrief.h"
179 #include "missiondebrief.h"
180 #include "alphacolors.h"
181 #include "localize.h"
183 // --------------------------------------------------------------------------------------
185 // --------------------------------------------------------------------------------------
186 hud_frames Icon_bitmaps[MAX_BRIEF_ICONS][MAX_SPECIES_NAMES];
187 hud_anim Icon_highlight_anims[MAX_BRIEF_ICONS][MAX_SPECIES_NAMES];
188 hud_anim Icon_fade_anims[MAX_BRIEF_ICONS][MAX_SPECIES_NAMES];
191 // --------------------------------------------------------------------------------------
193 // --------------------------------------------------------------------------------------
195 brief_screen bscreen;
197 // briefing screen sections
198 #define BRIEF_CUP_X1 400
199 #define BRIEF_CUP_Y1 70
200 #define BRIEF_CUP_X2 639
201 #define BRIEF_CUP_Y2 245
202 #define BRIEF_CUPINFO_X1 445
203 #define BRIEF_CUPINFO_Y1 247
204 #define BRIEF_CUPINFO_X2 639
205 #define BRIEF_CUPINFO_Y2 438
207 char *Brief_static_name[GR_NUM_RESOLUTIONS] = {
212 int Brief_static_coords[GR_NUM_RESOLUTIONS][2] = {
221 int Brief_bmap_coords[GR_NUM_RESOLUTIONS][2] = {
230 int Brief_grid_coords[GR_NUM_RESOLUTIONS][4] = {
239 int Brief_text_coords[GR_NUM_RESOLUTIONS][4] = {
248 int Brief_stage_text_coords[GR_NUM_RESOLUTIONS][2] = {
257 int Brief_stage_text_coords_multi[GR_NUM_RESOLUTIONS][2] = {
266 int Brief_text_max_lines[GR_NUM_RESOLUTIONS] = {
270 #define LOOKAT_DIST 500.0f
272 // --------------------------------------------------------------------------------------
273 // Game-wide global data
274 // --------------------------------------------------------------------------------------
275 briefing Briefings[MAX_TEAMS]; // there is exactly one briefing per mission
276 debriefing Debriefings[MAX_TEAMS]; // there can be multiple debriefings per mission
277 briefing *Briefing; // pointer used in code -- points to correct briefing
278 debriefing *Debriefing; // pointer to correct debriefing
280 int Briefing_voice_enabled=1; // flag which turn on/off voice playback of briefings/debriefings
282 // --------------------------------------------------------------------------------------
283 // Module global data
284 // --------------------------------------------------------------------------------------
286 static int Last_new_stage;
289 const char BRIEF_META_CHAR = '$';
291 // static int Brief_voice_ask_for_cd;
294 static vector Current_cam_pos; // current camera position
295 static vector Target_cam_pos; // desired camera position
296 static matrix Current_cam_orient; // current camera orientation
297 static matrix Target_cam_orient; // desired camera orientation
298 static matrix Start_cam_orient; // start camera orientation
299 static vector Start_cam_pos; // position of camera at the start of a translation
300 static vector Cam_vel; // camera velocity
301 static vector Current_lookat_pos; // lookat point
302 static vector Target_lookat_pos; // lookat point
303 static vector Start_lookat_pos;
304 static vector Lookat_vel; // lookat point velocity
306 static float Start_cam_move; // time at which camera started moving (seconds)
307 static float Total_move_time; // time in which camera should move from current pos to target pos (seconds)
308 static float Elapsed_time;
310 static float Start_dist;
311 static float End_dist;
312 static float Dist_change_rate;
314 static vector Acc_limit;
315 static vector Vel_limit;
317 static float Total_dist;
318 static float Peak_speed;
319 static float Cam_accel;
320 static float Last_dist;
321 static vector W_init;
323 // flag to indicate that the sound for a spinning highlight animation has played
324 static int Brief_stage_highlight_sound_handle = -1;
326 // used for scrolling briefing text ( if necessary )
327 int Num_brief_text_lines[MAX_TEXT_STREAMS];
328 int Top_brief_text_line;
329 static char Brief_text[MAX_BRIEF_LINES][MAX_BRIEF_LINE_LEN];
331 // Used to support drawing colored text for the briefing. Gets complicates since we
332 // need to be able to draw one character at a time as well when the briefing text
334 typedef struct colored_char
337 ubyte color; // index into Brief_text_colors[]
340 static colored_char Colored_text[MAX_TEXT_STREAMS][MAX_BRIEF_LINES][MAX_BRIEF_LINE_LEN];
341 static int Colored_text_len[MAX_TEXT_STREAMS][MAX_BRIEF_LINES];
343 #define MAX_BRIEF_TEXT_COLORS 9
344 #define BRIEF_TEXT_WHITE 0
345 #define BRIEF_TEXT_BRIGHT_WHITE 1
346 #define BRIEF_TEXT_RED 2
347 #define BRIEF_TEXT_GREEN 3
348 #define BRIEF_TEXT_YELLOW 4
349 #define BRIEF_TEXT_BLUE 5
350 #define BRIEF_IFF_FRIENDLY 6
351 #define BRIEF_IFF_HOSTILE 7
352 #define BRIEF_IFF_NEUTRAL 8
354 color Brief_color_red, Brief_color_green;
356 color *Brief_text_colors[MAX_BRIEF_TEXT_COLORS] =
366 &IFF_colors[IFF_COLOR_NEUTRAL][0],
369 #define BRIGHTEN_LEAD 2
371 float Brief_text_wipe_time_elapsed;
372 static int Max_briefing_line_len;
374 static int Brief_voice_ended;
375 static int Brief_textdraw_finished;
376 static int Brief_voice_started;
377 static int Brief_stage_time;
379 const float BRIEF_TEXT_WIPE_TIME = 1.5f; // time in seconds for wipe to occur
380 static int Brief_text_wipe_snd; // sound handle of sound effect for text wipe
381 static int Play_brief_voice;
384 static int Play_highlight_flag;
385 static int Cam_target_reached;
386 static int Cam_movement_done;
389 typedef struct icon_move_info
391 icon_move_info *next, *prev;
398 // used to move icons smoothly
402 float total_move_time;
408 #define MAX_MOVE_ICONS 10
409 icon_move_info Icon_movers[MAX_MOVE_ICONS];
410 icon_move_info Icon_move_list; // head of linked list
413 typedef struct fade_icon
415 hud_anim fade_anim; // anim info
420 #define MAX_FADE_ICONS 30
421 fade_icon Fading_icons[MAX_FADE_ICONS];
424 // voice id's for briefing text
425 int Brief_voices[MAX_BRIEF_STAGES];
427 cmd_brief *Cur_cmd_brief;
428 cmd_brief Cmd_briefs[MAX_TEAMS];
430 // --------------------------------------------------------------------------------------
431 // forward declarations
432 // --------------------------------------------------------------------------------------
433 void brief_render_elements(vector *pos, grid *gridp);
434 void brief_render_icons(int stage_num, float frametime);
435 void brief_parse_icon_tbl();
436 void brief_grid_read_camera_controls( control_info * ci, float frametime );
437 void brief_maybe_create_new_grid(grid *gridp, vector *pos, matrix *orient, int force = 0);
438 grid *brief_create_grid(grid *gridp, vector *forward, vector *right, vector *center, int nrows, int ncols, float square_size);
439 grid *brief_create_default_grid(void);
440 void brief_render_grid(grid *gridp);
441 void brief_modify_grid(grid *gridp);
442 void brief_rpd_line(vector *v0, vector *v1);
443 void brief_set_text_color(int color_index);
444 extern void get_camera_limits(matrix *start_camera, matrix *end_camera, float time, vector *acc_max, vector *w_max);
445 int brief_text_wipe_finished();
447 void brief_set_icon_color(int team)
450 case TEAM_FRIENDLY: SET_COLOR_FRIENDLY; break;
451 case TEAM_HOSTILE: SET_COLOR_HOSTILE; break;
452 case TEAM_NEUTRAL: SET_COLOR_NEUTRAL; break;
453 case TEAM_TRAITOR: SET_COLOR_HOSTILE; break;
455 SET_COLOR_HOSTILE; break;
459 // --------------------------------------------------------------------------------------
460 // brief_move_icon_reset()
463 void brief_move_icon_reset()
467 list_init(&Icon_move_list);
468 for ( i = 0; i < MAX_MOVE_ICONS; i++ )
469 Icon_movers[i].used = 0;
473 // --------------------------------------------------------------------------------------
474 // Does one time initialization of the briefing and debriefing structures.
475 // Namely setting all malloc'ble pointers to NULL. Called once at game startup.
476 void mission_brief_common_init()
480 // setup brief text colors
481 gr_init_alphacolor( &Brief_color_green, 50, 100, 50, 255 );
482 gr_init_alphacolor( &Brief_color_red, 140, 20, 20, 255 );
484 if ( Fred_running ) {
485 // If Fred is running malloc out max space
486 for (i=0; i<MAX_TEAMS; i++ ) {
487 for (j=0; j<MAX_BRIEF_STAGES; j++ ) {
488 Briefings[i].stages[j].new_text = (char *)malloc(MAX_BRIEF_LEN);
489 Assert(Briefings[i].stages[j].new_text!=NULL);
490 Briefings[i].stages[j].icons = (brief_icon *)malloc(sizeof(brief_icon)*MAX_STAGE_ICONS);
491 Assert(Briefings[i].stages[j].icons!=NULL);
492 Briefings[i].stages[j].lines = (brief_line *)malloc(sizeof(brief_line)*MAX_BRIEF_STAGE_LINES);
493 Assert(Briefings[i].stages[j].lines!=NULL);
494 Briefings[i].stages[j].num_icons = 0;
495 Briefings[i].stages[j].num_lines = 0;
499 for (i=0; i<MAX_TEAMS; i++ ) {
500 for (j=0; j<MAX_DEBRIEF_STAGES; j++ ) {
501 Debriefings[i].stages[j].new_text = (char *)malloc(MAX_DEBRIEF_LEN);
502 Assert(Debriefings[i].stages[j].new_text!=NULL);
503 Debriefings[i].stages[j].new_recommendation_text = (char *)malloc(MAX_RECOMMENDATION_LEN);
504 Assert(Debriefings[i].stages[j].new_recommendation_text!=NULL);
509 // If game is running don't malloc anything
510 for (i=0; i<MAX_TEAMS; i++ ) {
511 for (j=0; j<MAX_BRIEF_STAGES; j++ ) {
512 Briefings[i].stages[j].new_text = NULL;
513 Briefings[i].stages[j].num_icons = 0;
514 Briefings[i].stages[j].icons = NULL;
515 Briefings[i].stages[j].num_lines = 0;
516 Briefings[i].stages[j].lines = NULL;
520 for (i=0; i<MAX_TEAMS; i++ ) {
521 for (j=0; j<MAX_DEBRIEF_STAGES; j++ ) {
522 Debriefings[i].stages[j].new_text = NULL;
523 Debriefings[i].stages[j].new_recommendation_text = NULL;
532 //--------------------------------------------------------------------------------------
533 // Frees all the memory allocated in the briefing and debriefing structures
534 // and sets all pointers to NULL.
535 void mission_brief_common_reset()
539 if ( Fred_running ) {
540 return; // Don't free these under Fred.
543 for (i=0; i<MAX_TEAMS; i++ ) {
544 for (j=0; j<MAX_BRIEF_STAGES; j++ ) {
545 if ( Briefings[i].stages[j].new_text ) {
546 free(Briefings[i].stages[j].new_text);
547 Briefings[i].stages[j].new_text = NULL;
550 if ( Briefings[i].stages[j].icons ) {
551 free(Briefings[i].stages[j].icons);
552 Briefings[i].stages[j].icons = NULL;
555 if ( Briefings[i].stages[j].lines ) {
556 free(Briefings[i].stages[j].lines);
557 Briefings[i].stages[j].lines = NULL;
562 for (i=0; i<MAX_TEAMS; i++ ) {
563 for (j=0; j<MAX_DEBRIEF_STAGES; j++ ) {
564 if ( Debriefings[i].stages[j].new_text ) {
565 free(Debriefings[i].stages[j].new_text);
566 Debriefings[i].stages[j].new_text = NULL;
568 if ( Debriefings[i].stages[j].new_recommendation_text ) {
569 free(Debriefings[i].stages[j].new_recommendation_text);
570 Debriefings[i].stages[j].new_recommendation_text = NULL;
580 // --------------------------------------------------------------------------------------
589 for ( i = 0; i < MAX_TEAMS; i++ )
590 Briefings[i].num_stages = 0;
594 // --------------------------------------------------------------------------------------
603 for ( i = 0; i < MAX_TEAMS; i++ ) {
604 Debriefings[i].num_stages = 0;
605 for (j=0; j<MAX_DEBRIEF_STAGES; j++ ) {
606 if ( Debriefings[i].stages[j].new_recommendation_text ) {
607 Debriefings[i].stages[j].new_recommendation_text[0] = 0;
612 // MWA 4/27/98 -- must initialize this variable here since we cannot do it as debrief
613 // init time because race conditions between all players in the game make that type of
614 // initialization unsafe.
615 Debrief_multi_stages_loaded = 0;
618 // --------------------------------------------------------------------------------------
619 // brief_init_screen()
621 // Set up the screen regions. A mulitplayer briefing will look different than a single player
624 void brief_init_screen(int multiplayer_flag)
626 bscreen.map_x1 = Brief_grid_coords[gr_screen.res][0];
627 bscreen.map_x2 = Brief_grid_coords[gr_screen.res][0] + Brief_grid_coords[gr_screen.res][2];
628 bscreen.map_y1 = Brief_grid_coords[gr_screen.res][1];
629 bscreen.map_y2 = Brief_grid_coords[gr_screen.res][1] + Brief_grid_coords[gr_screen.res][3];
631 bscreen.map_x1 = BRIEF_GRID3_X1;
632 bscreen.map_x2 = BRIEF_GRID0_X2;
633 bscreen.map_y1 = BRIEF_GRID3_Y1;
634 bscreen.map_y2 = BRIEF_GRID0_Y2+4;
635 bscreen.btext_x1 = BRIEF_TEXT_X1;
636 bscreen.btext_x2 = BRIEF_TEXT_X2;
637 bscreen.btext_y1 = BRIEF_TEXT_Y1;
638 bscreen.btext_y2 = BRIEF_TEXT_Y2;
639 bscreen.cup_x1 = BRIEF_CUP_X1;
640 bscreen.cup_y1 = BRIEF_CUP_Y1;
641 bscreen.cup_x2 = BRIEF_CUP_X2;
642 bscreen.cup_y2 = BRIEF_CUP_Y2;
643 bscreen.cupinfo_x1 = BRIEF_CUPINFO_X1;
644 bscreen.cupinfo_y1 = BRIEF_CUPINFO_Y1;
645 bscreen.cupinfo_x2 = BRIEF_CUPINFO_X2;
646 bscreen.cupinfo_y2 = BRIEF_CUPINFO_Y2;
650 // --------------------------------------------------------------------------------------
651 // brief_init_icons()
654 void brief_init_icons()
656 if ( Fred_running ) {
657 gr_init_alphacolor( &IFF_colors[IFF_COLOR_HOSTILE][0], 0xff, 0x00, 0x00, 15*16 );
658 gr_init_alphacolor( &IFF_colors[IFF_COLOR_FRIENDLY][0], 0x00, 0xff, 0x00, 15*16 );
661 // Load in the bitmaps for the icons from icons.tbl
662 brief_parse_icon_tbl();
665 // Reset the highlight and fade anims... call before brief_parse_icon_tbl();
666 void brief_init_anims()
670 for (i=0; i<MAX_BRIEF_ICONS; i++) {
671 for(idx=0; idx<MAX_SPECIES_NAMES; idx++){
672 Icon_highlight_anims[i][idx].num_frames=0;
673 Icon_fade_anims[i][idx].num_frames=0;
678 // ------------------------------------------------------------------------
679 // brief_unload_icons()
682 void brief_unload_icons()
687 for ( i = 0; i < MAX_BRIEF_ICONS; i++ ) {
688 for(idx=0; idx<MAX_SPECIES_NAMES; idx++){
689 ib = &Icon_bitmaps[i][idx];
691 for ( j=0; j<ib->num_frames; j++ ) {
692 bm_unload(ib->first_frame+j);
698 // determine if icon type is used in the current briefing
699 int brief_icon_used_in_briefing(int icon_type)
701 int num_icons, num_stages, i, j;
703 num_stages = Briefing->num_stages;
705 for ( i = 0; i < num_stages; i++ ) {
706 num_icons = Briefing->stages[i].num_icons;
707 for ( j = 0; j < num_icons; j++ ) {
708 if ( Briefing->stages[i].icons[j].type == icon_type ) {
717 // --------------------------------------------------------------------------------------
718 // brief_parse_icon_tbl()
721 void brief_parse_icon_tbl()
724 char name[NAME_LENGTH];
732 if ((rval = setjmp(parse_abort)) != 0) {
733 Error(LOCATION, "Unable to parse icons.tbl! Code = %i.\n", rval);
736 read_file_text("icons.tbl");
741 required_string("#Start");
744 int load_this_icon = 0;
746 while (required_string_either("#End","$Name:")) {
747 for(idx=0; idx<MAX_SPECIES_NAMES; idx++){
748 Assert( num_icons < MAX_BRIEF_ICONS);
749 hf = &Icon_bitmaps[num_icons][idx];
751 // load in regular frames
752 required_string("$Name:");
753 stuff_string(name, F_NAME, NULL);
755 if ( Fred_running ) {
758 load_this_icon = brief_icon_used_in_briefing(num_icons);
761 if ( load_this_icon ) {
762 hf->first_frame = bm_load_animation(name, &hf->num_frames);
763 if ( hf->first_frame == -1 ) {
764 Int3(); // missing briefing icon
768 // load in fade frames
769 required_string("$Name:");
770 stuff_string(name, F_NAME, NULL);
771 ha = &Icon_fade_anims[num_icons][idx];
772 hud_anim_init(ha, 0, 0, name);
774 // load in highlighting frames
775 required_string("$Name:");
776 stuff_string(name, F_NAME, NULL);
777 ha = &Icon_highlight_anims[num_icons][idx];
778 hud_anim_init(ha, 0, 0, name);
784 required_string("#End");
786 // close localization
790 // --------------------------------------------------------------------------------------
794 void brief_close_map()
796 brief_unload_icons();
799 void brief_preload_highlight_anim(brief_icon *bi)
802 int species = ship_get_species_by_type(bi->ship_class);
808 ha = &Icon_highlight_anims[bi->type][species];
809 if ( !stricmp(NOX("none"), ha->name) ) {
813 // force read of data from disk, so we don't glitch on initial playback
814 if ( ha->first_frame == -1 ) {
816 Assert(ha->first_frame >= 0);
819 bi->highlight_anim = *ha;
821 gr_set_bitmap(ha->first_frame);
825 void brief_preload_fade_anim(brief_icon *bi)
828 int species = ship_get_species_by_type(bi->ship_class);
834 ha = &Icon_fade_anims[bi->type][species];
835 if ( !stricmp(NOX("none"), ha->name) ) {
839 // force read of data from disk, so we don't glitch on initial playback
840 if ( ha->first_frame == -1 ) {
842 Assert(ha->first_frame >= 0);
845 gr_set_bitmap(ha->first_frame);
849 // preload highlight, fadein and fadeout animations that are used in this stage
850 void brief_preload_anims()
852 int num_icons, num_stages, i, j;
855 num_stages = Briefing->num_stages;
857 for ( i = 0; i < num_stages; i++ ) {
858 num_icons = Briefing->stages[i].num_icons;
859 for ( j = 0; j < num_icons; j++ ) {
860 bi = &Briefing->stages[i].icons[j];
861 if ( bi->flags & BI_HIGHLIGHT ) {
862 brief_preload_highlight_anim(bi);
864 brief_preload_fade_anim(bi);
869 // --------------------------------------------------------------------------------------
873 void brief_init_map()
878 Assert( Briefing != NULL );
880 pos = &Briefing->stages[0].camera_pos;
881 orient = &Briefing->stages[0].camera_orient;
882 vm_vec_zero(&Current_lookat_pos);
883 vm_vec_zero(&Target_lookat_pos);
885 Total_move_time = 0.0f;
887 The_grid = brief_create_default_grid();
888 brief_maybe_create_new_grid(The_grid, pos, orient, 1);
892 brief_move_icon_reset();
893 brief_preload_anims();
895 Brief_text_wipe_snd = -1;
901 #pragma optimize("", off)
904 // render fade-out anim frame
906 void brief_render_fade_outs(float frametime)
910 vertex tv; // temp vertex used to find screen position for text
914 for (i=0; i<Num_fade_icons; i++) {
915 fi = &Fading_icons[i];
917 g3_rotate_vertex(&tv, &fi->pos);
919 if (!(tv.flags & PF_PROJECTED))
920 g3_project_vertex(&tv);
922 if (!(tv.flags & PF_OVERFLOW) ) { // make sure point projected before drawing text
924 brief_set_icon_color(fi->team);
926 if ( fi->fade_anim.first_frame < 0 ) {
930 bm_get_info( fi->fade_anim.first_frame, &w, &h, NULL);
932 bxf = tv.sx - w / 2.0f + 0.5f;
933 byf = tv.sy - h / 2.0f + 0.5f;
937 if ( fi->fade_anim.first_frame >= 0 ) {
938 fi->fade_anim.sx = bx;
939 fi->fade_anim.sy = by;
940 hud_anim_render(&fi->fade_anim, frametime, 1, 0, 0, 0);
946 // figure out how far an icon should move based on the elapsed time
947 float brief_icon_get_dist_moved(icon_move_info *mi, float elapsed_time)
949 float time, dist_moved=0.0f;
951 // first half of movement
952 if ( elapsed_time < mi->total_move_time/2.0f ) {
953 dist_moved=0.5f*mi->accel*elapsed_time*elapsed_time; // d = 1/2at^2
957 // second half of movement
958 time=elapsed_time - mi->total_move_time/2.0f;
959 dist_moved=(mi->total_dist/2.0f)+(mi->peak_speed*time) - 0.5f*mi->accel*time*time;
963 // Draw a line between two icons on the briefing screen
964 void brief_render_icon_line(int stage_num, int line_num)
968 vertex icon_vertex[2];
969 int icon_status[2] = {0,0};
970 int icon_w, icon_h, i;
971 float icon_x[2], icon_y[2];
973 bl = &Briefing->stages[stage_num].lines[line_num];
974 icon[0] = &Briefing->stages[stage_num].icons[bl->start_icon];
975 icon[1] = &Briefing->stages[stage_num].icons[bl->end_icon];
978 for (i=0; i<2; i++) {
979 g3_rotate_vertex(&icon_vertex[i],&icon[i]->pos);
980 if (!(icon_vertex[i].flags&PF_PROJECTED))
981 g3_project_vertex(&icon_vertex[i]);
983 if (!(icon_vertex[i].flags & PF_OVERFLOW) ) { // make sure point projected before drawing text
988 if ( !icon_status[0] || !icon_status[1] ) {
992 // get screen (x,y) for icons
993 for (i=0; i<2; i++) {
994 brief_common_get_icon_dimensions(&icon_w, &icon_h, icon[i]->type, icon[i]->ship_class);
995 icon_x[i] = icon_vertex[i].sx;
996 icon_y[i] = icon_vertex[i].sy;
999 brief_set_icon_color(icon[0]->team);
1001 gr_line(fl2i(icon_x[0]), fl2i(icon_y[0]), fl2i(icon_x[1]), fl2i(icon_y[1]));
1004 // -------------------------------------------------------------------------------------
1005 // Draw a briefing icon
1007 // parameters: stage_num => briefing stage number (start at 0)
1008 // icon_num => icon number in stage
1009 // frametime => time elapsed in seconds
1010 // selected => FRED only (will be 0 or non-zero)
1011 // w_scale_factor => scale icon in width by this amount (default 1.0f)
1012 // h_scale_factor => scale icon in height by this amount (default 1.0f)
1013 void brief_render_icon(int stage_num, int icon_num, float frametime, int selected, float w_scale_factor, float h_scale_factor)
1015 brief_icon *bi, *closeup_icon;
1017 vertex tv; // temp vertex used to find screen position for text
1019 int bx,by,bc,w,h,icon_w,icon_h,icon_bitmap=-1;
1020 float bxf, byf, dist=0.0f;
1022 Assert( Briefing != NULL );
1024 bi = &Briefing->stages[stage_num].icons[icon_num];
1026 icon_move_info *mi, *next;
1027 int interp_pos_found = 0;
1029 mi = GET_FIRST(&Icon_move_list);
1031 while ( mi != &Icon_move_list ) {
1033 if ( ( mi->id != 0 ) && ( mi->id == bi->id ) ) {
1035 if ( !mi->reached_dest ) {
1036 dist = brief_icon_get_dist_moved(mi, Elapsed_time);
1037 if ( dist < mi->last_dist ) {
1044 if ( !mi->reached_dest ) {
1046 vm_vec_copy_scale(&dist_moved, &mi->direction, dist);
1047 vm_vec_add(&mi->current, &mi->start, &dist_moved);
1049 mi->current = mi->finish;
1053 interp_pos_found = 1;
1059 if ( !interp_pos_found )
1062 brief_render_elements(pos, The_grid);
1063 g3_rotate_vertex(&tv,pos);
1065 if (!(tv.flags&PF_PROJECTED))
1066 g3_project_vertex(&tv);
1068 if (!(tv.flags & PF_OVERFLOW) ) { // make sure point projected before drawing text
1070 brief_set_icon_color(bi->team);
1072 int species = ship_get_species_by_type(bi->ship_class);
1078 ib = &Icon_bitmaps[bi->type][species];
1079 if ( ib->first_frame < 0 ) {
1084 brief_common_get_icon_dimensions(&icon_w, &icon_h, bi->type, bi->ship_class);
1086 closeup_icon = (brief_icon*)brief_get_closeup_icon();
1087 if ( bi == closeup_icon || selected ) {
1088 icon_bitmap=ib->first_frame+1;
1089 // gr_set_bitmap(ib->first_frame+1);
1092 icon_bitmap=ib->first_frame;
1093 // gr_set_bitmap(ib->first_frame);
1096 // draw icon centered at draw position
1097 // bx = fl2i(tv.sx - ib->icon_w/2.0f);
1098 // by = fl2i(tv.sy - ib->icon_h/2.0f);
1099 // bc = bx + fl2i(ib->icon_w/2.0f);
1100 //gr_aabitmap(bx, by);
1102 float scaled_w, scaled_h;
1104 scaled_w = icon_w * w_scale_factor;
1105 scaled_h = icon_h * h_scale_factor;
1106 bxf = tv.sx - scaled_w / 2.0f + 0.5f;
1107 byf = tv.sy - scaled_h / 2.0f + 0.5f;
1112 if ( (bx < 0) || (bx > gr_screen.max_w) || (by < 0) || (by > gr_screen.max_h) && !Fred_running ) {
1124 vb.sx = bxf+scaled_w-1;
1125 vb.sy = byf+scaled_h-1;
1129 // render highlight anim frame
1130 if ( (bi->flags&BI_SHOWHIGHLIGHT) && (bi->flags&BI_HIGHLIGHT) ) {
1131 hud_anim *ha = &bi->highlight_anim;
1132 if ( ha->first_frame >= 0 ) {
1133 ha->sx = bi->hold_x;
1134 if ( strlen(bi->label) > 0 ) {
1135 ha->sy = bi->hold_y - fl2i(gr_get_font_height()/2.0f +0.5) - 2;
1137 ha->sy = bi->hold_y;
1140 //hud_set_iff_color(bi->team);
1141 brief_set_icon_color(bi->team);
1143 hud_anim_render(ha, frametime, 1, 0, 1);
1145 if ( Brief_stage_highlight_sound_handle < 0 ) {
1146 if ( !Fred_running) {
1147 Brief_stage_highlight_sound_handle = snd_play(&Snds_iface[SND_ICON_HIGHLIGHT]);
1153 // render fade-in anim frame
1154 if ( bi->flags & BI_FADEIN ) {
1155 hud_anim *ha = &bi->fadein_anim;
1156 if ( ha->first_frame >= 0 ) {
1159 // hud_set_iff_color(bi->team);
1160 brief_set_icon_color(bi->team);
1162 if ( hud_anim_render(ha, frametime, 1, 0, 0, 1) == 0 ) {
1163 bi->flags &= ~BI_FADEIN;
1166 bi->flags &= ~BI_FADEIN;
1170 if ( !(bi->flags & BI_FADEIN) ) {
1171 gr_set_bitmap(icon_bitmap);
1173 if ( Fred_running ) {
1174 gr_aascaler(&va, &vb);
1176 // Don't bother scaling for the game
1177 gr_aabitmap(bx, by);
1180 // draw text centered over the icon (make text darker)
1181 if ( bi->type == ICON_FIGHTER_PLAYER || bi->type == ICON_BOMBER_PLAYER ) {
1182 gr_get_string_size(&w,&h,Players[Player_num].callsign);
1183 gr_printf(bc - fl2i(w/2.0f), by - h, Players[Player_num].callsign);
1188 strcpy(buf, bi->label);
1189 lcl_translate_brief_icon_name(buf);
1190 gr_get_string_size(&w, &h, buf);
1191 gr_printf(bc - fl2i(w/2.0f), by - h, buf);
1193 gr_get_string_size(&w,&h,bi->label);
1194 gr_printf(bc - fl2i(w/2.0f), by - h, bi->label);
1198 // show icon as selected (FRED only)
1200 gr_get_string_size(&w,&h,NOX("(S)"));
1201 gr_printf(bc - fl2i(w/2.0f), by - h*2, NOX("(S)"));
1205 // store screen x,y,w,h
1208 bi->w = fl2i(scaled_w);
1209 bi->h = fl2i(scaled_h);
1211 } // end if vertex is projected
1215 #pragma optimize("", on)
1218 // -------------------------------------------------------------------------------------
1219 // brief_render_icons()
1221 void brief_render_icons(int stage_num, float frametime)
1223 int i, num_icons, num_lines;
1225 Assert( Briefing != NULL );
1227 num_icons = Briefing->stages[stage_num].num_icons;
1228 num_lines = Briefing->stages[stage_num].num_lines;
1230 if ( Cam_target_reached ) {
1231 for ( i = 0; i < num_lines; i++ ) {
1232 brief_render_icon_line(stage_num, i);
1236 for ( i = 0; i < num_icons; i++ ) {
1237 brief_render_icon(stage_num, i, frametime, 0);
1241 // ------------------------------------------------------------------------------------
1242 // brief_start_highlight_anims()
1244 // see if there are any highlight animations to play
1246 void brief_start_highlight_anims(int stage_num)
1250 int x,y,i,anim_w,anim_h;
1252 Assert( Briefing != NULL );
1253 bs = &Briefing->stages[stage_num];
1255 for ( i = 0; i < bs->num_icons; i++ ) {
1257 if ( bi->flags & BI_HIGHLIGHT ) {
1258 bi->flags &= ~BI_SHOWHIGHLIGHT;
1259 if ( bi->highlight_anim.first_frame < 0 ) {
1263 bi->highlight_anim.time_elapsed=0.0f;
1265 bm_get_info( bi->highlight_anim.first_frame, &anim_w, &anim_h, NULL);
1266 x = fl2i( i2fl(bi->x) + bi->w/2.0f - anim_w/2.0f );
1267 y = fl2i( i2fl(bi->y) + bi->h/2.0f - anim_h/2.0f );
1270 bi->flags |= BI_SHOWHIGHLIGHT;
1271 bi->highlight_anim.time_elapsed=0.0f;
1276 // -------------------------------------------------------------------------------------
1277 // brief_render_map()
1280 void brief_render_map(int stage_num, float frametime)
1284 gr_set_clip(bscreen.map_x1 + 1, bscreen.map_y1 + 1, bscreen.map_x2 - bscreen.map_x1 - 1, bscreen.map_y2 - bscreen.map_y1 - 2);
1286 // REMOVED by neilk: removed gr_clear for FS2 because interface no longer calls for black background on grid
1289 if (stage_num >= Briefing->num_stages) {
1295 bs = &Briefing->stages[stage_num];
1298 g3_set_view_matrix(&Current_cam_pos, &Current_cam_orient, 0.5f);
1300 brief_maybe_create_new_grid(The_grid, &Current_cam_pos, &Current_cam_orient);
1301 brief_render_grid(The_grid);
1303 brief_render_fade_outs(frametime);
1305 // go ahead and render everything that is in the active objects list
1306 brief_render_icons(stage_num, frametime);
1308 if ( Cam_target_reached && brief_text_wipe_finished() ) {
1310 if ( Brief_textdraw_finished == 0 ) {
1311 Brief_textdraw_finished = 1;
1312 Brief_stage_time = 0;
1315 if ( Play_highlight_flag ) {
1316 brief_start_highlight_anims(stage_num);
1317 Play_highlight_flag = 0;
1321 anim_render_all(ON_BRIEFING_SELECT, frametime);
1328 // -------------------------------------------------------------------------------------
1329 // brief_text_set_color()
1331 void brief_text_set_color(char c) {
1343 gr_set_color_fast(&Color_red);
1346 gr_set_color_fast(&Color_green);
1349 gr_set_color_fast(&Color_blue);
1352 Int3(); // unsupported meta-code
1357 // Display what stage of the briefing is active
1358 void brief_blit_stage_num(int stage_num, int stage_max)
1363 Assert( Briefing != NULL );
1364 gr_set_color_fast(&Color_text_heading);
1365 sprintf(buf, XSTR( "Stage %d of %d", 394), stage_num + 1, stage_max);
1366 if (Game_mode & GM_MULTIPLAYER) {
1367 gr_printf(Brief_stage_text_coords_multi[gr_screen.res][0], Brief_stage_text_coords_multi[gr_screen.res][1], buf);
1369 gr_printf(Brief_stage_text_coords[gr_screen.res][0], Brief_stage_text_coords[gr_screen.res][1], buf);
1372 // draw the title of the mission
1373 // if this goes above briefing text, it will need to be raised 10 pixels in multiplayer to make
1374 // room for stage num, which makes toom for chat box
1376 if (Game_mode & GM_MULTIPLAYER) {
1377 gr_get_string_size(&w,NULL,The_mission.name);
1378 gr_string(bscreen.map_x2 - w, bscreen.map_y2 + 5, The_mission.name);
1380 gr_get_string_size(&w,NULL,The_mission.name);
1381 gr_string(bscreen.map_x2 - w, bscreen.map_y2 + 5, The_mission.name);
1386 // Render a line of text for the briefings. Lines are drawn in as a wipe, with leading bright
1387 // white characters. Have to jump through some hoops since we support colored words. This means
1388 // that we need to process the line one character at a time.
1389 void brief_render_line(int line_num, int x, int y, int instance)
1391 int len, count, next, truncate_len, last_color, offset, w, h, bright_len, i;
1393 char line[MAX_BRIEF_LINE_LEN];
1395 src = &Colored_text[instance][line_num][0];
1396 len = Colored_text_len[instance][line_num];
1402 truncate_len = fl2i(Brief_text_wipe_time_elapsed / BRIEF_TEXT_WIPE_TIME * Max_briefing_line_len);
1403 if (truncate_len > len){
1408 if (truncate_len < len) {
1409 if (truncate_len <= BRIGHTEN_LEAD) {
1410 bright_len = truncate_len;
1414 bright_len = BRIGHTEN_LEAD;
1415 truncate_len -= BRIGHTEN_LEAD;
1423 gr_set_color_fast(&Color_white);
1424 last_color = BRIEF_TEXT_WHITE;
1425 for (i=0; i<truncate_len; i++) {
1426 if (count >= truncate_len){
1430 line[next] = src[count].letter;
1432 if (is_white_space(line[next])) {
1433 // end of word reached, blit it
1435 gr_string(x + offset, y, line);
1436 gr_get_string_size(&w, &h, line);
1441 if (last_color != BRIEF_TEXT_WHITE) {
1442 brief_set_text_color(BRIEF_TEXT_WHITE);
1443 last_color = BRIEF_TEXT_WHITE;
1450 if (src[count].color != last_color) {
1451 brief_set_text_color(src[count].color);
1452 last_color = src[count].color;
1460 gr_string(x + offset, y, line);
1463 // draw leading portion of the line bright white
1466 gr_set_color_fast(&Color_bright_white);
1467 for (i=0; i<truncate_len+bright_len; i++) {
1468 line[i] = src[i].letter;
1474 if ( truncate_len > 0 ) {
1475 int width_dim, height_dim;
1476 gr_get_string_size(&width_dim, &height_dim, line, truncate_len );
1477 gr_string(x+width_dim, y, &line[truncate_len]);
1479 gr_string(x, y, line);
1483 // // now erase the part we don't want to be bright white
1484 // gr_set_color_fast(&Color_black);
1485 // if (i > BRIGHTEN_LEAD) {
1486 // line[i - BRIGHTEN_LEAD] = 0;
1487 // gr_get_string_size(&w, &h, line);
1488 // gr_set_clip(x, y, w, gr_get_font_height());
1495 int brief_text_wipe_finished()
1497 if ( Brief_text_wipe_time_elapsed > (BRIEF_TEXT_WIPE_TIME+0.5f) ) {
1504 // -------------------------------------------------------------------------------------
1505 // brief_render_text()
1507 // input: frametime => Time in seconds of previous frame
1508 // instance => Optional parameter. Used to indicate which text stream is used.
1509 // This value is 0 unless multiple text streams are required
1510 int brief_render_text(int line_offset, int x, int y, int h, float frametime, int instance, int line_spacing)
1514 fh = gr_get_font_height();
1515 if (Brief_text_wipe_time_elapsed == 0) {
1516 if (snd_is_playing(Brief_text_wipe_snd)) {
1517 snd_stop(Brief_text_wipe_snd);
1519 gamesnd_play_iface(SND_BRIEF_TEXT_WIPE);
1520 Play_brief_voice = 1;
1523 Brief_text_wipe_time_elapsed += frametime;
1527 while (yy + fh <= h) {
1528 if (line >= Num_brief_text_lines[instance])
1531 brief_render_line(line, x, y + yy, instance);
1534 yy += fh + line_spacing;
1537 if ( brief_text_wipe_finished() && (Play_brief_voice) ) {
1538 Play_brief_voice = 0;
1545 // ------------------------------------------------------------------------------------
1546 // brief_render_elements()
1548 // Draw the lines that show objects positions on the grid
1550 void brief_render_elements(vector *pos, grid* gridp)
1552 vector gpos; // Location of point on grid.
1558 if ( pos->y < 1 && pos->y > -1 )
1561 tplane.A = gridp->gmatrix.uvec.x;
1562 tplane.B = gridp->gmatrix.uvec.y;
1563 tplane.C = gridp->gmatrix.uvec.z;
1564 tplane.D = gridp->planeD;
1566 compute_point_on_plane(&gpos, &tplane, pos);
1568 dxz = vm_vec_dist(pos, &gpos)/8.0f;
1570 gv = &gridp->gmatrix.uvec;
1571 if (gv->x * pos->x + gv->y * pos->y + gv->z * pos->z < -gridp->planeD)
1572 gr_set_color(127, 127, 127);
1574 gr_set_color(255, 255, 255); // white
1576 // AL 11-20-97: don't draw elevation lines.. they are confusing
1578 brief_rpd_line(&gpos, pos); // Line from grid to object center.
1582 vm_vec_scale_add2(&gpos, &gridp->gmatrix.rvec, -dxz/2);
1583 vm_vec_scale_add2(&gpos, &gridp->gmatrix.fvec, -dxz/2);
1585 vm_vec_scale_add2(&tpos, &gridp->gmatrix.rvec, dxz/2);
1586 vm_vec_scale_add2(&tpos, &gridp->gmatrix.fvec, dxz/2);
1588 brief_rpd_line(&gpos, &tpos);
1590 vm_vec_scale_add2(&gpos, &gridp->gmatrix.rvec, dxz);
1591 vm_vec_scale_add2(&tpos, &gridp->gmatrix.rvec, -dxz);
1593 brief_rpd_line(&gpos, &tpos);
1598 // ------------------------------------------------------------------------------------
1599 // brief_reset_icons()
1601 void brief_reset_icons(int stage_num)
1607 Assert( Briefing != NULL );
1608 bs = &Briefing->stages[stage_num];
1610 for ( i = 0; i < bs->num_icons; i++ ) {
1612 bi->flags &= ~BI_SHOWHIGHLIGHT;
1616 // ------------------------------------------------------------------------------------
1617 // brief_set_camera_target()
1619 // input: pos => target position for the camera
1620 // orient => target orientation for the camera
1621 // time => time in ms to reach target
1623 void brief_set_camera_target(vector *pos, matrix *orient, int time)
1625 float time_in_seconds;
1627 time_in_seconds = time / 1000.0f;
1630 Current_cam_pos = *pos;
1631 Current_cam_orient = *orient;
1634 Target_cam_pos = *pos;
1635 Target_cam_orient = *orient;
1636 Start_cam_orient = Current_cam_orient;
1637 Start_cam_pos = Current_cam_pos; // we need this when checking if camera movement complete
1638 Start_cam_move = timer_get_milliseconds()*1000.0f; // start time, convert to seconds
1639 Total_move_time = time_in_seconds;
1640 Elapsed_time = 0.0f;
1642 vm_vec_scale_add(&Start_lookat_pos, &Start_cam_pos, &Start_cam_orient.fvec, LOOKAT_DIST);
1643 vm_vec_scale_add(&Target_lookat_pos, &Target_cam_pos, &Target_cam_orient.fvec, LOOKAT_DIST);
1645 Play_highlight_flag = 1; // once target reached, play highlight anims
1646 Cam_target_reached = 0;
1647 Cam_movement_done=0;
1648 anim_release_all_instances(ON_BRIEFING_SELECT); // stop any briefing-specific anims
1650 // calculate camera velocity
1651 vm_vec_sub(&Cam_vel, pos, &Current_cam_pos);
1652 // vm_vec_scale(&Cam_vel, 1.0f/time_in_seconds);
1653 if ( !IS_VEC_NULL(&Cam_vel) ) {
1654 vm_vec_normalize(&Cam_vel);
1657 // calculate lookat point velocity
1658 vm_vec_sub(&Lookat_vel, &Target_lookat_pos, &Current_lookat_pos);
1659 vm_vec_scale(&Lookat_vel, 1.0f/time_in_seconds);
1661 Start_dist = vm_vec_dist(&Start_cam_pos, &Start_lookat_pos);
1662 End_dist = vm_vec_dist(&Target_cam_pos, &Target_lookat_pos);
1663 Dist_change_rate = (End_dist - Start_dist) / time_in_seconds;
1665 Total_dist=vm_vec_dist(&Start_cam_pos, &Target_cam_pos);
1667 // Peak_speed=Total_dist/Total_move_time*1.5f;
1668 // Cam_accel = Peak_speed/Total_move_time*3.0f;
1670 Peak_speed=Total_dist/Total_move_time*2.0f;
1671 Cam_accel = 4*Total_dist/(Total_move_time*Total_move_time);
1674 vm_vec_zero(&W_init);
1676 get_camera_limits(&Start_cam_orient, &Target_cam_orient, Total_move_time, &Acc_limit, &Vel_limit);
1680 ubyte brief_return_color_index(char c)
1684 return BRIEF_IFF_FRIENDLY;
1687 return BRIEF_IFF_HOSTILE;
1690 return BRIEF_IFF_NEUTRAL;
1693 return BRIEF_TEXT_RED;
1696 return BRIEF_TEXT_GREEN;
1699 return BRIEF_TEXT_BLUE;
1702 Int3(); // unsupported meta-code
1706 return BRIEF_TEXT_WHITE;
1709 void brief_set_text_color(int color_index)
1711 Assert(color_index < MAX_BRIEF_TEXT_COLORS);
1712 gr_set_color_fast(Brief_text_colors[color_index]);
1715 // Set up the Colored_text array.
1716 // input: index => Index into Brief_text[] for source text.
1717 // instance => Which instance of Colored_text[] to use.
1718 // Value is 0 unless multiple text streams are required.
1719 int brief_text_colorize(int index, int instance)
1722 int len, i, skip_to_next_word, dest_len;
1724 ubyte active_color_index;
1726 src = Brief_text[index];
1727 dest = &Colored_text[instance][index][0];
1730 skip_to_next_word = 0;
1732 active_color_index = BRIEF_TEXT_WHITE;
1733 for (i=0; i<len; i++) {
1734 if (skip_to_next_word) {
1735 if (is_white_space(src[i])) {
1736 skip_to_next_word = 0;
1742 if ( src[i] == BRIEF_META_CHAR && is_white_space(src[i + 2]) ) {
1743 active_color_index = brief_return_color_index(src[i + 1]);
1744 skip_to_next_word = 1;
1748 if (is_white_space(src[i])) {
1749 active_color_index = BRIEF_TEXT_WHITE;
1752 dest[dest_len].letter = src[i];
1753 dest[dest_len].color = active_color_index;
1757 dest[dest_len].letter = 0;
1758 Colored_text_len[instance][index] = dest_len;
1762 // ------------------------------------------------------------------------------------
1763 // brief_color_text_init()
1765 // input: src => paragraph of text to process
1766 // w => max width of line in pixels
1767 // instance => optional parameter, used when multiple text streams are required
1768 // (default value is 0)
1769 int brief_color_text_init(char *src, int w, int instance)
1771 int i, n_lines, len;
1772 int n_chars[MAX_BRIEF_LINES];
1773 char *p_str[MAX_BRIEF_LINES];
1776 n_lines = split_str(src, w, n_chars, p_str, MAX_BRIEF_LINES, BRIEF_META_CHAR);
1777 Assert(n_lines >= 0);
1779 Max_briefing_line_len = 1;
1780 for (i=0; i<n_lines; i++) {
1781 Assert(n_chars[i] < MAX_BRIEF_LINE_LEN);
1782 strncpy(Brief_text[i], p_str[i], n_chars[i]);
1783 Brief_text[i][n_chars[i]] = 0;
1784 drop_leading_white_space(Brief_text[i]);
1785 len = brief_text_colorize(i, instance);
1786 if (len > Max_briefing_line_len)
1787 Max_briefing_line_len = len;
1790 Brief_text_wipe_time_elapsed = 0.0f;
1791 Play_brief_voice = 0;
1793 Num_brief_text_lines[instance] = n_lines;
1797 // ------------------------------------------------------------------------------------
1798 // brief_get_free_move_icon()
1800 // returns: failure => -1
1801 // success => handle to a free move icon struct
1803 int brief_get_free_move_icon()
1807 for ( i = 0; i < MAX_MOVE_ICONS; i++ ) {
1808 if ( Icon_movers[i].used == 0 )
1812 if ( i == MAX_MOVE_ICONS )
1815 Icon_movers[i].used = 1;
1820 // ------------------------------------------------------------------------------------
1821 // brief_set_move_list()
1823 // input: new_stage => new stage number that briefing is now moving to
1824 // current_stage => current stage that the briefing is on
1825 // time => time in seconds
1827 int brief_set_move_list(int new_stage, int current_stage, float time)
1829 brief_stage *newb, *cb;
1830 icon_move_info *imi;
1831 int i,j,k,num_movers,is_gone=0;
1833 Assert(new_stage != current_stage);
1835 Assert( Briefing != NULL );
1836 newb = &Briefing->stages[new_stage];
1837 cb = &Briefing->stages[current_stage];
1840 for ( i = 0; i < cb->num_icons; i++ ) {
1842 for ( j = 0; j < newb->num_icons; j++ ) {
1843 if ( ( cb->icons[i].id != 0 ) && ( cb->icons[i].id == newb->icons[j].id ) ) {
1845 if ( vm_vec_cmp(&cb->icons[i].pos, &newb->icons[j].pos) ) {
1846 //nprintf(("Alan","We found a match in icon %s\n", cb->icons[i].label));
1847 k = brief_get_free_move_icon();
1849 Int3(); // should never happen, get Alan
1852 imi = &Icon_movers[k];
1853 imi->id = cb->icons[i].id;
1854 imi->start = cb->icons[i].pos;
1855 imi->finish = newb->icons[j].pos;
1856 imi->current = imi->start;
1857 list_append(&Icon_move_list, imi);
1859 imi->total_dist = vm_vec_dist(&imi->start, &imi->finish);
1860 imi->total_move_time = time;
1861 imi->peak_speed = imi->total_dist/imi->total_move_time*2.0f;
1862 imi->accel = 4*imi->total_dist/(time*time);
1863 imi->last_dist=0.0f;
1864 imi->reached_dest=0;
1867 vm_vec_sub(&imi->direction, &imi->finish, &imi->start);
1868 if ( !IS_VEC_NULL(&imi->direction) ) {
1869 vm_vec_normalize(&imi->direction);
1877 // Set up fading icon (to fade out)
1879 if ( Num_fade_icons >= MAX_FADE_ICONS ) {
1884 int species = ship_get_species_by_type(cb->icons[i].ship_class);
1889 Fading_icons[Num_fade_icons].fade_anim = Icon_fade_anims[cb->icons[i].type][species];
1890 Fading_icons[Num_fade_icons].pos = cb->icons[i].pos;
1891 Fading_icons[Num_fade_icons].team = cb->icons[i].team;
1896 // flag new icons for fading in
1897 for ( i=0; i<newb->num_icons; i++ ) {
1899 newb->icons[i].flags &= ~BI_FADEIN;
1900 for ( j=0; j<cb->num_icons; j++ ) {
1901 if ( ( cb->icons[j].id != 0 ) && ( cb->icons[j].id == newb->icons[i].id ) ) {
1906 int species = ship_get_species_by_type(newb->icons[i].ship_class);
1911 newb->icons[i].flags |= BI_FADEIN;
1912 newb->icons[i].fadein_anim = Icon_fade_anims[newb->icons[i].type][species];
1913 newb->icons[i].fadein_anim.time_elapsed = 0.0f;
1920 void brief_clear_fade_out_icons()
1926 // ------------------------------------------------------------------------------------
1927 // brief_set_new_stage()
1929 // input: pos => target position for the camera
1930 // orient => target orientation for the camera
1931 // time => time in ms to reach target
1932 // stage_num => stage number of briefing (start numbering at 0)
1935 void brief_set_new_stage(vector *pos, matrix *orient, int time, int stage_num)
1937 char msg[MAX_BRIEF_LEN];
1938 int num_movers, new_time, not_objv = 1;
1940 Assert( Briefing != NULL );
1943 if (stage_num >= Briefing->num_stages) {
1944 not_objv = 0; // turns out this is an objectives stage
1948 if ( stage_num == Last_new_stage ) {
1953 brief_move_icon_reset();
1954 brief_clear_fade_out_icons();
1955 if ( (Last_new_stage != -1) && not_objv ) {
1956 num_movers = brief_set_move_list(stage_num, Last_new_stage, new_time / 1000.0f);
1959 if ( (Last_new_stage != -1) && (num_movers == 0) && not_objv ) {
1960 if ( !vm_vec_cmp( &Briefing->stages[stage_num].camera_pos, &Briefing->stages[Last_new_stage].camera_pos) ) {
1961 if ( !vm_vec_cmp( &Briefing->stages[stage_num].camera_orient.fvec, &Briefing->stages[Last_new_stage].camera_orient.fvec) ){
1968 if(Briefing->stages[stage_num].new_text == NULL){
1971 strcpy(msg, Briefing->stages[stage_num].new_text);
1974 strcpy(msg, XSTR( "Please review your objectives for this mission.", 395));
1977 if (gr_screen.res == GR_640) {
1979 Num_brief_text_lines[0] = brief_color_text_init(msg, MAX_BRIEF_LINE_W_640);
1982 Num_brief_text_lines[0] = brief_color_text_init(msg, MAX_BRIEF_LINE_W_1024);
1984 Top_brief_text_line = 0;
1987 brief_set_camera_target(pos, orient, new_time);
1990 if ( snd_is_playing(Brief_stage_highlight_sound_handle) ) {
1991 snd_stop(Brief_stage_highlight_sound_handle);
1994 Brief_voice_ended = 0;
1995 Brief_textdraw_finished = 0;
1996 Brief_voice_started = 0;
1997 Brief_stage_time = 0;
2000 Brief_stage_highlight_sound_handle = -1;
2001 Last_new_stage = stage_num;
2004 // ------------------------------------------------------------------------------------
2005 // camera_pos_past_target()
2008 int camera_pos_past_target(vector *start, vector *current, vector *dest)
2013 vm_vec_sub(&num, current, start);
2014 vm_vec_sub(&den, start, dest);
2016 ratio = vm_vec_mag_quick(&num) / vm_vec_mag_quick(&den);
2023 // ------------------------------------------------------------------------------------
2024 // Interpolate between matrices.
2025 // elapsed_time/total_time gives percentage of interpolation between cur
2027 void interpolate_matrix(matrix *result, matrix *goal, matrix *start, float elapsed_time, float total_time)
2032 if ( !vm_matrix_cmp( goal, start ) ) {
2036 time0 = elapsed_time / total_time;
2037 time1 = (total_time - elapsed_time) / total_time;
2039 vm_vec_copy_scale(&fvec, &start->fvec, time1);
2040 vm_vec_scale_add2(&fvec, &goal->fvec, time0);
2042 vm_vec_copy_scale(&rvec, &start->rvec, time1);
2043 vm_vec_scale_add2(&rvec, &goal->rvec, time0);
2045 vm_vector_2_matrix(result, &fvec, NULL, &rvec);
2048 // calculate how far the camera should have moved
2049 float brief_camera_get_dist_moved(float elapsed_time)
2051 float time, dist_moved=0.0f;
2053 // first half of movement
2054 if ( elapsed_time < Total_move_time/2.0f ) {
2055 dist_moved=0.5f*Cam_accel*elapsed_time*elapsed_time; // d = 1/2at^2
2059 // second half of movement
2060 time=elapsed_time - Total_move_time/2.0f;
2061 dist_moved=(Total_dist/2.0f)+(Peak_speed*time) - 0.5f*Cam_accel*time*time;
2066 // ------------------------------------------------------------------------------------
2067 // Update the camera position
2068 void brief_camera_move(float frametime, int stage_num)
2075 Elapsed_time += frametime;
2077 if ( Cam_target_reached ) {
2078 // Current_cam_pos = Target_cam_pos;
2079 // Current_lookat_pos = Target_lookat_pos;
2080 // Current_cam_orient = Target_cam_orient;
2084 // Update orientation
2085 if ( (Elapsed_time < Total_move_time) ) {
2086 // interpolate_matrix(&Current_cam_orient, &Target_cam_orient, &Start_cam_orient, Elapsed_time, Total_move_time );
2087 vm_matrix_interpolate(&Target_cam_orient, &Current_cam_orient, &W_init, frametime, &result, &w_out, &Vel_limit, &Acc_limit);
2088 Current_cam_orient = result;
2093 // interpolate lookat position
2094 if ( vm_vec_cmp( &Current_lookat_pos, &Target_lookat_pos ) ) {
2095 vm_vec_copy_scale(&dist_moved, &Lookat_vel, Elapsed_time);
2096 vm_vec_add(&Current_lookat_pos, &Start_lookat_pos, &dist_moved);
2098 if ( camera_pos_past_target(&Start_lookat_pos, &Current_lookat_pos, &Target_lookat_pos) ) {
2099 Current_lookat_pos = Target_lookat_pos;
2103 cur_dist = Start_dist + Dist_change_rate * Elapsed_time;
2104 vm_vec_copy_scale(&dist_moved, &Current_cam_orient.fvec, -cur_dist);
2105 vm_vec_add(&Current_cam_pos, &Current_lookat_pos, &dist_moved);
2108 // use absolute pos to update position
2109 if ( vm_vec_cmp( &Current_cam_pos, &Target_cam_pos ) ) {
2110 dist = brief_camera_get_dist_moved(Elapsed_time);
2111 if ( dist < Last_dist ) {
2112 Cam_movement_done=1;
2117 if ( Cam_movement_done == 0 ) {
2118 vm_vec_copy_scale(&dist_moved, &Cam_vel, dist);
2119 vm_vec_add(&Current_cam_pos, &Start_cam_pos, &dist_moved);
2121 Current_cam_pos=Target_cam_pos;
2125 Cam_movement_done=1;
2126 Current_cam_pos=Target_cam_pos;
2129 if ( Cam_movement_done && (Elapsed_time >= Total_move_time) ) {
2130 Cam_target_reached=1;
2134 // Project the viewer's position onto the grid plane. If more than threshold distance
2135 // from grid center, move grid center.
2136 void brief_maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int force)
2140 vector gpos, tmp, c;
2141 float dist_to_plane;
2142 float square_size, ux, uy, uz;
2144 ux = tplane.A = gridp->gmatrix.uvec.x;
2145 uy = tplane.B = gridp->gmatrix.uvec.y;
2146 uz = tplane.C = gridp->gmatrix.uvec.z;
2147 tplane.D = gridp->planeD;
2149 compute_point_on_plane(&c, &tplane, pos);
2150 dist_to_plane = fl_abs(vm_dist_to_plane(pos, &gridp->gmatrix.uvec, &c));
2153 while (dist_to_plane >= 25.0f)
2155 square_size *= 10.0f;
2156 dist_to_plane /= 10.0f;
2159 if (fvi_ray_plane(&gpos, &gridp->center, &gridp->gmatrix.uvec, pos, &orient->fvec, 0.0f)<0.0f) {
2161 vm_vec_scale_add(&p,pos,&orient->fvec, 100.0f );
2162 compute_point_on_plane(&gpos, &tplane, &p );
2165 if (vm_vec_dist(&gpos, &c) > 50.0f * square_size)
2167 vm_vec_sub(&tmp, &gpos, &c);
2168 vm_vec_normalize(&tmp);
2169 vm_vec_scale_add(&gpos, &c, &tmp, 50.0f * square_size);
2172 roundoff = (int) square_size * 10;
2174 gpos.x = fl_roundoff(gpos.x, roundoff);
2176 gpos.y = fl_roundoff(gpos.y, roundoff);
2178 gpos.z = fl_roundoff(gpos.z, roundoff);
2180 if ((square_size != gridp->square_size) ||
2181 (gpos.x != gridp->center.x) ||
2182 (gpos.y != gridp->center.y) ||
2183 (gpos.z != gridp->center.z) || force)
2185 gridp->square_size = square_size;
2186 gridp->center = gpos;
2187 brief_modify_grid(gridp);
2192 // *forward is vector pointing forward
2193 // *right is vector pointing right
2194 // *center is center point of grid
2195 // length is length of grid
2196 // width is width of grid
2197 // square_size is size of a grid square
2199 // *forward = (0.0, 0.0, 1.0)
2200 // *right = (1.0, 0.0, 0.0)
2201 // *center = (0.0, 0.0, 0.0)
2204 // square_size = 10.0
2205 // will generate a grid of squares 10 long by 5 wide.
2206 // Each grid square will be 10.0 x 10.0 units.
2207 // The center of the grid will be at the global origin.
2208 // The grid will be parallel to the xz plane (because the normal is 0,1,0).
2209 // (In fact, it will be the xz plane because it is centered on the origin.)
2211 // Stuffs grid in *gridp. If gridp == NULL, mallocs and returns a grid.
2212 grid *brief_create_grid(grid *gridp, vector *forward, vector *right, vector *center, int nrows, int ncols, float square_size)
2214 int i, ncols2, nrows2, d = 1;
2215 vector dfvec, drvec, cur, cur2, tvec, uvec, save, save2;
2217 Assert(square_size > 0.0);
2218 if (double_fine_gridlines)
2222 gridp = (grid *) malloc(sizeof(grid));
2226 gridp->center = *center;
2227 gridp->square_size = square_size;
2229 // Create the plane equation.
2230 Assert(!IS_VEC_NULL(forward));
2231 Assert(!IS_VEC_NULL(right));
2233 vm_vec_copy_normalize(&dfvec, forward);
2234 vm_vec_copy_normalize(&drvec, right);
2236 vm_vec_cross(&uvec, &dfvec, &drvec);
2238 Assert(!IS_VEC_NULL(&uvec));
2240 gridp->gmatrix.uvec = uvec;
2242 gridp->planeD = -(center->x * uvec.x + center->y * uvec.y + center->z * uvec.z);
2243 Assert(!_isnan(gridp->planeD));
2245 gridp->gmatrix.fvec = dfvec;
2246 gridp->gmatrix.rvec = drvec;
2248 vm_vec_scale(&dfvec, square_size);
2249 vm_vec_scale(&drvec, square_size);
2251 vm_vec_scale_add(&cur, center, &dfvec, (float) -nrows * d / 2);
2252 vm_vec_scale_add2(&cur, &drvec, (float) -ncols * d / 2);
2253 vm_vec_scale_add(&cur2, center, &dfvec, (float) -nrows * 5 / 2);
2254 vm_vec_scale_add2(&cur2, &drvec, (float) -ncols * 5 / 2);
2258 gridp->ncols = ncols;
2259 gridp->nrows = nrows;
2262 Assert(ncols < MAX_GRIDLINE_POINTS && nrows < MAX_GRIDLINE_POINTS);
2264 // Create the points along the edges of the grid, so we can just draw lines
2265 // between them to form the grid.
2266 for (i=0; i<=ncols*d; i++) {
2267 gridp->gpoints1[i] = cur; // small, dark gridline points
2268 vm_vec_scale_add(&tvec, &cur, &dfvec, (float) nrows * d);
2269 gridp->gpoints2[i] = tvec;
2270 vm_vec_add2(&cur, &drvec);
2273 for (i=0; i<=ncols2; i++) {
2274 gridp->gpoints5[i] = cur2; // large, brighter gridline points
2275 vm_vec_scale_add(&tvec, &cur2, &dfvec, (float) nrows2 * 10);
2276 gridp->gpoints6[i] = tvec;
2277 vm_vec_scale_add2(&cur2, &drvec, 10.0f);
2282 for (i=0; i<=nrows*d; i++) {
2283 gridp->gpoints3[i] = cur; // small, dark gridline points
2284 vm_vec_scale_add(&tvec, &cur, &drvec, (float) ncols * d);
2285 gridp->gpoints4[i] = tvec;
2286 vm_vec_add2(&cur, &dfvec);
2289 for (i=0; i<=nrows2; i++) {
2290 gridp->gpoints7[i] = cur2; // large, brighter gridline points
2291 vm_vec_scale_add(&tvec, &cur2, &drvec, (float) ncols2 * 10);
2292 gridp->gpoints8[i] = tvec;
2293 vm_vec_scale_add2(&cur2, &dfvec, 10.0f);
2299 // Create a nice grid -- centered at origin, 10x10, 10.0 size squares, in xz plane.
2300 grid *brief_create_default_grid(void)
2303 vector fvec, rvec, cvec;
2305 rgrid = brief_create_grid(&Global_grid, vm_vec_make(&fvec, 0.0f, 0.0f, 1.0f),
2306 vm_vec_make(&rvec, 1.0f, 0.0f, 0.0f),
2307 vm_vec_make(&cvec, 0.0f, -10.0f, 0.0f), 100, 100, 5.0f);
2309 physics_init(&rgrid->physics);
2310 rgrid->physics.flags |= (PF_ACCELERATES | PF_SLIDE_ENABLED);
2314 // Rotate and project points and draw a line.
2315 void brief_rpd_line(vector *v0, vector *v1)
2318 g3_rotate_vertex(&tv0, v0);
2319 g3_rotate_vertex(&tv1, v1);
2322 g3_project_vertex(&tv0);
2323 g3_project_vertex(&tv1);
2325 if ( (tv0.flags & PF_OVERFLOW) || (tv1.flags & PF_OVERFLOW) )
2329 gr_set_color_fast(&Color_grey);
2330 g3_draw_line(&tv0, &tv1);
2333 // Renders a grid defined in a grid struct
2334 void brief_render_grid(grid *gridp)
2336 int i, ncols, nrows;
2338 ncols = gridp->ncols;
2339 nrows = gridp->nrows;
2340 if (double_fine_gridlines)
2346 gr_set_color(30,30,30);
2349 // Draw the column lines.
2350 for (i=0; i<=ncols; i++)
2351 brief_rpd_line(&gridp->gpoints1[i], &gridp->gpoints2[i]);
2353 // Draw the row lines.
2354 for (i=0; i<=nrows; i++)
2355 brief_rpd_line(&gridp->gpoints3[i], &gridp->gpoints4[i]);
2357 ncols = gridp->ncols / 2;
2358 nrows = gridp->nrows / 2;
2360 // now draw the larger, brighter gridlines that is x10 the scale of smaller one.
2363 for (i=0; i<=ncols; i++)
2364 brief_rpd_line(&gridp->gpoints5[i], &gridp->gpoints6[i]);
2366 for (i=0; i<=nrows; i++)
2367 brief_rpd_line(&gridp->gpoints7[i], &gridp->gpoints8[i]);
2371 void brief_modify_grid(grid *gridp)
2373 brief_create_grid(gridp, &gridp->gmatrix.fvec, &gridp->gmatrix.rvec, &gridp->center,
2374 gridp->nrows, gridp->ncols, gridp->square_size);
2377 void brief_unload_anims()
2381 for (i=0; i<MAX_BRIEF_ICONS; i++) {
2382 for(idx=0; idx<MAX_SPECIES_NAMES; idx++){
2383 hud_anim_release(&Icon_highlight_anims[i][idx]);
2384 hud_anim_release(&Icon_fade_anims[i][idx]);
2389 void brief_common_close()
2392 brief_unload_anims();
2396 void brief_restart_text_wipe()
2398 Brief_stage_time = 0;
2399 Brief_voice_ended = 0;
2400 Brief_voice_started = 0;
2401 Brief_text_wipe_time_elapsed = 0.0f;
2404 // initialize the array of handles to the different voice streams
2405 void brief_voice_init()
2408 for ( i = 0; i < MAX_BRIEF_STAGES; i++ ) {
2409 Brief_voices[i] = -1;
2413 void brief_load_voice_file(int voice_num, char *name)
2415 int load_attempts = 0;
2418 if ( load_attempts++ > 5 ) {
2422 Brief_voices[voice_num] = audiostream_open( name, ASF_VOICE );
2423 if ( Brief_voices[voice_num] >= 0 ) {
2427 // Don't bother to ask for the CD in multiplayer
2428 if ( Game_mode & GM_MULTIPLAYER ) {
2432 // couldn't load animation, ask user to insert CD (if necessary)
2433 // if ( Brief_voice_ask_for_cd ) {
2434 // if ( game_do_cd_check() == 0 ) {
2435 // Brief_voice_ask_for_cd = 0;
2442 // open and pre-load the stream buffers for the different voice streams
2443 void brief_voice_load_all()
2448 // Brief_voice_ask_for_cd = 1;
2450 Assert( Briefing != NULL );
2451 for ( i = 0; i < Briefing->num_stages; i++ ) {
2452 bs = &Briefing->stages[i];
2453 if ( strnicmp(bs->voice, NOX("none"), 4) ) {
2454 brief_load_voice_file(i, bs->voice);
2455 // Brief_voices[i] = audiostream_open( bs->voice, ASF_VOICE );
2460 // close all the briefing voice streams
2461 void brief_voice_unload_all()
2465 for ( i = 0; i < MAX_BRIEF_STAGES; i++ ) {
2466 if ( Brief_voices[i] != -1 ) {
2467 audiostream_close_file(Brief_voices[i], 0);
2468 Brief_voices[i] = -1;
2473 // start playback of the voice for a particular briefing stage
2474 void brief_voice_play(int stage_num)
2476 if ( Brief_voices[stage_num] == -1 )
2477 return; // voice file doesn't exist
2479 if ( !Briefing_voice_enabled ) {
2483 if ( audiostream_is_playing( Brief_voices[stage_num]) )
2486 audiostream_play(Brief_voices[stage_num], Master_voice_volume, 0);
2487 Brief_voice_started = 1;
2490 // stop playback of the voice for a particular briefing stage
2491 void brief_voice_stop(int stage_num)
2493 if ( Brief_voices[stage_num] == -1 )
2496 audiostream_stop(Brief_voices[stage_num]); // stream is automatically rewound
2499 // pause playback of the voice for a particular briefing stage, to resume just
2500 // call brief_voice_unpause() again
2501 void brief_voice_pause(int stage_num)
2503 if ( Brief_voices[stage_num] == -1 )
2506 audiostream_pause(Brief_voices[stage_num]);
2509 void brief_voice_unpause(int stage_num)
2511 if ( Brief_voices[stage_num] == -1 )
2514 audiostream_unpause(Brief_voices[stage_num]);
2517 void brief_reset_last_new_stage()
2519 Last_new_stage = -1;
2522 // get the dimensions for a briefing icon
2523 void brief_common_get_icon_dimensions(int *w, int *h, int type, int ship_class)
2525 Assert(type >= 0 && type < MAX_BRIEF_ICONS);
2527 // in case anything goes wrong
2531 int species = ship_get_species_by_type(ship_class);
2536 if ( Icon_bitmaps[type][species].first_frame >= 0 ) {
2537 bm_get_info( Icon_bitmaps[type][species].first_frame, w, h, NULL);
2544 void cmd_brief_reset()
2547 static int inited = 0;
2550 for (i=0; i<MAX_TEAMS; i++) {
2551 for (j=0; j<Cmd_briefs[i].num_stages; j++) {
2552 if (Cmd_briefs[i].stage[j].text)
2553 free(Cmd_briefs[i].stage[j].text);
2559 for (i=0; i<MAX_TEAMS; i++)
2560 Cmd_briefs[i].num_stages = 0;
2563 #define STAGE_ADVANCE_DELAY 1000 // time in ms to wait after voice stops before advancing stage
2565 // should briefing advance to the next stage?
2566 int brief_time_to_advance(int stage_num, float frametime)
2568 int voice_active, advance = 0;
2569 brief_icon *closeup_icon;
2571 closeup_icon = (brief_icon*)brief_get_closeup_icon();
2572 if ( closeup_icon ) {
2576 if ( !Player->auto_advance ) {
2580 Brief_stage_time += fl2i(frametime*1000 + 0.5f);
2582 if ( (Brief_voices[stage_num] >= 0) && Briefing_voice_enabled ) {
2588 if ( voice_active && (Brief_voice_ended == 0) && Brief_voice_started) {
2589 if ( !audiostream_is_playing( Brief_voices[stage_num]) ) {
2590 Brief_voice_ended = 1;
2591 Brief_stage_time = 0;
2595 if ( Brief_voice_ended ) {
2596 if ( Brief_stage_time > STAGE_ADVANCE_DELAY ) {
2601 if ( !voice_active && (Brief_textdraw_finished > 0) ) {
2602 if ( Brief_stage_time > max(5000, Num_brief_text_lines[0] * 3500) ) {