// ----------------------------------------------------------- // town data // ----------------------------------------------------------- bool t_abstract_town::read_map_data( std::streambuf& stream, t_progress_handler* handler, bool& custom_garrison, bool& custom_buildings, bool & customized_school_skills, t_skill_set & available_school_skills, t_skill_set & required_school_skills ) { int version = get< t_uint16 >( stream ); if ( version < 6 || version > k_current_map_format_version ) return false; return read_map_data( stream, handler, custom_garrison, custom_buildings, customized_school_skills, available_school_skills, required_school_skills, version ); }
void RandomGenerateMap() { int trying = 1; if (game_load) { NewLevel(); /* FIXME: de-globalise this. */ read_map_data (&save); } else { NewLevel(); while (trying) { trying = !Generate(); } } /* SaveLevel(); */ }
extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) { msi_helper h(hInstall, _T("ImportConfig")); try { h.logMessage("importing config"); std::wstring target = h.getTargetPath(_T("INSTALLLOCATION")); std::wstring main = h.getPropery(_T("MAIN_CONFIGURATION_FILE")); std::wstring custom = h.getPropery(_T("CUSTOM_CONFIGURATION_FILE")); std::wstring allow = h.getPropery(_T("ALLOW_CONFIGURATION")); std::wstring pwd = h.getPropery(_T("NSCLIENT_PWD")); if (pwd == _T("$GEN$")) { h.setProperty(_T("NSCLIENT_PWD"), genpwd(16)); } std::wstring tmpPath = h.getTempPath(); std::wstring map_data = read_map_data(h); if (allow == _T("0")) { h.logMessage(_T("Configuration not allowed: ") + allow); h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); h.setProperty(_T("CONF_HAS_ERRORS"), _T("0")); return ERROR_SUCCESS; } if (!boost::filesystem::is_directory(utf8::cvt<std::string>(target))) { h.logMessage(_T("Target folder not found: ") + target); h.setProperty(_T("CONF_CAN_CHANGE"), _T("1")); h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); h.setProperty(_T("CONF_HAS_ERRORS"), _T("0")); return ERROR_SUCCESS; } boost::filesystem::path restore_path = h.getTempPath(); restore_path = restore_path / (_T("old_nsc.ini")); boost::filesystem::path old_path = target; old_path = old_path / (_T("nsc.ini")); h.logMessage(_T("Looking for old settings file (for archiving): ") + old_path.wstring()); h.logMessage(_T("Using restore path: ") + restore_path.wstring()); if (boost::filesystem::exists(old_path)) { h.logMessage(_T("Found old file: ") + strEx::xtos(boost::filesystem::file_size(old_path))); h.setProperty(_T("RESTORE_FILE"), restore_path.wstring()); copy_file(h, old_path.wstring(), restore_path.wstring()); } if (boost::filesystem::exists(restore_path)) h.logMessage(_T("Found restore file: ") + strEx::xtos(boost::filesystem::file_size(restore_path))); installer_settings_provider provider(&h, target, map_data); if (!settings_manager::init_settings(&provider, "")) { h.logMessage(_T("Settings context had fatal errors")); h.setProperty(_T("CONF_OLD_ERROR"), get_impl()->get_error()); h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); } if (get_impl()->has_errors()) { h.logMessage(_T("Settings context reported errors (debug log end)")); BOOST_FOREACH(std::wstring l, get_impl()->log_) { h.logMessage(l); } h.logMessage(_T("Settings context reported errors (debug log end)")); if (!settings_manager::has_boot_conf()) { h.logMessage(_T("boot.conf was NOT found (so no new configuration)")); if (settings_manager::context_exists(DEFAULT_CONF_OLD_LOCATION)) { h.logMessage("Old configuration found: " DEFAULT_CONF_OLD_LOCATION); h.setProperty(_T("CONF_OLD_ERROR"), std::wstring(_T("Old configuration (")) + utf8::cvt<std::wstring>(DEFAULT_CONF_OLD_LOCATION) + _T(") was found but we got errors accessing it: ") + get_impl()->get_error()); h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); return ERROR_SUCCESS; } else { h.logMessage(_T("Failed to read configuration but no configuration was found (so we are assuming there is no configuration).")); h.setProperty(_T("CONF_CAN_CHANGE"), _T("1")); h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); h.setProperty(_T("CONF_HAS_ERRORS"), _T("0")); return ERROR_SUCCESS; } } else { h.logMessage(_T("boot.conf was found but we got errors booting it...")); h.setProperty(_T("CONF_OLD_ERROR"), get_impl()->get_error()); h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); return ERROR_SUCCESS; } }