Пример #1
0
// ----------------------------------------------------------------------
void Squad::install()
{
	DEBUG_FATAL(s_installed, ("Already installed"));

	// Create the data table

	Iff iff;

	if (iff.open("datatables/space_mobile/space_mobile.iff", true))
	{
		DataTable dataTable;
		dataTable.load(iff);

		int const rowCount = dataTable.getNumRows();

		for (int row = 0; row < rowCount; ++row)
		{
			PersistentCrcString const shipName(dataTable.getStringValue("strIndex", row), false);
			int const formationPriority = dataTable.getIntValue("formationPriority", row);
			
			IGNORE_RETURN(s_formationPriorityList.insert(std::make_pair(shipName, formationPriority)));

			LOGC((ConfigServerGame::isSpaceAiLoggingEnabled() && formationPriority  <= 0), "space_debug_ai", ("Squad::install() ERROR: Invalid formationPriority(%d) specified for shipName(%s)", formationPriority, shipName.getString()));
		}
	}
	else
	{
		DEBUG_WARNING(true, ("Unable to load space_mobile.iff to retrieve formation priorities!"));
	}

	ExitChain::add(&remove, "Squad::remove");

	s_installed = true;
}
Пример #2
0
void SocialsManager::load (const std::string & filename)
{	
	Iff iff;
	
	if (!iff.open (filename.c_str (), true))
		WARNING (true, ("Data file %s not available.", filename.c_str ()));
	else
	{
		DataTable dt;
		dt.load (iff);
		iff.close ();

		const int numRows = dt.getNumRows ();

		uint32 count = 0;
		for (int i = 0; i < numRows; ++i)
		{
			const std::string & name = Unicode::toLower (dt.getStringValue (DC_name, i));
			++count;

			s_idToNameMap.insert (std::make_pair (count, name));
			s_crcToNameMap.insert (std::make_pair (Crc::calculate(name.c_str()), name));

			const std::pair<StringIntMap::const_iterator, bool> retval = s_nameToIdMap.insert (std::make_pair (name, count));

			if (!retval.second)
				WARNING_STRICT_FATAL (true, ("SocialsManager file '%s' duplicate social type '%s'", filename.c_str (), name.c_str ()));
		}
	}
}
DataTable* DataTableManager::open(const std::string& table)
{
	FATAL(!m_installed, ("DataTableManager::open: not installed."));
	DataTable *retVal = getTable(table, false);
	if (retVal)
		return retVal;

	if (!TreeFile::exists(table.c_str()))
	{
		DEBUG_WARNING(true, ("Could not find treefile table for open [%s]", table.c_str()));
		return 0;
	}

	Iff iff(table.c_str(), false);
	retVal = new DataTable;
	retVal->load(iff);

	m_cachedTable = retVal;
	m_cachedTableName = table;
	m_tables[table] = retVal;

	return retVal;
}
Пример #4
0
void ShipTurretManager::install() // static
{
    InstallTimer const installTimer("ShipTurretManager::install");

    Iff iff;
    if (iff.open("datatables/space/ship_turret.iff", true))
    {
        DataTable dataTable;
        dataTable.load(iff);
        int numberOfRows = dataTable.getNumRows();
        for (int row = 0; row < numberOfRows; ++row)
        {
            std::string const chassisName(dataTable.getStringValue("chassis", row));
            ShipChassis const * const chassis = ShipChassis::findShipChassisByName(TemporaryCrcString(chassisName.c_str(), false));
            FATAL(!chassis, ("ShipTurretManager::install: no such chassis '%s'", chassisName.c_str()));
            int const weaponIndex = dataTable.getIntValue("weaponIndex", row);
            ShipTurretData &shipTurretData = s_shipTurretData[chassis->getCrc()][weaponIndex];
            shipTurretData.minYaw = dataTable.getFloatValue("minYaw", row) * PI_OVER_180;
            shipTurretData.maxYaw = dataTable.getFloatValue("maxYaw", row) * PI_OVER_180;
            shipTurretData.minPitch = dataTable.getFloatValue("minPitch", row) * PI_OVER_180;
            shipTurretData.maxPitch = dataTable.getFloatValue("maxPitch", row) * PI_OVER_180;
        }
    }
}