示例#1
0
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;
}
示例#2
0
/** 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();
	}
}