////============================================================================= //// //// survey event //// // void ArtisanManager::surveyEvent(PlayerObject* player, CurrentResource* resource, SurveyTool* tool) { if(tool && resource && player->isConnected()) { Datapad* datapad = player->getDataPad(); ResourceLocation highestDist = gMessageLib->sendSurveyMessage(tool->getInternalAttribute<uint16>("survey_range"),tool->getInternalAttribute<uint16>("survey_points"),resource,player); // this is 0, if resource is not located if(highestDist.position.y == 5.0) { std::string name("Resource Survey"); std::u16string name_u16(name.begin(), name.end()); std::shared_ptr<WaypointObject> waypoint = datapad->getWaypointByName(name_u16); // remove the old one if(waypoint) { datapad->updateWaypoint(waypoint->getId(), waypoint->getName(), glm::vec3(highestDist.position.x,0.0f,highestDist.position.z), static_cast<uint16>(gWorldManager->getZoneId()), player->getId(), WAYPOINT_ACTIVE); } else { // create a new one if(datapad->getCapacity()) { gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "survey_waypoint"), player); //gMessageLib->sendSystemMessage(this,L"","survey","survey_waypoint"); } //the datapad automatically checks if there is room and gives the relevant error message std::string name("Resource Survey"); std::u16string name_u16(name.begin(), name.end()); datapad->requestNewWaypoint(name_u16, glm::vec3(highestDist.position.x,0.0f,highestDist.position.z),static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue); } gMissionManager->checkSurveyMission(player,resource,highestDist); } } player->getSampleData()->mPendingSurvey = false; }
void GroupManager::sendGroupMissionUpdate(GroupObject* group) { // this procedure ensures, that in case of a change in the mission pool of the group // all players get updated Mission waypoints // it concerns all players of the group on the zone, but not on other zones //get us the mission nearest to the most players on the Zone MissionObject* mission = getZoneGroupMission(group->getPlayerList()); if(!mission) return; //now set the GroupWaypoint for all onZone groupmembers Uint64List::iterator playerListIt = group->getPlayerList()->begin(); while(playerListIt != group->getPlayerList()->end()) { PlayerObject* player = dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt))); Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad)); WaypointObject* waypoint = datapad->getWaypointByName("@group:groupwaypoint"); // remove the old one if(waypoint) { gMessageLib->sendUpdateWaypoint(waypoint,ObjectUpdateAdd,player); datapad->removeWaypoint(waypoint); gObjectFactory->deleteObjectFromDB(waypoint); } else // create a new one if(datapad->getCapacity()) { datapad->requestNewWaypoint("@group:groupwaypoint",mission->getDestination().Coordinates,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue); gMessageLib->sendSystemMessage(player,L"","group","groupwaypoint"); } playerListIt++; } }
void Tutorial::handleDatabaseJobComplete(void* ref,swganh::database::DatabaseResult* result) { TutorialQueryContainer* asyncContainer = reinterpret_cast<TutorialQueryContainer*>(ref); switch(asyncContainer->mQueryType) { case TutorialQuery_MainData: { swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(3); binding->addField(swganh::database::DFT_uint32,offsetof(Tutorial,mState),4,0); binding->addField(swganh::database::DFT_int32,offsetof(Tutorial,mSubState),4,1); binding->addField(swganh::database::DFT_bstring,offsetof(Tutorial,mStartingProfession),64,2); uint64 count = result->getRowCount(); if (count == 1) { result->getNextRow(binding,this); } else if (count == 0) { // First time, no tutorial data saved. mSubState = 1; mState = 1; // Save the state. (gWorldManager->getKernel()->GetDatabase())->executeSqlAsync(0,0,"INSERT INTO %s.character_tutorial VALUES (%"PRIu64",%u,%u)",gWorldManager->getKernel()->GetDatabase()->galaxy(),asyncContainer->mId,mState, mSubState); } gWorldManager->getKernel()->GetDatabase()->destroyDataBinding(binding); // Here we go... this->startScript(); } break; case TutorialQuery_PlanetLocation: { PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->mId)); if (player) { swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(4); TutorialStartingLocation startingLocation; binding->addField(swganh::database::DFT_uint32, offsetof(TutorialStartingLocation, destinationPlanet), 4, 0); binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destX), 4, 1); binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destY), 4, 2); binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destZ), 4, 3); result->getNextRow(binding, &startingLocation); startingLocation.destX += (gRandom->getRand()%5 - 2); startingLocation.destZ += (gRandom->getRand()%5 - 2); gMessageLib->sendClusterZoneTransferRequestByPosition(player, glm::vec3(startingLocation.destX, startingLocation.destY, startingLocation.destZ), startingLocation.destinationPlanet); // create waypoint at starting location. glm::vec3 position; position.x = startingLocation.destX; position.z = startingLocation.destZ; Datapad* datapad = player->getDataPad(); std::string name("@ui:cpt_avatar_location"); std::u16string name_u16(name.begin(), name.end()); std::shared_ptr<WaypointObject> wp = datapad->getWaypointByName(name_u16); if(wp) { datapad->RemoveWaypoint(wp->getId()); } datapad->requestNewWaypoint(name_u16, position, startingLocation.destinationPlanet, Waypoint_blue); //send starting emails sendStartingMails(); } else { } } break; default: { } break; } delete asyncContainer; }
void Tutorial::handleDatabaseJobComplete(void* ref,DatabaseResult* result) { TutorialQueryContainer* asyncContainer = reinterpret_cast<TutorialQueryContainer*>(ref); switch(asyncContainer->mQueryType) { case TutorialQuery_MainData: { DataBinding* binding = gWorldManager->getDatabase()->CreateDataBinding(3); binding->addField(DFT_uint32,offsetof(Tutorial,mState),4,0); binding->addField(DFT_int32,offsetof(Tutorial,mSubState),4,1); binding->addField(DFT_bstring,offsetof(Tutorial,mStartingProfession),64,2); uint64 count = result->getRowCount(); if (count == 1) { result->GetNextRow(binding,this); gLogger->log(LogManager::DEBUG,"Tutorial::handleDatabaseJobComplete: Starting profession = %s", mStartingProfession.getAnsi()); } else if (count == 0) { // First time, no tutorial data saved. mSubState = 1; mState = 1; // Save the state. (gWorldManager->getDatabase())->ExecuteSqlAsync(0,0,"INSERT INTO character_tutorial VALUES (%"PRIu64",%u,%u)",asyncContainer->mId,mState, mSubState); } gWorldManager->getDatabase()->DestroyDataBinding(binding); // Here we go... this->startScript(); } break; case TutorialQuery_PlanetLocation: { PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->mId)); if (player) { DataBinding* binding = gWorldManager->getDatabase()->CreateDataBinding(4); TutorialStartingLocation startingLocation; binding->addField(DFT_uint32, offsetof(TutorialStartingLocation, destinationPlanet), 4, 0); binding->addField(DFT_float, offsetof(TutorialStartingLocation, destX), 4, 1); binding->addField(DFT_float, offsetof(TutorialStartingLocation, destY), 4, 2); binding->addField(DFT_float, offsetof(TutorialStartingLocation, destZ), 4, 3); result->GetNextRow(binding, &startingLocation); startingLocation.destX += (gRandom->getRand()%5 - 2); startingLocation.destZ += (gRandom->getRand()%5 - 2); gLogger->log(LogManager::DEBUG,"Tutorial::handleDatabaseJobComplete: New destination planet = %u", startingLocation.destinationPlanet); gMessageLib->sendClusterZoneTransferRequestByPosition(player, glm::vec3(startingLocation.destX, startingLocation.destY, startingLocation.destZ), startingLocation.destinationPlanet); // create waypoint at starting location. glm::vec3 position; position.x = startingLocation.destX; position.z = startingLocation.destZ; Datapad* datapad = player->getDataPad(); WaypointObject* wp = datapad->getWaypointByName("@ui:cpt_avatar_location"); if(wp) { datapad->removeWaypoint(wp->getId()); } datapad->requestNewWaypoint("@ui:cpt_avatar_location", position, startingLocation.destinationPlanet, Waypoint_blue); //send starting emails sendStartingMails(); } else { gLogger->log(LogManager::DEBUG,"Tutorial::handleDatabaseJobComplete: Player gone!"); } } break; default: { gLogger->log(LogManager::DEBUG,"Tutorial::handleDatabaseJobComplete: Unknown query = %u\n", asyncContainer->mQueryType); } break; } delete asyncContainer; }