2006-03-20 17:12:09 +00:00
|
|
|
/*
|
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* inferno.c: Entry point of program (main procedure)
|
|
|
|
*
|
|
|
|
* After main initializes everything, most of the time is spent in the loop
|
|
|
|
* while (Function_mode != FMODE_EXIT)
|
|
|
|
* In this loop, the main menu is brought up first.
|
|
|
|
*
|
|
|
|
* main() for Inferno
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <conf.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPORATION";
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#ifdef __unix__
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
2007-04-09 02:41:45 +00:00
|
|
|
#if !(defined(__APPLE__) && defined(__MACH__))
|
2006-03-20 17:12:09 +00:00
|
|
|
#include <physfs.h>
|
2007-04-09 02:41:45 +00:00
|
|
|
#else
|
|
|
|
#include <physfs/physfs.h>
|
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
#include "pstypes.h"
|
|
|
|
#include "strutil.h"
|
|
|
|
#include "console.h"
|
|
|
|
#include "gr.h"
|
|
|
|
#include "fix.h"
|
|
|
|
#include "vecmat.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "3d.h"
|
|
|
|
#include "bm.h"
|
|
|
|
#include "inferno.h"
|
|
|
|
#include "error.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "segment.h" //for Side_to_verts
|
|
|
|
#include "u_mem.h"
|
|
|
|
#include "segpoint.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "texmap.h"
|
|
|
|
#include "texmerge.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "wall.h"
|
|
|
|
#include "polyobj.h"
|
|
|
|
#include "effects.h"
|
|
|
|
#include "digi.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "args.h"
|
|
|
|
#include "sounds.h"
|
|
|
|
#include "titles.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "text.h"
|
2007-12-29 14:18:49 +00:00
|
|
|
#include "gauges.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#ifdef NETWORK
|
|
|
|
#include "network.h"
|
|
|
|
#endif
|
|
|
|
#include "gamefont.h"
|
|
|
|
#include "kconfig.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "newmenu.h"
|
|
|
|
#include "desc_id.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "multi.h"
|
|
|
|
#include "songs.h"
|
|
|
|
#include "cfile.h"
|
|
|
|
#include "gameseq.h"
|
|
|
|
#include "gamepal.h"
|
|
|
|
#include "mission.h"
|
|
|
|
#include "movie.h"
|
2006-10-21 09:23:52 +00:00
|
|
|
#include "playsave.h"
|
2007-02-10 23:19:21 +00:00
|
|
|
#include "collide.h"
|
2007-04-04 10:24:03 +00:00
|
|
|
#include "newdemo.h"
|
2007-07-14 22:36:04 +00:00
|
|
|
#include "joy.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "../texmap/scanline.h" //for select_tmap -MM
|
|
|
|
|
|
|
|
#ifdef EDITOR
|
|
|
|
#include "editor/editor.h"
|
|
|
|
#include "editor/kdefs.h"
|
|
|
|
#include "ui.h"
|
|
|
|
#endif
|
|
|
|
|
2007-04-09 02:41:45 +00:00
|
|
|
#include <SDL/SDL.h>
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
#include "vers_id.h"
|
|
|
|
|
|
|
|
void mem_init(void);
|
|
|
|
|
|
|
|
//Current version number
|
|
|
|
|
|
|
|
ubyte Version_major = 1; //FULL VERSION
|
|
|
|
ubyte Version_minor = 2;
|
|
|
|
|
|
|
|
//static const char desc_id_checksum_str[] = DESC_ID_CHKSUM_TAG "0000"; // 4-byte checksum
|
|
|
|
char desc_id_exit_num = 0;
|
|
|
|
|
|
|
|
int Function_mode=FMODE_MENU; //game or editor?
|
|
|
|
int Screen_mode=-1; //game screen or editor screen?
|
|
|
|
|
|
|
|
void show_order_form(void);
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int descent_critical_error = 0;
|
|
|
|
unsigned descent_critical_deverror = 0;
|
|
|
|
unsigned descent_critical_errcode = 0;
|
|
|
|
|
|
|
|
extern int Network_allow_socket_changes;
|
2007-10-30 00:01:55 +00:00
|
|
|
extern void piggy_init_pigfile(char *filename);
|
2008-11-14 16:56:40 +00:00
|
|
|
extern void arch_init(void);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
#define LINE_LEN 100
|
|
|
|
|
|
|
|
//read help from a file & print to screen
|
|
|
|
void print_commandline_help()
|
|
|
|
{
|
2006-10-18 12:53:34 +00:00
|
|
|
printf( "\n System Options:\n\n");
|
2007-07-14 20:33:42 +00:00
|
|
|
printf( " -fps %s\n", "Enable FPS indicator by default");
|
2008-04-21 18:39:49 +00:00
|
|
|
printf( " -nonicefps %s\n", "Don't free CPU-cycles");
|
2008-09-30 00:07:07 +00:00
|
|
|
printf( " -maxfps <n> %s\n", "Set maximum framerate (1-200)");
|
2007-07-15 21:22:07 +00:00
|
|
|
printf( " -hogdir <s> %s\n", "set shared data directory to <dir>");
|
2006-10-18 12:53:34 +00:00
|
|
|
printf( " -nohogdir %s\n", "don't try to use shared data directory");
|
2007-05-21 11:24:27 +00:00
|
|
|
printf( " -use_players_dir %s\n", "put player files and saved games in Players subdirectory");
|
2006-10-18 12:53:34 +00:00
|
|
|
printf( " -lowmem %s\n", "Lowers animation detail for better performance with low memory");
|
2007-03-31 21:00:47 +00:00
|
|
|
printf( " -legacyhomers %s\n", "Activate original homing missiles (FPS and physics dependent)");
|
2007-07-15 21:22:07 +00:00
|
|
|
printf( " -pilot <s> %s\n", "Select this pilot automatically");
|
2007-07-14 20:33:42 +00:00
|
|
|
printf( " -autodemo %s\n", "Start in demo mode");
|
2007-10-01 20:42:35 +00:00
|
|
|
printf( " -window %s\n", "Run the game in a window");
|
|
|
|
printf( " -nomovies %s\n", "Don't play movies");
|
2008-06-01 12:53:03 +00:00
|
|
|
printf( " -noredundancy %s\n", "Do not send messages when picking up redundant items");
|
2006-10-18 12:53:34 +00:00
|
|
|
|
|
|
|
printf( "\n Controls:\n\n");
|
2007-07-14 22:36:04 +00:00
|
|
|
printf( " -nomouse %s\n", "Deactivate mouse");
|
|
|
|
printf( " -nojoystick %s\n", "Deactivate joystick");
|
2006-10-18 12:53:34 +00:00
|
|
|
printf( " -mouselook %s\n", "Activate mouselook. Works in singleplayer only");
|
|
|
|
printf( " -grabmouse %s\n", "Keeps the mouse from wandering out of the window");
|
|
|
|
|
|
|
|
printf( "\n Sound:\n\n");
|
2007-07-14 22:36:04 +00:00
|
|
|
printf( " -nosound %s\n", "Disables sound output");
|
|
|
|
printf( " -nomusic %s\n", "Disables music output");
|
|
|
|
printf( " -sound11k %s\n", "Use 11KHz sounds");
|
2007-10-13 23:52:17 +00:00
|
|
|
#ifdef USE_SDLMIXER
|
2008-05-01 21:40:34 +00:00
|
|
|
printf( " -nosdlmixer %s\n", "Disable Sound output via SDL_mixer");
|
2007-10-13 23:52:17 +00:00
|
|
|
printf( " -music_ext <s> %s\n", "Play music files with extension <s> (i.e. mp3, ogg)");
|
|
|
|
#endif // USE SDLMIXER
|
2006-10-18 12:53:34 +00:00
|
|
|
|
|
|
|
printf( "\n Graphics:\n\n");
|
2008-02-24 14:41:27 +00:00
|
|
|
printf( " -lowresfont %s\n", "Force to use LowRes fonts");
|
|
|
|
printf( " -lowresgraphics %s\n", "Force to use LowRes graphics");
|
2007-07-15 21:55:00 +00:00
|
|
|
printf( " -lowresmovies %s\n", "Play low resolution movies if available (for slow machines)");
|
|
|
|
printf( " -subtitles %s\n", "Turn on movie subtitles");
|
2006-10-18 12:53:34 +00:00
|
|
|
#ifdef OGL
|
2007-10-18 14:44:02 +00:00
|
|
|
printf( " -gl_fixedfont %s\n", "Do not scale fonts to current resolution");
|
2006-10-18 12:53:34 +00:00
|
|
|
#endif // OGL
|
|
|
|
|
|
|
|
#ifdef NETWORK
|
|
|
|
printf( "\n Multiplayer:\n\n");
|
2007-09-20 14:22:57 +00:00
|
|
|
printf( " -mprofile %s\n", "Enable multiplayer game profiles");
|
2006-10-18 12:53:34 +00:00
|
|
|
printf( " -norankings %s\n", "Disable multiplayer ranking system");
|
2007-07-16 02:34:51 +00:00
|
|
|
printf( " -playermessages %s\n", "View only messages from other players in multi - overrides -noredundancy");
|
|
|
|
printf( " -ipxnetwork <n> %s\n", "Use IPX network number <n>");
|
2007-12-17 22:45:45 +00:00
|
|
|
printf( " -ip_baseport <n> %s\n", "Use <n> as offset from normal port (allows multiple instances of d1x to be run on a single computer)");
|
2008-05-07 14:02:01 +00:00
|
|
|
printf( " -ip_relay %s\n", "Relay players with closed port over host (increases traffic and lag)");
|
2008-10-20 12:34:45 +00:00
|
|
|
printf( " -ip_hostaddr <n> %s\n", "Use <n> as host ip address");
|
2006-10-18 12:53:34 +00:00
|
|
|
#endif // NETWORK
|
|
|
|
|
|
|
|
#ifdef EDITOR
|
|
|
|
printf( "\n Editor:\n\n");
|
2007-07-18 20:13:17 +00:00
|
|
|
printf( " -autoload <s> %s\n", "Autoload a level in the editor");
|
2007-07-14 22:36:04 +00:00
|
|
|
printf( " -macdata %s\n", "Read and write mac data files in editor (swap colors)");
|
|
|
|
printf( " -hoarddata %s\n", "Make the hoard ham file from some files, then exit");
|
2006-10-18 12:53:34 +00:00
|
|
|
#endif // EDITOR
|
|
|
|
|
2008-10-30 10:45:13 +00:00
|
|
|
printf( "\n Debug (use only if you know what you're doing):\n\n");
|
2007-07-18 20:13:17 +00:00
|
|
|
printf( " -debug %s\n", "Enable very verbose output");
|
|
|
|
printf( " -verbose %s\n", "Shows initialization steps for tech support");
|
|
|
|
printf( " -norun %s\n", "Bail out after initialization");
|
|
|
|
printf( " -renderstats %s\n", "Enable renderstats info by default");
|
|
|
|
printf( " -text <s> %s\n", "Specify alternate .tex file");
|
|
|
|
printf( " -tmap <s> %s\n", "Select texmapper to use (c,fp,quad,i386,pent,ppro)");
|
2007-07-18 22:23:06 +00:00
|
|
|
printf( " -showmeminfo %s\n", "Show memory statistics");
|
2007-07-22 01:34:00 +00:00
|
|
|
printf( " -nodoublebuffer %s\n", "Disable Doublebuffering");
|
2007-07-22 20:40:39 +00:00
|
|
|
printf( " -bigpig %s\n", "Use uncompressed RLE bitmaps");
|
2007-07-18 20:13:17 +00:00
|
|
|
#ifdef OGL
|
|
|
|
printf( " -gl_oldtexmerge %s\n", "Use old texmerge, uses more ram, but _might_ be a bit faster");
|
2007-07-22 20:40:39 +00:00
|
|
|
printf( " -gl_16bpp %s\n", "Use 16Bpp Color Depth");
|
2007-07-23 18:13:49 +00:00
|
|
|
printf( " -gl_intensity4_ok <n> %s\n", "Override DbgGlIntensity4Ok - Default: 1");
|
|
|
|
printf( " -gl_luminance4_alpha4_ok <n> %s\n", "Override DbgGlLuminance4Alpha4Ok - Default: 1");
|
|
|
|
printf( " -gl_rgba2_ok <n> %s\n", "Override DbgGlRGBA2Ok - Default: 1");
|
|
|
|
printf( " -gl_readpixels_ok <n> %s\n", "Override DbgGlReadPixelsOk - Default: 1");
|
|
|
|
printf( " -gl_gettexlevelparam_ok <n> %s\n", "Override DbgGlGetTexLevelParamOk - Default: 1");
|
|
|
|
#else
|
2008-10-30 10:45:13 +00:00
|
|
|
printf( " -hwsurface %s\n", "Use SDL HW Surface");
|
2008-10-28 17:04:35 +00:00
|
|
|
printf( " -asyncblit %s\n", "Use queued blits over SDL. Can speed up rendering");
|
2007-07-18 20:13:17 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
printf( "\n Help:\n\n");
|
2006-10-18 12:53:34 +00:00
|
|
|
printf( " -help, -h, -?, ? %s\n", "View this help screen");
|
|
|
|
printf( "\n\n");
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2008-04-08 12:51:21 +00:00
|
|
|
void error_messagebox(char *s)
|
|
|
|
{
|
|
|
|
nm_messagebox( TXT_SORRY, 1, TXT_OK, s );
|
|
|
|
}
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
#define PROGNAME argv[0]
|
|
|
|
|
|
|
|
extern char Language[];
|
|
|
|
|
|
|
|
int Inferno_verbose = 0;
|
|
|
|
|
|
|
|
// DESCENT II by Parallax Software
|
|
|
|
// Descent Main
|
|
|
|
|
|
|
|
//extern ubyte gr_current_pal[];
|
|
|
|
|
|
|
|
#ifdef EDITOR
|
|
|
|
char Auto_file[128] = "";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
mem_init();
|
|
|
|
error_init(NULL, NULL);
|
2006-10-02 13:55:58 +00:00
|
|
|
PHYSFSX_init(argc, argv);
|
2008-04-06 20:23:28 +00:00
|
|
|
con_init(); // Initialise the console
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2008-05-01 21:40:34 +00:00
|
|
|
con_printf (CON_VERBOSE, "%s", TXT_VERBOSE_1);
|
|
|
|
ReadConfigFile();
|
|
|
|
|
2007-07-26 23:57:29 +00:00
|
|
|
if (! cfile_init("descent2.hog", 1)) {
|
2007-05-27 02:24:00 +00:00
|
|
|
if (! cfile_init("d2demo.hog", 1))
|
2007-07-26 23:57:29 +00:00
|
|
|
{
|
2006-12-31 00:09:49 +00:00
|
|
|
Error("Could not find a valid hog file (descent2.hog or d2demo.hog)\nPossible locations are:\n"
|
2008-01-19 00:55:54 +00:00
|
|
|
#if defined(__unix__) && !defined(__APPLE__)
|
2006-10-02 12:53:08 +00:00
|
|
|
"\t$HOME/.d2x-rebirth\n"
|
2006-03-20 17:12:09 +00:00
|
|
|
"\t" SHAREPATH "\n"
|
|
|
|
#else
|
2008-01-19 00:55:54 +00:00
|
|
|
"\tDirectory containing D2X\n"
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif
|
2008-01-19 00:55:54 +00:00
|
|
|
"\tIn a subdirectory called 'Data'\n"
|
2006-03-20 17:12:09 +00:00
|
|
|
"Or use the -hogdir option to specify an alternate location.");
|
2007-07-26 23:57:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
load_text();
|
|
|
|
|
|
|
|
//print out the banner title
|
|
|
|
con_printf(CON_NORMAL, "\nDESCENT 2 %s v%d.%d",VERSION_TYPE,Version_major,Version_minor);
|
2006-12-26 03:42:13 +00:00
|
|
|
#if 1 //def VERSION_NAME
|
|
|
|
con_printf(CON_NORMAL, " %s", DESCENT_VERSION); // D2X version
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif
|
2007-03-22 11:32:22 +00:00
|
|
|
if (cfexist(MISSION_DIR "d2x.hog")) {
|
2006-03-20 17:12:09 +00:00
|
|
|
con_printf(CON_NORMAL, " Vertigo Enhanced");
|
2007-03-22 11:32:22 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
con_printf(CON_NORMAL, " %s %s\n", __DATE__,__TIME__);
|
|
|
|
con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
|
|
|
|
con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2. Copyright (c) 1999 Peter Hawkins\n");
|
|
|
|
con_printf(CON_NORMAL, " Copyright (c) 2002 Bradley Bell\n");
|
2006-12-26 03:42:13 +00:00
|
|
|
con_printf(CON_NORMAL, " Copyright (c) 2005 Christian Beckhaeuser\n");
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
|
2007-07-18 20:13:17 +00:00
|
|
|
if (GameArg.SysShowCmdHelp) {
|
2006-03-20 17:12:09 +00:00
|
|
|
print_commandline_help();
|
|
|
|
set_exit_message("");
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2008-04-06 20:23:28 +00:00
|
|
|
printf("\n");
|
|
|
|
printf(TXT_HELP, PROGNAME); //help message has %s for program name
|
|
|
|
printf("\n");
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
char **i, **list;
|
|
|
|
|
2006-12-31 00:00:44 +00:00
|
|
|
list = PHYSFS_getSearchPath();
|
|
|
|
for (i = list; *i != NULL; i++)
|
2006-03-20 17:12:09 +00:00
|
|
|
con_printf(CON_VERBOSE, "PHYSFS: [%s] is in the search path.\n", *i);
|
2006-12-31 00:00:44 +00:00
|
|
|
PHYSFS_freeList(list);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
list = PHYSFS_enumerateFiles("");
|
|
|
|
for (i = list; *i != NULL; i++)
|
|
|
|
con_printf(CON_DEBUG, "PHYSFS: * We've got [%s].\n", *i);
|
|
|
|
PHYSFS_freeList(list);
|
|
|
|
}
|
|
|
|
|
2008-11-14 16:56:40 +00:00
|
|
|
arch_init();
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2008-04-06 20:23:28 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
freopen( "CON", "w", stdout );
|
|
|
|
freopen( "CON", "w", stderr );
|
|
|
|
#endif
|
|
|
|
|
2007-07-18 20:13:17 +00:00
|
|
|
select_tmap(GameArg.DbgTexMap);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
Lighting_on = 1;
|
|
|
|
|
2007-08-16 09:16:53 +00:00
|
|
|
con_printf(CON_VERBOSE, "Going into graphics mode...\n");
|
|
|
|
gr_set_mode(Game_screen_mode);
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
// Load the palette stuff. Returns non-zero if error.
|
|
|
|
con_printf(CON_DEBUG, "Initializing palette system...\n" );
|
2007-06-11 15:54:09 +00:00
|
|
|
gr_use_palette_table(D2_DEFAULT_PALETTE );
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
con_printf(CON_DEBUG, "Initializing font system...\n" );
|
|
|
|
gamefont_init(); // must load after palette data loaded.
|
|
|
|
|
|
|
|
con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
|
|
|
|
init_movies(); //init movie libraries
|
|
|
|
|
2007-03-03 18:27:55 +00:00
|
|
|
show_titles();
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2007-08-08 18:07:21 +00:00
|
|
|
set_screen_mode(SCREEN_MENU);
|
|
|
|
|
2008-02-11 12:12:57 +00:00
|
|
|
con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
|
|
|
|
gamedata_init();
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
#ifdef EDITOR
|
2007-07-18 20:13:17 +00:00
|
|
|
if (GameArg.EdiSaveHoardData) {
|
2006-10-02 13:29:04 +00:00
|
|
|
save_hoard_data();
|
2006-03-20 17:12:09 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-18 20:13:17 +00:00
|
|
|
if (GameArg.DbgNoRun)
|
2006-03-20 17:12:09 +00:00
|
|
|
return(0);
|
|
|
|
|
2008-04-08 12:51:21 +00:00
|
|
|
error_init(error_messagebox, NULL);
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
|
|
|
|
texmerge_init( 10 ); // 10 cache bitmaps
|
|
|
|
|
2007-10-30 00:01:55 +00:00
|
|
|
piggy_init_pigfile("groupa.pig"); //get correct pigfile
|
2007-10-29 21:40:49 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
con_printf( CON_DEBUG, "\nRunning game...\n" );
|
|
|
|
init_game();
|
|
|
|
|
|
|
|
// If built with editor, option to auto-load a level and quit game
|
|
|
|
// to write certain data.
|
|
|
|
#ifdef EDITOR
|
2007-07-18 20:13:17 +00:00
|
|
|
if (GameArg.EdiAutoLoad) {
|
|
|
|
strcpy(Auto_file, GameArg.EdiAutoLoad);
|
2006-03-20 17:12:09 +00:00
|
|
|
strcpy(Players[0].callsign, "dummy");
|
|
|
|
} else
|
|
|
|
#endif
|
2006-10-10 09:53:58 +00:00
|
|
|
{
|
2007-07-14 20:33:42 +00:00
|
|
|
if(GameArg.SysPilot)
|
2006-10-10 09:53:58 +00:00
|
|
|
{
|
2007-05-21 11:24:27 +00:00
|
|
|
char filename[32] = "";
|
2006-10-18 12:53:34 +00:00
|
|
|
int j;
|
2007-10-18 14:44:02 +00:00
|
|
|
|
2007-07-14 20:33:42 +00:00
|
|
|
if (GameArg.SysUsePlayersDir)
|
2007-05-21 11:24:27 +00:00
|
|
|
strcpy(filename, "Players/");
|
2007-10-18 14:44:02 +00:00
|
|
|
strncat(filename, GameArg.SysPilot, 12);
|
|
|
|
filename[8 + 12] = '\0'; // unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n'
|
2007-07-14 20:33:42 +00:00
|
|
|
for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) {
|
2006-10-18 12:53:34 +00:00
|
|
|
switch (filename[j]) {
|
|
|
|
case ' ':
|
|
|
|
filename[j] = '\0';
|
|
|
|
}
|
|
|
|
}
|
2007-05-10 09:34:27 +00:00
|
|
|
if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it
|
|
|
|
strcat(filename,".plr");
|
2006-10-10 09:53:58 +00:00
|
|
|
if(cfexist(filename))
|
|
|
|
{
|
2006-10-18 12:53:34 +00:00
|
|
|
strcpy(strstr(filename,".plr"),"\0");
|
2007-07-14 20:33:42 +00:00
|
|
|
strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename);
|
2006-10-10 09:53:58 +00:00
|
|
|
read_player_file();
|
|
|
|
WriteConfigFile();
|
|
|
|
}
|
2006-10-18 12:53:34 +00:00
|
|
|
else //pilot doesn't exist. get pilot.
|
2007-08-27 23:01:34 +00:00
|
|
|
RegisterPlayer();
|
2006-10-10 09:53:58 +00:00
|
|
|
}
|
|
|
|
else
|
2007-08-27 23:01:34 +00:00
|
|
|
RegisterPlayer();
|
2006-10-10 09:53:58 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
Game_mode = GM_GAME_OVER;
|
|
|
|
|
|
|
|
while (Function_mode != FMODE_EXIT)
|
|
|
|
{
|
|
|
|
switch( Function_mode ) {
|
2008-04-06 20:23:28 +00:00
|
|
|
case FMODE_MENU:
|
|
|
|
set_screen_mode(SCREEN_MENU);
|
|
|
|
#ifdef EDITOR
|
|
|
|
if (GameArg.EdiAutoLoad) {
|
|
|
|
strcpy((char *)&Level_names[0], Auto_file);
|
|
|
|
LoadLevel(1, 1);
|
|
|
|
Function_mode = FMODE_EXIT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DoMenu();
|
|
|
|
#ifdef EDITOR
|
|
|
|
if ( Function_mode == FMODE_EDITOR ) {
|
|
|
|
create_new_mine();
|
|
|
|
SetPlayerFromCurseg();
|
|
|
|
load_palette(NULL,1,0);
|
|
|
|
}
|
|
|
|
#endif
|
2007-04-04 10:24:03 +00:00
|
|
|
break;
|
2008-04-06 20:23:28 +00:00
|
|
|
case FMODE_GAME:
|
|
|
|
#ifdef EDITOR
|
|
|
|
keyd_editor_mode = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
game();
|
|
|
|
|
|
|
|
if ( Function_mode == FMODE_MENU )
|
|
|
|
songs_play_song( SONG_TITLE, 1 );
|
|
|
|
break;
|
|
|
|
#ifdef EDITOR
|
|
|
|
case FMODE_EDITOR:
|
|
|
|
keyd_editor_mode = 1;
|
|
|
|
editor();
|
|
|
|
if ( Function_mode == FMODE_GAME ) {
|
|
|
|
Game_mode = GM_EDITOR;
|
|
|
|
editor_reset_stuff_on_level();
|
|
|
|
N_players = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
Error("Invalid function mode %d",Function_mode);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteConfigFile();
|
2007-03-03 18:27:55 +00:00
|
|
|
show_order_form();
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2008-11-14 16:56:40 +00:00
|
|
|
con_printf( CON_DEBUG, "\nCleanup...\n" );
|
2008-04-08 12:51:21 +00:00
|
|
|
error_init(NULL, NULL); // clear error func (won't have newmenu stuff loaded)
|
2008-11-14 16:56:40 +00:00
|
|
|
close_game();
|
|
|
|
texmerge_close();
|
|
|
|
gamedata_close();
|
|
|
|
gamefont_close();
|
|
|
|
free_text();
|
|
|
|
args_exit();
|
2008-11-09 23:51:19 +00:00
|
|
|
newmenu_close();
|
2008-11-14 16:56:40 +00:00
|
|
|
free_mission();
|
2007-12-23 00:51:59 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
return(0); //presumably successful exit
|
|
|
|
}
|
|
|
|
|
|
|
|
void quit_request()
|
|
|
|
{
|
|
|
|
exit(0);
|
|
|
|
}
|