2001-01-05 17:37:59 +00:00
|
|
|
// fg_props.cxx -- support for
|
|
|
|
//
|
|
|
|
// Written by David Megginson, started November 1999.
|
|
|
|
//
|
|
|
|
// Copyright (C) 1999, 2000 David Megginson - david@megginson.com
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
2001-04-02 02:59:31 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <simgear/compiler.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include STL_IOSTREAM
|
2001-01-05 17:37:59 +00:00
|
|
|
|
|
|
|
#include <Main/fgfs.hxx>
|
|
|
|
#include "fg_props.hxx"
|
|
|
|
|
2001-04-02 02:59:31 +00:00
|
|
|
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
|
|
|
SG_USING_STD(istream);
|
|
|
|
SG_USING_STD(ostream);
|
|
|
|
#endif
|
2001-01-05 17:37:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the current state of the simulator to a stream.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
fgSaveFlight (ostream &output)
|
|
|
|
{
|
|
|
|
return writeProperties(output, globals->get_props());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore the current state of the simulator from a stream.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
fgLoadFlight (istream &input)
|
|
|
|
{
|
2001-01-19 22:57:24 +00:00
|
|
|
SGPropertyNode props;
|
|
|
|
if (readProperties(input, &props)) {
|
|
|
|
copyProperties(&props, globals->get_props());
|
|
|
|
// When loading a flight, make it the
|
|
|
|
// new initial state.
|
|
|
|
globals->saveInitialState();
|
|
|
|
} else {
|
2001-03-24 06:03:11 +00:00
|
|
|
SG_LOG(SG_INPUT, SG_ALERT, "Error restoring flight; aborted");
|
2001-01-19 22:57:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
2001-01-05 17:37:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// end of fg_props.cxx
|
|
|
|
|