Open source remastering of the Freespace 2 engine
missioncampaign.cpp File Reference
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <errno.h>
#include "cfile/cfile.h"
#include "cutscene/cutscenes.h"
#include "cutscene/movie.h"
#include "freespace2/freespace.h"
#include "gamesequence/gamesequence.h"
#include "gamesnd/eventmusic.h"
#include "localization/localize.h"
#include "menuui/mainhallmenu.h"
#include "menuui/techmenu.h"
#include "mission/missioncampaign.h"
#include "mission/missiongoals.h"
#include "missionui/missionscreencommon.h"
#include "missionui/redalert.h"
#include "parse/parselo.h"
#include "parse/sexp.h"
#include "pilotfile/pilotfile.h"
#include "playerman/player.h"
#include "popup/popup.h"
#include "ship/ship.h"
#include "starfield/supernova.h"
#include "ui/ui.h"
#include "weapon/weapon.h"

Go to the source code of this file.


bool campaign_is_ignored (const char *filename)
int mission_campaign_get_info (const char *filename, char *name, int *type, int *max_players, char **desc)
int mission_campaign_get_mission_list (const char *filename, char **list, int max)
void mission_campaign_free_list ()
int mission_campaign_maybe_add (const char *filename)
void mission_campaign_build_list (bool desc, bool sort, bool multiplayer)
void mission_campaign_get_sw_info ()
int mission_campaign_load (char *filename, player *pl, int load_savefile, bool reset_stats)
int mission_campaign_load_by_name (char *filename)
int mission_campaign_load_by_name_csfe (char *filename, char *callsign)
void player_loadout_init ()
void mission_campaign_init ()
void mission_campaign_savefile_generate_root (char *filename, player *pl)
int campaign_savefile_save (char *pname)
void mission_campaign_savefile_delete (char *cfilename)
void campaign_delete_save (char *cfn, char *pname)
void mission_campaign_delete_all_savefiles (char *pilot_name)
void campaign_savefile_load (char *fname, char *pname)
int mission_campaign_next_mission ()
int mission_campaign_previous_mission ()
void mission_campaign_eval_next_mission ()
void mission_campaign_store_goals_and_events ()
void mission_campaign_store_variables ()
void mission_campaign_store_goals_and_events_and_variables ()
void mission_campaign_mission_over (bool do_next_mission)
void mission_campaign_clear ()
int mission_campaign_get_filenames (char *filename, char dest[][NAME_LENGTH], int *num)
void read_mission_goal_list (int num)
int mission_campaign_find_mission (char *name)
void mission_campaign_maybe_play_movie (int type)
int mission_campaign_parse_is_multi (char *filename, char *name)
void mission_campaign_save_persistent (int type, int sindex)
int mission_load_up_campaign (player *pl)
void mission_campaign_end_init ()
void mission_campaign_end_do ()
void mission_campaign_end_close ()
void mission_campaign_skip_to_next (int start_game)
void mission_campaign_exit_loop ()
void mission_campaign_jump_to_mission (char *name, bool no_skip)
void mission_campaign_save_player_persistent_variables ()
void mission_campaign_load_failure_popup ()


int Campaign_ending_via_supernova = 0
char * Campaign_names [MAX_CAMPAIGNS] = { NULL }
char * Campaign_file_names [MAX_CAMPAIGNS] = { NULL }
char * Campaign_descs [MAX_CAMPAIGNS] = { NULL }
int Num_campaigns
int Campaign_file_missing
int Campaign_load_failure = 0
int Campaign_names_inited = 0
SCP_vector< SCP_stringIgnored_campaigns
char Default_campaign_file_name [MAX_FILENAME_LEN-4] = { 0 }
char * campaign_types [MAX_CAMPAIGN_TYPES]
int Num_granted_ships
int Num_granted_weapons
int Granted_ships [MAX_SHIP_CLASSES]
int Granted_weapons [MAX_WEAPON_TYPES]
LOCAL UI_WINDOW Campaign_window
LOCAL UI_LISTBOX Campaign_listbox
LOCAL UI_BUTTON Campaign_okb
LOCAL UI_BUTTON Campaign_cancelb
campaign Campaign

Function Documentation

