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 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."); }