int CraftingSessionImplementation::clearSession() { Locker slocker(_this.get()); ManagedReference<CraftingTool*> craftingTool = this->craftingTool.get(); ManagedReference<CreatureObject*> crafter = this->crafter.get(); ManagedReference<PlayerObject*> crafterGhost = this->crafterGhost.get(); ManagedReference<CraftingStation*> craftingStation = this->craftingStation.get(); ManagedReference<ManufactureSchematic*> manufactureSchematic = this->manufactureSchematic.get(); ManagedReference<TangibleObject*> prototype = this->prototype.get(); if (manufactureSchematic != NULL) { Locker locker(manufactureSchematic); if (manufactureSchematic->getParent() == craftingTool) { manufactureSchematic->setDraftSchematic(NULL); manufactureSchematic->cleanupIngredientSlots(crafter); manufactureSchematic->destroyObjectFromWorld(true); } this->manufactureSchematic = NULL; } if (craftingTool != NULL) { Locker locker2(craftingTool); // Remove all items that aren't the prototype while (craftingTool->getContainerObjectsSize() > 1) { craftingTool->getContainerObject(1)->destroyObjectFromWorld(true); } craftingTool->dropSlottedObject("crafted_components"); if (prototype != NULL) { Locker locker3(prototype); if (craftingTool->isReady()) { if (prototype->getParent() == craftingTool) { prototype->destroyObjectFromWorld(true); } this->prototype = NULL; } } } if(crafterGhost != NULL && crafterGhost->getDebug()) { crafter->sendSystemMessage("*** Clearing crafting session ***"); } return 0; }
void MTPSessionData::clear() { RPCCallbackClears clearCallbacks; { QReadLocker locker1(haveSentMutex()), locker2(toResendMutex()), locker3(haveReceivedMutex()), locker4(wereAckedMutex()); mtpResponseMap::const_iterator end = haveReceived.cend(); clearCallbacks.reserve(haveSent.size() + wereAcked.size()); for (mtpRequestMap::const_iterator i = haveSent.cbegin(), e = haveSent.cend(); i != e; ++i) { mtpRequestId requestId = i.value()->requestId; if (haveReceived.find(requestId) == end) { clearCallbacks.push_back(requestId); } } for (mtpRequestIdsMap::const_iterator i = toResend.cbegin(), e = toResend.cend(); i != e; ++i) { mtpRequestId requestId = i.value(); if (haveReceived.find(requestId) == end) { clearCallbacks.push_back(requestId); } } for (mtpRequestIdsMap::const_iterator i = wereAcked.cbegin(), e = wereAcked.cend(); i != e; ++i) { mtpRequestId requestId = i.value(); if (haveReceived.find(requestId) == end) { clearCallbacks.push_back(requestId); } } } { QWriteLocker locker(haveSentMutex()); haveSent.clear(); } { QWriteLocker locker(toResendMutex()); toResend.clear(); } { QWriteLocker locker(wereAckedMutex()); wereAcked.clear(); } { QWriteLocker locker(receivedIdsMutex()); receivedIds.clear(); } _mtp_internal::clearCallbacksDelayed(clearCallbacks); }
void PlanetManagerImplementation::initialize() { performanceLocations = new MissionTargetMap(); numberOfCities = 0; info("Loading planet."); planetTravelPointList->setZoneName(zone->getZoneName()); loadClientRegions(); loadClientPoiData(); loadLuaConfig(); loadTravelFares(); if (zone->getZoneName() == "dathomir") { Reference<ActiveArea*> area = zone->getZoneServer()->createObject(STRING_HASHCODE("object/fs_village_area.iff"), 0).castTo<ActiveArea*>(); Locker locker(area); area->setRadius(768.f); area->initializePosition(5306, 0, -4145); zone->transferObject(area, -1, true); ManagedReference<SceneObject*> scenery = zone->getZoneServer()->createObject(STRING_HASHCODE("object/static/structure/general/fs_village_nobuild_768m.iff"), 0); Locker slocker(scenery, area); scenery->initializePosition(5306, zone->getHeight(5306, -4145), -4145); area->attachScenery(scenery); slocker.release(); locker.release(); Reference<ActiveArea*> sarlaccArea = zone->getZoneServer()->createObject(STRING_HASHCODE("object/sarlacc_area.iff"), 0).castTo<ActiveArea*>(); Locker locker2(sarlaccArea); sarlaccArea->setRadius(60.f); sarlaccArea->initializePosition(-2085, 0, 3147); zone->transferObject(sarlaccArea, -1, true); locker2.release(); Reference<ActiveArea*> sarlaccPreArea = zone->getZoneServer()->createObject(STRING_HASHCODE("object/sarlacc_area.iff"), 0).castTo<ActiveArea*>(); Locker locker3(sarlaccPreArea); sarlaccPreArea->setRadius(30.f); sarlaccPreArea->initializePosition(-2085, 0, 3147); zone->transferObject(sarlaccPreArea, -1, true); } if (zone->getZoneName() == "tatooine") { Reference<ActiveArea*> area = zone->getZoneServer()->createObject(STRING_HASHCODE("object/sarlacc_area.iff"), 0).castTo<ActiveArea*>(); Locker locker(area); area->setRadius(30.f); area->initializePosition(-6174, 0, -3361); zone->transferObject(area, -1, true); locker.release(); Reference<ActiveArea*> preArea = zone->getZoneServer()->createObject(STRING_HASHCODE("object/sarlacc_area.iff"), 0).castTo<ActiveArea*>(); Locker locker2(preArea); preArea->setRadius(60.f); preArea->initializePosition(-6174, 0, -3361); zone->transferObject(preArea, -1, true); } }
void CraftingSessionImplementation::customization(const String& name, byte templateChoice, int schematicCount, const String& customizationString) { ManagedReference<CraftingTool*> craftingTool = this->craftingTool.get(); ManagedReference<CreatureObject*> crafter = this->crafter.get(); ManagedReference<PlayerObject*> crafterGhost = this->crafterGhost.get(); ManagedReference<CraftingStation*> craftingStation = this->craftingStation.get(); ManagedReference<ManufactureSchematic*> manufactureSchematic = this->manufactureSchematic.get(); ManagedReference<TangibleObject*> prototype = this->prototype.get(); ManagedReference<CraftingManager*> craftingManager = this->craftingManager.get(); if (manufactureSchematic == NULL) { sendSlotMessage(0, IngredientSlot::NOSCHEMATIC); return; } if (prototype == NULL) { sendSlotMessage(0, IngredientSlot::PROTOTYPENOTFOUND); return; } //if(NameManager::instance()->isProfane(name)) { // player->sendSystemMessage("Your selected name has been declined because it may contain inappropriate language. Close the 'customizing' window and try again"); // return; //} Locker locker(craftingTool); Locker locker2(manufactureSchematic); Locker locker3(_this.get()); if (templateChoice != 0xFF) { Reference<DraftSchematic*> draftSchematic = manufactureSchematic->getDraftSchematic(); if (draftSchematic != NULL) { if (draftSchematic->getTemplateListSize() >= (int) templateChoice) { String chosenTemplate = draftSchematic->getTemplate((int) templateChoice); uint32 clientCRC = chosenTemplate.hashCode(); prototype->setClientObjectCRC(clientCRC); String minusShared = chosenTemplate.replaceAll("shared_",""); SharedObjectTemplate* newTemplate = TemplateManager::instance()->getTemplate(minusShared.hashCode()); prototype->loadTemplateData(newTemplate); prototype->updateCraftingValues(manufactureSchematic->getCraftingValues(), false); prototype->sendDestroyTo(crafter); prototype->sendTo(crafter, true); } } } if(schematicCount < 0 || schematicCount > 1000) schematicCount = 1000; manufactureSchematic->setManufactureLimit(schematicCount); StringTokenizer tokenizer(customizationString); byte customizationindex, customizationvalue; String customizationname = ""; //Database::escapeString(name); //Remove color codes String newName = name; while (newName.contains("\\#")) { int index = newName.indexOf("\\#"); String sub = "\\" + newName.subString(index, index + 2); newName = newName.replaceFirst(sub,""); } UnicodeString customName(newName); prototype->setCustomObjectName(customName, false); /// Set Name manufactureSchematic->getObjectName()->setStringId( prototype->getObjectNameStringIdFile(), prototype->getObjectNameStringIdName()); /// Set Manufacture Schematic Custom name if (!newName.isEmpty()) manufactureSchematic->setCustomObjectName(customName, false); while (tokenizer.hasMoreTokens()) { customizationindex = (byte) tokenizer.getIntToken(); customizationname = variables.elementAt(customizationindex).getKey(); customizationvalue = (byte) tokenizer.getIntToken(); prototype->setCustomizationVariable(customizationname, customizationvalue); } TangibleObjectDeltaMessage3* dtano3 = new TangibleObjectDeltaMessage3(prototype); dtano3->updateName(newName); dtano3->updateCustomizationString(); dtano3->close(); crafter->sendMessage(dtano3); ManufactureSchematicObjectDeltaMessage3 * dMsco3 = new ManufactureSchematicObjectDeltaMessage3( manufactureSchematic); dMsco3->updateName(newName); dMsco3->updateCondition(schematicCount); dMsco3->close(); crafter->sendMessage(dMsco3); //Object Controller ObjectControllerMessage* objMsg = new ObjectControllerMessage( crafter->getObjectID(), 0x1B, 0x010C); objMsg->insertInt(0x15A); objMsg->insertInt(0); objMsg->insertByte(0); crafter->sendMessage(objMsg); state = 5; }
void CraftingSessionImplementation::experiment(int rowsAttempted, const String& expAttempt, int clientCounter) { ManagedReference<CraftingTool*> craftingTool = this->craftingTool.get(); ManagedReference<CreatureObject*> crafter = this->crafter.get(); ManagedReference<PlayerObject*> crafterGhost = this->crafterGhost.get(); ManagedReference<CraftingStation*> craftingStation = this->craftingStation.get(); ManagedReference<ManufactureSchematic*> manufactureSchematic = this->manufactureSchematic.get(); ManagedReference<TangibleObject*> prototype = this->prototype.get(); ManagedReference<CraftingManager*> craftingManager = this->craftingManager.get(); if (manufactureSchematic == NULL) { sendSlotMessage(0, IngredientSlot::NOSCHEMATIC); return; } if (prototype == NULL) { sendSlotMessage(0, IngredientSlot::PROTOTYPENOTFOUND); return; } Locker locker(craftingTool); Locker locker2(manufactureSchematic); Locker locker3(_this.get()); StringTokenizer tokenizer(expAttempt); int rowEffected, pointsAttempted, failure; int lowestExpSuccess = 0; //lastExperimentationTimestamp = Time::currentNanoTime(); Reference<CraftingValues*> craftingValues = manufactureSchematic->getCraftingValues(); craftingValues->clear(); // Loop through all the lines of experimentation for (int i = 0; i < rowsAttempted; ++i) { rowEffected = tokenizer.getIntToken(); pointsAttempted = tokenizer.getIntToken(); experimentationPointsUsed += pointsAttempted; // Each line gets it's own rolls // Calcualte a new failure rate for each line of experimentation failure = craftingManager->calculateExperimentationFailureRate(crafter, manufactureSchematic, pointsAttempted); if (experimentationPointsUsed <= experimentationPointsTotal) { // Set the experimentation result ie: Amazing Success experimentationResult = craftingManager->calculateExperimentationSuccess( crafter, manufactureSchematic->getDraftSchematic(), failure); } else { // If this code is reached, they have likely tried to hack to // get more experimenting points, so lets just give them a failure experimentationResult = CraftingManager::CRITICALFAILURE; } // Make sure to store the lowest roll to display (Effect the multiline rolls if (lowestExpSuccess < experimentationResult) lowestExpSuccess = experimentationResult; manufactureSchematic->increaseComplexity(); prototype->setComplexity(manufactureSchematic->getComplexity()); // Do the experimenting - sets new percentages craftingManager->experimentRow(manufactureSchematic, craftingValues, rowEffected, pointsAttempted, failure, experimentationResult); } manufactureSchematic->setExperimentingCounter( manufactureSchematic->getExperimentingCounter() + rowsAttempted); // Use percentages to recalculate the values craftingValues->recalculateValues(false); // Update the Tano with new values prototype->updateCraftingValues(manufactureSchematic->getCraftingValues(), false); // Sets the result for display experimentationResult = lowestExpSuccess; // Start Player Object Delta ************************************** PlayerObjectDeltaMessage9* dplay9 = new PlayerObjectDeltaMessage9( crafter->getPlayerObject()); dplay9->setExperimentationPoints(experimentationPointsTotal - experimentationPointsUsed); dplay9->close(); crafter->sendMessage(dplay9); // End Player Object Delta ************************************** ManufactureSchematicObjectDeltaMessage3* dMsco3 = new ManufactureSchematicObjectDeltaMessage3( manufactureSchematic); dMsco3->updateComplexity(manufactureSchematic->getComplexity()); dMsco3->updateCraftingValues(manufactureSchematic); dMsco3->close(); crafter->sendMessage(dMsco3); ManufactureSchematicObjectDeltaMessage7* dMsco7 = new ManufactureSchematicObjectDeltaMessage7( manufactureSchematic); dMsco7->update9(manufactureSchematic, false); dMsco7->close(); crafter->sendMessage(dMsco7); TangibleObjectDeltaMessage3* dtano3 = new TangibleObjectDeltaMessage3( prototype); dtano3->updateComplexity(); dtano3->close(); crafter->sendMessage(dtano3); ObjectControllerMessage* objMsg = new ObjectControllerMessage( crafter->getObjectID(), 0x1B, 0x0113); objMsg->insertInt(0x105); objMsg->insertInt(experimentationResult); // Experimentation Result objMsg->insertByte(clientCounter); crafter->sendMessage(objMsg); crafter->notifyObservers(ObserverEventType::CRAFTINGEXPERIMENTATION, crafter, 0); if(crafterGhost != NULL && crafterGhost->getDebug()) { crafter->sendSystemMessage(craftingValues->toString()); } }
void PlanetManagerImplementation::initialize() { performanceLocations = new MissionTargetMap(); numberOfCities = 0; info("Loading planet."); planetTravelPointList->setZoneName(zone->getZoneName()); loadClientRegions(); loadClientPoiData(); loadLuaConfig(); loadTravelFares(); loadBadgeAreas(); loadPerformanceLocations(); loadStaticTangibleObjects(); if (zone->getZoneName() == "dathomir") { Reference<ActiveArea*> area = zone->getZoneServer()->createObject(String("object/fs_village_area.iff").hashCode(), 0).castTo<ActiveArea*>(); Locker locker(area); area->setRadius(512.f); area->initializePosition(5306, 0, -4145); zone->transferObject(area, -1, true); locker.release(); Reference<ActiveArea*> sarlaccArea = zone->getZoneServer()->createObject(String("object/sarlacc_area.iff").hashCode(), 0).castTo<ActiveArea*>(); Locker locker2(sarlaccArea); sarlaccArea->setRadius(60.f); sarlaccArea->initializePosition(-2085, 0, 3147); zone->transferObject(sarlaccArea, -1, true); locker2.release(); Reference<ActiveArea*> sarlaccPreArea = zone->getZoneServer()->createObject(String("object/sarlacc_area.iff").hashCode(), 0).castTo<ActiveArea*>(); Locker locker3(sarlaccPreArea); sarlaccPreArea->setRadius(30.f); sarlaccPreArea->initializePosition(-2085, 0, 3147); zone->transferObject(sarlaccPreArea, -1, true); } if (zone->getZoneName() == "tatooine") { Reference<ActiveArea*> area = zone->getZoneServer()->createObject(String("object/sarlacc_area.iff").hashCode(), 0).castTo<ActiveArea*>(); Locker locker(area); area->setRadius(30.f); area->initializePosition(-6174, 0, -3361); zone->transferObject(area, -1, true); locker.release(); Reference<ActiveArea*> preArea = zone->getZoneServer()->createObject(String("object/sarlacc_area.iff").hashCode(), 0).castTo<ActiveArea*>(); Locker locker2(preArea); preArea->setRadius(60.f); preArea->initializePosition(-6174, 0, -3361); zone->transferObject(preArea, -1, true); } }