Open source remastering of the Freespace 2 engine
missioncampaign.h File Reference
#include "stats/scoring.h"

Go to the source code of this file.


struct  mgoal
struct  mevent
class  cmission
class  campaign
struct  campaign_info


#define BUILTIN_CAMPAIGN   "FreeSpace2"
#define CAMPAIGN_SINGLE_PLAYER_SIG   0xddddeeee
#define CAMPAIGN_MULTI_PLAYER_SIG   0xeeeeffff
#define CMISSION_FLAG_BASTION   (1<<0)
#define CMISSION_FLAG_SKIPPED   (1<<1)
#define CMISSION_FLAG_HAS_LOOP   (1<<2)
#define CMISSION_FLAG_HAS_FORK   (1<<3)
#define CF_DEFAULT_VALUE   0
#define CF_CUSTOM_TECH_DATABASE   (1 << 0)
#define MAX_CAMPAIGNS   128


typedef struct mgoal mgoal
typedef struct mevent mevent
typedef struct campaign_info campaign_info


void player_loadout_init ()
void mission_campaign_init (void)
int mission_campaign_load_by_name (char *filename)
int mission_campaign_load_by_name_csfe (char *filename, char *callsign)
int mission_campaign_load (char *filename, player *pl=NULL, int load_savefile=1, bool reset_stats=true)
int mission_campaign_save (void)
void mission_campaign_savefile_delete (char *cfilename)
void mission_campaign_delete_all_savefiles (char *pilot_name)
int mission_campaign_parse_is_multi (char *filename, char *name)
int mission_campaign_next_mission (void)
void mission_campaign_mission_over (bool do_next_mission=true)
void mission_campaign_clear (void)
int mission_campaign_load_fred (char *filename, char *name_verify=NULL)
void read_mission_goal_list (int num)
void mission_campaign_build_list (bool desc=false, bool sort=true, bool multiplayer=false)
void mission_campaign_free_list ()
int mission_campaign_find_mission (char *name)
void mission_campaign_maybe_play_movie (int type)
void mission_campaign_save_persistent (int type, int index)
void mission_campaign_savefile_generate_root (char *filename, player *pl=NULL)
int mission_campaign_savefile_save ()
int campaign_savefile_save (char *pname)
void campaign_delete_save (char *cfn, char *pname)
void campaign_savefile_load (char *fname, char *pname)
int mission_campaign_get_info (const char *filename, char *name, int *type, int *max_players, char **desc=NULL)
int mission_campaign_get_mission_list (const char *filename, char **list, int max)
int mission_load_up_campaign (player *p=NULL)
void mission_campaign_store_goals_and_events ()
void mission_campaign_store_variables ()
void mission_campaign_store_goals_and_events_and_variables ()
void mission_campaign_eval_next_mission ()
int mission_campaign_previous_mission ()
void mission_campaign_skip_to_next (int start_game=1)
void mission_campaign_exit_loop ()
void mission_campaign_jump_to_mission (char *name, bool no_skip=false)
void mission_campaign_end_init ()
void mission_campaign_end_close ()
void mission_campaign_end_do ()
void mission_campaign_save_player_persistent_variables ()
void mission_campaign_load_failure_popup ()


char * campaign_types [MAX_CAMPAIGN_TYPES]
campaign Campaign
int Campaign_ending_via_supernova
char * Campaign_names [MAX_CAMPAIGNS]
char * Campaign_file_names [MAX_CAMPAIGNS]
char * Campaign_descs [MAX_CAMPAIGNS]
int Num_campaigns
int Campaign_names_inited
SCP_vector< SCP_stringIgnored_campaigns
char Default_campaign_file_name [MAX_FILENAME_LEN-4]
int Campaign_file_missing

Macro Definition Documentation

#define BUILTIN_CAMPAIGN   "FreeSpace2"

Definition at line 20 of file missioncampaign.h.


Definition at line 24 of file missioncampaign.h.


Definition at line 28 of file missioncampaign.h.


Definition at line 26 of file missioncampaign.h.


Definition at line 27 of file missioncampaign.h.


Definition at line 25 of file missioncampaign.h.


Definition at line 58 of file missioncampaign.h.


Definition at line 40 of file missioncampaign.h.

#define CAMPAIGN_MULTI_PLAYER_SIG   0xeeeeffff

Definition at line 44 of file missioncampaign.h.


Definition at line 47 of file missioncampaign.h.


Definition at line 48 of file missioncampaign.h.

#define CAMPAIGN_SINGLE_PLAYER_SIG   0xddddeeee

Definition at line 43 of file missioncampaign.h.


Definition at line 34 of file missioncampaign.h.


Definition at line 35 of file missioncampaign.h.


Definition at line 33 of file missioncampaign.h.

#define CF_CUSTOM_TECH_DATABASE   (1 << 0)

Definition at line 65 of file missioncampaign.h.

#define CF_DEFAULT_VALUE   0

Definition at line 64 of file missioncampaign.h.


Definition at line 41 of file missioncampaign.h.

#define CMISSION_FLAG_BASTION   (1<<0)

Definition at line 52 of file missioncampaign.h.

#define CMISSION_FLAG_HAS_FORK   (1<<3)

Definition at line 56 of file missioncampaign.h.

#define CMISSION_FLAG_HAS_LOOP   (1<<2)

Definition at line 55 of file missioncampaign.h.

#define CMISSION_FLAG_SKIPPED   (1<<1)

Definition at line 54 of file missioncampaign.h.


Definition at line 22 of file missioncampaign.h.


Definition at line 37 of file missioncampaign.h.

#define MAX_CAMPAIGNS   128

Definition at line 157 of file missioncampaign.h.

Typedef Documentation

typedef struct campaign_info campaign_info
typedef struct mevent mevent
typedef struct mgoal mgoal

Function Documentation

void campaign_delete_save ( char *  cfn,
char *  pname 

Definition at line 854 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_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_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_load_fred ( char *  filename,
char *  name_verify = NULL 
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.

int mission_campaign_save ( void  )
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.

int mission_campaign_savefile_save ( )
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 p = NULL)

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.

char* Campaign_descs[MAX_CAMPAIGNS]

Definition at line 58 of file missioncampaign.cpp.

int Campaign_ending_via_supernova

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]

Definition at line 57 of file missioncampaign.cpp.

char* Campaign_names[MAX_CAMPAIGNS]

Definition at line 56 of file missioncampaign.cpp.

int Campaign_names_inited

Definition at line 62 of file missioncampaign.cpp.

char* campaign_types[MAX_CAMPAIGN_TYPES]

Definition at line 71 of file missioncampaign.cpp.

char Default_campaign_file_name[MAX_FILENAME_LEN-4]

Definition at line 65 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.