[612] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
[1293] | 3 | * > www.orxonox.net < |
---|
[612] | 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 |
---|
[1755] | 24 | * Reto Grieder |
---|
[612] | 25 | * Co-authors: |
---|
| 26 | * ... |
---|
| 27 | * |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | /** |
---|
[1021] | 31 | @file |
---|
[2710] | 32 | @brief Entry point of the program. |
---|
[612] | 33 | */ |
---|
| 34 | |
---|
[1293] | 35 | #include "OrxonoxStableHeaders.h" |
---|
[2799] | 36 | #include "OrxonoxConfig.h" |
---|
[612] | 37 | |
---|
[1293] | 38 | #include <exception> |
---|
[1755] | 39 | #include <cassert> |
---|
[1293] | 40 | |
---|
[1891] | 41 | #include "util/Debug.h" |
---|
[2799] | 42 | #include "core/Core.h" |
---|
[2662] | 43 | #include "core/Identifier.h" |
---|
[612] | 44 | |
---|
[1755] | 45 | #include "gamestates/GSRoot.h" |
---|
| 46 | #include "gamestates/GSGraphics.h" |
---|
| 47 | #include "gamestates/GSStandalone.h" |
---|
| 48 | #include "gamestates/GSServer.h" |
---|
| 49 | #include "gamestates/GSClient.h" |
---|
| 50 | #include "gamestates/GSDedicated.h" |
---|
| 51 | #include "gamestates/GSGUI.h" |
---|
| 52 | #include "gamestates/GSIOConsole.h" |
---|
| 53 | |
---|
[2710] | 54 | #ifdef ORXONOX_PLATFORM_APPLE |
---|
[612] | 55 | #include <CoreFoundation/CoreFoundation.h> |
---|
| 56 | |
---|
| 57 | // This function will locate the path to our application on OS X, |
---|
| 58 | // unlike windows you can not rely on the curent working directory |
---|
| 59 | // for locating your configuration files and resources. |
---|
| 60 | std::string macBundlePath() |
---|
| 61 | { |
---|
[1755] | 62 | char path[1024]; |
---|
| 63 | CFBundleRef mainBundle = CFBundleGetMainBundle(); |
---|
| 64 | assert(mainBundle); |
---|
[612] | 65 | |
---|
[1755] | 66 | CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); |
---|
| 67 | assert(mainBundleURL); |
---|
[612] | 68 | |
---|
[1755] | 69 | CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); |
---|
| 70 | assert(cfStringRef); |
---|
[612] | 71 | |
---|
[1755] | 72 | CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); |
---|
[612] | 73 | |
---|
[1755] | 74 | CFRelease(mainBundleURL); |
---|
| 75 | CFRelease(cfStringRef); |
---|
[612] | 76 | |
---|
[1755] | 77 | return std::string(path); |
---|
[612] | 78 | } |
---|
| 79 | #endif |
---|
| 80 | |
---|
| 81 | |
---|
[2103] | 82 | |
---|
[1755] | 83 | int main(int argc, char** argv) |
---|
[622] | 84 | { |
---|
[2799] | 85 | orxonox::Core* core = new orxonox::Core(argc, argv); |
---|
| 86 | if (!core->isLoaded()) |
---|
[2103] | 87 | { |
---|
[2799] | 88 | COUT(0) << "Core was not fully loaded, probably an exception occurred during consruction. Aborting" << std::endl; |
---|
| 89 | abort(); |
---|
[2103] | 90 | } |
---|
| 91 | |
---|
[2662] | 92 | // put GameStates in its own scope so we can destroy the identifiers at the end of main(). |
---|
| 93 | { |
---|
[2799] | 94 | using namespace orxonox; |
---|
[2662] | 95 | // create the gamestates |
---|
| 96 | GSRoot root; |
---|
| 97 | GSGraphics graphics; |
---|
| 98 | GSStandalone standalone; |
---|
| 99 | GSServer server; |
---|
| 100 | GSClient client; |
---|
| 101 | GSDedicated dedicated; |
---|
| 102 | GSGUI gui; |
---|
| 103 | GSIOConsole ioConsole; |
---|
[612] | 104 | |
---|
[2662] | 105 | // make the hierarchy |
---|
| 106 | root.addChild(&graphics); |
---|
| 107 | graphics.addChild(&standalone); |
---|
| 108 | graphics.addChild(&server); |
---|
| 109 | graphics.addChild(&client); |
---|
| 110 | graphics.addChild(&gui); |
---|
| 111 | root.addChild(&ioConsole); |
---|
| 112 | root.addChild(&dedicated); |
---|
[1755] | 113 | |
---|
[2662] | 114 | // Here happens the game |
---|
| 115 | root.start(); |
---|
| 116 | } |
---|
[1755] | 117 | |
---|
[2799] | 118 | // Destroy pretty much everyhting left |
---|
[2662] | 119 | delete core; |
---|
[2103] | 120 | |
---|
[2662] | 121 | // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand) |
---|
[2799] | 122 | // Needs to be done after 'delete core' because of ~OrxonoxClass |
---|
| 123 | orxonox::Identifier::destroyAllIdentifiers(); |
---|
[2662] | 124 | |
---|
[1755] | 125 | return 0; |
---|
[612] | 126 | } |
---|