bool
SingleAttributeConfigManager::Export(const std::string &filename,
                                     bool complete)
{
    completeSave = complete;
    return WriteConfigFile(filename.c_str());
}
// ****************************************************************************
// Method: SingleAttributeConfigManager::Export
//
// Purpose: 
//   Exports the attribute to the named file.
//
// Returns:    true on success; false otherwise
//
// Programmer: Jeremy Meredith
// Creation:   January  2, 2009
//
// Modifications:
//   Jeremy Meredith, Thu Apr 29 12:14:13 EDT 2010
//   Added ability to do a selective save.
//
// ****************************************************************************
bool
SingleAttributeConfigManager::Export(std::ostream& out,
                                     bool complete)
{
    completeSave = complete;
    return WriteConfigFile(out);
}
bool
ColorTableManager::Export(const std::string &ctName,
    const ColorControlPointList &ccpl_, std::string &message)
{
    ccpl = ccpl_;

    //
    // Make sure that if the color table already contains the colortable 
    // directory that we don't decorate the name.
    //
    std::string ctDir(GetUserVisItDirectory());
    std::string ctFileName(ctDir + ctName + ".ct");
    if(ctName.size() > ctDir.size() &&
       ctName.substr(0, ctDir.size()) == ctDir)
    {
        ctFileName = ctName;
    }

    bool retval;
    if((retval = WriteConfigFile(ctFileName.c_str())) == true)
        message = ctFileName;
    else
    {
        message = std::string("VisIt could not export ") + ctName +
                  std::string(" to ") + ctFileName + ".";
    }

    return retval;
}
示例#4
0
void DataSearchConfig::on_btn_Apply_clicked()
{
    ReadUi();
    if(VerifyValues())
    {
        WriteConfigFile();
    }
}
示例#5
0
文件: Port.cpp 项目: neolynx/tvdaemon
bool Port::SaveConfig( )
{
  WriteConfig( "Name",   name );
  WriteConfig( "ID", port_num );
  WriteConfig( "Source", source ? source->GetKey( ) : -1 );

  return WriteConfigFile( );
}
示例#6
0
bool ConfigFile::Save()
{
    bool bSuccess = WriteConfigFile();

    if(bSuccess)
    {
        m_bOpenSuccessful = true;
        bIsModified = false;
    }

    return bSuccess;
}
示例#7
0
bool Adapter::SaveConfig( )
{
  WriteConfig( "Name", name );
  WriteConfig( "UDev-ID", uid );

  WriteConfigFile( );

  for( std::vector<Frontend *>::iterator it = frontends.begin( ); it != frontends.end( ); it++ )
  {
    (*it)->SaveConfig( );
  }
  return true;
}
示例#8
0
bool Frontend::SaveConfig( )
{
  WriteConfig( "Name", name );
  WriteConfig( "Type", type );
  WriteConfig( "TuneTimeout", tune_timeout );

  WriteConfigFile( );

  LockPorts( );
  for( std::map<int, Port *>::iterator it = ports.begin( ); it != ports.end( ); it++ )
    it->second->SaveConfig( );
  UnlockPorts( );
  return true;
}
示例#9
0
void OpenOCDDriver::OnOpenProject(void)
{
    if (m_Auto == true) {

        Log(_T("Project opened, writing config file..."));

        // Write config file
        if (WriteConfigFile() < 0) {
            Log(_T("Writing config failed."));
        } else {
            Log(_T("Config file written."));
        }
    }
}
示例#10
0
//Save the file to the new filename and switch all preceding saves to that file
bool ConfigFile::SaveAs(std::string filename)
{
    std::string strTempFilename = m_strFilename;
    m_strFilename = filename;
    if(WriteConfigFile() == 0)
    {
        //Saveas failed so revert to old filename
        m_strFilename = strTempFilename;
        return false;
    }
    m_bOpenSuccessful = true;
    bIsModified = false;
    return true;
}
示例#11
0
//Inputs the player's name, without putting up the background screen
RegisterPlayer()
{
	int i,j;
	char filename[14];
	int allow_abort_flag = 1;

	if ( Players[Player_num].callsign[0] == 0 )	{
		//---------------------------------------------------------------------
		// Set default config options in case there is no config file
		// kc_keyboard, kc_joystick, kc_mouse are statically defined.
		Config_joystick_sensitivity = 8;
		Config_control_type =CONTROL_NONE;
		for (i=0; i<CONTROL_MAX_TYPES; i++ )
			for (j=0; j<MAX_CONTROLS; j++ )
				kconfig_settings[i][j] = default_kconfig_settings[i][j];
		kc_set_controls();
		//----------------------------------------------------------------

		// Read the last player's name from config file, not lastplr.txt
		strncpy( Players[Player_num].callsign, config_last_player, CALLSIGN_LEN );

		if (config_last_player[0]==0)
			allow_abort_flag = 0;
	}

do_menu_again:
	;

	if (!newmenu_get_filename( TXT_SELECT_PILOT, "*.plr", filename, allow_abort_flag ))	{
		return 0;		// They hit Esc in file selector
	}

	if ( filename[0] == '<' )	{
		// They selected 'create new pilot'
		if (!MakeNewPlayerFile(allow_abort_flag))
			//return 0;		// They hit Esc during enter name stage
			goto do_menu_again;
	} else {
		strncpy(Players[Player_num].callsign,filename, CALLSIGN_LEN);
	}

	read_player_file();

	Auto_leveling_on = Default_leveling_on;

	WriteConfigFile();		// Update lastplr

	return 1;
}
示例#12
0
void joydefs_calibrate()
{

	int i;
	int temp_values[MAX_AXES];
	char title[50];
	char text[256];
//added/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix
//-killed-        int nsticks = 0;
//end this section kill - Hans

	joydefs_calibrate_flag = 0;

	if (!joy_present)	{
		nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
		return;
	}

	if (j_joystick[0].version) {
		joycal_message ("No Calibration", "calibration not required for\njoystick v1.x");
		return;
	}
	
	for (i = 0; i < j_num_axes; i += 2) {
		sprintf (title, "js%d Calibration", j_axis[i].joydev);

		sprintf (text, "center joystick %d", j_axis[i].joydev);
		joycal_message (title, text);
		joystick_read_raw_axis (JOY_ALL_AXIS, temp_values);
		j_axis[i].center_val = temp_values[i];
		j_axis[i + 1].center_val = temp_values[i + 1];

		sprintf (text, "move joystick %d to the upper left", j_axis[i].joydev);
		joycal_message (title, text);
		joystick_read_raw_axis (JOY_ALL_AXIS, temp_values);
		j_axis[i].min_val = temp_values[i];
		j_axis[i + 1].min_val = temp_values[i + 1];

		sprintf (text, "move joystick %d to the lower right", j_axis[i].joydev);
		joycal_message (title, text);
		joystick_read_raw_axis (JOY_ALL_AXIS, temp_values);
		j_axis[i].max_val = temp_values[i];
		j_axis[i + 1].max_val = temp_values[i + 1];

	}
	
	WriteConfigFile ();
}
bool
VLIFileManager::WriteConfigFile(const char *filename)
{
    // Try to open the output file.
    std::ofstream outf(filename, ios::out | ios::trunc);
    if(outf.is_open() == false)
    {
        return false;
    }

    bool res = WriteConfigFile(outf);

    // Close the file
    outf.close();

    return res;
}
bool
SingleAttributeConfigManager::WriteConfigFile(const char *filename)
{
    std::ofstream outf;

    // Try to open the output file.
    outf.open(filename, ios::out | ios::binary); //"wb"
    if(outf.is_open() == false)
        return false;

    bool res = WriteConfigFile(outf);

    // Close the file
    outf.close();

    return res;
}
bool
AccessViewerSession::WriteConfigFile(const char *filename)
{
    // If we have no root then return.
    if(root == 0)
        return false;
    std::ofstream outf;
    // Try to open the output file.
    outf.open(filename, ios::out | ios::trunc);
    if(outf.is_open() == false)
        return false;

    bool res = WriteConfigFile(outf);

    // close the file
    outf.close();

    return res;
}
示例#16
0
void create_map( const std::string& realm, unsigned short width, unsigned short height )
{
  auto mapwriter = new MapWriter();
  INFO_PRINT << "Creating map base and solids files.\n"
             << "  Realm: " << realm << "\n"
             << "  Map ID: " << uo_mapid << "\n"
             << "  Use Dif files: " << ( uo_usedif ? "Yes" : "No" ) << "\n"
             << "  Size: " << uo_map_width << "x" << uo_map_height << "\n"
             << "Initializing files: ";
  mapwriter->CreateNewFiles( realm, width, height );
  INFO_PRINT << "Done.\n";
  Tools::Timer<> timer;
  rawmapfullread();
  rawstaticfullread();
  INFO_PRINT << "  Reading mapfiles time: " << timer.ellapsed() << " ms.\n";
  for ( unsigned short y_base = 0; y_base < height; y_base += SOLIDX_Y_SIZE )
  {
    for ( unsigned short x_base = 0; x_base < width; x_base += SOLIDX_X_SIZE )
    {
      ProcessSolidBlock( x_base, y_base, *mapwriter );
    }
    INFO_PRINT << "\rConverting: " << y_base * 100 / height << "%";
  }
  timer.stop();

  mapwriter->WriteConfigFile();
  delete mapwriter;

  INFO_PRINT << "\rConversion complete.              \n"
             << "Conversion details:\n"
             << "  Total blocks: " << empty + nonempty << "\n"
             << "  Blocks with solids: " << nonempty << " ("
             << ( nonempty * 100 / ( empty + nonempty ) ) << "%)"
             << "\n"
             << "  Blocks without solids: " << empty << " ("
             << ( empty * 100 / ( empty + nonempty ) ) << "%)"
             << "\n"
             << "  Locations with solids: " << with_more_solids << "\n"
             << "  Total number of solids: " << total_statics << "\n"
             << "  Elapsed time: " << timer.ellapsed() << " ms.\n";
}
示例#17
0
/*!
    \brief Apply settings.

    Called when the 'apply' button is clicked from the ConfigSettings dialog.

    \return Always true.
*/
bool OpenOCDDriver::OnConfigApply(void)
{
    m_Config->SaveSettings();
    m_Settings->SaveSettings();

    // Get data from interface panel.
    m_Interface = m_Config->m_Interface;
    m_Option = m_Config->m_Option;
    m_JTAGSpeed = m_Config->m_Speed;
    m_Auto = m_Config->m_Auto;
    m_ConfigFile = m_Config->m_ConfigFile;
    m_AdvOpts = m_Config->m_AdvOpts;

    // Get data from settings panel.
    m_ProgramPath = m_Settings->m_ProgramPath;
    m_GDBPort = m_Settings->m_GDBPort;
    m_TelnetPort = m_Settings->m_TelnetPort;
    m_TCLPort = m_Settings->m_TCLPort;

    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("mcumanager"));
    cfg->Write(_T("/programpath"), m_ProgramPath);

    // Re-write config file
    if (m_Auto == true) {

        Log(_T("Settings changed, writing config file..."));

        // Write config file
        if (WriteConfigFile() < 0) {
            Log(_T("Writing config failed."));
            return -1;
        } else {
            Log(_T("Config file written."));
        }
    }

    return true;
}
示例#18
0
文件: descent.cpp 项目: paud/d2x-xl
int CleanUp (void)
{
if (gameStates.input.bHaveTrackIR) {
	pfnTIRExit ();
	TIRUnload ();
	}
songManager.StopAll ();
audio.StopCurrentSong ();
SaveModelData ();
/*---*/PrintLog ("Saving configuration file\n");
WriteConfigFile (true);
/*---*/PrintLog ("Saving player profile\n");
SavePlayerProfile ();
/*---*/PrintLog ("Releasing tracker list\n");
tracker.DestroyList ();
profile.Destroy ();
#if DBG
if (!FindArg ("-notitles"))
#endif
	//ShowOrderForm ();
ogl.DestroyDrawBuffer ();
return 0;
}
示例#19
0
//Inputs the player's name, without putting up the background screen
int RegisterPlayer()
{
	char filename[14];
	int allow_abort_flag = 1;

        if ( Players[Player_num].callsign[0] == 0 )     {
		// Read the last player's name from config file, not lastplr.txt
		strncpy( Players[Player_num].callsign, GameCfg.LastPlayer, CALLSIGN_LEN );

		if (GameCfg.LastPlayer[0]==0)
			allow_abort_flag = 0;
        }

do_menu_again:
	;

	if (!newmenu_get_filename( TXT_SELECT_PILOT, ".plr", filename, allow_abort_flag ))	{
		goto do_menu_again;		// They hit Esc in file selector
	}

	if ( filename[0] == '<' )	{
		// They selected 'create new pilot'
		if (!MakeNewPlayerFile(allow_abort_flag))
			//return 0;		// They hit Esc during enter name stage
			goto do_menu_again;
	} else {
		strncpy(Players[Player_num].callsign,filename, CALLSIGN_LEN);
		strlwr(Players[Player_num].callsign);
	}

	read_player_file();

	WriteConfigFile();		// Update lastplr

        return 1;
}
示例#20
0
//write out player's saved games.  returns errno (0 == no error)
int write_player_file()
{
	char filename[PATH_MAX];
	PHYSFS_file *file;
	int errno_ret, i;

	if ( Newdemo_state == ND_STATE_PLAYBACK )
		return -1;

	errno_ret = WriteConfigFile();

	memset(filename, '\0', PATH_MAX);
        snprintf(filename, PATH_MAX, GameArg.SysUsePlayersDir? "Players/%.8s.plx" : "%.8s.plx", Players[Player_num].callsign);
	write_player_d1x(filename);

	snprintf(filename, PATH_MAX, GameArg.SysUsePlayersDir? "Players/%.8s.plr" : "%.8s.plr", Players[Player_num].callsign);
	file = PHYSFSX_openWriteBuffered(filename);

	if (!file)
		return errno;

	PHYSFS_writeULE32(file, SAVE_FILE_ID);
	PHYSFS_writeULE16(file, SAVED_GAME_VERSION);
	PHYSFS_writeULE16(file, PLAYER_STRUCT_VERSION);
	PHYSFS_writeSLE32(file, PlayerCfg.NHighestLevels);
	PHYSFS_writeSLE32(file, PlayerCfg.DefaultDifficulty);
	PHYSFS_writeSLE32(file, PlayerCfg.AutoLeveling);
	errno_ret = EZERO;

	//write higest level info
	if ((PHYSFS_write( file, PlayerCfg.HighestLevels, sizeof(hli), PlayerCfg.NHighestLevels) != PlayerCfg.NHighestLevels)) {
		errno_ret = errno;
		PHYSFS_close(file);
		return errno_ret;
	}

	if (PHYSFS_write( file, saved_games,sizeof(saved_games),1) != 1) {
		errno_ret = errno;
		PHYSFS_close(file);
		return errno_ret;
	}

	#ifdef NETWORK
	if ((PHYSFS_write( file, PlayerCfg.NetworkMessageMacro, MAX_MESSAGE_LEN, 4) != 4)) {
		errno_ret = errno;
		PHYSFS_close(file);
		return errno_ret;
	}
	#else
	{
		//PHYSFS_seek( file, PHYSFS_tell(file)+MAX_MESSAGE_LEN * 4 );	// Seeking is bad for Mac OS 9
		char dummy[MAX_MESSAGE_LEN][4];
		
		if ((PHYSFS_write( file, dummy, MAX_MESSAGE_LEN, 4) != 4)) {
			errno_ret = errno;
			PHYSFS_close(file);
			return errno_ret;
		}
	}
	#endif

	//write kconfig info
	{
		if (PHYSFS_write(file, PlayerCfg.KeySettings[0], sizeof(PlayerCfg.KeySettings[0]), 1) != 1)
			errno_ret=errno;
		if (PHYSFS_write(file, PlayerCfg.KeySettings[1], sizeof(PlayerCfg.KeySettings[1]), 1) != 1)
			errno_ret=errno;
		for (i = 0; i < MAX_CONTROLS*3; i++)
			if (PHYSFS_write(file, "0", sizeof(ubyte), 1) != 1) // Skip obsolete Flightstick/Thrustmaster/Gravis map fields
				errno_ret=errno;
		if (PHYSFS_write(file, PlayerCfg.KeySettings[2], sizeof(PlayerCfg.KeySettings[2]), 1) != 1)
			errno_ret=errno;
		for (i = 0; i < MAX_CONTROLS; i++)
			if (PHYSFS_write(file, "0", sizeof(ubyte), 1) != 1) // Skip obsolete Cyberman map field
				errno_ret=errno;
	
		if(errno_ret == EZERO)
		{
			ubyte old_avg_joy_sensitivity = 8;
			if (PHYSFS_write( file,  &PlayerCfg.ControlType, sizeof(ubyte), 1 )!=1)
				errno_ret=errno;
			else if (PHYSFS_write( file, &old_avg_joy_sensitivity, sizeof(ubyte), 1 )!=1)
				errno_ret=errno;
		}
	}

	if (!PHYSFS_close(file))
		errno_ret = errno;

	if (errno_ret != EZERO) {
		PHYSFS_delete(filename);			//delete bogus file
		nm_messagebox(TXT_ERROR, 1, TXT_OK, "%s\n\n%s",TXT_ERROR_WRITING_PLR, strerror(errno_ret));
	}

	return errno_ret;
}
示例#21
0
INT_PTR
	BitmapIO_EPS::OutputControl (HWND hWnd, UINT message, WPARAM wParam,
	LPARAM lParam) 
{
	float factor;
	switch (message) {
	case WM_INITDIALOG:
		factor = (userSettings.units == INCHES) ? 1.0F : MM_PER_INCHES;

		widthSpin = GetISpinner (GetDlgItem (hWnd, IDC_WIDTH_SPINNER));
		widthSpin->SetLimits (0, 1000, FALSE);
		widthSpin->SetScale (0.1F);
		widthSpin->LinkToEdit (GetDlgItem (hWnd, IDC_WIDTH_EDIT),
			EDITTYPE_FLOAT);
		widthSpin->SetValue (userSettings.paperWidth * factor, FALSE);

		heightSpin = GetISpinner (GetDlgItem (hWnd, IDC_HEIGHT_SPINNER));
		heightSpin->SetLimits (0, 1000, FALSE);
		heightSpin->SetScale (0.1F);
		heightSpin->LinkToEdit (GetDlgItem (hWnd, IDC_HEIGHT_EDIT),
			EDITTYPE_FLOAT);
		heightSpin->SetValue (userSettings.paperHeight * factor, FALSE);

		widthResSpin = GetISpinner (GetDlgItem (hWnd, 
			IDC_RES_WIDTH_SPINNER));
		widthResSpin->SetLimits (0, 1000, FALSE);
		widthResSpin->SetScale (0.1F);
		widthResSpin->LinkToEdit (GetDlgItem (hWnd, IDC_RES_WIDTH_EDIT), 
			EDITTYPE_FLOAT);
		widthResSpin->SetValue (userSettings.xResolution / factor, FALSE);

		heightResSpin = GetISpinner (GetDlgItem (hWnd, 
			IDC_RES_HEIGHT_SPINNER));
		heightResSpin->SetLimits (0, 1000, FALSE);
		heightResSpin->SetScale (0.1F);
		heightResSpin->LinkToEdit (GetDlgItem (hWnd, IDC_RES_HEIGHT_EDIT), 
			EDITTYPE_FLOAT);
		heightResSpin->SetValue (userSettings.yResolution / factor, FALSE);

		//      CenterWindow(hWnd,GetParent(hWnd));
		CheckRadioButton (hWnd, IDC_INCHES, IDC_MILLIMETERS, 
			(userSettings.units == INCHES) ? 
IDC_INCHES : IDC_MILLIMETERS);  
		CheckRadioButton (hWnd, IDC_PORTRAIT, IDC_LANDSCAPE, 
			(userSettings.orientation == PORTRAIT) ? 
IDC_PORTRAIT : IDC_LANDSCAPE);
		CheckRadioButton (hWnd, IDC_BINARY, IDC_ASCII,
			(userSettings.binary) ? 
IDC_BINARY : IDC_ASCII);
		CheckRadioButton (hWnd, IDC_COLOR, IDC_GRAY,
			(userSettings.colorType == RGBIMAGE) ? 
IDC_COLOR : IDC_GRAY);
		CheckDlgButton (hWnd, IDC_INCLUDE_PREVIEW, 
			userSettings.preview);
		return 1;
	case WM_DESTROY:
		ReleaseISpinner (widthSpin);                      
		ReleaseISpinner (heightSpin);                     
		ReleaseISpinner (widthResSpin);                   
		ReleaseISpinner (heightResSpin);                          
		return 1;
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_INCHES:
			// Don't do anything unless this is a change
			if (userSettings.units != INCHES)  {
				userSettings.units = INCHES;
				userSettings.paperHeight = heightSpin->GetFVal () / 
					MM_PER_INCHES;
				userSettings.paperWidth = widthSpin->GetFVal () /
					MM_PER_INCHES;
				userSettings.xResolution = widthResSpin->GetFVal () *
					MM_PER_INCHES;
				userSettings.yResolution = heightResSpin->GetFVal () *
					MM_PER_INCHES;
				widthSpin->SetValue (userSettings.paperWidth, FALSE);
				heightSpin->SetValue (userSettings.paperHeight, FALSE);
				widthResSpin->SetValue (userSettings.xResolution, FALSE);
				heightResSpin->SetValue (userSettings.yResolution, FALSE);
			}
			break;
		case IDC_MILLIMETERS:
			if (userSettings.units != MM)  {
				userSettings.units = MM;
				userSettings.paperHeight = heightSpin->GetFVal ();
				userSettings.paperWidth = widthSpin->GetFVal ();
				userSettings.xResolution = widthResSpin->GetFVal ();
				userSettings.yResolution = heightResSpin->GetFVal ();
				widthSpin->SetValue (userSettings.paperWidth *
					MM_PER_INCHES, FALSE);
				heightSpin->SetValue (userSettings.paperHeight *
					MM_PER_INCHES, FALSE);
				widthResSpin->SetValue (userSettings.xResolution /
					MM_PER_INCHES, FALSE);
				heightResSpin->SetValue (userSettings.yResolution / 
					MM_PER_INCHES, FALSE);
			}
			break;
		case IDOK:              
			userSettings.units = 
				IsDlgButtonChecked (hWnd, IDC_INCHES) ? INCHES : MM;
			factor = (userSettings.units == INCHES) ? 1.0F : 
				MM_PER_INCHES;
			userSettings.orientation = 
				IsDlgButtonChecked (hWnd, IDC_PORTRAIT) ? PORTRAIT : LANDSCAPE;
			userSettings.binary = 
				IsDlgButtonChecked (hWnd, IDC_BINARY);
			userSettings.colorType = 
				IsDlgButtonChecked (hWnd, IDC_COLOR) ? RGBIMAGE : 
				GRAYIMAGE;
			userSettings.preview = 
				IsDlgButtonChecked (hWnd, IDC_INCLUDE_PREVIEW);
			userSettings.paperHeight = heightSpin->GetFVal () / factor;
			userSettings.paperWidth = widthSpin->GetFVal () / factor;
			userSettings.xResolution = widthResSpin->GetFVal () * factor;
			userSettings.yResolution = heightResSpin->GetFVal () * factor;
			WriteConfigFile ();
			EndDialog(hWnd,1);
			break;
		case IDCANCEL:
			EndDialog(hWnd,0);
			break;
		}
		return 1;
	}
	return 0;
}
示例#22
0
static int main(int argc, char *argv[])
{
	if (!PHYSFSX_init(argc, argv))
		return 1;
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (CGameArg.SysShowCmdHelp) {
		print_commandline_help();

		return(0);
	}

	printf("\nType '%s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

#if defined(DXX_BUILD_DESCENT_I)
	if (! PHYSFSX_contfile_init("descent.hog", 1))
#define DXX_NAME_NUMBER	"1"
#define DXX_HOGFILE_NAMES	"descent.hog"
#elif defined(DXX_BUILD_DESCENT_II)
	if (! PHYSFSX_contfile_init("descent2.hog", 1) && ! PHYSFSX_contfile_init("d2demo.hog", 1))
#define DXX_NAME_NUMBER	"2"
#define DXX_HOGFILE_NAMES	"descent2.hog or d2demo.hog"
#endif
	{
#if defined(__unix__) && !defined(__APPLE__)
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
			      "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n"	\
			      "\t" SHAREPATH "\n"
#else
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
				  "\tDirectory containing D" DXX_NAME_NUMBER "X\n"
#endif
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
#define DXX_HOGFILE_APPLICATION_BUNDLE	\
				  "\tIn 'Resources' inside the application bundle\n"
#else
#define DXX_HOGFILE_APPLICATION_BUNDLE	""
#endif
#define DXX_MISSING_HOGFILE_ERROR_TEXT	\
		"Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n"	\
		DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
		"\tIn a subdirectory called 'Data'\n"	\
		DXX_HOGFILE_APPLICATION_BUNDLE	\
		"Or use the -hogdir option to specify an alternate location."
		UserError(DXX_MISSING_HOGFILE_ERROR_TEXT);
	}

#if defined(DXX_BUILD_DESCENT_I)
	switch (PHYSFSX_fsize("descent.hog"))
	{
		case D1_MAC_SHARE_MISSION_HOGSIZE:
		case D1_MAC_MISSION_HOGSIZE:
			MacHog = 1;	// used for fonts and the Automap
			break;
	}
#endif

	load_text();

	//print out the banner title
#if defined(DXX_BUILD_DESCENT_I)
	con_printf(CON_NORMAL, "%s  %s", DESCENT_VERSION, g_descent_build_datetime); // D1X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent, based on %s.", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 2005-2013 Christian Beckhaeuser");
#elif defined(DXX_BUILD_DESCENT_II)
	con_printf(CON_NORMAL, "%s%s  %s", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? "  Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on %s.", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2013 Christian Beckhaeuser");
#endif

	if (CGameArg.DbgVerbose)
		con_puts(CON_VERBOSE, TXT_VERBOSE_1);
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(CGameArg.DbgTexMap);

#if defined(DXX_BUILD_DESCENT_II)
	Lighting_on = 1;
#endif

	con_printf(CON_VERBOSE, "Going into graphics mode...");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system..." );
#if defined(DXX_BUILD_DESCENT_I)
	gr_use_palette_table( "PALETTE.256" );
#elif defined(DXX_BUILD_DESCENT_II)
	gr_use_palette_table(D2_DEFAULT_PALETTE );
#endif

	con_printf(CON_DEBUG, "Initializing font system..." );
	gamefont_init();	// must load after palette data loaded.

#if defined(DXX_BUILD_DESCENT_II)
	con_printf( CON_DEBUG, "Initializing movie libraries..." );
	init_movies();		//init movie libraries
#endif

	show_titles();

	set_screen_mode(SCREEN_MENU);
#ifdef DEBUG_MEMORY_ALLOCATIONS
	/* Memdebug runs before global destructors, so it incorrectly
	 * reports as leaked any allocations that would be freed by a global
	 * destructor.  This local will force the newmenu globals to be
	 * reset before memdebug scans, which prevents memdebug falsely
	 * reporting them as leaked.
	 *
	 * External tools, such as Valgrind, know to run global destructors
	 * before checking for leaks, so this hack is only necessary when
	 * memdebug is used.
	 */
	struct hack_free_global_backgrounds
	{
		~hack_free_global_backgrounds()
		{
			newmenu_free_background();
		}
	};
	hack_free_global_backgrounds hack_free_global_background;
#endif

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

#if defined(DXX_BUILD_DESCENT_II)
#if DXX_USE_EDITOR
	if (GameArg.EdiSaveHoardData) {
		save_hoard_data();
		exit(1);
	}
	#endif
#endif

	if (CGameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init();		// 10 cache bitmaps

#if defined(DXX_BUILD_DESCENT_II)
	piggy_init_pigfile("groupa.pig");	//get correct pigfile
#endif

	con_printf( CON_DEBUG, "\nRunning game..." );
	init_game();

	get_local_player().callsign = {};

#if defined(DXX_BUILD_DESCENT_I)
	key_flush();
#elif defined(DXX_BUILD_DESCENT_II)
	//	If built with editor, option to auto-load a level and quit game
	//	to write certain data.
	#ifdef	EDITOR
	if (!GameArg.EdiAutoLoad.empty()) {
		Players[0].callsign = "dummy";
	} else
	#endif
#endif
	{
		if (!CGameArg.SysPilot.empty())
		{
			char filename[sizeof(PLAYER_DIRECTORY_TEXT) + CALLSIGN_LEN + 4];

			/* Step over the literal PLAYER_DIRECTORY_TEXT when it is
			 * present.  Point at &filename[0] when
			 * PLAYER_DIRECTORY_TEXT is absent.
			 */
			const auto b = &filename[-CGameArg.SysUsePlayersDir];
			snprintf(filename, sizeof(filename), PLAYER_DIRECTORY_STRING("%.12s"), CGameArg.SysPilot.c_str());
			/* The pilot name is never used after this.  Clear it to
			 * free the allocated memory, if any.
			 */
			CGameArg.SysPilot.clear();
			auto p = b;
			for (const auto &facet = std::use_facet<std::ctype<char>>(std::locale::classic()); char &c = *p; ++p)
			{
				c = facet.tolower(static_cast<uint8_t>(c));
			}
			auto j = p - filename;
			if (j < sizeof(filename) - 4 && (j <= 4 || strcmp(&filename[j - 4], ".plr"))) // if player hasn't specified .plr extension in argument, add it
			{
				strcpy(&filename[j], ".plr");
				j += 4;
			}
			if(PHYSFSX_exists(filename,0))
			{
				get_local_player().callsign.copy(b, std::distance(b, &filename[j - 4]));
				read_player_file();
				WriteConfigFile();
			}
		}
	}

#if defined(DXX_BUILD_DESCENT_II)
#if DXX_USE_EDITOR
	if (!GameArg.EdiAutoLoad.empty()) {
		/* Any number >= FILENAME_LEN works */
		Level_names[0].copy_if(GameArg.EdiAutoLoad.c_str(), GameArg.EdiAutoLoad.size());
		LoadLevel(1, 1);
	}
	else
#endif
#endif
	{
		Game_mode = GM_GAME_OVER;
		DoMenu();
	}

	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup..." );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	Current_mission.reset();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
示例#23
0
BOOL EXPENTRY CleanConfigSys(HWND hwnd,char szDDspec[],USHORT usHelpID,BOOL bAskFirst)
  {
  int iCount;
  char *pchFile;
  char szLine[255];
  char szCaption[80];
  int iOffset;
  int iLength;
  ULONG ulFilePosition;
  BOOL bFileChanged = FALSE;
  ULONG flStyle;
  char szFileSpec[CCHMAXPATH] = "C:\\CONFIG.SYS";

  if (DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE,&iCount,4L) == 0)
    szFileSpec[0] = ('A' + ((BYTE)iCount - 1));
  if ((iCount = ReadConfigFile(hwnd, szFileSpec,&pchFile)) == 0)
    {
    if (hwnd != NULLHANDLE)
      {
      sprintf(szCaption,"Unable to Open System Configuration File");
      sprintf(szLine,"You will need to remove all DEVICE=%s.SYS statement(s) from your CONFIG.SYS file to complete this process.",szDDspec);
      flStyle =  (MB_MOVEABLE | MB_OK | MB_ICONHAND);
      if (usHelpID != 0)
        flStyle |= MB_HELP;
      WinMessageBox(HWND_DESKTOP,
                    hwnd,
                    szLine,
                    szCaption,
                    (usHelpID + 1),
                    flStyle);
      }
    return(FALSE);
    }
  pchFile[iCount] = 0;
  iOffset = 0;
  if (hwnd != NULLHANDLE)
    MessageBox(hwnd,szDDspec);
  while ((iOffset = FindLineWith(szDDspec,pchFile,iOffset,&iLength,FALSE)) >= 0)
    {
    bFileChanged = TRUE;
    iCount -= iLength;
    memcpy(&pchFile[iOffset],&pchFile[iOffset + iLength],(iCount - iOffset));
    iOffset += iLength;
    }
//  pchFile[iCount] = 0;
  if (bFileChanged)
    {
    if (bAskFirst)
      {
      if (hwnd != NULLHANDLE)
        {
        sprintf(szCaption,"System configuration file needs to be updated");
        if (szDDspec[strlen(szDDspec) - 4] == '.')
          szDDspec[strlen(szDDspec) - 4] = 0;
        sprintf(szLine,"All ""DEVICE=%s.SYS"" statements from a previous device driver version need to be removed from your CONFIG.SYS file.\n\nOK to make changes?",szDDspec);
        flStyle =  (MB_MOVEABLE | MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1);
        if (usHelpID != 0)
          flStyle |= MB_HELP;
        if (WinMessageBox(HWND_DESKTOP,
                          hwnd,
                          szLine,
                          szCaption,
                          usHelpID ,
                          flStyle) != MBID_YES)
          {
          sprintf(szLine,"You will need to remove all DEVICE=%s.SYS statements from your CONFIG.SYS file to complete this configuration.",szDDspec);
          WinMessageBox(HWND_DESKTOP,
                        hwnd,
                        szLine,
                        szCaption,
                        0L,
                       (MB_MOVEABLE | MB_OK | MB_ICONASTERISK));

          DosFreeMem(pchFile);
          return(FALSE);
          }
        }
      }
    WriteConfigFile(hwnd,szFileSpec,pchFile,iCount);
    }
  DosFreeMem(pchFile);
  return(bFileChanged);
  }
示例#24
0
int main(int argc, char *argv[])
{
	mem_init();
#ifdef __LINUX__
	error_init(NULL, NULL);
#else
	error_init(msgbox_error, NULL);
	set_warn_func(msgbox_warning);
#endif
	PHYSFSX_init(argc, argv);
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (GameArg.SysShowCmdHelp) {
		print_commandline_help();
		set_exit_message("");

		return(0);
	}

	printf("\nType %s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

	if (! PHYSFSX_contfile_init("descent.hog", 1))
		Error("Could not find a valid hog file (descent.hog)\nPossible locations are:\n"
#if defined(__unix__) && !defined(__APPLE__)
			  "\t$HOME/.d1x-rebirth\n"
			  "\t" SHAREPATH "\n"
#else
			  "\tDirectory containing D1X\n"
#endif
			  "\tIn a subdirectory called 'Data'\n"
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
			  "\tIn 'Resources' inside the application bundle\n"
#endif
			  "Or use the -hogdir option to specify an alternate location.");
	
	switch (PHYSFSX_fsize("descent.hog"))
	{
		case D1_MAC_SHARE_MISSION_HOGSIZE:
		case D1_MAC_MISSION_HOGSIZE:
			MacHog = 1;	// used for fonts and the Automap
			break;
	}

	load_text();

	//print out the banner title
	con_printf(CON_NORMAL, "%s", DESCENT_VERSION); // D1X version
	con_printf(CON_NORMAL, "  %s %s\n", __DATE__,__TIME__);
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent, based on %s.\n", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 2005-2011 Christian Beckhaeuser\n\n");

	if (GameArg.DbgVerbose)
		con_printf(CON_VERBOSE,"%s%s", TXT_VERBOSE_1, "\n");
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(GameArg.DbgTexMap);

	con_printf(CON_VERBOSE, "Going into graphics mode...\n");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system...\n" );
	gr_use_palette_table( "PALETTE.256" );

	con_printf(CON_DEBUG, "Initializing font system...\n" );
	gamefont_init();	// must load after palette data loaded.

	set_default_handler(standard_handler);

	show_titles();

	set_screen_mode(SCREEN_MENU);

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

	if (GameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init( 10 );		// 10 cache bitmaps

	con_printf( CON_DEBUG, "\nRunning game...\n" );
	init_game();

	Players[Player_num].callsign[0] = '\0';

	key_flush();

	if(GameArg.SysPilot)
	{
		char filename[32] = "";
		int j;

		if (GameArg.SysUsePlayersDir)
			strcpy(filename, "Players/");
		strncat(filename, GameArg.SysPilot, 12);
		filename[8 + 12] = '\0';	// unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n'
		for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) {
			switch (filename[j]) {
				case ' ':
					filename[j] = '\0';
			}
		}
		if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it
			strcat(filename,".plr");
		if(PHYSFSX_exists(filename,0))
		{
			strcpy(strstr(filename,".plr"),"\0");
			strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename);
			read_player_file();
			WriteConfigFile();
		}
	}


	Game_mode = GM_GAME_OVER;
	DoMenu();

	setjmp(LeaveEvents);
	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup...\n" );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	free_text();
	args_exit();
	newmenu_free_background();
	free_mission();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
示例#25
0
BOOL EXPENTRY AdjustConfigFile(HWND hwnd,char szFileSpec[], char szConfigLine[],int iLineCount, BOOL bNoPrompt, USHORT usHelpID)
  {
  int iCount;
  char *pchNew;
  char *pchFile;
  char *pchLines;
  int iIndex;
  int iOffset;
  int iDDcount = 0;
  int iLength;
  int iFirstOffset = 0;
  int iLastOffset = 0;
  char szCaption[80];
  char szMessage[120];
  int iLen;
  ULONG ulFilePosition;
  char szDeviceStatement[CCHMAXPATH];
  ULONG flStyle;

  if ((iCount = ReadConfigFile(hwnd, szFileSpec,&pchFile)) == 0)
    {
    if (hwnd != NULLHANDLE)
      {
      sprintf(szCaption,"Unable to open system configuration File");
      sprintf(szMessage,"You will need to add or remove %s statement(s) from your CONFIG.SYS file to complete this configuration.",szConfigLine);
      flStyle =  (MB_MOVEABLE | MB_OK | MB_ICONHAND);
      if (usHelpID != 0)
        flStyle |= MB_HELP;
      WinMessageBox(HWND_DESKTOP,
                    hwnd,
                    szMessage,
                    szCaption,
                   (usHelpID + 1),
                    flStyle);
      }
//    DosFreeMem(pchLines);
    return(FALSE);
    }
  if (DosAllocMem((PVOID)&pchLines,(iCount * 2),(PAG_COMMIT | PAG_READ | PAG_WRITE)) != NO_ERROR)
    {
    if (hwnd != NULLHANDLE)
      {
      sprintf(szCaption,"Unable to allocate memory to adjust system configuration file");
      sprintf(szMessage,"You will need to add or remove %s statement(s) from your CONFIG.SYS file to complete this configuration.",szConfigLine);
      flStyle =  (MB_MOVEABLE | MB_OK | MB_ICONHAND);
      if (usHelpID != 0)
        flStyle |= MB_HELP;
      WinMessageBox(HWND_DESKTOP,
                    hwnd,
                    szMessage,
                    szCaption,
                   (usHelpID + 2),
                    flStyle);
      }
//    DosFreeMem(pchLines);
    return(FALSE);
    }
  pchFile[iCount] = 0;
//  iCount = strlen(pchFile);
  iOffset = 0;
  while ((iOffset = FindLineWith(szConfigLine,pchFile,iOffset,&iLength,FALSE)) >= 0)
    {
    if (iFirstOffset == 0)
      iFirstOffset = iOffset;
    iDDcount++;
    iOffset += iLength;
    iLastOffset = iOffset;
    }
  if (iDDcount != iLineCount)
    {
//    DosSetFilePtr(hFile,0L,0L,&ulFilePosition);
    if (hwnd != NULLHANDLE)
      sprintf(szCaption,"System configuration file needs to be updated");
    if (iDDcount > iLineCount)
      {
      iDDcount -= iLineCount;
      if (!bNoPrompt)
        {
        if (hwnd != NULLHANDLE)
          {
          if (iDDcount > 1)
            sprintf(szMessage,"%s device driver load statements need to be removed from your CONFIG.SYS file.\n\nOK to make changes?",aszCapOrdinals[iDDcount]);
          else
            sprintf(szMessage,"One device driver load statement needs to be removed from your CONFIG.SYS file.\n\nOK to make changes?");
          flStyle =  (MB_MOVEABLE | MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1);
          if (usHelpID != 0)
            flStyle |= MB_HELP;
          if (WinMessageBox(HWND_DESKTOP,hwnd,szMessage,szCaption,usHelpID,flStyle) != MBID_YES)
            {
            if (iDDcount > 1)
              sprintf(szMessage,"You will need to remove %s %s statements from your CONFIG.SYS file to complete this configuration.",aszOrdinals[iDDcount],szConfigLine);
            else
              sprintf(szMessage,"You will need to remove one %s statement from your CONFIG.SYS file to complete this configuration.",szConfigLine);
            WinMessageBox(HWND_DESKTOP,hwnd,szMessage,szCaption,0L,(MB_MOVEABLE | MB_OK | MB_ICONASTERISK));
            DosFreeMem(pchFile);
            DosFreeMem(pchLines);
            return(FALSE);
            }
          }
        }
      iOffset = iFirstOffset;
      for (iIndex = 0;iIndex < iDDcount;iIndex++)
        {
        if ((iOffset = FindLineWith(szConfigLine,pchFile,iOffset,&iLength,FALSE)) < 0)
          break;
        iCount -= iLength;
        memcpy(&pchFile[iOffset],&pchFile[iOffset + iLength],(iCount - iOffset));
        }
//      if (iLoadCount == 0)
//        if (pchFile[ulCount - 1] == '\x0a')
//          iCount -= 2;
      WriteConfigFile(hwnd,szFileSpec,pchFile,iCount);
      }
    else
      {
      iLineCount -= iDDcount;
      if (!bNoPrompt)
        {
        if (hwnd != NULLHANDLE)
          {
          if (iLineCount > 1)
            sprintf(szMessage,"%s COMi load statements need to be added to your CONFIG.SYS file.\n\nOK to make changes?",aszCapOrdinals[iLineCount]);
          else
            sprintf(szMessage,"One COMi load statement needs to be added to your CONFIG.SYS file.\n\nOK to make changes?");
          flStyle =  (MB_MOVEABLE | MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1);
          if (usHelpID != 0)
            flStyle |= MB_HELP;
          if (WinMessageBox(HWND_DESKTOP,hwnd,szMessage,szCaption,usHelpID,flStyle) != MBID_YES)
            {
            if (iLineCount > 1)
              sprintf(szMessage,"You will need to add %s %s statement lines to your CONFIG.SYS file to complete this configuration.",aszOrdinals[iLineCount],szConfigLine);
            else
              sprintf(szMessage,"You will need to add one %s statement to your CONFIG.SYS file to complete this configuration.",szConfigLine);
            WinMessageBox(HWND_DESKTOP,
                          hwnd,
                          szMessage,
                          szCaption,
                          0L,
                         (MB_MOVEABLE | MB_OK | MB_ICONASTERISK));
            DosFreeMem(pchFile);
            DosFreeMem(pchLines);
            return(FALSE);
            }
          }
        }
      iLen = 0;
//      if (iDDcount == 0)
//        iLen = sprintf(pchLines,"\x0d\x0a");
      for (iIndex = 0;iIndex < iLineCount;iIndex++)
        iLen += sprintf(&pchLines[iLen],"%s\x0d\x0a",szConfigLine);
      if (DosAllocMem((PVOID)&pchNew,(iCount + iLen + 20),(PAG_COMMIT | PAG_READ | PAG_WRITE)) == NO_ERROR)
        {
        memcpy(pchNew,pchFile,iCount);
        if (iDDcount == 0)
          {
          iLastOffset = iCount;
          while (pchNew[iLastOffset - 1] == '\x1a')
            iLastOffset--;
          }
        else
          memcpy(&pchNew[iLastOffset + iLen],&pchFile[iLastOffset],(iCount - iLastOffset));
        memcpy(&pchNew[iLastOffset],pchLines,iLen);
        iCount += iLen;
//        pchNew[iCount++] = '\x1a';
        WriteConfigFile(hwnd,szFileSpec,pchNew,iCount);
        DosFreeMem(pchNew);
        }
      }
    }
  DosFreeMem(pchLines);
  DosFreeMem(pchFile);
  return(TRUE);
  }
示例#26
0
int main(int argc, char *argv[])
{
	mem_init();
#ifdef __LINUX__
	error_init(NULL);
#else
	error_init(msgbox_error);
	set_warn_func(msgbox_warning);
#endif
	PHYSFSX_init(argc, argv);
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (GameArg.SysShowCmdHelp) {
		print_commandline_help();

		return(0);
	}

	printf("\nType %s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

	if (! PHYSFSX_contfile_init("descent2.hog", 1)) {
		if (! PHYSFSX_contfile_init("d2demo.hog", 1))
#define DXX_NAME_NUMBER	"2"
#define DXX_HOGFILE_NAMES	"descent2.hog or d2demo.hog"
#if defined(__unix__) && !defined(__APPLE__)
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
			      "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n"	\
			      "\t" SHAREPATH "\n"
#else
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
				  "\tDirectory containing D" DXX_NAME_NUMBER "X\n"
#endif
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
#define DXX_HOGFILE_APPLICATION_BUNDLE	\
				  "\tIn 'Resources' inside the application bundle\n"
#else
#define DXX_HOGFILE_APPLICATION_BUNDLE	""
#endif
#define DXX_MISSING_HOGFILE_ERROR_TEXT	\
		"Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n"	\
		DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
		"\tIn a subdirectory called 'Data'\n"	\
		DXX_HOGFILE_APPLICATION_BUNDLE	\
		"Or use the -hogdir option to specify an alternate location."
		Error(DXX_MISSING_HOGFILE_ERROR_TEXT);
	}

	load_text();

	//print out the banner title
	con_printf(CON_NORMAL, "%s%s  %s\n", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? "  Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on %s.\n", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2011 Christian Beckhaeuser\n\n");

	if (GameArg.DbgVerbose)
		con_printf(CON_VERBOSE,"%s%s", TXT_VERBOSE_1, "\n");
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(GameArg.DbgTexMap);

	Lighting_on = 1;

	con_printf(CON_VERBOSE, "Going into graphics mode...\n");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system...\n" );
	gr_use_palette_table(D2_DEFAULT_PALETTE );

	con_printf(CON_DEBUG, "Initializing font system...\n" );
	gamefont_init();	// must load after palette data loaded.

	set_default_handler(standard_handler);

	con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
	init_movies();		//init movie libraries

	show_titles();

	set_screen_mode(SCREEN_MENU);

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

	#ifdef EDITOR
	if (GameArg.EdiSaveHoardData) {
		save_hoard_data();
		exit(1);
	}
	#endif

	if (GameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init( 10 );		// 10 cache bitmaps

	piggy_init_pigfile("groupa.pig");	//get correct pigfile

	con_printf( CON_DEBUG, "\nRunning game...\n" );
	init_game();

	Players[Player_num].callsign[0] = '\0';

	//	If built with editor, option to auto-load a level and quit game
	//	to write certain data.
	#ifdef	EDITOR
	if (GameArg.EdiAutoLoad) {
		strcpy(Auto_file, GameArg.EdiAutoLoad);
		strcpy(Players[0].callsign, "dummy");
	} else
	#endif
	{
		if(GameArg.SysPilot)
		{
			char filename[32] = "";
			int j;

			if (GameArg.SysUsePlayersDir)
				strcpy(filename, "Players/");
			strncat(filename, GameArg.SysPilot, 12);
			filename[8 + 12] = '\0';	// unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n'
			for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) {
				switch (filename[j]) {
					case ' ':
						filename[j] = '\0';
				}
			}
			if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it
				strcat(filename,".plr");
			if(PHYSFSX_exists(filename,0))
			{
				strcpy(strstr(filename,".plr"),"\0");
				strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename);
				read_player_file();
				WriteConfigFile();
			}
		}
	}

#ifdef EDITOR
	if (GameArg.EdiAutoLoad) {
		strcpy((char *)&Level_names[0], Auto_file);
		LoadLevel(1, 1);
	}
	else
#endif
	{
		Game_mode = GM_GAME_OVER;
		DoMenu();
	}

	setjmp(LeaveEvents);
	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup...\n" );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	free_text();
	args_exit();
	newmenu_free_background();
	free_mission();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
示例#27
0
文件: config.cpp 项目: paud/d2x-xl
bool CfgCreateHashs (void)
{
gameConfig.cfgDataHash = GetCfgHash ();
return WriteConfigFile () == 0;
}