Fixed windings on map.
[poopmup2.git] / poopmup / main.cpp
blob85a895f04e64c61ee35373f7a7f6e7303f8c477d
1 /**
2 * @file main.cpp
3 * The mainline driver for PoopmUp.
5 * Copyright 2008, 2010 Stephen M. Webb <stephenw@poopmup.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <fstream>
23 #include <iostream>
24 #include <poopmup/application.h>
25 #include <SDL/SDL_main.h>
26 #include <string>
29 namespace
31 /**
32 * A class that futzes around wit cerr to force-redirect it to a log file.
33 * This is mostly for use on windows or under a GUI where stderr is not
34 * normally seen except by gooroos.
36 class LogFutzer
38 public:
39 // Redirects stderr into a log file.
40 LogFutzer(std::ostream& stream, const std::string& fname)
41 : m_stream(stream)
42 , m_errbuf(std::cerr.rdbuf())
43 , m_logfile(fname.c_str())
45 m_stream.rdbuf(m_logfile.rdbuf());
48 // Restores stderr.
49 ~LogFutzer()
51 m_stream.rdbuf(m_errbuf);
54 private:
55 std::ostream& m_stream;
56 std::streambuf* m_errbuf;
57 std::ofstream m_logfile;
59 } // anonymous namespace
62 /**
63 * @brief The main entyry point for the game.
65 int main(int argc, char* argv[])
67 #if defined(_WIN32)
68 LogFutzer out(std::cout, "poopmup.out");
69 LogFutzer err(std::cerr, "poopmup.err");
70 #endif
72 // Create and run the application.
73 Poopmup::Application application(argc, argv);
74 return application.exec();