void PlanetManagerImplementation::loadPerformanceLocations() { info("loading performance locations...", true); SortedVector<ManagedReference<SceneObject*> > planetaryLocs; planetaryLocs.setNoDuplicateInsertPlan(); // get hotels planetaryLocs = zone->getPlanetaryObjectList("hotel"); for (int j = 0; j < planetaryLocs.size(); j++) { SceneObject* obj = planetaryLocs.get(j); addPerformanceLocation(obj); } // get theaters planetaryLocs = zone->getPlanetaryObjectList("guild_theater"); for (int j = 0; j < planetaryLocs.size(); j++) { SceneObject* obj = planetaryLocs.get(j); addPerformanceLocation(obj); } // get cantinas planetaryLocs.removeAll(); planetaryLocs = zone->getPlanetaryObjectList("cantina"); for (int j = 0; j < planetaryLocs.size(); j++) { SceneObject* obj = planetaryLocs.get(j); addPerformanceLocation(obj); } }
void FactionManager::awardFactionStanding(CreatureObject* player, const String& factionName) { if (player == NULL) return; ManagedReference<PlayerObject*> ghost = player->getPlayerObject(); if (!factionMap.contains(factionName)) return; float lose = floor((float)75); //TODO: Find the equation for this. float gain = floor((float)lose / 2); //you gain half of what you lose Faction faction = factionMap.get(factionName); SortedVector<String>* enemies = faction.getEnemies(); SortedVector<String>* allies = faction.getAllies(); ghost->decreaseFactionStanding(factionName, lose); //Lose faction standing to allies of the creature. for (int i = 0; i < allies->size(); ++i) { String ally = allies->get(i); ghost->decreaseFactionStanding(ally, lose); } //Gain faction standing to enemies of the creature. for (int i = 0; i < enemies->size(); ++i) { String enemy = enemies->get(i); ghost->increaseFactionStanding(enemy, gain); } }
void AudioPort::toAudioPort(struct audio_port *port) const { // TODO: update this function once audio_port structure reflects the new profile definition. // For compatibility reason: flatening the AudioProfile into audio_port structure. SortedVector<audio_format_t> flatenedFormats; SampleRateVector flatenedRates; ChannelsVector flatenedChannels; for (size_t profileIndex = 0; profileIndex < mProfiles.size(); profileIndex++) { if (mProfiles[profileIndex]->isValid()) { audio_format_t formatToExport = mProfiles[profileIndex]->getFormat(); const SampleRateVector &ratesToExport = mProfiles[profileIndex]->getSampleRates(); const ChannelsVector &channelsToExport = mProfiles[profileIndex]->getChannels(); if (flatenedFormats.indexOf(formatToExport) < 0) { flatenedFormats.add(formatToExport); } for (size_t rateIndex = 0; rateIndex < ratesToExport.size(); rateIndex++) { uint32_t rate = ratesToExport[rateIndex]; if (flatenedRates.indexOf(rate) < 0) { flatenedRates.add(rate); } } for (size_t chanIndex = 0; chanIndex < channelsToExport.size(); chanIndex++) { audio_channel_mask_t channels = channelsToExport[chanIndex]; if (flatenedChannels.indexOf(channels) < 0) { flatenedChannels.add(channels); } } if (flatenedRates.size() > AUDIO_PORT_MAX_SAMPLING_RATES || flatenedChannels.size() > AUDIO_PORT_MAX_CHANNEL_MASKS || flatenedFormats.size() > AUDIO_PORT_MAX_FORMATS) { ALOGE("%s: bailing out: cannot export profiles to port config", __FUNCTION__); return; } } } port->role = mRole; port->type = mType; strlcpy(port->name, mName, AUDIO_PORT_MAX_NAME_LEN); port->num_sample_rates = flatenedRates.size(); port->num_channel_masks = flatenedChannels.size(); port->num_formats = flatenedFormats.size(); for (size_t i = 0; i < flatenedRates.size(); i++) { port->sample_rates[i] = flatenedRates[i]; } for (size_t i = 0; i < flatenedChannels.size(); i++) { port->channel_masks[i] = flatenedChannels[i]; } for (size_t i = 0; i < flatenedFormats.size(); i++) { port->formats[i] = flatenedFormats[i]; } ALOGV("AudioPort::toAudioPort() num gains %zu", mGains.size()); uint32_t i; for (i = 0; i < mGains.size() && i < AUDIO_PORT_MAX_GAINS; i++) { port->gains[i] = mGains[i]->getGain(); } port->num_gains = i; }
void SceneObjectImplementation::broadcastDestroyPrivate(SceneObject* object, SceneObject* selfObject) { ZoneServer* zoneServer = getZoneServer(); if (zoneServer != NULL && zoneServer->isServerLoading()) return; if (parent.get() != NULL) { ManagedReference<SceneObject*> grandParent = getRootParent().get(); if (grandParent != NULL) { grandParent->broadcastDestroyPrivate(object, selfObject); return; } else { return; } } if (zone == NULL) return; SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects; int maxInRangeObjectCount = 0; if (closeobjects == NULL) { info("Null closeobjects vector in SceneObjectImplementation::broadcastDestroyPrivate", true); zone->getInRangeObjects(getPositionX(), getPositionY(), 256, &closeSceneObjects, true); maxInRangeObjectCount = closeSceneObjects.size(); } else { CloseObjectsVector* vec = (CloseObjectsVector*) closeobjects; closeSceneObjects.removeAll(vec->size(), 10); vec->safeCopyTo(closeSceneObjects); maxInRangeObjectCount = closeSceneObjects.size(); } for (int i = 0; i < maxInRangeObjectCount; ++i) { SceneObject* scno = static_cast<SceneObject*>(closeSceneObjects.get(i).get()); ManagedReference<ZoneClientSession*> client = scno->getClient(); if (scno->isVehicleObject() || client != NULL || scno->isMount()) { object->sendDestroyTo(scno); } } }
bool PlanetManagerImplementation::isBuildingPermittedAt(float x, float y, SceneObject* object, float margin) { SortedVector<ManagedReference<ActiveArea* > > activeAreas; Vector3 targetPos(x, y, zone->getHeight(x, y)); zone->getInRangeActiveAreas(x, y, &activeAreas, true); for (int i = 0; i < activeAreas.size(); ++i) { ActiveArea* area = activeAreas.get(i); if (area->isNoBuildArea()) { return false; } } if (isInObjectsNoBuildZone(x, y, margin)) { return false; } if (isInWater(targetPos.getX(), targetPos.getY())) { return false; } if (isInRangeWithPoi(targetPos.getX(), targetPos.getY(), 150)) return false; return true; }
bool PlanetManagerImplementation::isInObjectsNoBuildZone(float x, float y, float extraMargin) { SortedVector<ManagedReference<QuadTreeEntry* > > closeObjects; Vector3 targetPos(x, y, zone->getHeight(x, y)); zone->getInRangeObjects(x, y, 512, &closeObjects, true); for (int i = 0; i < closeObjects.size(); ++i) { SceneObject* obj = cast<SceneObject*>(closeObjects.get(i).get()); SharedObjectTemplate* objectTemplate = obj->getObjectTemplate(); if (objectTemplate != NULL) { float radius = objectTemplate->getNoBuildRadius(); // Only check objects with an actual NoBuildRadius if (radius > 0) { // Add margin to check radius += extraMargin; Vector3 objWorldPos = obj->getWorldPosition(); if (objWorldPos.squaredDistanceTo(targetPos) < radius * radius) { return true; } } } } return false; }
void InstallationObjectImplementation::broadcastMessage(BasePacket* message, bool sendSelf) { Zone* zone = getZone(); if (zone == NULL) return; Locker zoneLocker(zone); SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects; zone->getInRangeObjects(getPositionX(), getPositionY(), 512, &closeSceneObjects, false); for (int i = 0; i < closeSceneObjects.size(); ++i) { ManagedReference<SceneObject*> scno = cast<SceneObject*>( closeSceneObjects.get(i).get()); if (!sendSelf && scno == _this.get()) continue; if(!scno->isPlayerCreature()) continue; CreatureObject* creo = cast<CreatureObject*>( scno.get()); if(isOnAdminList(creo)) scno->sendMessage(message->clone()); } delete message; }
int SceneObjectImplementation::inRangeObjects(unsigned int gameObjectType, float range) { if (getZone() == NULL) return 0; int numberOfObjects = 0; Locker zoneLocker(getZone()); SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects; int maxInRangeObjectCount = 0; if (closeobjects == NULL) { info("Null closeobjects vector in SceneObjectImplementation::inRangeObjects", true); zone->getInRangeObjects(getPositionX(), getPositionY(), range, &closeSceneObjects, true); maxInRangeObjectCount = closeSceneObjects.size(); } else maxInRangeObjectCount = closeobjects->size(); for (int i = 0; i < maxInRangeObjectCount; ++i) { SceneObject* scno; if (closeobjects != NULL) scno = cast<SceneObject*>( closeobjects->get(i).get()); else scno = cast<SceneObject*>(closeSceneObjects.get(i).get()); if (scno->isInRange(_this.get(), range) && scno->getGameObjectType() == gameObjectType) ++numberOfObjects; } return numberOfObjects; }
Reference<SceneObject*> PlanetManagerImplementation::findObjectTooCloseToDecoration(float x, float y, float margin) { SortedVector<ManagedReference<QuadTreeEntry* > > closeObjects; Vector3 targetPos(x, y,0); zone->getInRangeObjects(x, y, 256, &closeObjects, true); for (int i = 0; i < closeObjects.size(); ++i) { ManagedReference<SceneObject*> obj = cast<SceneObject*>(closeObjects.get(i).get()); if(obj == NULL || obj->isCreatureObject() || obj->getObjectTemplate() == NULL) continue; Vector3 objVec(obj->getPositionX(), obj->getPositionY(),0); int squaredDistance = (obj->getObjectTemplate()->getNoBuildRadius() + margin) * (obj->getObjectTemplate()->getNoBuildRadius() + margin); if(objVec.squaredDistanceTo(targetPos) < squaredDistance){ return obj; } if(obj->isStructureObject() && StructureManager::instance()->isInStructureFootprint(cast<StructureObject*>(obj.get()), x, y, margin) ){ return obj; } } return NULL; }
void JukeboxImplementation::notifyInsertToZone(Zone* zone) { ManagedReference<Jukebox*> jbox = _this.getReferenceUnsafeStaticCast(); Locker _lock(jbox); createChildObjects(); ManagedReference<JukeboxObserver*> observer = new JukeboxObserver(jbox); jbox->registerObserver(ObserverEventType::PARENTCHANGED, observer); ManagedReference<SceneObject*> obj = jbox->getRootParent().get(); if (obj == NULL || !obj->isStructureObject()) setRadius(100); else setRadius(30); SortedVector<ManagedReference<SceneObject*> >* children = jbox->getChildObjects(); for (int i = 0; i < children->size(); ++i) { ManagedReference<SceneObject*> child = children->get(i); if (child != NULL && child->isActiveArea()) { ManagedReference<ActiveArea*> area = cast<ActiveArea*>(child.get()); area->registerObserver(ObserverEventType::ENTEREDAREA, observer); area->registerObserver(ObserverEventType::EXITEDAREA, observer); } } }
void LairMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject, ObjectMenuResponse* menuResponse, CreatureObject* player) const { if (!sceneObject->isTangibleObject()) return; TangibleObject* tano = cast<TangibleObject*>(sceneObject); if(tano == NULL) return; ManagedReference<LairObserver*> lairObserver = NULL; SortedVector<ManagedReference<Observer*> > observers = tano->getObservers(ObserverEventType::OBJECTDESTRUCTION); for (int i = 0; i < observers.size(); i++) { lairObserver = cast<LairObserver*>(observers.get(i).get()); if (lairObserver != NULL) break; } if(player->hasSkill("outdoors_scout_novice") && player->getDistanceTo(sceneObject) < 8 && lairObserver && lairObserver->getMobType() != LairTemplate::NPC) { menuResponse->addRadialMenuItem(50, 3, "@lair_n:search_lair"); //Search Lair } TangibleObjectMenuComponent::fillObjectMenuResponse(sceneObject, menuResponse, player); }
SceneObject* StructureManager::getInRangeParkingGarage(SceneObject* obj, int range) { ManagedReference<Zone*> zone = obj->getZone(); if (zone == NULL) return NULL; SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects; CloseObjectsVector* closeObjectsVector = (CloseObjectsVector*) obj->getCloseObjects(); if (closeObjectsVector == NULL) { zone->getInRangeObjects(obj->getPositionX(), obj->getPositionY(), 128, &closeSceneObjects, true); } else { closeObjectsVector->safeCopyTo(closeSceneObjects); } for (int i = 0; i < closeSceneObjects.size(); ++i) { SceneObject* scno = cast<SceneObject*>(closeSceneObjects.get(i).get()); if (scno == obj) continue; if (scno->isGarage() && scno->isInRange(obj, range)) return scno; } return NULL; }
bool PlanetManagerImplementation::isBuildingPermittedAt(float x, float y, SceneObject* object, float margin) { SortedVector<ActiveArea*> activeAreas; Vector3 targetPos(x, y, 0); if (!zone->isWithinBoundaries(targetPos)) return false; //targetPos.setZ(zone->getHeight(x, y)); not needed zone->getInRangeActiveAreas(x, y, &activeAreas, true); for (int i = 0; i < activeAreas.size(); ++i) { ActiveArea* area = activeAreas.get(i); if (area->isNoBuildArea()) { return false; } } if (isInObjectsNoBuildZone(x, y, margin)) { return false; } if (isInWater(x, y)) { return false; } if (isInRangeWithPoi(x, y, 150)) return false; return true; }
bool PlanetManagerImplementation::isSpawningPermittedAt(float x, float y, float margin) { SortedVector<ActiveArea*> activeAreas; Vector3 targetPos(x, y, zone->getHeight(x, y)); if (!zone->isWithinBoundaries(targetPos)) return false; zone->getInRangeActiveAreas(x, y, &activeAreas, true); zone->getInRangeActiveAreas(x, y, margin + 64.f, &activeAreas, true); for (int i = 0; i < activeAreas.size(); ++i) { ActiveArea* area = activeAreas.get(i); if (area->isRegion() || area->isMunicipalZone() || area->isNoSpawnArea()) { return false; } } if (isInObjectsNoBuildZone(x, y, margin)) { return false; } if (isInWater(x, y)) { return false; } if (isInRangeWithPoi(x, y, 150)) return false; if (terrainManager->getHighestHeightDifference(x - 10, y - 10, x + 10, y + 10) > 15.0) return false; return true; }
bool PlanetManagerImplementation::isCampingPermittedAt(float x, float y, float margin) { SortedVector<ManagedReference<ActiveArea* > > activeAreas; Vector3 targetPos(x, y, zone->getHeight(x, y)); zone->getInRangeActiveAreas(x, y, &activeAreas, true); for (int i = 0; i < activeAreas.size(); ++i) { ActiveArea* area = activeAreas.get(i); // Skip areas explicitly marked as camping allowed if (area->isCampingPermitted()) { continue; } // Honor no-build after checking for areas that camping is explicitly allowed if (area->isNoBuildArea()) { return false; } } if (isInWater(x, y)) { return false; } if (isInRangeWithPoi(x, y, 150)) return false; return true; }
void CampTerminalMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject, ObjectMenuResponse* menuResponse, CreatureObject* player) const { if (!sceneObject->isTerminal()) return; Terminal* terminal = cast<Terminal*>(sceneObject); if(terminal == NULL) { error("Terminal is null in fillObjectMenuResponse"); return; } StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject()); if(camp == NULL) { error("Camp is null in fillObjectMenuResponse"); return; } TangibleObjectMenuComponent::fillObjectMenuResponse(sceneObject, menuResponse, player); /// Get Ghost Reference<PlayerObject*> ghost = player->getSlottedObject("ghost").castTo<PlayerObject*>(); if (ghost == NULL) { error("PlayerCreature has no ghost: " + String::valueOf(player->getObjectID())); return; } if (!player->isInRange(terminal, 16)) { return; } menuResponse->addRadialMenuItem(68, 3, "@camp:mnu_status"); /// Make sure player doesn't already have a camp setup somewhere else for (int i = 0; i < ghost->getTotalOwnedStructureCount(); ++i) { uint64 oid = ghost->getOwnedStructure(i); ManagedReference<StructureObject*> structure = ghost->getZoneServer()->getObject(oid).castTo<StructureObject*>(); if (structure == camp) { menuResponse->addRadialMenuItem(182, 3, "@camp:mnu_disband"); return; } } SortedVector<ManagedReference<ActiveArea*> >* areas = camp->getActiveAreas(); ManagedReference<ActiveArea*> area = NULL; for (int i = 0; i < areas->size(); ++i) { area = areas->get(i); if (area->isCampArea()) { break; } area == NULL; } if (area != NULL && area->isCampArea() && (area.castTo<CampSiteActiveArea*>())->isAbandoned()) { menuResponse->addRadialMenuItem(183, 3, "@camp:mnu_assume_ownership"); } }
Vector<CreatureObject*> TurretDataComponent::getAvailableTargets(bool aggroOnly) { Vector<CreatureObject*> targets; ManagedReference<TangibleObject*> turret = cast<TangibleObject*>(getParent()); if (turret == NULL) return targets; CloseObjectsVector* vec = (CloseObjectsVector*)turret->getCloseObjects(); SortedVector<QuadTreeEntry*> closeObjects; vec->safeCopyTo(closeObjects); int targetTotal = 0; for (int i = 0; i < closeObjects.size(); ++i) { CreatureObject* creo = cast<CreatureObject*>(closeObjects.get(i)); if (creo != NULL && checkTarget(creo, turret, aggroOnly)) { targets.add(creo); } } return targets; }
int ZoneImplementation::getInRangeActiveAreas(float x, float y, float range, SortedVector<ManagedReference<ActiveArea*> >* objects, bool readLockZone) { //Locker locker(_this.getReferenceUnsafeStaticCast()); bool readlock = readLockZone && !_this.getReferenceUnsafeStaticCast()->isLockedByCurrentThread(); //_this.getReferenceUnsafeStaticCast()->rlock(readlock); Zone* thisZone = _this.getReferenceUnsafeStaticCast(); try { thisZone->rlock(readlock); SortedVector<ManagedReference<QuadTreeEntry*> > entryObjects; regionTree->inRange(x, y, range, entryObjects); thisZone->runlock(readlock); for (int i = 0; i < entryObjects.size(); ++i) { ActiveArea* obj = dynamic_cast<ActiveArea*>(entryObjects.get(i).get()); objects->put(obj); } }catch (...) { // _this.getReferenceUnsafeStaticCast()->runlock(readlock); throw; } // _this.getReferenceUnsafeStaticCast()->runlock(readlock); return objects->size(); }
void printStringPool(const ResStringPool* pool) { if (pool->getError() == NO_INIT) { printf("String pool is unitialized.\n"); return; } else if (pool->getError() != NO_ERROR) { printf("String pool is corrupt/invalid.\n"); return; } SortedVector<const void*> uniqueStrings; const size_t N = pool->size(); for (size_t i=0; i<N; i++) { size_t len; if (pool->isUTF8()) { uniqueStrings.add(pool->string8At(i, &len)); } else { uniqueStrings.add(pool->stringAt(i, &len)); } } printf("String pool of " ZD " unique %s %s strings, " ZD " entries and " ZD " styles using " ZD " bytes:\n", (ZD_TYPE)uniqueStrings.size(), pool->isUTF8() ? "UTF-8" : "UTF-16", pool->isSorted() ? "sorted" : "non-sorted", (ZD_TYPE)N, (ZD_TYPE)pool->styleCount(), (ZD_TYPE)pool->bytes()); const size_t NS = pool->size(); for (size_t s=0; s<NS; s++) { String8 str = pool->string8ObjectAt(s); printf("String #" ZD ": %s\n", (ZD_TYPE) s, str.string()); } }
void JukeboxImplementation::setRadius(float newRadius) { ManagedReference<Jukebox*> jbox = _this.getReferenceUnsafeStaticCast(); SortedVector<ManagedReference<SceneObject*> >* children = jbox->getChildObjects(); if (newRadius == radius) return; if (children == NULL) return; radius = newRadius; for (int i = 0; i < children->size(); ++i) { ManagedReference<SceneObject*> child = children->get(i); if (child != NULL && child->isActiveArea()) { ManagedReference<ActiveArea*> area = cast<ActiveArea*>(child.get()); Locker clocker(area, jbox); area->setRadius(newRadius); return; } } }
void ObjectVersionUpdateManager::updateResidences(){ ObjectDatabase* database = ObjectDatabaseManager::instance()->loadObjectDatabase("sceneobjects", true); ObjectDatabaseIterator iterator(database); ObjectInputStream objectData(2000); uint64 objectID = 0; info("---------------Setting residences---------------------",true); info("Setting residence values for all active player residences ", true); int count = 0; try { while (iterator.getNextKeyAndValue(objectID, &objectData)) { String className; uint64 residence = 0; try { if (!Serializable::getVariable<String>(STRING_HASHCODE("_className"), &className, &objectData) || !Serializable::getVariable<uint64>(STRING_HASHCODE("PlayerObject.declaredResidence"), &residence, &objectData)) { objectData.clear(); continue; } } catch (...) { objectData.clear(); continue; } if (className == "PlayerObject") { // info("we found a Player " + String::valueOf(objectID) + " with residence " + String::valueOf(residence),true); SortedVector<unsigned long long> structureList; uint64 residence = 0; count++; printf("\r\tUpdating player residence [%d] / [?]\t", count); if( Serializable::getVariable< SortedVector<unsigned long long> >(STRING_HASHCODE("PlayerObject.ownedStructures"), &structureList, &objectData) && Serializable::getVariable<uint64>(STRING_HASHCODE("PlayerObject.declaredResidence"), &residence, &objectData)){ for(int i = 0; i < structureList.size(); i++){ bool isRes = (structureList.get(i) == residence); //info("Owned structure " + String::valueOf(structureList.get(i)) + " residence = " + String::valueOf(isRes),true); setResidence(structureList.get(i),isRes); } } else { info("ERROR unable to get ownedStructures for player " + String::valueOf(objectID),true); } } objectData.clear(); } } catch (Exception& e) { error(e.getMessage()); e.printStackTrace(); } info("\n",true); }
bool CollisionManager::checkMovementCollision(CreatureObject* creature, float x, float z, float y, Zone* zone) { SortedVector<ManagedReference<QuadTreeEntry*> > closeObjects; zone->getInRangeObjects(x, y, 128, &closeObjects, true); //Vector3 rayStart(x, z + 0.25, y); //Vector3 rayStart(creature->getWorldPositionX(), creature->getWorldPositionZ(), creature->getPos) Vector3 rayStart = creature->getWorldPosition(); rayStart.set(rayStart.getX(), rayStart.getY(), rayStart.getZ() + 0.25f); //Vector3 rayEnd(x + System::random(512), z + 0.3f, y + System::random(512)); /*Vector3 rayEnd; rayEnd.set(targetPosition.getX(), targetPosition.getY(), targetPosition.getZ());*/ Vector3 rayEnd(x, z + 0.25, y); float maxDistance = rayEnd.distanceTo(rayStart); if (maxDistance == 0) return false; printf("%f\n", maxDistance); SortedVector<IntersectionResult> results; results.setAllowDuplicateInsertPlan(); printf("starting test\n"); Triangle* triangle; for (int i = 0; i < closeObjects.size(); ++i) { SceneObject* object = dynamic_cast<SceneObject*>(closeObjects.get(i).get()); if (object == NULL) continue; AABBTree* tree = getAABBTree(object, 255); if (tree == NULL) continue; Ray ray = convertToModelSpace(rayStart, rayEnd, object); //results.removeAll(10, 10); //ordered by intersection distance //tree->intersects(ray, maxDistance, results); float intersectionDistance; if (tree->intersects(ray, maxDistance, intersectionDistance, triangle, true)) { String str = object->getObjectTemplate()->getFullTemplateString(); object->info("intersecting with me " + str, true); return true; } } return false; }
void CampTerminalMenuComponent::disbandCamp(SceneObject* sceneObject, CreatureObject* player) const { Terminal* terminal = cast<Terminal*>(sceneObject); if(terminal == NULL) { error("Terminal is null in disbandCamp"); return; } if (!player->isInRange(terminal, 16)) { return; } StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject()); if(camp == NULL) { error("Camp is null in disbandCamp"); return; } if (camp->getZone() == NULL) return; PlayerObject* ghost = player->getPlayerObject(); if (ghost == NULL) { return; } if (!ghost->isOwnedStructure(camp)) { return; } if(player->isSitting()) { player->setPosture(CreaturePosture::UPRIGHT, true); } // Find Camp Area SortedVector<ManagedReference<ActiveArea* > >* areas = camp->getActiveAreas(); ManagedReference<ActiveArea*> area = NULL; for(int i = 0; i < areas->size(); ++i) { area = areas->get(i); if(area->isCampArea()) { break; } area == NULL; } CampSiteActiveArea* campArea = cast<CampSiteActiveArea*>(area.get()); if(campArea != NULL && campArea->despawnCamp()) return; StructureManager::instance()->destroyStructure(camp); if(campArea != NULL) { campArea->destroyObjectFromWorld(true); campArea->destroyObjectFromDatabase(true); } }
MBOOL HalSensor:: onCreate( SortedVector<MUINT>const& vSensorIndex ) { MBOOL ret = MFALSE; // MY_LOGD("+ #Sensor:%d", vSensorIndex.size()); // Mutex::Autolock _l(mMutex); // // mSensorDataMap.clear(); mSensorDataMap.setCapacity(vSensorIndex.size()); for (MUINT i = 0; i < vSensorIndex.size(); i++) { MUINT const uSensorIndex = vSensorIndex[i]; // sp<PerData> pData = new PerData; mSensorDataMap.add(uSensorIndex, pData); mpSensorDrv = SensorDrv::get(); if ( ! mpSensorDrv ) { MY_LOGE("SensorDrv::get() return NULL"); goto lbExit; } mpSeninfDrv = SeninfDrv::createInstance(); if ( ! mpSeninfDrv ) { MY_LOGE("SeninfDrv::createInstance() return NULL"); goto lbExit; } } ret = MTRUE; // lbExit: if ( ! ret ) { mSensorDataMap.clear(); } // MY_LOGD("- ret:%d", ret); return ret; }
bool DroidObjectImplementation::sendConversationStartTo(SceneObject* player) { if (!player->isPlayerCreature() || isDead()) return false; if (player != getLinkedCreature().get()) return false; BaseDroidModuleComponent* m = getModule("personality_chip"); if (m == NULL) { return false; } DroidPersonalityModuleDataComponent* personality = dynamic_cast<DroidPersonalityModuleDataComponent*>(m); if (personality == NULL) { return false; } if (personality->getPersonalityConversationTemplate() == 0) { return false; } //Face player. faceObject(player); PatrolPoint current(coordinates.getPosition(), getParent().get()); broadcastNextPositionUpdate(¤t); CreatureObject* playerCreature = cast<CreatureObject*>( player); StartNpcConversation* conv = new StartNpcConversation(playerCreature, getObjectID(), ""); player->sendMessage(conv); SortedVector<ManagedReference<Observer*> > observers = getObservers(ObserverEventType::STARTCONVERSATION); for (int i = 0; i < observers.size(); ++i) { if (dynamic_cast<ConversationObserver*>(observers.get(i).get()) != NULL) { return true; } } //Create conversation observer. ConversationObserver* conversationObserver = ConversationManager::instance()->getConversationObserver(personality->getPersonalityConversationTemplate()); if (conversationObserver != NULL) { //Register observers. registerObserver(ObserverEventType::CONVERSE, conversationObserver); registerObserver(ObserverEventType::STARTCONVERSATION, conversationObserver); registerObserver(ObserverEventType::SELECTCONVERSATION, conversationObserver); registerObserver(ObserverEventType::STOPCONVERSATION, conversationObserver); } else { error("Could not create conversation observer."); return false; } return true; }
bool ZoneContainerComponent::insertActiveArea(Zone* newZone, ActiveArea* activeArea) { if (newZone == NULL) return false; if (!activeArea->isDeplyoed()) activeArea->deploy(); Zone* zone = activeArea->getZone(); ManagedReference<SceneObject*> thisLocker = activeArea; Locker zoneLocker(newZone); if (activeArea->isInQuadTree() && newZone != zone) { activeArea->error("trying to insert to zone an object that is already in a different quadtree"); activeArea->destroyObjectFromWorld(true); //StackTrace::printStackTrace(); } activeArea->setZone(newZone); QuadTree* regionTree = newZone->getRegionTree(); regionTree->insert(activeArea); //regionTree->inRange(activeArea, 512); // lets update area to the in range players SortedVector<QuadTreeEntry*> objects; float range = activeArea->getRadius() + 64; newZone->getInRangeObjects(activeArea->getPositionX(), activeArea->getPositionY(), range, &objects, false); for (int i = 0; i < objects.size(); ++i) { SceneObject* object = cast<SceneObject*>(objects.get(i)); if (!object->isTangibleObject()) { continue; } TangibleObject* tano = cast<TangibleObject*>(object); Vector3 worldPos = object->getWorldPosition(); if (!tano->hasActiveArea(activeArea) && activeArea->containsPoint(worldPos.getX(), worldPos.getY())) { tano->addActiveArea(activeArea); activeArea->enqueueEnterEvent(object); } } newZone->addSceneObject(activeArea); return true; }
MBOOL HalSensor:: isMatch(SortedVector<MUINT>const& vSensorIndex) const { if ( vSensorIndex.size() != mSensorDataMap.size() ) { MY_LOGD("isMatch vSensorIndex:%d, mSensorDataMap:%d\n", vSensorIndex.size(),mSensorDataMap.size());//ToDo: remove return MFALSE; } // for (MUINT i = 0; i < vSensorIndex.size(); i++) { if ( vSensorIndex[i] != mSensorDataMap.keyAt(i) ) { MY_LOGD("isMatch vSensorIndex[i]:%d, mSensorDataMap[i]:%d\n", vSensorIndex[i],mSensorDataMap.keyAt(i));//ToDo:remove return MFALSE; } } // return MTRUE; }
void StructurePermissionList::migrateLists(ZoneServer* zoneServer, uint64 ownerObjectID) { Locker locker(&lock); ManagedReference<GuildManager*> guildManager = zoneServer->getGuildManager(); ManagedReference<PlayerManager*> playerManager = zoneServer->getPlayerManager(); for (int i = 0; i < permissionLists.size(); i++) { String listName = permissionLists.elementAt(i).getKey(); addList(listName); SortedVector<String>* list = &permissionLists.get(i); for (int j = 0; j < list->size(); j++) { String name = list->get(j); if (name.beginsWith("guild:")) { String abbrev = name.replaceAll("guild:",""); if (abbrev == "" || !guildManager->guildAbbrevExists(abbrev)) { continue; } ManagedReference<GuildObject*> guild = guildManager->getGuildFromAbbrev(abbrev); if (guild == NULL) { continue; } grantPermission(listName, guild->getObjectID()); } else { if (!playerManager->existsName(name)) { continue; } ManagedReference<CreatureObject*> player = playerManager->getPlayer(name); if (player == NULL || !player->isPlayerCreature()) { continue; } grantPermission(listName, player->getObjectID()); } } } ownerID = ownerObjectID; permissionLists.removeAll(); }
void ZoneComponent::insertChildObjectsToZone(SceneObject* sceneObject, Zone* zone) { SortedVector<ManagedReference<SceneObject*> >* childObjects = sceneObject->getChildObjects(); //Insert all outdoor child objects to zone for (int i = 0; i < childObjects->size(); ++i) { ManagedReference<SceneObject*> outdoorChild = childObjects->get(i); if (outdoorChild == NULL) continue; if (outdoorChild->getContainmentType() != 4 && outdoorChild->getParent() == NULL) zone->transferObject(outdoorChild, -1, true); } }
void ScavengerDroidImplementation::announceToPlayers(const String& message) { SortedVector<ManagedReference<QuadTreeEntry*> > closeObjects; zone->getInRangeObjects(getPositionX(), getPositionY(), 256, &closeObjects, true); for (int i = 0; i < closeObjects.size(); i++) { SceneObject* targetObject = cast<SceneObject*>(closeObjects.get(i).get()); if (targetObject != NULL && targetObject->isPlayerCreature()) { ManagedReference<CreatureObject*> player = cast<CreatureObject*>(targetObject); if (player != NULL) player->sendSystemMessage("@event_perk:" + message); } } }