| 65 | } |
| 66 | |
| 67 | Host::Host( const int argc, const char* const* const argv ) |
| 68 | : program_arguments_( argc, argv ) |
| 69 | , settings_( "PanzerChasm.cfg" ) |
| 70 | , commands_processor_( settings_ ) |
| 71 | { |
| 72 | { // Register host commands |
| 73 | CommandsMapPtr commands= std::make_shared<CommandsMap>(); |
| 74 | |
| 75 | commands->emplace( "quit", std::bind( &Host::Quit, this ) ); |
| 76 | commands->emplace( "new", std::bind( &Host::NewGameCommand, this, std::placeholders::_1 ) ); |
| 77 | commands->emplace( "go", std::bind( &Host::RunLevelCommand, this, std::placeholders::_1 ) ); |
| 78 | commands->emplace( "connect", std::bind( &Host::ConnectCommand, this, std::placeholders::_1 ) ); |
| 79 | commands->emplace( "disconnect", std::bind( &Host::DisconnectCommand, this ) ); |
| 80 | commands->emplace( "runserver", std::bind( &Host::RunServerCommand, this, std::placeholders::_1 ) ); |
| 81 | commands->emplace( "save", std::bind( &Host::SaveCommand, this, std::placeholders::_1 ) ); |
| 82 | commands->emplace( "load", std::bind( &Host::LoadCommand, this, std::placeholders::_1 ) ); |
| 83 | commands->emplace( "vid_restart", std::bind( &Host::VidRestart, this ) ); |
| 84 | |
| 85 | host_commands_= std::move( commands ); |
| 86 | commands_processor_.RegisterCommands( host_commands_ ); |
| 87 | } |
| 88 | |
| 89 | base_window_title_= "PanzerChasm"; |
| 90 | |
| 91 | { |
| 92 | Log::Info( "Read game archive" ); |
| 93 | |
| 94 | const char* csm_file= "CSM.BIN"; |
| 95 | if( const char* const overrided_csm_file = program_arguments_.GetParamValue( "csm" ) ) |
| 96 | { |
| 97 | csm_file= overrided_csm_file; |
| 98 | Log::Info( "Trying to load CSM file: \"", overrided_csm_file, "\"" ); |
| 99 | } |
| 100 | |
| 101 | const char* const addon_path= program_arguments_.GetParamValue( "addon" ); |
| 102 | if( addon_path != nullptr ) |
| 103 | { |
| 104 | base_window_title_+= " - "; |
| 105 | base_window_title_+= addon_path; |
| 106 | |
| 107 | Log::Info( "Trying to load addon \"", addon_path, "\"" ); |
| 108 | } |
| 109 | |
| 110 | vfs_= std::make_shared<Vfs>( csm_file, addon_path ); |
| 111 | } |
| 112 | |
| 113 | // Create directory for saves. |
| 114 | // TODO - allow user change this directory, using command-line argument or settings, for example. |
| 115 | CreateSlotSavesDir(); |
| 116 | |
| 117 | Log::Info( "Loading game resources" ); |
| 118 | game_resources_= LoadGameResources( vfs_ ); |
| 119 | |
| 120 | VidRestart(); |
| 121 | |
| 122 | Log::Info( "Initialize console" ); |
| 123 | console_.reset( new Console( commands_processor_, shared_drawers_ ) ); |
| 124 |
nothing calls this directly
no test coverage detected