]> icculus.org git repositories - btb/d2x.git/blob - main/mission.c
comments
[btb/d2x.git] / main / mission.c
1 /* $Id: mission.c,v 1.16 2003-01-06 23:06:18 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Code to handle multiple missions
18  *
19  * Old Log:
20  * Revision 1.4  1995/10/31  10:21:40  allender
21  * no mission support in shareware
22  *
23  * Revision 1.3  1995/10/21  22:53:04  allender
24  * moved missions to data folder
25  *
26  * Revision 1.2  1995/09/13  08:47:29  allender
27  * made to work with Chris' direct stuff
28  *
29  * Revision 1.1  1995/05/16  15:27:48  allender
30  * Initial revision
31  *
32  * Revision 2.9  1995/05/26  16:16:32  john
33  * Split SATURN into define's for requiring cd, using cd, etc.
34  * Also started adding all the Rockwell stuff.
35  *
36  * Revision 2.8  1995/03/20  15:49:31  mike
37  * Remove eof char from comment which confused make depend, causing
38  * no mission.obj: line in makefile.  Pretty stupid tool, huh?
39  *
40  * Revision 2.7  1995/03/20  12:12:11  john
41  * Added ifdef SATURN.
42  *
43  * Revision 2.6  1995/03/15  14:32:49  john
44  * Added code to force the Descent CD-rom in the drive.
45  *
46  * Revision 2.5  1995/03/15  11:41:15  john
47  * Better Saturn CD-ROM support.
48  *
49  * Revision 2.4  1995/03/14  18:24:14  john
50  * Force Destination Saturn to use CD-ROM drive.
51  *
52  * Revision 2.3  1995/03/07  14:19:41  mike
53  * More destination saturn stuff.
54  *
55  * Revision 2.2  1995/03/06  23:09:03  mike
56  * more saturn stuff: make briefings work for saturn mission.
57  *
58  * Revision 2.1  1995/03/06  16:47:48  mike
59  * destination saturn
60  *
61  * Revision 2.0  1995/02/27  11:27:49  john
62  * New version 2.0, which has no anonymous unions, builds with
63  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
64  *
65  * Revision 1.14  1995/02/15  11:30:37  john
66  * Fixed bug with potential mem overwrite on line 160.
67  *
68  * Revision 1.13  1995/02/10  17:53:20  matt
69  * Changed mission name again
70  *
71  * Revision 1.12  1995/02/10  17:35:38  matt
72  * Changed name of built-in mission
73  *
74  * Revision 1.11  1995/02/07  17:13:51  allender
75  * removed return statement in load_mission so that built in mission will
76  * actually set the Current_mission_name and _filename
77  *
78  * Revision 1.10  1995/01/31  01:19:45  matt
79  * Made build_mission_list() sort missions by name
80  *
81  * Revision 1.9  1995/01/30  13:49:58  allender
82  * changed build_mission_list in load_mission_by_name to include
83  * anarchy levels.
84  *
85  * Revision 1.8  1995/01/30  13:03:51  matt
86  * Fixed dumb mistake
87  *
88  * Revision 1.7  1995/01/30  12:55:22  matt
89  * Added vars to point to mission names
90  *
91  * Revision 1.6  1995/01/22  18:57:28  matt
92  * Made player highest level work with missions
93  *
94  * Revision 1.5  1995/01/22  14:13:08  matt
95  * Added flag in mission list for anarchy-only missions
96  *
97  * Revision 1.4  1995/01/21  23:13:12  matt
98  * Made high scores with (not work, really) with loaded missions
99  * Don't give player high score when quit game
100  *
101  * Revision 1.3  1995/01/21  16:27:12  matt
102  * Made endlevel briefing work with missions
103  *
104  * Revision 1.2  1995/01/20  22:47:50  matt
105  * Mission system implemented, though imcompletely
106  *
107  * Revision 1.1  1995/01/20  13:42:19  matt
108  * Initial revision
109  *
110  *
111  */
112
113 #ifdef HAVE_CONFIG_H
114 #include <conf.h>
115 #endif
116
117 #include <stdio.h>
118 #include <stdlib.h>
119 #include <string.h>
120 #include <ctype.h>
121 #include <limits.h>
122
123 #include "pstypes.h"
124 #include "cfile.h"
125
126 #include "strutil.h"
127 #include "inferno.h"
128 #include "mission.h"
129 #include "gameseq.h"
130 #include "titles.h"
131 #include "songs.h"
132 #include "mono.h"
133 #include "error.h"
134 #include "findfile.h"
135 #include "hoard.h"
136
137 mle Mission_list[MAX_MISSIONS];
138
139 int Current_mission_num, Builtin_mission_num;
140 int     N_secret_levels;                //      Made a global by MK for scoring purposes.  August 1, 1995.
141 char *Current_mission_filename,*Current_mission_longname;
142
143 char Builtin_mission_filename[9];
144 int Builtin_mission_hogsize;
145
146 //this stuff should get defined elsewhere
147
148 char Level_names[MAX_LEVELS_PER_MISSION][FILENAME_LEN];
149 char Secret_level_names[MAX_SECRET_LEVELS_PER_MISSION][FILENAME_LEN];
150
151 //where the missions go
152 #ifndef EDITOR
153 #define MISSION_DIR "missions/"
154 #else
155 #define MISSION_DIR "./"
156 #endif
157
158 //
159 //  Special versions of mission routines for shareware
160 //
161
162 int load_mission_shareware(int mission_num)
163 {
164         Current_mission_num = mission_num;
165         Current_mission_filename = Mission_list[mission_num].filename;
166         Current_mission_longname = Mission_list[mission_num].mission_name;
167
168         N_secret_levels = 0;
169
170         Last_level = 3;
171         Last_secret_level = 0;
172
173         switch (Builtin_mission_hogsize) {
174         case MAC_SHARE_MISSION_HOGSIZE:
175                 // mac demo is using the regular hog and rl2 files
176                 strcpy(Level_names[0],"d2leva-1.rl2");
177                 strcpy(Level_names[1],"d2leva-2.rl2");
178                 strcpy(Level_names[2],"d2leva-3.rl2");
179                 break;
180         default:
181                 Int3(); // fall through
182         case SHAREWARE_MISSION_HOGSIZE:
183                 strcpy(Level_names[0],"d2leva-1.sl2");
184                 strcpy(Level_names[1],"d2leva-2.sl2");
185                 strcpy(Level_names[2],"d2leva-3.sl2");
186         }
187
188         return 1;
189 }
190
191
192 //
193 //  Special versions of mission routines for Diamond/S3 version
194 //
195
196 int load_mission_oem(int mission_num)
197 {
198         Current_mission_num = mission_num;
199         Current_mission_filename = Mission_list[mission_num].filename;
200         Current_mission_longname = Mission_list[mission_num].mission_name;
201
202         N_secret_levels = 2;
203
204         Last_level = 8;
205         Last_secret_level = -2;
206
207         strcpy(Level_names[0],"d2leva-1.rl2");
208         strcpy(Level_names[1],"d2leva-2.rl2");
209         strcpy(Level_names[2],"d2leva-3.rl2");
210         strcpy(Level_names[3],"d2leva-4.rl2");
211
212         strcpy(Secret_level_names[0],"d2leva-s.rl2");
213
214         strcpy(Level_names[4],"d2levb-1.rl2");
215         strcpy(Level_names[5],"d2levb-2.rl2");
216         strcpy(Level_names[6],"d2levb-3.rl2");
217         strcpy(Level_names[7],"d2levb-4.rl2");
218
219         strcpy(Secret_level_names[1],"d2levb-s.rl2");
220
221         Secret_level_table[0] = 1;
222         Secret_level_table[1] = 5;
223
224         return 1;
225 }
226
227
228 //strips damn newline from end of line
229 char *mfgets(char *s,int n,CFILE *f)
230 {
231         char *r;
232
233         r = cfgets(s,n,f);
234         if (r && s[strlen(s)-1] == '\n')
235                 s[strlen(s)-1] = 0;
236
237         return r;
238 }
239
240 //compare a string for a token. returns true if match
241 int istok(char *buf,char *tok)
242 {
243         return strnicmp(buf,tok,strlen(tok)) == 0;
244
245 }
246
247 //adds a terminating 0 after a string at the first white space
248 void add_term(char *s)
249 {
250         while (*s && !isspace(*s)) s++;
251
252         *s = 0;         //terminate!
253 }
254
255 //returns ptr to string after '=' & white space, or NULL if no '='
256 //adds 0 after parm at first white space
257 char *get_value(char *buf)
258 {
259         char *t;
260
261         t = strchr(buf,'=')+1;
262
263         if (t) {
264                 while (*t && isspace(*t)) t++;
265
266                 if (*t)
267                         return t;
268         }
269
270         return NULL;            //error!
271 }
272
273 //reads a line, returns ptr to value of passed parm.  returns NULL if none
274 char *get_parm_value(char *parm,CFILE *f)
275 {
276         static char buf[80];
277
278         if (!mfgets(buf,80,f))
279                 return NULL;
280
281         if (istok(buf,parm))
282                 return get_value(buf);
283         else
284                 return NULL;
285 }
286
287 int ml_sort_func(mle *e0,mle *e1)
288 {
289         return stricmp(e0->mission_name,e1->mission_name);
290
291 }
292
293 extern char CDROM_dir[];
294
295 //returns 1 if file read ok, else 0
296 int read_mission_file(char *filename,int count,int location)
297 {
298         char filename2[100];
299         CFILE *mfile;
300
301         //printf("reading: %s\n", filename);
302
303         switch (location) {
304                 case ML_MISSIONDIR:
305                         strcpy(filename2,MISSION_DIR);
306                         break;
307
308                 case ML_CDROM:
309                         songs_stop_redbook();           //so we can read from the CD
310                         strcpy(filename2,CDROM_dir);
311                         break;
312
313                 default:
314                         Int3();         //fall through
315
316                 case ML_CURDIR:
317                         strcpy(filename2,"");
318                         break;
319         }
320         strcat(filename2,filename);
321
322         mfile = cfopen(filename2,"rb");
323
324         if (mfile) {
325                 char *p;
326                 char temp[FILENAME_LEN],*t;
327
328                 strcpy(temp,filename);
329                 if ((t = strchr(temp,'.')) == NULL)
330                         return 0;       //missing extension
331                 // look if it's .mn2 or .msn
332                 Mission_list[count].descent_version = (t[3] == '2') ? 2 : 1;
333                 *t = 0;                 //kill extension
334
335                 strncpy( Mission_list[count].filename, temp, 9 );
336                 Mission_list[count].anarchy_only_flag = 0;
337                 Mission_list[count].location = location;
338
339                 p = get_parm_value("name",mfile);
340
341                 if (!p) {               //try enhanced mission
342                         cfseek(mfile,0,SEEK_SET);
343                         p = get_parm_value("xname",mfile);
344                 }
345
346                 if (HoardEquipped())
347                 {
348                         if (!p) {               //try super-enhanced mission!
349                                 cfseek(mfile,0,SEEK_SET);
350                                 p = get_parm_value("zname",mfile);
351                         }
352                 }
353
354                 if (p) {
355                         char *t;
356                         if ((t=strchr(p,';'))!=NULL)
357                                 *t=0;
358                         t = p + strlen(p)-1;
359                         while (isspace(*t)) t--;
360                         strncpy(Mission_list[count].mission_name,p,MISSION_NAME_LEN);
361                 }
362                 else {
363                         cfclose(mfile);
364                         return 0;
365                 }
366
367                 p = get_parm_value("type",mfile);
368
369                 //get mission type
370                 if (p)
371                         Mission_list[count].anarchy_only_flag = istok(p,"anarchy");
372
373                 cfclose(mfile);
374
375                 return 1;
376         }
377
378         return 0;
379 }
380
381 void add_builtin_mission_to_list(int *count)
382 {
383         Builtin_mission_hogsize = cfile_size("descent2.hog");
384         if (Builtin_mission_hogsize == -1)
385                 Builtin_mission_hogsize = cfile_size("d2demo.hog");
386
387         switch (Builtin_mission_hogsize) {
388         case SHAREWARE_MISSION_HOGSIZE:
389         case MAC_SHARE_MISSION_HOGSIZE:
390                 strcpy(Mission_list[*count].filename,SHAREWARE_MISSION_FILENAME);
391                 strcpy(Mission_list[*count].mission_name,SHAREWARE_MISSION_NAME);
392                 Mission_list[*count].anarchy_only_flag = 0;
393                 break;
394         case OEM_MISSION_HOGSIZE:
395                 strcpy(Mission_list[*count].filename,OEM_MISSION_FILENAME);
396                 strcpy(Mission_list[*count].mission_name,OEM_MISSION_NAME);
397                 Mission_list[*count].anarchy_only_flag = 0;
398                 break;
399         default:
400                 Warning("Unknown hogsize %d, trying %s\n", Builtin_mission_hogsize, FULL_MISSION_FILENAME ".mn2");
401                 Int3(); //fall through
402         case FULL_MISSION_HOGSIZE:
403                 if (!read_mission_file(FULL_MISSION_FILENAME ".mn2", 0, ML_CURDIR))
404                         Error("Could not find required mission file <%s>", FULL_MISSION_FILENAME ".mn2");
405         }
406
407         strcpy(Builtin_mission_filename, Mission_list[*count].filename);
408         Mission_list[*count].descent_version = 2;
409         Mission_list[*count].anarchy_only_flag = 0;
410         ++(*count);
411 }
412
413
414 void add_missions_to_list(char *search_name, int *count, int anarchy_mode)
415 {
416         FILEFINDSTRUCT find;
417         if( !FileFindFirst( search_name, &find ) ) {
418                 do      {
419                         if (read_mission_file( find.name, *count, ML_MISSIONDIR )) {
420
421                                 if (anarchy_mode || !Mission_list[*count].anarchy_only_flag)
422                                         ++(*count);
423                         }
424
425                 } while( !FileFindNext( &find ) && *count < MAX_MISSIONS);
426                 FileFindClose();
427                 if (*count >= MAX_MISSIONS)
428                         mprintf((0, "Warning: more missions than d2x can handle\n"));
429         }
430 }
431
432 /* move <mission_name> to <place> on mission list, increment <place> */
433 void promote (char * mission_name, int * top_place, int num_missions)
434 {
435         int i;
436         char name[FILENAME_LEN], * t;
437         strcpy(name, mission_name);
438         if ((t = strchr(name,'.')) != NULL)
439                 *t = 0; //kill extension
440         //printf("promoting: %s\n", name);
441         for (i = *top_place; i < num_missions; i++)
442                 if (!stricmp(Mission_list[i].filename, name)) {
443                         //swap mission positions
444                         mle temp;
445
446                         temp = Mission_list[*top_place];
447                         Mission_list[*top_place] = Mission_list[i];
448                         Mission_list[i] = temp;
449                         ++(*top_place);
450                         break;
451                 }
452 }
453
454
455
456 //fills in the global list of missions.  Returns the number of missions
457 //in the list.  If anarchy_mode set, don't include non-anarchy levels.
458
459 extern char CDROM_dir[];
460 extern char AltHogDir[];
461 extern char AltHogdir_initialized;
462
463 int build_mission_list(int anarchy_mode)
464 {
465         static int num_missions=-1;
466         int count = 0;
467         int top_place;
468
469         //now search for levels on disk
470
471 //@@Took out this code because after this routine was called once for
472 //@@a list of single-player missions, a subsequent call for a list of
473 //@@anarchy missions would not scan again, and thus would not find the
474 //@@anarchy-only missions.  If we retain the minimum level of install,
475 //@@we may want to put the code back in, having it always scan for all
476 //@@missions, and have the code that uses it sort out the ones it wants.
477 //@@    if (num_missions != -1) {
478 //@@            if (Current_mission_num != 0)
479 //@@                    load_mission(0);                                //set built-in mission as default
480 //@@            return num_missions;
481 //@@    }
482
483         add_builtin_mission_to_list(&count);  //read built-in first
484         add_missions_to_list(MISSION_DIR "*.mn2", &count, anarchy_mode);
485         add_missions_to_list(MISSION_DIR "*.msn", &count, anarchy_mode);
486
487         if (AltHogdir_initialized) {
488                 char search_name[PATH_MAX + 5];
489                 strcpy(search_name, AltHogDir);
490                 strcat(search_name, "/" MISSION_DIR "*.mn2");
491                 add_missions_to_list(search_name, &count, anarchy_mode);
492                 strcpy(search_name, AltHogDir);
493                 strcat(search_name, "/" MISSION_DIR "*.msn");
494                 add_missions_to_list(search_name, &count, anarchy_mode);
495         }
496
497         // move original missions (in story-chronological order)
498         // to top of mission list
499         top_place = 0;
500         promote("descent", &top_place, count); // original descent 1 mission
501         promote(Builtin_mission_filename, &top_place, count); // d2 or d2demo
502         Builtin_mission_num = top_place - 1;
503         promote("d2x", &top_place, count); // vertigo
504
505         if (count > top_place)
506                 qsort(&Mission_list[top_place],
507                       count - top_place,
508                       sizeof(*Mission_list),
509                                 (int (*)( const void *, const void * ))ml_sort_func);
510
511
512         if (count > top_place)
513                 qsort(&Mission_list[top_place],
514                       count - top_place,
515                       sizeof(*Mission_list),
516                       (int (*)( const void *, const void * ))ml_sort_func);
517
518         //load_mission(0);   //set built-in mission as default
519
520         num_missions = count;
521
522         return count;
523 }
524
525 void init_extra_robot_movie(char *filename);
526
527 //values for built-in mission
528
529 //loads the specfied mission from the mission list.
530 //build_mission_list() must have been called.
531 //Returns true if mission loaded ok, else false.
532 int load_mission(int mission_num)
533 {
534         CFILE *mfile;
535         char buf[80], *v;
536         int found_hogfile;
537         int enhanced_mission = 0;
538
539         if (mission_num == Builtin_mission_num) {
540                 switch (Builtin_mission_hogsize) {
541                 case SHAREWARE_MISSION_HOGSIZE:
542                 case MAC_SHARE_MISSION_HOGSIZE:
543                         return load_mission_shareware(mission_num);
544                         break;
545                 case OEM_MISSION_HOGSIZE:
546                         return load_mission_oem(mission_num);
547                         break;
548                 case FULL_MISSION_HOGSIZE:
549                 default:
550                         // continue on...
551                 }
552         }
553
554         Current_mission_num = mission_num;
555
556         mprintf(( 0, "Loading mission %d\n", mission_num ));
557
558         //read mission from file
559
560         switch (Mission_list[mission_num].location) {
561         case ML_MISSIONDIR:
562                 strcpy(buf,MISSION_DIR);
563                 break;
564         case ML_CDROM:
565                 strcpy(buf,CDROM_dir);
566                 break;
567         default:
568                 Int3();                                                 //fall through
569         case ML_CURDIR:
570                 strcpy(buf,"");
571                 break;
572         }
573         strcat(buf,Mission_list[mission_num].filename);
574         if (Mission_list[mission_num].descent_version == 2)
575                 strcat(buf,".mn2");
576         else
577                 strcat(buf,".msn");
578
579         mfile = cfopen(buf,"rb");
580         if (mfile == NULL) {
581                 Current_mission_num = -1;
582                 return 0;               //error!
583         }
584
585         //for non-builtin missions, load HOG
586         if (strcmp(Mission_list[mission_num].filename, Builtin_mission_filename)) {
587
588                 strcpy(buf+strlen(buf)-4,".hog");               //change extension
589
590                 found_hogfile = cfile_use_alternate_hogfile(buf);
591
592                 #ifdef RELEASE                          //for release, require mission to be in hogfile
593                 if (! found_hogfile) {
594                         cfclose(mfile);
595                         Current_mission_num = -1;
596                         return 0;
597                 }
598                 #endif
599
600                 // for Descent 1 missions, load descent.hog
601                 if (Mission_list[mission_num].descent_version == 1 && strcmp(buf, "descent.hog"))
602                         if (!cfile_use_descent1_hogfile("descent.hog"))
603                                 Warning("descent.hog not available, this mission may be missing some files required for briefings\n");
604         }
605
606         //init vars
607         Last_level = 0;
608         Last_secret_level = 0;
609         Briefing_text_filename[0] = 0;
610         Ending_text_filename[0] = 0;
611
612         while (mfgets(buf,80,mfile)) {
613
614                 if (istok(buf,"name"))
615                         continue;                                               //already have name, go to next line
616                 if (istok(buf,"xname")) {
617                         enhanced_mission = 1;
618                         continue;                                               //already have name, go to next line
619                 }
620                 if (istok(buf,"zname")) {
621                         enhanced_mission = 2;
622                         continue;                                               //already have name, go to next line
623                 }
624                 else if (istok(buf,"type"))
625                         continue;                                               //already have name, go to next line
626                 else if (istok(buf,"hog")) {
627                         char    *bufp = buf;
628
629                         while (*(bufp++) != '=')
630                                 ;
631
632                         if (*bufp == ' ')
633                                 while (*(++bufp) == ' ')
634                                         ;
635
636                         cfile_use_alternate_hogfile(bufp);
637                         mprintf((0, "Hog file override = [%s]\n", bufp));
638                 }
639                 else if (istok(buf,"briefing")) {
640                         if ((v = get_value(buf)) != NULL) {
641                                 add_term(v);
642                                 if (strlen(v) < 13)
643                                         strcpy(Briefing_text_filename,v);
644                         }
645                 }
646                 else if (istok(buf,"ending")) {
647                         if ((v = get_value(buf)) != NULL) {
648                                 add_term(v);
649                                 if (strlen(v) < 13)
650                                         strcpy(Ending_text_filename,v);
651                         }
652                 }
653                 else if (istok(buf,"num_levels")) {
654
655                         if ((v=get_value(buf))!=NULL) {
656                                 int n_levels,i;
657
658                                 n_levels = atoi(v);
659
660                                 for (i=0;i<n_levels && mfgets(buf,80,mfile);i++) {
661
662                                         add_term(buf);
663                                         if (strlen(buf) <= 12) {
664                                                 strcpy(Level_names[i],buf);
665                                                 Last_level++;
666                                         }
667                                         else
668                                                 break;
669                                 }
670
671                         }
672                 }
673                 else if (istok(buf,"num_secrets")) {
674                         if ((v=get_value(buf))!=NULL) {
675                                 int i;
676
677                                 N_secret_levels = atoi(v);
678
679                                 Assert(N_secret_levels <= MAX_SECRET_LEVELS_PER_MISSION);
680
681                                 for (i=0;i<N_secret_levels && mfgets(buf,80,mfile);i++) {
682                                         char *t;
683
684                                         
685                                         if ((t=strchr(buf,','))!=NULL) *t++=0;
686                                         else
687                                                 break;
688
689                                         add_term(buf);
690                                         if (strlen(buf) <= 12) {
691                                                 strcpy(Secret_level_names[i],buf);
692                                                 Secret_level_table[i] = atoi(t);
693                                                 if (Secret_level_table[i]<1 || Secret_level_table[i]>Last_level)
694                                                         break;
695                                                 Last_secret_level--;
696                                         }
697                                         else
698                                                 break;
699                                 }
700
701                         }
702                 }
703
704         }
705
706         cfclose(mfile);
707
708         if (Last_level <= 0) {
709                 Current_mission_num = -1;               //no valid mission loaded
710                 return 0;
711         }
712
713         Current_mission_filename = Mission_list[Current_mission_num].filename;
714         Current_mission_longname = Mission_list[Current_mission_num].mission_name;
715
716         if (enhanced_mission) {
717                 char t[50];
718                 extern void bm_read_extra_robots();
719                 sprintf(t,"%s.ham",Current_mission_filename);
720                 bm_read_extra_robots(t,enhanced_mission);
721                 strncpy(t,Current_mission_filename,6);
722                 strcat(t,"-l.mvl");
723                 init_extra_robot_movie(t);
724         }
725
726         return 1;
727 }
728
729 //loads the named mission if exists.
730 //Returns true if mission loaded ok, else false.
731 int load_mission_by_name(char *mission_name)
732 {
733         int n,i;
734
735         n = build_mission_list(1);
736
737         for (i=0;i<n;i++)
738                 if (!stricmp(mission_name,Mission_list[i].filename))
739                         return load_mission(i);
740
741         return 0;               //couldn't find mission
742 }