コード例 #1
0
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);
		}
	}
}
コード例 #2
0
ファイル: main.cpp プロジェクト: DahBlount/SheevanPhitars
//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();
	}
}
コード例 #3
0
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));
		}
	}
}
コード例 #4
0
ファイル: Rename.cpp プロジェクト: HeIIoween/FLHook
	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();
		}
	}
コード例 #5
0
ファイル: Main.cpp プロジェクト: HeIIoween/FLHook
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();
	}
}
コード例 #6
0
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);
}
コード例 #7
0
ファイル: ZoneUtilities.cpp プロジェクト: HeIIoween/FLHook
/**
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();
	}
}
コード例 #8
0
ファイル: ZoneUtilities.cpp プロジェクト: HeIIoween/FLHook
/** 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();
	}
}
コード例 #9
0
ファイル: Event.cpp プロジェクト: HeIIoween/FLBoard
				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;
					}
				}