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 PlayerCreationManager::loadRacialCreationData() { TemplateManager* templateManager = TemplateManager::instance(); IffStream* iffStream = templateManager->openIffFile( "datatables/creation/attribute_limits.iff"); if (iffStream == NULL) { error("Could not open attribute limits file."); return; } DataTableIff attributeLimitsTable; attributeLimitsTable.readObject(iffStream); delete iffStream; iffStream = templateManager->openIffFile( "datatables/creation/racial_mods.iff"); DataTableIff racialModsTable; racialModsTable.readObject(iffStream); delete iffStream; for (int i = 0; i < attributeLimitsTable.getTotalRows(); ++i) { DataTableRow* attributeLimitRow = attributeLimitsTable.getRow(i); String maleTemplate; String femaleTemplate; attributeLimitRow->getValue(0, maleTemplate); attributeLimitRow->getValue(1, femaleTemplate); Vector<DataTableRow*> maleRows = racialModsTable.getRowsByColumn(0, maleTemplate); Vector<DataTableRow*> femaleRows = racialModsTable.getRowsByColumn(1, femaleTemplate); Reference<RacialCreationData*> rcd = new RacialCreationData(); rcd->parseAttributeData(attributeLimitRow); if (!maleTemplate.isEmpty()) { if (maleRows.size() > 0) rcd->parseRacialModData(maleRows.get(0)); racialCreationData.put(maleTemplate, rcd); } if (!femaleTemplate.isEmpty()) { if (femaleRows.size() > 0) rcd->parseRacialModData(femaleRows.get(0)); racialCreationData.put(femaleTemplate, rcd); } } info( "Loaded " + String::valueOf(racialCreationData.size()) + " playable species."); }
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; }
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 CustomizationIdManager::loadAllowBald(IffStream* iffStream) { DataTableIff dataTable; dataTable.readObject(iffStream); for (int i = 0; i < dataTable.getTotalRows(); ++i) { String species; bool val; DataTableRow* row = dataTable.getRow(i); row->getValue(0, species); row->getValue(1, val); allowBald.put(species, val); } info("loaded " + String::valueOf(allowBald.size()) + " allow bald species data", true); }
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."); }
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); }
void SkillManager::loadXpLimits() { IffStream* iffStream = TemplateManager::instance()->openIffFile("datatables/skill/xp_limits.iff"); if (iffStream == NULL) { error("Could not load skills."); return; } DataTableIff dtiff; dtiff.readObject(iffStream); delete iffStream; for (int i = 0; i < dtiff.getTotalRows(); ++i) { DataTableRow* row = dtiff.getRow(i); String type; int value; row->getValue(0, type); row->getValue(1, value); defaultXpLimits.put(type, value); info(type + ": " + String::valueOf(value)); } }
void PlanetManagerImplementation::loadClientRegions() { TemplateManager* templateManager = TemplateManager::instance(); IffStream* iffStream = templateManager->openIffFile("datatables/clientregion/" + zone->getZoneName() + ".iff"); Reference<PlanetMapCategory*> cityCat = TemplateManager::instance()->getPlanetMapCategoryByName("city"); if (iffStream == NULL) { info("No client regions found."); return; } DataTableIff dtiff; dtiff.readObject(iffStream); for (int i = 0; i < dtiff.getTotalRows(); ++i) { String regionName; float x, y, radius; DataTableRow* row = dtiff.getRow(i); row->getValue(0, regionName); row->getValue(1, x); row->getValue(2, y); row->getValue(3, radius); ManagedReference<CityRegion*> cityRegion = regionMap.getRegion(regionName); if (cityRegion == NULL) { cityRegion = new CityRegion(); Locker locker(cityRegion); cityRegion->deploy(); cityRegion->setRegionName(regionName); cityRegion->setZone(zone); regionMap.addRegion(cityRegion); } Locker locker(cityRegion); ManagedReference<Region*> region = cityRegion->addRegion(x, y, radius, false); locker.release(); if (region != NULL) { Locker rlocker(region); if (cityRegion->getRegionsCount() == 1) {//Register the first region only. region->setPlanetMapCategory(cityCat); zone->registerObjectWithPlanetaryMap(region); } region->setMunicipalZone(true); ManagedReference<SceneObject*> scenery = NULL; if (gcwManager != NULL) { int strongholdFaction = gcwManager->isStrongholdCity(regionName); if (strongholdFaction == GCWManager::IMPERIALHASH || regionName.contains("imperial")) { scenery = zone->getZoneServer()->createObject(STRING_HASHCODE("object/static/particle/particle_distant_ships_imperial.iff"), 0); } else if (strongholdFaction == GCWManager::REBELHASH || regionName.contains("rebel")) { scenery = zone->getZoneServer()->createObject(STRING_HASHCODE("object/static/particle/particle_distant_ships_rebel.iff"), 0); } else { scenery = zone->getZoneServer()->createObject(STRING_HASHCODE("object/static/particle/particle_distant_ships.iff"), 0); } } else { scenery = zone->getZoneServer()->createObject(STRING_HASHCODE("object/static/particle/particle_distant_ships.iff"), 0); } Locker slocker(scenery, region); scenery->initializePosition(x, zone->getHeight(x, y) + 100, y); region->attachScenery(scenery); } ManagedReference<ActiveArea*> noBuild = zone->getZoneServer()->createObject(STRING_HASHCODE("object/active_area.iff"), 0).castTo<ActiveArea*>(); Locker areaLocker(noBuild); noBuild->initializePosition(x, 0, y); ManagedReference<CircularAreaShape*> areaShape = new CircularAreaShape(); Locker shapeLocker(areaShape); areaShape->setRadius(radius * 2); areaShape->setAreaCenter(x, y); noBuild->setAreaShape(areaShape); noBuild->setRadius(radius * 2); noBuild->setNoBuildArea(true); // Cities already have "Municipal" protection so the structure no-build should not apply to camps noBuild->setCampingPermitted(true); Locker zoneLocker(zone); zone->transferObject(noBuild, -1, true); } info("Added " + String::valueOf(regionMap.getTotalRegions()) + " client regions."); delete iffStream; }
void DataTableIff::readObject(IffStream* iffStream) { iffStream->openForm('DTII'); uint32 version = iffStream->getNextFormType(); iffStream->openForm(version); //Parse the columns Chunk* chunk = iffStream->openChunk('COLS'); uint32 totalColumns = chunk->readInt(); for (int i = 0; i < totalColumns; ++i) { String columnName; chunk->readString(columnName); columns.add(columnName); } iffStream->closeChunk('COLS'); //Parse the types chunk = iffStream->openChunk('TYPE'); for (int i = 0; i < totalColumns; ++i) { String typeName; chunk->readString(typeName); columnTypes.add(typeName.charAt(0)); //Just need the first character to know the type. Default value doesn't seem to matter. } iffStream->closeChunk('TYPE'); chunk = iffStream->openChunk('ROWS'); uint32 totalRows = chunk->readInt(); for (int i = 0; i < totalRows; ++i) { DataTableRow* row = new DataTableRow(); for (int j = 0; j < totalColumns; ++j) { byte type = columnTypes.get(j); DataTableCell* cell = NULL; switch (type) { case 'f': cell = new DataTableCellFloat(); cell->parse(chunk); break; case 's': cell = new DataTableCellString(); cell->parse(chunk); break; case 'h': cell = new DataTableCellHex(); cell->parse(chunk); break; case 'b': cell = new DataTableCellBinary(); cell->parse(chunk); break; case 'c': case 'p': case 'e': case 'z': case 'i': case 'I': default: cell = new DataTableCellInt(); cell->parse(chunk); break; } row->addCell(cell); } rows.add(row); } iffStream->closeChunk('ROWS'); iffStream->closeForm(version); iffStream->closeForm('DTII'); }
void PlayerCreationManager::loadProfessionDefaultsInfo() { TemplateManager* templateManager = TemplateManager::instance(); IffStream* iffStream = templateManager->openIffFile( "creation/profession_defaults.iff"); if (iffStream == NULL) { error("Could not open creation profession data."); return; } SkillDataForm pfdt; pfdt.readObject(iffStream); delete iffStream; //Load the data into useful structs and store them in a map. for (int i = 0; i < pfdt.getTotalPaths(); ++i) { String name = pfdt.getSkillNameAt(i); String path = pfdt.getPathBySkillName(name); iffStream = templateManager->openIffFile(path); if (iffStream == NULL) continue; Reference<ProfessionDefaultsInfo*> pdi = new ProfessionDefaultsInfo(); pdi->readObject(iffStream); delete iffStream; professionDefaultsInfo.put(name, pdi); //info("Loading: " + pfdt.getSkillNameAt(i) + " Path: " + pfdt.getPathBySkillName(pfdt.getSkillNameAt(i)), true); } //Now we want to load the profession mods. iffStream = templateManager->openIffFile( "datatables/creation/profession_mods.iff"); DataTableIff dtiff; dtiff.readObject(iffStream); delete iffStream; for (int i = 0; i < dtiff.getTotalRows(); ++i) { DataTableRow* row = dtiff.getRow(i); String key; row->getValue(0, key); //Check if the professionInfo for this exists. Reference<ProfessionDefaultsInfo*> pdi = professionDefaultsInfo.get( key); if (pdi == NULL) continue; for (int i = 1; i < 10; ++i) { int value = 0; row->getValue(i, value); pdi->setAttributeMod(i - 1, value); } } info( "Loaded " + String::valueOf(professionDefaultsInfo.size()) + " creation professions."); }
void PlanetManagerImplementation::loadClientRegions() { TemplateManager* templateManager = TemplateManager::instance(); IffStream* iffStream = templateManager->openIffFile("datatables/clientregion/" + zone->getZoneName() + ".iff"); Reference<PlanetMapCategory*> cityCat = TemplateManager::instance()->getPlanetMapCategoryByName("city"); if (iffStream == NULL) { info("No client regions found."); return; } DataTableIff dtiff; dtiff.readObject(iffStream); for (int i = 0; i < dtiff.getTotalRows(); ++i) { String regionName; float x, y, radius; DataTableRow* row = dtiff.getRow(i); row->getValue(0, regionName); row->getValue(1, x); row->getValue(2, y); row->getValue(3, radius); ManagedReference<CityRegion*> cityRegion = regionMap.getRegion(regionName); if (cityRegion == NULL) { cityRegion = new CityRegion(); cityRegion->deploy(); cityRegion->setRegionName(regionName); cityRegion->setZone(zone); regionMap.addRegion(cityRegion); } ManagedReference<Region*> region = cityRegion->addRegion(x, y, radius, false); if (region != NULL) { if (cityRegion->getRegionsCount() == 1) {//Register the first region only. region->setPlanetMapCategory(cityCat); zone->registerObjectWithPlanetaryMap(region); } region->setMunicipalZone(true); } ManagedReference<ActiveArea*> noBuild = zone->getZoneServer()->createObject(String("object/active_area.iff").hashCode(), 0).castTo<ActiveArea*>(); noBuild->initializePosition(x, 0, y); ManagedReference<CircularAreaShape*> areaShape = new CircularAreaShape(); areaShape->setRadius(radius * 2); areaShape->setAreaCenter(x, y); noBuild->setAreaShape(areaShape); noBuild->setRadius(radius * 2); noBuild->setNoBuildArea(true); // Cities already have "Municipal" protection so the structure no-build should not apply to camps noBuild->setCampingPermitted(true); zone->transferObject(noBuild, -1, true); } info("Added " + String::valueOf(regionMap.getTotalRegions()) + " client regions."); }
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; }