From fba00332f876166a99e42ca6080cae259228281b Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Wed, 7 Aug 2002 07:34:09 +0000 Subject: [PATCH] recognize .msn mission files. patch from Martin Schaffner --- descent.mn2 => descent.msn | 0 main/mission.c | 79 +++++++++++++++++++++----------------- main/mission.h | 26 +++++++------ 3 files changed, 57 insertions(+), 48 deletions(-) rename descent.mn2 => descent.msn (100%) diff --git a/descent.mn2 b/descent.msn similarity index 100% rename from descent.mn2 rename to descent.msn diff --git a/main/mission.c b/main/mission.c index 4598b951..9033880f 100644 --- a/main/mission.c +++ b/main/mission.c @@ -1,4 +1,4 @@ -/* $Id: mission.c,v 1.5 2002-08-06 05:12:09 btb Exp $ */ +/* $Id: mission.c,v 1.6 2002-08-07 07:34:09 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -285,6 +285,8 @@ int read_mission_file(char *filename,int count,int location) strcpy(temp,filename); if ((t = strchr(temp,'.')) == NULL) return 0; //missing extension + // look if it's .mn2 or .msn + Mission_list[count].descent_version = (t[3] == '2') ? 2 : 1; *t = 0; //kill extension strncpy( Mission_list[count].filename, temp, 9 ); @@ -336,6 +338,24 @@ int read_mission_file(char *filename,int count,int location) } +void add_missions_to_list(char * search_name, int * count, int anarchy_mode) { + FILEFINDSTRUCT find; + if( !FileFindFirst( search_name, &find ) ) { + do { + if (read_mission_file( find.name, *count, ML_MISSIONDIR )) { + + if (anarchy_mode || !Mission_list[*count].anarchy_only_flag) + ++(*count); + } + + } while( !FileFindNext( &find ) && *count < MAX_MISSIONS); + FileFindClose(); + if (*count >= MAX_MISSIONS) + mprintf((0, "Warning: more missions than d2x can handle\n")); + } +} + + //fills in the global list of missions. Returns the number of missions //in the list. If anarchy_mode set, don't include non-anarchy levels. //if there is only one mission, this function will call load_mission on it. @@ -348,8 +368,6 @@ int build_mission_list(int anarchy_mode) { static int num_missions=-1; int count=0,special_count=0; - FILEFINDSTRUCT find; - char search_name[PATH_MAX + 5] = MISSION_DIR "*.mn2"; //now search for levels on disk @@ -370,38 +388,17 @@ int build_mission_list(int anarchy_mode) special_count = count=1; - if( !FileFindFirst( search_name, &find ) ) { - do { - if (stricmp(find.name,BUILTIN_MISSION)==0) - continue; //skip the built-in - - if (read_mission_file(find.name,count,ML_MISSIONDIR)) { - - if (anarchy_mode || !Mission_list[count].anarchy_only_flag) - count++; - } - - } while( !FileFindNext( &find ) && count -#define MAX_MISSIONS 300 -#define MAX_LEVELS_PER_MISSION 30 -#define MAX_SECRET_LEVELS_PER_MISSION 6 -#define MISSION_NAME_LEN 25 +#define MAX_MISSIONS 300 +#define MAX_LEVELS_PER_MISSION 30 +#define MAX_SECRET_LEVELS_PER_MISSION 6 +#define MISSION_NAME_LEN 25 //mission list entry typedef struct mle { - char filename[9]; //path and filename without extension - char mission_name[MISSION_NAME_LEN+1]; - ubyte anarchy_only_flag; //if true, mission is anarchy only - ubyte location; //see defines below + char filename[9]; // path and filename without extension + char mission_name[MISSION_NAME_LEN+1]; + ubyte anarchy_only_flag; // if true, mission is anarchy only + ubyte location; // see defines below + ubyte descent_version; // descent 1 or descent 2? } mle; //values that describe where a mission is located -#define ML_CURDIR 0 -#define ML_MISSIONDIR 1 -#define ML_CDROM 2 +#define ML_CURDIR 0 +#define ML_MISSIONDIR 1 +#define ML_CDROM 2 extern mle Mission_list[MAX_MISSIONS]; -- 2.39.2