Skip to content

Commit

Permalink
mjn.mixael's request for per-mission briefing backgrounds; see http:/…
Browse files Browse the repository at this point in the history
  • Loading branch information
Goober5000 committed Aug 27, 2015
1 parent 3a5f714 commit 05d4e44
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 30 deletions.
14 changes: 14 additions & 0 deletions code/fred2/missionsave.cpp
Expand Up @@ -883,6 +883,20 @@ int CFred_mission_save::save_briefing()
required_string_fred("$start_briefing");
parse_comments();

// Goober5000's briefing background stuff (c.f. Phreak's loading screen stuff)
if (Format_fs2_open != FSO_FORMAT_RETAIL)
{
if (strlen(Briefings[nb].background[GR_640]) > 0)
{
fout("\n$background_640: %s", Briefings[nb].background[GR_640]);
}

if (strlen(Briefings[nb].background[GR_1024]) > 0)
{
fout("\n$background_1024: %s", Briefings[nb].background[GR_1024]);
}
}

Assert(Briefings[nb].num_stages <= MAX_BRIEF_STAGES);
required_string_fred("$num_stages:");
parse_comments();
Expand Down
5 changes: 4 additions & 1 deletion code/mission/missionbriefcommon.h
Expand Up @@ -183,10 +183,13 @@ class briefing
public:
int num_stages;
brief_stage stages[MAX_BRIEF_STAGES];
char background[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN];

briefing()
: num_stages(0)
{}
{
memset(background, GR_NUM_RESOLUTIONS * MAX_FILENAME_LEN * sizeof(char), 0);

This comment has been minimized.

Copy link
@Echelon9

Echelon9 Oct 5, 2015

Contributor

@Goober5000 this memset() call is backwards.
I think you intended to write memset(background, 0, GR_NUM_RESOLUTIONS * MAX_FILENAME_LEN * sizeof(char));.

As reported by GCC warnings:

./mission/missionbriefcommon.h: In constructor ‘briefing::briefing()’:
./mission/missionbriefcommon.h:193:77: warning: ‘memset’ used with constant zero length parameter; this could be due to transposed parameters [-Wmemset-transposed-args]
   memset(background, GR_NUM_RESOLUTIONS * MAX_FILENAME_LEN * sizeof(char), 0);
                                                                             ^

This comment has been minimized.

Copy link
@Goober5000

Goober5000 Oct 6, 2015

Contributor

Agreed. Fixed in #370.

}
};

class debriefing
Expand Down
61 changes: 36 additions & 25 deletions code/mission/missionparse.cpp
Expand Up @@ -399,6 +399,36 @@ MONITOR(NumShipArrivals)
MONITOR(NumShipDepartures)


// Goober5000
void parse_custom_bitmap(const char *expected_string_640, const char *expected_string_1024, char *string_field_640, char *string_field_1024)
{
int found640 = 0, found1024 = 0;
strcpy(string_field_640, "");
strcpy(string_field_1024, "");

// custom mission loading background, or whatever
if (optional_string(expected_string_640))
{
found640 = 1;
stuff_string(string_field_640, F_NAME, MAX_FILENAME_LEN);
}
if (optional_string(expected_string_1024))
{
found1024 = 1;
stuff_string(string_field_1024, F_NAME, MAX_FILENAME_LEN);
}

// error testing
if (Fred_running && (found640) && !(found1024))
{
Warning(LOCATION, "Mission: found an entry for %s but not a corresponding entry for %s!", expected_string_640, expected_string_1024);
}
if (Fred_running && !(found640) && (found1024))
{
Warning(LOCATION, "Mission: found an entry for %s but not a corresponding entry for %s!", expected_string_1024, expected_string_640);
}
}

void parse_mission_info(mission *pm, bool basic = false)
{
int i;
Expand Down Expand Up @@ -688,30 +718,8 @@ void parse_mission_info(mission *pm, bool basic = false)
Num_teams = 2;
}

int found640=0, found1024=0;
strcpy_s(pm->loading_screen[GR_640],"");
strcpy_s(pm->loading_screen[GR_1024],"");
//custom mission loading background
if (optional_string("$Load Screen 640:"))
{
found640=1;
stuff_string(pm->loading_screen[GR_640], F_NAME, MAX_FILENAME_LEN);
}
if (optional_string("$Load Screen 1024:"))
{
found1024=1;
stuff_string(pm->loading_screen[GR_1024], F_NAME, MAX_FILENAME_LEN);
}

//error testing
if (Fred_running && (found640) && !(found1024))
{
Warning(LOCATION, "Mission: %s\nhas a 640x480 loading screen but no 1024x768 loading screen!",pm->name);
}
if (Fred_running && !(found640) && (found1024))
{
Warning(LOCATION, "Mission: %s\nhas a 1024x768 loading screen but no 640x480 loading screen!",pm->name);
}
// Goober5000 - made this into a function since we use much the same technique for the briefing background
parse_custom_bitmap("$Load Screen 640:", "$Load Screen 1024:", pm->loading_screen[GR_640], pm->loading_screen[GR_1024]);

strcpy_s(pm->skybox_model, "");
if (optional_string("$Skybox Model:"))
Expand Down Expand Up @@ -1345,8 +1353,11 @@ void parse_briefing(mission *pm, int flags)
break;

bp = &Briefings[nt];

required_string("$start_briefing");

// Goober5000 - use the same code as for mission loading screens
parse_custom_bitmap("$background_640:", "$background_1024:", bp->background[GR_640], bp->background[GR_1024]);

required_string("$num_stages:");
stuff_int(&bp->num_stages);
Assert(bp->num_stages <= MAX_BRIEF_STAGES);
Expand Down
20 changes: 16 additions & 4 deletions code/missionui/missionbrief.cpp
Expand Up @@ -739,10 +739,22 @@ void brief_load_bitmaps()
//
void brief_ui_init()
{
if(Game_mode & GM_MULTIPLAYER) {
Brief_background_bitmap = bm_load(Brief_multi_filename[gr_screen.res]);
} else {
Brief_background_bitmap = bm_load(Brief_filename[gr_screen.res]);
Brief_background_bitmap = -1;

if (*Briefing->background[gr_screen.res]) {
Brief_background_bitmap = bm_load(Briefing->background[gr_screen.res]);
if (Brief_background_bitmap < 0) {
mprintf(("Failed to load custom briefing bitmap %s!\n", Briefing->background[gr_screen.res]));
}
}

// if special background failed to load, or if no special background was supplied, load the standard bitmap
if (Brief_background_bitmap < 0) {
if (Game_mode & GM_MULTIPLAYER) {
Brief_background_bitmap = bm_load(Brief_multi_filename[gr_screen.res]);
} else {
Brief_background_bitmap = bm_load(Brief_filename[gr_screen.res]);
}
}

if ( Num_brief_stages <= 0 ){
Expand Down

0 comments on commit 05d4e44

Please sign in to comment.