2 // Copyright (C) 2007 by Martin Moracek
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * @file server/main.cpp
22 * This file contains the main() function for the terra client.
24 * main() simply initializes few core subsystems, parses command line and
25 * executes the application instance.
28 #include "../core/platform.h"
29 #include "../core/exception.h"
31 #include "../support/vfs.h"
33 #include "../framework/application.h"
35 void ParseArguments(int argc
, char * argv
[])
37 for(int i
= 1; i
< argc
; ++i
) {
38 if(argv
[i
][0] == '-') {
40 case 'm': // mount directory
42 vfs::vLog
<< "Error: Too few parameters for mounting.\n";
45 if(!vfs::sInterface().HasRoot() && strcmp(argv
[i
+ 2], "/") != 0) {
46 vfs::vLog
<< "Error: First mounted directory "
50 if(!vfs::sInterface().MountPath(argv
[i
+ 1], argv
[i
+ 2])) {
51 vfs::vLog
<< "Error: Unable to mount directory ";
52 // "'%s' as '%s',\n", argv[i + 1], argv[i + 2]);
58 vfs::vLog
<< "Warning: Unknown command line ";
59 // "argument '%s'.\n", argv[i];
66 int main(int argc
, char * argv
[])
69 // turn off exhaustive logging
70 SET_LOG_ALWAYS(false);
72 // check program arguments
73 ParseArguments(argc
,argv
);
75 // mount default root if needed
76 if(!vfs::sInterface().HasRoot())
77 throw(Exception("Unable to initialize vfs"));
79 // create and run the game instance
80 framework::Application server
;
84 } catch(std::exception
& exc
) {
85 vfs::vLog
<< "Error: Caught fatal exception: %s!\n";
86 // "Error: Program termination imminent!\n",exc.what());
89 vfs::vLog
<< "Error: Caught unhandled exception!\n";
90 // "Error: Program termination imminent!\n");