void campaign_delete_save ( char *  cfn,
char *  pname 

Definition at line 854 of file missioncampaign.cpp.

bool campaign_is_ignored ( const char *  filename)

Definition at line 1683 of file missioncampaign.cpp.

void campaign_savefile_load ( char *  fname,
char *  pname 

The following code only ever called by CSFE!!!!

Definition at line 896 of file missioncampaign.cpp.

int campaign_savefile_save ( char *  pname)

The following function always only ever ever ever called by CSFE!!!!!

Definition at line 818 of file missioncampaign.cpp.

void mission_campaign_build_list ( bool  desc,
bool  sort,
bool  multiplayer 

Builds up the list of campaigns that the user might be able to pick from. It uses the multiplayer flag to tell if we should display a list of single or multiplayer campaigns. This routine sets the Num_campaigns and Campaign_names global variables

Definition at line 279 of file missioncampaign.cpp.

void mission_campaign_clear ( void  )

Called when the game closes – to get rid of memory errors for Bounds checker also called at campaign init and campaign load

Definition at line 1297 of file missioncampaign.cpp.

void mission_campaign_delete_all_savefiles ( char *  pilot_name)

Deletes all the save files for this particular pilot. Just call cfile function which will delete multiple files

pilot_nameName of pilot

Definition at line 866 of file missioncampaign.cpp.

void mission_campaign_end_close ( )

Definition at line 1796 of file missioncampaign.cpp.

void mission_campaign_end_do ( )

Definition at line 1770 of file missioncampaign.cpp.

void mission_campaign_end_init ( )

For end of campaign in the single player game. Called when the end of campaign state is entered, which is triggered when the end-campaign sexpression is hit

Definition at line 1765 of file missioncampaign.cpp.

void mission_campaign_eval_next_mission ( )

Evaluate next campaign mission - set as Campaign.next_mission. Also set Campaign.loop_mission

Definition at line 983 of file missioncampaign.cpp.

void mission_campaign_exit_loop ( )

Breaks your ass out of the loop this also posts the state change

Definition at line 1851 of file missioncampaign.cpp.

int mission_campaign_find_mission ( char *  name)

Return index into Campaign's list of missions of the mission with the given filename.

This function tried to be a little smart about filename looking for the .fsm extension since filenames are stored with the extension in the campaign file.

index of mission in campaign structure. -1 if mission name not found.

Definition at line 1567 of file missioncampaign.cpp.

void mission_campaign_free_list ( )

Definition at line 216 of file missioncampaign.cpp.

int mission_campaign_get_filenames ( char *  filename,
char  dest[][NAME_LENGTH],
int num 

Extract the mission filenames for a campaign.

filenameName of campaign file
destStorage for the mission filename, must be already allocated
numOutput parameter for the number of mission filenames in the campaign

note that dest should allocate at least dest[MAX_CAMPAIGN_MISSIONS][NAME_LENGTH]

Definition at line 1408 of file missioncampaign.cpp.

int mission_campaign_get_info ( const char *  filename,
char *  name,
int type,
int max_players,
char **  desc 

Returns a string (which is malloced in this routine) of the name of the given freespace campaign file. In the type field, we return if the campaign is a single player or multiplayer campaign. The type field will only be valid if the name returned is non-NULL

Definition at line 101 of file missioncampaign.cpp.

int mission_campaign_get_mission_list ( const char *  filename,
char **  list,
int  max 

Parses campaign and returns a list of missions in it.

Number of missions added to the 'list', and up to 'max' missions may be added to 'list'.
Negative on error.

Definition at line 181 of file missioncampaign.cpp.

void mission_campaign_get_sw_info ( )

Gets optional ship/weapon information

Definition at line 370 of file missioncampaign.cpp.

void mission_campaign_init ( void  )

Initializes some variables then loads the default FreeSpace single player campaign.

Definition at line 781 of file missioncampaign.cpp.

void mission_campaign_jump_to_mission ( char *  name,
bool  no_skip 

Used for jumping to a particular campaign mission all previous missions marked skipped this relies on correct mission ordering in the campaign file

Definition at line 1869 of file missioncampaign.cpp.

int mission_campaign_load ( char *  filename,
player pl,
int  load_savefile,
bool  reset_stats 

Starts a new campaign. It reads in the mission information in the campaign file It also sets up all variables needed inside of the game to deal with starting mission numbers, etc

Note: Due to difficulties in generalizing this function, parts of it are duplicated throughout this file. If you change the format of the campaign file, you should be sure these related functions work properly and update them if it breaks them.

Definition at line 417 of file missioncampaign.cpp.

int mission_campaign_load_by_name ( char *  filename)

Loads up a freespace campaign given the filename. This routine is used to load up campaigns when a pilot file is loaded. Generally, the filename will probably be the freespace campaign file, but not necessarily.

Definition at line 711 of file missioncampaign.cpp.

int mission_campaign_load_by_name_csfe ( char *  filename,
char *  callsign 

Definition at line 742 of file missioncampaign.cpp.

void mission_campaign_load_failure_popup ( )

Definition at line 1957 of file missioncampaign.cpp.

int mission_campaign_maybe_add ( const char *  filename)

Definition at line 244 of file missioncampaign.cpp.

void mission_campaign_maybe_play_movie ( int  type)

Definition at line 1591 of file missioncampaign.cpp.

void mission_campaign_mission_over ( bool  do_next_mission)

Called when the player's mission is over. It updates the internal store of goals and their status then saves the state of the campaign in the campaign file. This gets called after player accepts mission results in debriefing.

Definition at line 1208 of file missioncampaign.cpp.

int mission_campaign_next_mission ( void  )

Sets up the internal veriables of the campaign structure so the player can play the next mission. If there are no more missions available in the campaign, this function returns -1, else 0 if the mission was set successfully

Definition at line 915 of file missioncampaign.cpp.

int mission_campaign_parse_is_multi ( char *  filename,
char *  name 

Return the type of campaign of the passed filename

Definition at line 1629 of file missioncampaign.cpp.

int mission_campaign_previous_mission ( )

Called to go to the previous mission in the campaign. Used only for Red Alert missions

Definition at line 940 of file missioncampaign.cpp.

void mission_campaign_save_persistent ( int  type,
int  sindex 

Save persistent information during a mission – which then might or might not get saved out when the mission is over depending on whether player replays mission or commits.

Definition at line 1667 of file missioncampaign.cpp.

void mission_campaign_save_player_persistent_variables ( )

Definition at line 1919 of file missioncampaign.cpp.

void mission_campaign_savefile_delete ( char *  cfilename)

Deletes any save file in the players directory for the given campaign filename

Definition at line 839 of file missioncampaign.cpp.

void mission_campaign_savefile_generate_root ( char *  filename,
player pl 

Fill in the root of the campaign save filename

Definition at line 793 of file missioncampaign.cpp.

void mission_campaign_skip_to_next ( int  start_game)

Skip to the next mission in the campaign this also posts the state change by default. pass 0 to override that

Definition at line 1806 of file missioncampaign.cpp.

void mission_campaign_store_goals_and_events ( )

Store mission's goals and events in Campaign struct

Definition at line 1019 of file missioncampaign.cpp.

void mission_campaign_store_goals_and_events_and_variables ( )

Definition at line 1197 of file missioncampaign.cpp.

void mission_campaign_store_variables ( )

Definition at line 1096 of file missioncampaign.cpp.

int mission_load_up_campaign ( player pl)

Definition at line 1698 of file missioncampaign.cpp.

void player_loadout_init ( )

Definition at line 752 of file missioncampaign.cpp.

void read_mission_goal_list ( int  num)

Read the goals and events from a mission in a campaign file and store that information in the campaign structure for use in the campaign editor, error checking, etc

Definition at line 1443 of file missioncampaign.cpp.

Variable Documentation

campaign Campaign

Definition at line 91 of file missioncampaign.cpp.

LOCAL UI_BUTTON Campaign_cancelb

Definition at line 88 of file missioncampaign.cpp.

char* Campaign_descs[MAX_CAMPAIGNS] = { NULL }

Definition at line 58 of file missioncampaign.cpp.

int Campaign_ending_via_supernova = 0

Definition at line 52 of file missioncampaign.cpp.

int Campaign_file_missing

Definition at line 60 of file missioncampaign.cpp.

char* Campaign_file_names[MAX_CAMPAIGNS] = { NULL }

Definition at line 57 of file missioncampaign.cpp.

LOCAL UI_LISTBOX Campaign_listbox

Definition at line 87 of file missioncampaign.cpp.

int Campaign_load_failure = 0

Definition at line 61 of file missioncampaign.cpp.

char* Campaign_names[MAX_CAMPAIGNS] = { NULL }

Definition at line 56 of file missioncampaign.cpp.

int Campaign_names_inited = 0

Definition at line 62 of file missioncampaign.cpp.

LOCAL UI_BUTTON Campaign_okb

Definition at line 88 of file missioncampaign.cpp.

char* campaign_types[MAX_CAMPAIGN_TYPES]
Initial value:
"multi coop",
"multi teams"

Definition at line 71 of file missioncampaign.cpp.

LOCAL UI_WINDOW Campaign_window

Definition at line 86 of file missioncampaign.cpp.

char Default_campaign_file_name[MAX_FILENAME_LEN-4] = { 0 }

Definition at line 65 of file missioncampaign.cpp.

int Granted_ships[MAX_SHIP_CLASSES]

Definition at line 82 of file missioncampaign.cpp.

int Granted_weapons[MAX_WEAPON_TYPES]

Definition at line 83 of file missioncampaign.cpp.

SCP_vector<SCP_string> Ignored_campaigns

Definition at line 63 of file missioncampaign.cpp.

int Num_campaigns

Definition at line 59 of file missioncampaign.cpp.

int Num_granted_ships

Definition at line 81 of file missioncampaign.cpp.

int Num_granted_weapons

Definition at line 81 of file missioncampaign.cpp.