#include <simgear/compiler.h>
#include <simgear/structure/exception.hxx>
-#include <simgear/debug/logstream.hxx>
-#include <simgear/math/SGMath.hxx>
#include <cstring>
#include <iostream>
using std::cerr;
using std::endl;
+#include <Viewer/fgviewer.hxx>
#include "main.hxx"
#include "globals.hxx"
#include "fg_props.hxx"
-#include "fgviewer.hxx"
#include "fg_os.hxx"
-char *homedir = NULL;
-char *hostname = NULL;
-bool free_hostname = false;
+std::string homedir;
+std::string hostname;
-// foreward declaration.
+// forward declaration.
void fgExitCleanup();
static bool fpeAbort = false;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
- logbuf::has_no_console();
main( __argc, __argv );
}
#endif
int _bootstrap_OSInit;
// Main entry point; catch any exceptions that have made it this far.
-int main ( int argc, char **argv ) {
+int main ( int argc, char **argv )
+{
#if _MSC_VER
// Don't show blocking "no disk in drive" error messages on Windows 7,
// silently return errors to application instead.
// See Microsoft MSDN #ms680621: "GUI apps should specify SEM_NOOPENFILEERRORBOX"
SetErrorMode(SEM_NOOPENFILEERRORBOX);
- // Windows has no $HOME aka %HOME%, so we have to construct the full path.
- // make sure it fits into the buffer. Max. path length is 255, but who knows
- // what's in these environment variables?
- char homepath[256] = "";
- homepath[sizeof(homepath)-1] = 0;
- strncpy( homepath, ::getenv("APPDATA"), sizeof(homepath)-1 );
- strncat( homepath, "\\flightgear.org", sizeof(homepath)-strlen(homepath)-1 );
-
- homedir = strdup(homepath);
hostname = ::getenv( "COMPUTERNAME" );
#else
// Unix(alike) systems
char _hostname[256];
gethostname(_hostname, 256);
- hostname = strdup(_hostname);
- free_hostname = true;
-
- homedir = ::getenv( "HOME" );
-
+ hostname = _hostname;
+
signal(SIGPIPE, SIG_IGN);
#endif
if (std::strlen(t.getOrigin()) != 0)
cerr << " (received from " << t.getOrigin() << ')' << endl;
- } catch (const string &s) {
+ } catch (const std::string &s) {
cerr << "Fatal error: " << s << endl;
} catch (const char *s) {
return 0;
}
-// do some clean up on exit. Specifically we want to call alutExit()
-// which happens in the sound manager destructor.
+// do some clean up on exit. Specifically we want to delete the sound-manager,
+// so OpenAL device and context are released cleanly
void fgExitCleanup() {
if (_bootstrap_OSInit != 0)
fgSetMouseCursor(MOUSE_CURSOR_POINTER);
delete globals;
-
- if (free_hostname && hostname != NULL)
- free(hostname);
}