[5635] | 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 | |
---|
[10017] | 30 | |
---|
| 31 | |
---|
[5635] | 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 | |
---|
[8858] | 47 | #include "util/Output.h" |
---|
[5747] | 48 | #include "util/Exception.h" |
---|
[5733] | 49 | #include "orxonox/Main.h" |
---|
[5635] | 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) |
---|
[8351] | 57 | #elif defined(ORXONOX_PLATFORM_APPLE) |
---|
| 58 | int main_mac(int argc, char** argv) |
---|
[5635] | 59 | #else |
---|
| 60 | int main(int argc, char** argv) |
---|
| 61 | #endif |
---|
| 62 | { |
---|
[8858] | 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 | |
---|
[5635] | 70 | try |
---|
| 71 | { |
---|
| 72 | #ifndef ORXONOX_USE_WINMAIN |
---|
[8351] | 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 |
---|
[8858] | 81 | |
---|
[5635] | 82 | std::string strCmdLine; |
---|
[8351] | 83 | for (int i = firstArgument; i < argc; ++i) |
---|
[6417] | 84 | strCmdLine = strCmdLine + argv[i] + ' '; |
---|
[5929] | 85 | #endif |
---|
[5635] | 86 | |
---|
[8858] | 87 | int value = main(strCmdLine); |
---|
| 88 | orxout(internal_status) << "Terminating main() normally with value " << value << endl; |
---|
| 89 | return value; |
---|
[5635] | 90 | } |
---|
| 91 | catch (...) |
---|
| 92 | { |
---|
[8858] | 93 | orxout(user_error) << "Exception caught in main(): " << orxonox::Exception::handleMessage() << endl; |
---|
| 94 | orxout(user_error) << "Terminating program." << endl; |
---|
[5635] | 95 | return 1; |
---|
| 96 | } |
---|
| 97 | } |
---|