| 163 | constexpr path_translator<config_tree::data_type> config_tree_path_translator; |
| 164 | |
| 165 | void load_config() { |
| 166 | config_tree config; |
| 167 | boost::filesystem::path path(get_config_path()); |
| 168 | if (boost::filesystem::is_regular_file(path)) |
| 169 | boost::property_tree::read_info(boost::filesystem::ifstream(path), config); |
| 170 | bool modified = set_defaults(config); |
| 171 | |
| 172 | if (!boost::filesystem::is_directory(path.parent_path())) |
| 173 | if (!boost::filesystem::create_directory(path.parent_path())) throw std::exception(); |
| 174 | if (modified) boost::property_tree::write_info(boost::filesystem::ofstream(path), config); |
| 175 | |
| 176 | glo_windowed_mode = config.get<bool>("window"); |
| 177 | config_assets_name = config.get<std::string>("assets"); |
| 178 | |
| 179 | config_gamepath = config.get<boost::filesystem::path>("gamepath", config_tree_path_translator); |
| 180 | if (config_gamepath.empty()) { |
| 181 | config_gamepath = try_default_paths(); |
| 182 | if (config_gamepath.empty()) config_gamepath = ask_game_path(); |
| 183 | config.put("gamepath", config_gamepath, config_tree_path_translator); |
| 184 | boost::property_tree::write_info(boost::filesystem::ofstream(path), config); |
| 185 | } |
| 186 | |
| 187 | glo_Settings.tree_load_settings(config.get_child("settings")); |
| 188 | |
| 189 | net_config.main = config.get<std::string>("net.main"); |
| 190 | net_config.master = config.get<std::string>("net.master"); |
| 191 | net_config.natneg1 = config.get<std::string>("net.natneg1"); |
| 192 | net_config.natneg2 = config.get<std::string>("net.natneg2"); |
| 193 | |
| 194 | if (!net_config.main.empty()) glo_6C4C74 = net_config.main.c_str(); // ms0 |
| 195 | if (!net_config.master.empty()) safe_strncpy(glo_6C4EA0, net_config.master.c_str(), sizeof(glo_6C4EA0)); // master |
| 196 | if (!net_config.natneg1.empty()) glo_6738A0 = net_config.natneg1.c_str(); // natneg1 |
| 197 | if (!net_config.natneg2.empty()) glo_6738A4 = net_config.natneg2.c_str(); // natneg2 |
| 198 | |
| 199 | // This should be set via the debug options, but that doesn't work correctly as-is. |
| 200 | boost::filesystem::current_path(config_gamepath); |
| 201 | AddDllHooks(config_gamepath); |
| 202 | } |
| 203 | |
| 204 | void save_config() { |
| 205 | config_tree config; |
no test coverage detected