1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * > www.orxonox.net < |
---|
4 | * |
---|
5 | * |
---|
6 | * License notice: |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
21 | * |
---|
22 | * Author: |
---|
23 | * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 |
---|
24 | * Reto Grieder |
---|
25 | * Co-authors: |
---|
26 | * ... |
---|
27 | * |
---|
28 | */ |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | /** |
---|
33 | @file |
---|
34 | @brief |
---|
35 | Entry point of the program. |
---|
36 | */ |
---|
37 | |
---|
38 | #include "SpecialConfig.h" |
---|
39 | |
---|
40 | #ifdef ORXONOX_USE_WINMAIN |
---|
41 | # ifndef WIN32_LEAN_AND_MEAN |
---|
42 | # define WIN32_LEAN_AND_MEAN |
---|
43 | # endif |
---|
44 | #include <windows.h> |
---|
45 | #endif |
---|
46 | |
---|
47 | #include "util/Output.h" |
---|
48 | #include "util/Exception.h" |
---|
49 | #include "orxonox/Main.h" |
---|
50 | |
---|
51 | /* |
---|
52 | @brief |
---|
53 | Main method. Game starts here (except for static initialisations). |
---|
54 | */ |
---|
55 | #ifdef ORXONOX_USE_WINMAIN |
---|
56 | INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) |
---|
57 | #elif defined(ORXONOX_PLATFORM_APPLE) |
---|
58 | int main_mac(int argc, char** argv) |
---|
59 | #else |
---|
60 | int main(int argc, char** argv) |
---|
61 | #endif |
---|
62 | { |
---|
63 | using namespace orxonox; |
---|
64 | |
---|
65 | orxout(user_status) << "Welcome to Orxonox (v" << ORXONOX_VERSION_MAJOR << '.' << ORXONOX_VERSION_MINOR << '.' << ORXONOX_VERSION_PATCH << ' ' << ORXONOX_VERSION_NAME << ')' << endl; |
---|
66 | orxout(internal_status) << "Congratulations, you survived the static initialization. Entering main()" << endl; |
---|
67 | if (argc > 0) |
---|
68 | orxout(internal_info) << "argv[0]: " << argv[0] << endl; |
---|
69 | |
---|
70 | try |
---|
71 | { |
---|
72 | #ifndef ORXONOX_USE_WINMAIN |
---|
73 | |
---|
74 | #ifdef ORXONOX_PLATFORM_APPLE |
---|
75 | // On Apples, the kernel supplies a second argument, which we have to circumvent |
---|
76 | const int firstArgument = 2; |
---|
77 | #else |
---|
78 | // 0 is the execution path |
---|
79 | const int firstArgument = 1; |
---|
80 | #endif |
---|
81 | |
---|
82 | std::string strCmdLine; |
---|
83 | for (int i = firstArgument; i < argc; ++i) |
---|
84 | strCmdLine = strCmdLine + argv[i] + ' '; |
---|
85 | #endif |
---|
86 | |
---|
87 | int value = main(strCmdLine); |
---|
88 | orxout(internal_status) << "Terminating main() normally with value " << value << endl; |
---|
89 | return value; |
---|
90 | } |
---|
91 | catch (...) |
---|
92 | { |
---|
93 | orxout(user_error) << "Exception caught in main(): " << orxonox::Exception::handleMessage() << endl; |
---|
94 | orxout(user_error) << "Terminating program." << endl; |
---|
95 | return 1; |
---|
96 | } |
---|
97 | } |
---|