bool PlanetManagerImplementation::validateRegionName(const String& name) {
	String lowerCase = name.toLowerCase();
	Locker locker(_this.getReferenceUnsafeStaticCast());

	if (hasRegion(name) || hasRegion(lowerCase))
		return false;

	for (int i = 0; i < regionMap.getTotalRegions(); ++i) {
		String regionName = regionMap.getRegion(i)->getRegionName();

		if (regionName.beginsWith("@")) {
			String fullName = StringIdManager::instance()->getStringId(regionName.hashCode()).toString().toLowerCase();

			if ((!fullName.isEmpty()) && (lowerCase == fullName || fullName.contains(lowerCase) || lowerCase.contains(fullName)))
				return false;
		}
	}

	return true;
}
Esempio n. 2
0
	bool RegionManager::jumpRegion(const std::string& _targetRegion, unsigned int _x, unsigned int _y, RegionEntity *_entity, bool _updateCurrentRegion) {
		if (hasRegion(_targetRegion)) {
			std::cout << "Region '" << _targetRegion << "' is present" << std::endl;
			auto& r = getRegion(_targetRegion);

			r.addEntity(_entity);
			_entity->setPosition(sf::Vector2f(static_cast<float>(_x), static_cast<float>(_y)));
			if (_updateCurrentRegion) {
				setCurrentRegion(_targetRegion);
			}
			return true;
		}
		return false;
	}
Esempio n. 3
0
 uint32_t findParent(uint32_t packed_locale, const char *script) {
     if (hasRegion(packed_locale)) {
         for (size_t i = 0; i < SCRIPT_PARENTS_COUNT; i++) {
             if (memcmp(script, SCRIPT_PARENTS[i].script, SCRIPT_LENGTH) == 0) {
                 auto map = SCRIPT_PARENTS[i].map;
                 auto lookup_result = map->find(packed_locale);
                 if (lookup_result != map->end()) {
                     return lookup_result->second;
                 }
                 break;
             }
         }
         return dropRegion(packed_locale);
     }
     return PACKED_ROOT;
 }