/[usata]/usata2/src/main.cpp
ViewVC logotype

Diff of /usata2/src/main.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by skunix, Sun Dec 26 09:35:23 2004 UTC revision 1.19 by skunix, Sun Dec 26 09:59:13 2004 UTC
# Line 12  Line 12 
12  //  //
13  // $Id$  // $Id$
14  // $Log$  // $Log$
15    // Revision 1.19  2004/12/26 09:59:13  skunix
16    // added base exceptions
17    //
18  // Revision 1.18  2004/12/26 09:35:23  skunix  // Revision 1.18  2004/12/26 09:35:23  skunix
19  // use logging functionality  // use logging functionality
20  //  //
# Line 32  Line 35 
35    
36  #include <string>  #include <string>
37  #include <iostream>  #include <iostream>
 #include <cstdlib>  
38    
39  #include <boost/format.hpp>  #include <boost/format.hpp>
 #include <boost/program_options.hpp>  
   
40  #include "system.hpp"  #include "system.hpp"
41  #include "build_info.hpp"  #include "build_info.hpp"
42  #include "usata.hpp"  #include "usata.hpp"
43  #include "config.hpp"  #include "config.hpp"
44  #include "log.hpp"  #include "log.hpp"
45    #include "exception_types.hpp"
46  using namespace usata;  using namespace usata;
47    
48  namespace usata  namespace usata
# Line 112  int main(int argc, char **argv) Line 112  int main(int argc, char **argv)
112          init_config();          init_config();
113          cxx_init();          cxx_init();
114    
115          Configuration* op_conf = parse_options(argc, argv);          std::auto_ptr<Configuration> op_conf(parse_options(argc, argv));
116    
117          // load config          // load config
118          ConfigSection csection("config");          ConfigSection csection("config");
# Line 121  int main(int argc, char **argv) Line 121  int main(int argc, char **argv)
121          std::string cfile = csection.get("filename",get_default_config_file());          std::string cfile = csection.get("filename",get_default_config_file());
122          load_config(cfile);          load_config(cfile);
123          op_conf->value_export(get_configuration());          op_conf->value_export(get_configuration());
124            op_conf.reset();
125          setup_log();          setup_log();
126          logstream << boost::format("Loaded config file \"%1%\"") % cfile << log::Commit;          logstream << boost::format("Loaded config file \"%1%\"") % cfile << log::Commit;
127          // then export op_conf          // then export op_conf
         delete op_conf;  
128    
129          try          try
130          {          {
# Line 135  int main(int argc, char **argv) Line 135  int main(int argc, char **argv)
135                  logstream << log::set_level(log::Level::ERROR) << "system::init() failed:\n\t" << error.what();                  logstream << log::set_level(log::Level::ERROR) << "system::init() failed:\n\t" << error.what();
136                  return 1;                  return 1;
137          }          }
138            int exit_value;
139            try
140            {
141                    Usata game;
142                    int exit_value = game.run();
143            }
144            catch (std::runtime_error& error)
145            {
146                    std::cerr << "uncaught exception occurred" <<std::endl;
147                    std::cerr << "This is a bug in the program." <<std::endl;
148                    std::cerr << ">>> " << error.what() << std::endl;      
149            }
150            catch (FatalError &fe)
151            {
152                    std::cerr << "FATAL: "  << fe.what() << std::endl;
153                    exit_value = 1;
154            }
155    
         Usata game;  
         int exit_value = game.run();  
           
156          usata::system::quit();            usata::system::quit();  
   
157          return exit_value;          return exit_value;
158  }  }
159    

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26