src/proto2/Application.cc
branchno-netsession
changeset 35 e21cfda0edde
parent 25 af75a1894a32
child 36 785d220fc6b7
child 89 825c4613e087
equal deleted inserted replaced
34:1ea6554d703e 35:e21cfda0edde
    76                         throw ArgumentError(std::string(1, (char) args.get_key()));
    76                         throw ArgumentError(std::string(1, (char) args.get_key()));
    77 
    77 
    78                 }
    78                 }
    79             }
    79             }
    80             
    80             
    81             // check for valid combinations of arugments
    81             // check for invalid combinations of arugments
    82             if (!(arg_server xor !arg_connect.empty()))
    82             if (arg_server and !arg_connect.empty())
    83                 throw ArgumentError("must supply *exactly* one of --server/--client");
    83                 throw ArgumentError("cannot be both server and client");
    84         }
    84         }
    85 
    85 
    86     public:
    86     public:
    87         virtual int main (int argc, char **argv) {
    87         virtual int main (int argc, char **argv) {
    88             // initialize the ClanLib components that we use
    88             // initialize the ClanLib components that we use
   100                 
   100                 
   101                 // setup graphics
   101                 // setup graphics
   102                 if (arg_graphics)
   102                 if (arg_graphics)
   103                     engine.setupGraphics();
   103                     engine.setupGraphics();
   104 
   104 
   105                 // setup either network server or client
   105                 // setup either network server, client or singleplayer
   106                 if (arg_server) {
   106                 if (arg_server) {
   107                     engine.setupNetworkServer(arg_port);
   107                     engine.setupNetworkServer(arg_port);
   108 
   108 
   109                 } else if (!arg_connect.empty()) {
   109                 } else if (!arg_connect.empty()) {
   110                     engine.setupNetworkClient(arg_connect, arg_port);
   110                     engine.setupNetworkClient(arg_connect, arg_port);
   111                 
   111                 
   112                 } else
   112                 } else {
   113                     assert(false);
   113                     engine.setupSinglePlayer();
       
   114                 }
   114 
   115 
   115                 // run the main loop
   116                 // run the main loop
   116                 engine.run();
   117                 engine.run();
   117                 
   118                 
   118                 // succesful return
   119                 // succesful return