Example #1
0
void SchematicMap::loadSchematicGroups() {
	TemplateManager* templateManager = TemplateManager::instance();

	IffStream* iffStream = templateManager->openIffFile(
			"datatables/crafting/schematic_group.iff");

	if (iffStream == NULL) {
		info("schematic_group.iff could not be found.", true);
		return;
	}

	DataTableIff dtiff;
	dtiff.readObject(iffStream);

	String groupId, schematicName;

	for (int i = 0; i < dtiff.getTotalRows(); ++i) {

		DataTableRow* row = dtiff.getRow(i);

		row->getCell(0)->getValue(groupId);
		row->getCell(1)->getValue(schematicName);

		iffGroupMap.put(schematicName.hashCode(), groupId);
	}

	delete iffStream;

	buildSchematicGroups();
}
void PlanetManagerImplementation::loadTravelFares() {
	TemplateManager* templateManager = TemplateManager::instance();

	IffStream* iffStream = templateManager->openIffFile("datatables/travel/travel.iff");

	if (iffStream == NULL) {
		warning("Travel fares could not be found.");
		return;
	}

	DataTableIff dtiff;
	dtiff.readObject(iffStream);

	delete iffStream;

	//Initialize the rows so we can do a symmetric insert
	for(int i = 0; i < dtiff.getTotalRows(); i++) {
		VectorMap<String, int> planetFares;
		DataTableRow* row =  dtiff.getRow(i);
		String departurePlanet = "";
		row->getCell(0)->getValue(departurePlanet);
		travelFares.put(departurePlanet, planetFares);
	}

	//Insert values
	for(int i = 0; i < dtiff.getTotalRows(); i++) {
		DataTableRow* row =  dtiff.getRow(i);
		String departurePlanet = "";
		row->getCell(0)->getValue(departurePlanet);

		for(int j=i+1; j<dtiff.getTotalColumns(); j++) {
			String arrivalPlanet = dtiff.getColumnNameByIndex(j);
			int fare = 0;
			row->getCell(j)->getValue(fare);
			travelFares.get(departurePlanet).put(arrivalPlanet, fare);
			if(arrivalPlanet != departurePlanet)
				travelFares.get(arrivalPlanet).put(departurePlanet, fare);
		}
	}

	info("Loaded travel fares to " + String::valueOf(travelFares.size()) + " planets.");
}
Example #3
0
Vector<DataTableRow*> DataTableIff::getRowsByColumn(int columnIdx, const String& columnValue) {
	Vector<DataTableRow*> retRows;

	for (int i = 0; i < rows.size(); ++i) {
		DataTableRow* row = rows.get(i);

		if (row->getCell(columnIdx)->toString() == columnValue)
			retRows.add(row);
	}

	return retRows;
}
Example #4
0
void ImageDesignManager::loadCustomizationData() {
	TemplateManager* templateManager = TemplateManager::instance();

	IffStream* iffStream = templateManager->openIffFile("datatables/customization/customization_data.iff");

	if (iffStream == NULL)
		return;

	//Get the datatable, and parse it into a datatable object.
	DataTableIff dataTable;
	dataTable.readObject(iffStream);

	for (int i = 0; i < dataTable.getTotalRows(); i++) {
		DataTableRow* dataRow = dataTable.getRow(i);

		if (dataRow == NULL)
			continue;

		//Get the species gender
		String speciesGender = dataRow->getCell(0)->toString();
		uint32 templateCRC = String::hashCode("object/creature/player/" + speciesGender + ".iff");
		PlayerCreatureTemplate* tmpl = dynamic_cast<PlayerCreatureTemplate*>(templateManager->getTemplate(templateCRC));

		if (tmpl == NULL)
			continue;

		CustomizationDataMap* dataMap = tmpl->getCustomizationDataMap();

		if (dataMap == NULL)
			continue;

		CustomizationData customizationData;
		customizationData.parseRow(dataRow);

		customizationData.setMinScale(tmpl->getMinScale());
		customizationData.setMaxScale(tmpl->getMaxScale());

		dataMap->put(customizationData.getCustomizationName(), customizationData);

	}

	//Done with the stream, so delete it.
	if (iffStream != NULL) {
		delete iffStream;
		iffStream = NULL;
	}

}
void ChatManagerImplementation::loadSocialTypes() {
	IffStream* iffStream = TemplateManager::instance()->openIffFile("datatables/chat/social_types.iff");

	if (iffStream == NULL) {
		error("Could not load social types.");
		return;
	}

	DataTableIff dtiff;
	dtiff.readObject(iffStream);

	delete iffStream;

	for (int i = 0; i < dtiff.getTotalRows(); ++i) {
		DataTableRow* row = dtiff.getRow(i);

		String key;
		row->getCell(0)->getValue(key);
		socialTypes.put(i + 1, key);
	}

	info("Loaded " + String::valueOf(socialTypes.size()) + " social types.", true);
}
Example #6
0
bool ResourceTree::buildTreeFromClient() {
	TemplateManager* templateManager = TemplateManager::instance();

	IffStream* iffStream = templateManager->openIffFile("datatables/resource/resource_tree.iff");

	if (iffStream == NULL) {
		info("The Resource Tree could not be found.", true);
		return false;
	}

	DataTableIff dtiff;
	dtiff.readObject(iffStream);

	Vector<String> currentClasses;
	Vector<String> currentStfClasses;

	baseNode = new ResourceTreeNode("resource", "Resources", 0);

	String stringvalue, randomname, resourcecontainer;
	int intvalue;
	bool boolValue;

	for (int i = 1; i < dtiff.getTotalRows(); ++i) {

		DataTableRow* row = dtiff.getRow(i);

		row->getValue(1, stringvalue);

		ResourceTreeEntry* entry = new ResourceTreeEntry(stringvalue);

		for (int j = 3; j <= 9; ++j) {
			String resourceclass;
			row->getValue(j, resourceclass);

			if (resourceclass.isEmpty())
				continue;

			while (currentStfClasses.size() > j - 3) {
				currentStfClasses.removeElementAt(j - 3);
				currentClasses.removeElementAt(j - 3);
			}

			currentStfClasses.add(stringvalue);
			currentClasses.add(resourceclass);
		}

		for (int j = 0; j < currentStfClasses.size(); ++j) {
			entry->addClass(currentClasses.get(j));
			entry->addStfClass(currentStfClasses.get(j));
		}

		row->getValue(10, intvalue);
		entry->setMaxtype(intvalue);

		row->getValue(11, intvalue);
		entry->setMintype(intvalue);

		row->getValue(12, intvalue);
		entry->setMinpool(intvalue);

		row->getValue(13, intvalue);
		entry->setMaxpool(intvalue);

		row->getValue(14, boolValue);
		entry->setRecycled(boolValue);

		for (int j = 16; j <= 26; ++j) {
			row->getValue(j, stringvalue);
			if (stringvalue == "")
				break;

			int min;
			row->getCell(j + 11 + (j - 16))->getValue(min);

			int max;
			row->getCell(j + 12 + (j - 16))->getValue(max);

			entry->addAttribute(new ResourceAttribute(stringvalue, min, max));
		}

		row->getCell(49)->getValue(stringvalue);
		if(stringvalue != "")
			resourcecontainer = stringvalue;
		entry->setResourceContainerType(resourcecontainer);

		row->getCell(50)->getValue(stringvalue);
		if(stringvalue != "")
				randomname = stringvalue;
		entry->setRandomNameClass(randomname);

		setZoneRestriction(entry);
		setJtl(entry);
		setSurveyToolType(entry);
		setRecycleToolType(entry);

		/// Add entry to the tree
		baseNode->add(entry);
	}
	/// Update the Stf Entries now that the tree is built
	//baseNode->updateEntries();

	return true;
}