void BuildModule::LoadState(INI_Reader &ini) { while (ini.read_value()) { if (ini.is_value("build_type")) { build_type = ini.get_value_int(0); } else if (ini.is_value("produced_item")) { active_recipe.produced_item = ini.get_value_int(0); } else if (ini.is_value("cooking_rate")) { active_recipe.cooking_rate = ini.get_value_int(0); } else if (ini.is_value("infotext")) { active_recipe.infotext = stows(ini.get_value_string()); } else if (ini.is_value("consumed")) { active_recipe.consumed_items[ini.get_value_int(0)] = ini.get_value_int(1); } } }
/** Read the asteroid sections out of the system ini */ void ReadSystemLootableZones(zone_map_t &set_mmapZones, const string &systemNick, const string &file) { string path="..\\data\\universe\\"; path += file; INI_Reader ini; if (ini.open(path.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("Asteroids")) { string file=""; string zoneNick=""; while (ini.read_value()) { if (ini.is_value("zone")) zoneNick=ToLower(ini.get_value_string()); if (ini.is_value("file")) file=ini.get_value_string(); } ReadLootableZone(set_mmapZones, systemNick,zoneNick, file); } } ini.close(); } }
//Load from our INI void LoadIni() { char CurDir[_MAX_PATH]; GetCurrentDirectoryA(sizeof(CurDir), CurDir); string ini_file = string(CurDir) + "\\STLExample.ini"; testMap.clear(); myList.clear(); myVector.clear(); if (myQueue.empty() != true) { queue<string> empty; swap(myQueue, empty); //This literally swaps all of the values in myQueue out with empty, which is an empty queue at all times, this is one of the only ways to properly clear memory from a queue. } myDeque.clear(); INI_Reader ini; if (ini.open(ini_file.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("MAP_EXAMPLE")) { myStruct mapExample; while (ini.read_value()) { if (ini.is_value("id")) { mapExample.id = ini.get_value_int(0); } else if (ini.is_value("name")) { mapExample.name = ini.get_value_string(); } } testMap[mapExample.id] = mapExample; } else if (ini.is_header("LIST_EXAMPLE")) { myStruct listStruct; while (ini.read_value()) { if (ini.is_value("id")) { listStruct.id = ini.get_value_int(0); } else if (ini.is_value("name")) { listStruct.name = ini.get_value_string(); } } myList.push_back(listStruct); } } ini.close(); } }
void LoadSettings(const string &scPluginCfgFile) { set_iRenameCost = IniGetI(scPluginCfgFile, "Rename", "RenameCost", 5000000); set_iRenameTimeLimit = IniGetI(scPluginCfgFile, "Rename", "RenameTimeLimit", 3600); set_iMoveCost = IniGetI(scPluginCfgFile, "Rename", "MoveCost", 5000000); set_bCharnameTags = IniGetB(scPluginCfgFile, "Rename", "CharnameTag", false); set_bAsciiCharnameOnly = IniGetB(scPluginCfgFile, "Rename", "AsciiCharnameOnly", true); set_iMakeTagCost = IniGetI(scPluginCfgFile, "Rename", "MakeTagCost", 50000000); char szDataPath[MAX_PATH]; GetUserDataPath(szDataPath); string scPath = string(szDataPath) + "\\Accts\\MultiPlayer\\tags.ini"; INI_Reader ini; if (ini.open(scPath.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("faction")) { wstring tag; while (ini.read_value()) { if (ini.is_value("tag")) { ini_get_wstring(ini, tag); mapTagToPassword[tag].tag = tag; } else if (ini.is_value("master_password")) { wstring pass; ini_get_wstring(ini, pass); mapTagToPassword[tag].master_password = pass; } else if (ini.is_value("rename_password")) { wstring pass; ini_get_wstring(ini, pass); mapTagToPassword[tag].rename_password = pass; } else if (ini.is_value("last_access")) { mapTagToPassword[tag].last_access = ini.get_value_int(0); } else if (ini.is_value("description")) { wstring description; ini_get_wstring(ini, description); mapTagToPassword[tag].description = description; } } } } ini.close(); } }
/** Read freelancer data to determine mod settings. */ void EquipmentUtilities::ReadIniNicknames() { string dataDirPath = "..\\data"; INI_Reader ini; if (ini.open("freelancer.ini", false)) { while (ini.read_header()) { if (ini.is_header("Freelancer")) { while (ini.read_value()) { if (ini.is_value("data path")) { dataDirPath = ini.get_value_string(); break; } } } } ini.close(); } mapHashToNickname.clear(); if (ini.open("freelancer.ini", false)) { while (ini.read_header()) { if (ini.is_header("Data")) { while (ini.read_value()) { if (ini.is_value("equipment")) { ReadIniNicknameFile(dataDirPath+string("\\")+ini.get_value_string()); } else if (ini.is_value("ships")) { ReadIniNicknameFile(dataDirPath+string("\\")+ini.get_value_string()); } else if (ini.is_value("goods")) { ReadIniNicknameFile(dataDirPath+string("\\")+ini.get_value_string()); } else if (ini.is_value("loadouts")) { ReadIniNicknameFile(dataDirPath+string("\\")+ini.get_value_string()); } } } } ini.close(); } }
bool HkLoadBaseMarket() { INI_Reader ini; if(!ini.open("..\\data\\equipment\\market_misc.ini", false)) return false; while(ini.read_header()) { try { if(!ini.is_header("BaseGood")) throw ""; if(!ini.read_value()) throw ""; if(!ini.is_value("base")) throw ""; const char *szBaseName = ini.get_value_string(); BASE_INFO *biBase = 0; foreach(lstBases, BASE_INFO, it) { const char *szBN = it->scBasename.c_str(); if(!ToLower(it->scBasename).compare(ToLower(szBaseName))) { biBase = &(*it); break; } } if(!biBase) throw ""; // base not found ini.read_value(); biBase->lstMarketMisc.clear(); if(!ini.is_value("MarketGood")) throw ""; do { DATA_MARKETITEM mi; const char *szEquipName = ini.get_value_string(0); mi.iArchID = CreateID(szEquipName); mi.fRep = ini.get_value_float(2); biBase->lstMarketMisc.push_back(mi); } while(ini.read_value()); } catch(char*) {} } ini.close(); return true; }
/** Read all systems in the universe ini */ void ReadUniverse(zone_map_t &set_mmapZones) { // Read all system ini files and build the lootable zone list. INI_Reader ini; if (ini.open("..\\data\\universe\\universe.ini", false)) { while (ini.read_header()) { if (ini.is_header("System")) { string systemNick=""; string file=""; while (ini.read_value()) { if (ini.is_value("nickname")) systemNick = ToLower(ini.get_value_string()); if (ini.is_value("file")) file = ini.get_value_string(); } ReadSystemLootableZones(set_mmapZones, systemNick,file); } } ini.close(); } // Read all system ini files again this time extracting zone size/postion // information for the lootable zone list. if (ini.open("..\\data\\universe\\universe.ini", false)) { while (ini.read_header()) { if (ini.is_header("System")) { string systemNick=""; string file=""; while (ini.read_value()) { if (ini.is_value("nickname")) systemNick = ini.get_value_string(); if (ini.is_value("file")) file = ini.get_value_string(); } ReadSystemZones(set_mmapZones, systemNick,file); } } ini.close(); } }
void REP::LoadSettings() { // The path to the configuration file. char szCurDir[MAX_PATH]; GetCurrentDirectory(sizeof(szCurDir), szCurDir); string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\alley_rep.cfg"; INI_Reader ini; if (ini.open(scPluginCfgFile.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("reputations")) { while (ini.read_value()) { if (ini.is_value("rep")) { uint solarnick = CreateID(ini.get_value_string(0)); const char* newrep = ini.get_value_string(1); ConPrint(L"DEBUG: Rep of %s is %s \n", stows(ini.get_value_string(0)).c_str(), stows(ini.get_value_string(1)).c_str()); uint obj_rep_group; pub::Reputation::GetReputationGroup(obj_rep_group, newrep); pub::Reputation::SetAffiliation(solarnick, obj_rep_group); } } } } ini.close(); } }
void HkLoadStringDLLs() { HkUnloadStringDLLs(); HINSTANCE hDLL = LoadLibraryEx("resources.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); //typically resources.dll if(hDLL) vDLLs.push_back(hDLL); INI_Reader ini; if (ini.open("freelancer.ini", false)) { while (ini.read_header()) { if (ini.is_header("Resources")) { while (ini.read_value()) { if (ini.is_value("DLL")) { hDLL = LoadLibraryEx(ini.get_value_string(0), NULL, LOAD_LIBRARY_AS_DATAFILE); if (hDLL) vDLLs.push_back(hDLL); } } } } ini.close(); } }
void AP::LoadSettings() { // The path to the configuration file. char szCurDir[MAX_PATH]; GetCurrentDirectory(sizeof(szCurDir), szCurDir); string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\alley_permissions.cfg"; INI_Reader ini; if (ini.open(scPluginCfgFile.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("angels")) { while (ini.read_value()) { if (ini.is_value("permission")) { angels.push_back(stows(ini.get_value_string())); } } } else if (ini.is_header("event")) { while (ini.read_value()) { if (ini.is_value("permission")) { events.push_back(stows(ini.get_value_string())); } } } else if (ini.is_header("bastillebase")) { while (ini.read_value()) { if (ini.is_value("base")) { uint base = CreateID(ini.get_value_string()); bastillebase[base] = base; } } } } ini.close(); } }
void FactoryModule::LoadState(INI_Reader &ini) { active_recipe.nickname = 0; while (ini.read_value()) { if (ini.is_value("type")) { type = ini.get_value_int(0); } else if (ini.is_value("nickname")) { active_recipe.nickname = ini.get_value_int(0); } else if (ini.is_value("produced_item")) { active_recipe.produced_item = ini.get_value_int(0); } else if (ini.is_value("cooking_rate")) { active_recipe.cooking_rate = ini.get_value_int(0); } else if (ini.is_value("infotext")) { active_recipe.infotext = stows(ini.get_value_string()); } else if (ini.is_value("consumed")) { active_recipe.consumed_items[ini.get_value_int(0)] = ini.get_value_int(1); } else if (ini.is_value("build_queue")) { build_queue.push_back(ini.get_value_int(0)); } } }
void LoadSettings() { returncode = DEFAULT_RETURNCODE; string File_FLHook = "..\\exe\\flhook_plugins\\changesys.cfg"; int iLoaded = 0; INI_Reader ini; if (ini.open(File_FLHook.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("config")) { while (ini.read_value()) { if (ini.is_value("enabled")) { bPluginEnabled = ini.get_value_bool(0); } } } if (ini.is_header("AllowedSystems")) { while (ini.read_value()) { if (ini.is_value("sys")) { bPluginAllowedSystems.push_back(ini.get_value_string(0)); } if (ini.is_value("desc")) { bPluginAllowedSystemsFriendly = ini.get_value_string(); } } } } ini.close(); } ConPrint(L"ChangeSys: Loaded\n", iLoaded); }
/** Clean up old bounties **/ void CleanUpBounties() { conDebug(L"attempting to clean up bounties"); string File_FLHook_bounties = "..\\exe\\flhook_plugins\\bountytrackerbounties.cfg"; INI_Reader ini; if (ini.open(File_FLHook_bounties.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("bounty")) { while (ini.read_value()) { if (ini.is_value("hit")) { wstring wscTargetName = stows(ini.get_value_string(0)); //if bounty has expired if ((uint)time(0) - stoi(mapBountyTargets[wscTargetName].issueTime) > iBountyAge) { conDebug(L"removing " + wscTargetName); //find bounty BountyTargetInfo BTIc = mapBountyTargets[wscTargetName]; //refund remaining credits to issuer HkAddCash(stows(BTIc.issuer), (stoi(BTIc.Cash) * stoi(BTIc.xTimes)));//issuer needs to be online(?) //notify issuer their bounty has been refunded //delete bounty deleteBountyCfg(BTIc); } //if target has changed name CAccount *caTargetAcc = HkGetAccountByCharname(wscTargetName); int iTargetAcc = stoi(HkGetAccountID(caTargetAcc)); if (iTargetAcc == -1) { //find bounty BountyTargetInfo BTIc = mapBountyTargets[wscTargetName]; //refund remaining credits to issuer HkAddCash(stows(BTIc.issuer), (stoi(BTIc.Cash) * stoi(BTIc.xTimes)));//issuer needs to be online(?) //notify issuer their bounty has been refunded //delete bounty deleteBountyCfg(BTIc); } } } } } ini.close(); } }
/// Read an ini file for nicknames and save the associated hashcode static void ReadIniNicknameFile(const string &filePath) { INI_Reader ini; if (ini.open(filePath.c_str(), false)) { while (ini.read_header()) { while (ini.read_value()) { if (ini.is_value("nickname")) { uint hash = CreateID(Trim(ToLower(ini.get_value_string())).c_str()); mapHashToNickname[hash] = ini.get_value_string(); } } } ini.close(); } }
void LoadSettings() { returncode = DEFAULT_RETURNCODE; // The path to the configuration file. string marketshipsfile = "..\\data\\equipment\\market_ships.ini"; string marketcommoditiesfile = "..\\data\\equipment\\market_commodities.ini"; string flhookitems = "..\\exe\\flhook_plugins\\alley_mf.cfg"; int shipamount1 = 0; int shipamount2 = 0; int commodamount1 = 0; int commodamount2 = 0; INI_Reader ini; if (ini.open(marketshipsfile.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("BaseGood")) { while (ini.read_value()) { uint currentbase; if (ini.is_value("base")) { currentbase = CreateID(ini.get_value_string(0)); shipamount1 = shipamount1 + 1; } else if (ini.is_value("marketgood")) { mapACShips[currentbase].push_back(CreateID(ini.get_value_string(0))); shipamount2 = shipamount2 + 1; } } } } ini.close(); } if (ini.open(marketcommoditiesfile.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("BaseGood")) { while (ini.read_value()) { //uint temple = CreateID("st04_03_base"); uint bastilleguard = CreateID("iw09_03_base"); uint currentbase; if (ini.is_value("base")) { currentbase = CreateID(ini.get_value_string(0)); //we don't record operations from the temple of the damned so when we come across it we'll ignore it. //if (currentbase == temple) //{ // ConPrint(L"MARKETFUCKER: Ignoring Temple of the Damned. \n"); //} if (currentbase == bastilleguard) { ConPrint(L"MARKETFUCKER: Ignoring Bastille Guard Station. \n"); } else { mapACBases.push_back(currentbase); commodamount1 = commodamount1 + 1; } } } } } ini.close(); } if (ini.open(flhookitems.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("items")) { while (ini.read_value()) { uint currentitem; if (ini.is_value("item")) { currentitem = CreateID(ini.get_value_string(0)); //mapACItems.push_back(currentitem); mapACItems[currentitem] = ini.get_value_string(0); commodamount2 = commodamount2 + 1; } } } } ini.close(); } ConPrint(L"MARKETFUCKER: Loaded %u ships for %u bases \n", shipamount2, shipamount1); ConPrint(L"MARKETFUCKER: Loaded %u items for %u bases \n", commodamount2, commodamount1); }
EXPORT void Import(string scPluginCfgFile, bool emptyFail) { int boardIndex = 0; string boardIndexStr = ""; string errorMessage = ""; Data::ParameterSet parameters; INI_Reader ini; if (!ini.open(scPluginCfgFile.c_str(), false)) { Common::PrintConInfo(L"Can't read config file. Don't see any possibility to load. Aborted.", true); return; } while (ini.read_header()) { if (ini.is_header("API")) { Sync::APILogin login; Sync::APIServer server; boardIndex++; while (ini.read_value()) { if (ini.is_value("URI")) { login.URI = ini.get_value_string(0); } else if (ini.is_value("Account")) { login.Account = ini.get_value_string(0); } else if (ini.is_value("Password")) { login.Password = ini.get_value_string(0); } else if (ini.is_value("Secret")) { login.Secret = Misc::Encode::stringToInt(ini.get_value_string(0)); } else if (ini.is_value("Queue")) { login.Queue = ini.get_value_int(0); } else if (ini.is_value("Operation")) { login.Operations.push_back(ini.get_value_string(0)); } else if (ini.is_value("Response")) { login.Responses.push_back(ini.get_value_string(0)); } } if (login.URI == "" || login.Account == "" || login.Password == "") { boardIndexStr = itos(boardIndex); Common::PrintConInfo(L"There is an error on configuration: At least one of the parameter (URI, Account, Password) is missing for [API] " + wstring(boardIndexStr.begin(), boardIndexStr.end()) + L". Ignoring.\r\n", true); continue; } try { server = Sync::Client::Get(login); Data::ParameterData data; data[L"Name"] = server.Name; data[L"LastSent"] = (uint)server.LastSent; data[L"Queue"] = server.QueueLimit; data[L"Delay"] = server.Delay; Data::Parameter parameter(data); parameters.push_back(parameter); } catch (exception &e) { errorMessage = e.what(); Common::PrintConInfo(L"Got a failure when try to load setting for API " + wstring(login.URI.begin(), login.URI.end()) + L": " + wstring(errorMessage.begin(), errorMessage.end())); } } } Config::Config::APIs = parameters; ini.close(); if (emptyFail && boardIndex <= 0) { Common::PrintConInfo(L"No board information. Don't see why loading. Aborted.", true); return; } }
void LoadSettings() { // The path to the configuration file. char szCurDir[MAX_PATH]; GetCurrentDirectory(sizeof(szCurDir), szCurDir); string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\event.cfg"; INI_Reader ini; set_mapCargoMissions.clear(); set_mapNpcMissions.clear(); if (ini.open(scPluginCfgFile.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("General")) { while (ini.read_value()) { if (ini.is_value("debug")) { set_iPluginDebug = ini.get_value_int(0); } else if (ini.is_value("cargo")) { CARGO_MISSION mis; mis.nickname = ini.get_value_string(0); mis.base = CreateID(ini.get_value_string(1)); mis.item = CreateID(ini.get_value_string(2)); mis.required_amount = ini.get_value_int(3); set_mapCargoMissions.insert(multimap<uint, CARGO_MISSION>::value_type(mis.base, mis)); } else if (ini.is_value("npc")) { NPC_MISSION mis; mis.nickname = ini.get_value_string(0); mis.system = CreateID(ini.get_value_string(1)); mis.sector = ini.get_value_string(2); pub::Reputation::GetReputationGroup(mis.reputation, ini.get_value_string(3)); mis.required_amount = ini.get_value_int(4); set_mapNpcMissions.insert(multimap<uint, NPC_MISSION>::value_type(mis.reputation, mis)); } } } ini.close(); } if (set_iPluginDebug&1) { ConPrint(L"CargoMissionSettings loaded [%d]\n",set_mapCargoMissions.size()); ConPrint(L"NpcMissionSettings loaded [%d]\n",set_mapNpcMissions.size()); } ini.close(); } // Read the last saved event status char szDataPath[MAX_PATH]; GetUserDataPath(szDataPath); string scStatsPath = string(szDataPath) + "\\Accts\\MultiPlayer\\event_stats.txt"; if (ini.open(scStatsPath.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("Missions")) { while (ini.read_value()) { if (ini.is_value("cargo")) { string nickname = ini.get_value_string(0); int curr_amount = ini.get_value_int(2); for (multimap<uint, CARGO_MISSION>::iterator i = set_mapCargoMissions.begin(); i != set_mapCargoMissions.end(); ++i) { if (i->second.nickname == nickname) { i->second.curr_amount = curr_amount; } } } else if (ini.is_value("npc")) { NPC_MISSION mis; string nickname = ini.get_value_string(0); int curr_amount = ini.get_value_int(2); for (multimap<uint, NPC_MISSION>::iterator i = set_mapNpcMissions.begin(); i != set_mapNpcMissions.end(); ++i) { if (i->second.nickname == nickname) { i->second.curr_amount = curr_amount; } } } } } } ini.close(); } }
void LoadSettings() { returncode = DEFAULT_RETURNCODE; string File_FLHook = "..\\exe\\flhook_plugins\\bountytracker.cfg"; string File_FLHook_bounties = "..\\exe\\flhook_plugins\\bountytrackerbounties.cfg"; int iLoaded = 0; INI_Reader ini; if (ini.open(File_FLHook.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("config")) { while (ini.read_value()) { if (ini.is_value("enabled")) { bPluginEnabled = ini.get_value_bool(0); } if (ini.is_value("CleanInterval")) { iCleanInterval = ini.get_value_int(0); conDebug(L"cleaning interval set to " + stows(itos(iCleanInterval))); } if (ini.is_value("BountyAge")) { iBountyAge = ini.get_value_int(0); conDebug(L"bounty age set to " + stows(itos(iBountyAge))); } } } }ini.close(); } if (ini.open(File_FLHook_bounties.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("bounty")) { while (ini.read_value()) { if (ini.is_value("hit")) { string setTargetName = ini.get_value_string(0); wstring theTargetName = ToLower(stows(setTargetName)); BTI.Char = ToLower(ini.get_value_string(0)); BTI.Cash = ini.get_value_string(1); BTI.xTimes = ini.get_value_string(2); BTI.issuer = ToLower(ini.get_value_string(3)); BTI.active = ini.get_value_bool(4); BTI.lastIssuer = ToLower(ini.get_value_string(5)); BTI.lastTime = ini.get_value_string(6); BTI.issueTime = ini.get_value_string(7); mapBountyTargets[theTargetName] = BTI; ++iLoaded; } } } } ini.close(); } ConPrint(L"BOUNTYTRACKER: Loaded %u Bounties\n", iLoaded); }
/** Read the zone size/rotation and position information out of the specified file and calcuate the lootable zone transformation matrix */ void ReadSystemZones(zone_map_t &set_mmapZones, const string &systemNick, const string &file) { string path="..\\data\\universe\\"; path += file; INI_Reader ini; if (ini.open(path.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("zone")) { string zoneNick=""; Vector size={0,0,0}; Vector pos={0,0,0}; Vector rotation={0,0,0}; int idsName = 0; string idsNameTxt = ""; int idsInfo = 0; string idsInfoTxt = ""; while (ini.read_value()) { if (ini.is_value("nickname")) { zoneNick=ToLower(ini.get_value_string()); } else if (ini.is_value("pos")) { pos.x = ini.get_value_float(0); pos.y = ini.get_value_float(1); pos.z = ini.get_value_float(2); } else if (ini.is_value("rotate")) { rotation.x = 180 + ini.get_value_float(0); rotation.y = 180 + ini.get_value_float(1); rotation.z = 180 + ini.get_value_float(2); } else if (ini.is_value("size")) { size.x = ini.get_value_float(0); size.y = ini.get_value_float(1); size.z = ini.get_value_float(2); if (size.y==0 || size.z==0) { size.y=size.x; size.z=size.x; } } else if (ini.is_value("ids_name")) { idsName = ini.get_value_int(0); } else if (ini.is_value("ids_info")) { idsInfo = ini.get_value_int(0); } } for (zone_map_iter_t i=set_mmapZones.begin(); i!=set_mmapZones.end(); i++) { if (i->second.zoneNick==zoneNick) { i->second.pos = pos; i->second.size = size; break; } } } } ini.close(); } }
/** Parse the specified ini file (usually in the data/solar/asteriods) and retrieve the lootable zone details. */ void ReadLootableZone(zone_map_t &set_mmapZones, const string &systemNick, const string &defaultZoneNick, const string &file) { string path="..\\data\\"; path += file; INI_Reader ini; if (ini.open(path.c_str(), false)) { while (ini.read_header()) { if (ini.is_header("LootableZone")) { string zoneNick=defaultZoneNick; string crateNick=""; string lootNick=""; int iMinLoot = 0; int iMaxLoot = 0; uint iLootDifficulty = 0; while (ini.read_value()) { if (ini.is_value("zone")) { zoneNick=ToLower(ini.get_value_string()); } else if (ini.is_value("dynamic_loot_container")) { crateNick=ToLower(ini.get_value_string()); } else if (ini.is_value("dynamic_loot_commodity")) { lootNick=ToLower(ini.get_value_string()); } else if (ini.is_value("dynamic_loot_count")) { iMinLoot=ini.get_value_int(0); iMaxLoot=ini.get_value_int(1); } else if (ini.is_value("dynamic_loot_difficulty")) { iLootDifficulty=ini.get_value_int(0); } } LOOTABLE_ZONE lz; lz.systemID = CreateID(systemNick.c_str()); lz.zoneNick = zoneNick; lz.lootNick = lootNick; lz.iLootID = CreateID(lootNick.c_str()); lz.iCrateID = CreateID(crateNick.c_str()); lz.iMinLoot = iMinLoot; lz.iMaxLoot = iMaxLoot; lz.iLootDifficulty = iLootDifficulty; lz.pos.x = lz.pos.y = lz.pos.z = 0; lz.size.x = lz.size.y = lz.size.z = 0; bool exists = false; for (zone_map_iter_t i=set_mmapZones.begin(); i!=set_mmapZones.end(); i++) { if (i->second.zoneNick==zoneNick) { exists = true; break; } } if (!exists) set_mmapZones.insert(zone_map_pair_t(lz.systemID,lz)); } } ini.close(); } }
bool loadModInfo(string scPluginCfgFile) { INI_Reader ini; string key; wstring wsKey, wsVal; if (!ini.open(scPluginCfgFile.c_str(), false)) { return false; } try { while (ini.read_header()) { if (ini.is_header("Base")) // Base Info { DataItem::BaseData base; while (ini.read_value()) { if (ini.is_value("Nickname")) { base.setNickname(stows(ini.get_value_string())); } else if (ini.is_value("Name")) { base.setName(stows(ini.get_value_string())); } else if (ini.is_value("System")) { base.setSystem(stows(ini.get_value_string())); } else if (ini.is_value("Faction")) { base.setFaction(stows(ini.get_value_string())); } } Data::addBase(base); } else if (ini.is_header("System")) // System Info { DataItem::SystemData system; while (ini.read_value()) { if (ini.is_value("Nickname")) { system.setNickname(stows(ini.get_value_string())); } else if (ini.is_value("Name")) { system.setName(stows(ini.get_value_string())); } else if (ini.is_value("Faction")) { system.setFaction(stows(ini.get_value_string())); } else if (ini.is_value("Territory")) { system.setTerritory(stows(ini.get_value_string())); } } Data::addSystem(system); } else if (ini.is_header("Ship")) // Ship Info { DataItem::ShipData ship; while (ini.read_value()) { if (ini.is_value("Nickname")) { ship.setNickname(stows(ini.get_value_string())); } else if (ini.is_value("Name")) { ship.setName(stows(ini.get_value_string())); } else if (ini.is_value("Type")) { ship.setType(ini.get_value_string()); } } Data::addShip(ship); } else if (ini.is_header("Faction")) // Faction Info { DataItem::FactionData faction; while (ini.read_value()) { if (ini.is_value("Nickname")) { faction.setNickname(stows(ini.get_value_string())); } else if (ini.is_value("Name")) { faction.setName(stows(ini.get_value_string())); } else if (ini.is_value("Short")) { faction.setShort(stows(ini.get_value_string())); } } Data::addFaction(faction); } else if (ini.is_header("Goods")) // Goods Info { DataItem::GoodsData goods; while (ini.read_value()) { if (ini.is_value("Nickname")) { goods.setNickname(stows(ini.get_value_string())); } else if (ini.is_value("Name")) { goods.setName(stows(ini.get_value_string())); } } Data::addGoods(goods); } } } catch (Exception::NickNameNotFound &e) { Print::Error(L"Can't load MOD data with error: " + e.message() + L".", L""); return false; } catch (Exception::RedeclaredNickname &e) { Print::Error(L"Can't load MOD data with error: " + e.message() + L".", L""); return false; } catch (exception &e) { string errorMessage = e.what(); Print::Error(L"Can't load MOD setting with error: " + wstring(errorMessage.begin(), errorMessage.end()) + L".", L""); return false; } ini.close(); return true; }