void MissionManager::checkDancerMission(PlayerObject* player)
{
	Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

	if(datapad->hasMission()) //player has a mission
	{
		MissionList::iterator it = datapad->getMissions()->begin();
		while(it != datapad->getMissions()->end())
		{
			MissionObject* mission = dynamic_cast<MissionObject*>(*it);
			if(mission->getMissionType() == dancer)
			{
				if(mission->getInProgress()) { ++it; continue; }
                if(glm::distance(player->mPosition, mission->getDestination().Coordinates) < 20)
				{
					BuffAttribute* performance_timer = new BuffAttribute(Mission_Timer, 0,0,0);
					Buff* timer = Buff::SimpleBuff(player, player, 600000, 0, gWorldManager->GetCurrentGlobalTick());
					timer->AddAttribute(performance_timer);
					player->AddBuff(timer);
					mission->setInProgress(true);
				}
			}
			++it;
		}
	}

return;
}
void MissionManager::missionFailedEntertainer(PlayerObject* player)
{
	Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

	if(datapad->hasMission()) //player has a mission
	{
		MissionList::iterator it = datapad->getMissions()->begin();
		while(it != datapad->getMissions()->end())
		{
			MissionObject* mission = dynamic_cast<MissionObject*>(*it);
			if(mission->getMissionType() == dancer || mission->getMissionType() == musician)
			{
				if(!mission->getInProgress()) { ++it; continue; }
                if(glm::distance(player->mPosition, mission->getDestination().Coordinates) < 20)
				{
						missionFailed(player,mission);
						it = datapad->removeMission(it);
						delete mission;
						return;
				}
			}
			++it;
		}
	}
}
void ObjectController::_handleFindFriendDBReply(uint64 retCode,string friendName)
{
	PlayerObject*	player	= dynamic_cast<PlayerObject*>(mObject);
	friendName.convert(BSTRType_Unicode16);
	if(retCode == 0)
	{
		gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed_noname","","",L"",0,"","",friendName.getUnicode16());
		return;
	}

	PlayerObject*	searchObject	= dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(retCode));

	if(!searchObject)
	{
		gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed","","",L"",0,"","",friendName.getUnicode16());
		return;
	}

	//are we on our targets friendlist???
	if(!searchObject->checkFriendList(player->getFirstName().getCrc()))
	{
		gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed","","",L"",0,"","",friendName.getUnicode16());
		return;
	}

	Datapad* thePad = dynamic_cast<Datapad*>(searchObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

	if(thePad && thePad->getCapacity())
	{
		//the datapad automatically checks for waypoint caspacity and gives the relevant error messages
		thePad->requestNewWaypoint(searchObject->getFirstName().getAnsi(),searchObject->mPosition,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
	}
}
void ObjectController::_handleRequestWaypointAtPosition(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	player	= dynamic_cast<PlayerObject*>(mObject);
    Datapad* datapad			= player->getDataPad();

    //if(!datapad->getCapacity())
    //{
    //	gMessageLib->sendSystemMessage(player,L"","base_player","too_many_waypoints");
    //	return;
    //}

    BStringVector	dataElements;
    BString			dataStr;
    std::string			nameStr;

    message->getStringUnicode16(dataStr);

    // Have to convert BEFORE using split, since the conversion done there is removed It will assert().. evil grin...
    // Either do the conversion HERE, or better fix the split so it handles unicoe also.
    dataStr.convert(BSTRType_ANSI);
    uint32 elementCount = dataStr.split(dataElements,' ');

    if(elementCount < 5)
    {
        if(elementCount < 4)
        {
            return;
        }
        else
        {
            nameStr = gWorldManager->getPlanetNameThis();
            std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), &tolower);
        }
    }
    else
    {
        for(uint i = 4; i < elementCount; i++)
        {
            nameStr.append(dataElements[i].getAnsi());

            if(i + 1 < elementCount)
                nameStr.append(" ");
        }
    }

    BString	planetStr	= dataElements[0].getAnsi();
    //gLogger->log(LogManager::DEBUG,"ObjController::handleCreateWaypointAtPosition: planet %s",planetStr.getAnsi());
    float	x			= static_cast<float>(atof(dataElements[1].getAnsi()));
    float	y			= static_cast<float>(atof(dataElements[2].getAnsi()));
    float	z			= static_cast<float>(atof(dataElements[3].getAnsi()));

    int32 planetId = gWorldManager->getPlanetIdByName(planetStr);

    if(planetId == -1)
    {
        return;
    }

    datapad->requestNewWaypoint(nameStr.c_str(), glm::vec3(x,y,z),static_cast<uint16>(planetId),Waypoint_blue);
}
void ObjectController::_handleSetWaypointName(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	player		= dynamic_cast<PlayerObject*>(mObject);
    BString			name;
    Datapad* datapad			= player->getDataPad();
    WaypointObject*	waypoint	= datapad->getWaypointById(targetId);
    int8			sql[1024],restStr[64],*sqlPointer;

    if(waypoint == NULL)
    {
        DLOG(info) << "ObjController::handlesetwaypointname: could not find waypoint "<< targetId;
        return;
    }

    message->getStringUnicode16(name);

    if(!(name.getLength()))
        return;

    waypoint->setName(name);

    name.convert(BSTRType_ANSI);

    sprintf(sql,"UPDATE %s.waypoints SET name='",mDatabase->galaxy());
    sqlPointer = sql + strlen(sql);
    sqlPointer += mDatabase->escapeString(sqlPointer,name.getAnsi(),name.getLength());
    sprintf(restStr,"' WHERE waypoint_id=%" PRIu64 "",targetId);
    strcat(sql,restStr);

    mDatabase->executeSqlAsync(NULL,NULL,sql);


    gMessageLib->sendUpdateWaypoint(waypoint,ObjectUpdateChange,player);
}
bool MissionManager::checkCraftingMission(PlayerObject* player,NPCObject* npc)
{
	Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
	if(datapad->hasMission()) //player has a mission
	{
		MissionList::iterator it = datapad->getMissions()->begin();
		while(it != datapad->getMissions()->end())
		{
			MissionObject* mission = dynamic_cast<MissionObject*>(*it);
			if(mission->getMissionType() == crafting)
			{
				if(mission->getStartNPC() == npc)
				{
					//This is the start npc for the deliver mission
					char mp[10];
					sprintf(mp,"m%dp",mission->getNum());
					gMessageLib->sendSpatialChat(npc,player,L"",mission->getTitleFile(),mp);
					mission->setStartNPC(NULL);
					gMessageLib->sendSystemMessage(player,L"","mission/mission_generic","deliver_received_data");
					MissionObject* updater = new MissionObject();
					updater->clear();
					updater->setId(mission->getId());
					updater->getWaypoint()->setId(mission->getId()+1);
					updater->getWaypoint()->setCoords(mission->getDestination().Coordinates);
					updater->getWaypoint()->setPlanetCRC(mission->getDestination().PlanetCRC);
					char name[150];
					sprintf(name, "@%s:%s",mission->getTitleFile().getRawData(),mission->getTitle().getRawData());
					updater->getWaypoint()->setName(name);
					updater->getWaypoint()->setActive(true);
					gMessageLib->sendMISO_Delta(updater,player);
					delete updater;
					return true;
				}
				else if(mission->getDestinationNPC() == npc && mission->getStartNPC() == NULL)
				{
					//This is the end npc for the deliver mission.
					char mr[10];
					sprintf(mr,"m%dr",mission->getNum());
					gMessageLib->sendSpatialChat(npc,player,L"",mission->getTitleFile(),mr);
					missionComplete(player,mission);
					mission->setDestinationNPC(NULL);
					it = datapad->removeMission(it);
					delete mission;
					return true;
				}
			}

			++it;
		}
	}

return false;
}
void ObjectController::_handleWaypoint(uint64 targetId, Message* message, ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	player			= dynamic_cast<PlayerObject*>(mObject);
    Datapad* datapad			= player->getDataPad();
    BString			waypoint_data;
    glm::vec3       waypoint_position;

    // Before anything else verify the datapad can hold another waypoint.
    if(! datapad->getCapacity()) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "too_many_waypoints"), player);
        return;
    }

    // Read in any waypoint data that may have been sent:
    //  [SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>
    message->getStringUnicode16(waypoint_data);

    // Check and see if any parameters were passed to the /waypoint command. For
    // immediate purposes the length can be used to tell if anything or nothing was passed.
    if (waypoint_data.getLength()) {
        int count = swscanf(waypoint_data.getUnicode16(), L"%f %f %f", &waypoint_position.x, &waypoint_position.y, &waypoint_position.z);

        // If there are an invalid number of items then disregard and notify the player of the correct
        // format for the /waypoint command.
        if (count < 2 || count > 3) {
            gMessageLib->SendSystemMessage(L"[SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>", player);
            return;
        }

        // If the item count is 2 it means no y value was set in the /waypoint command so
        // update the waypoint_position data values accordingly.
        if (count == 2) {
            waypoint_position.z = waypoint_position.y;
            waypoint_position.y = 0;
        }

        // Validate the position values.
        if (waypoint_position.x < -8192 || waypoint_position.x > 8192 ||
                waypoint_position.y < -500 || waypoint_position.y > 500 ||
                waypoint_position.z < -8192 || waypoint_position.z > 8192) {
            gMessageLib->SendSystemMessage( L"[SYNTAX] Invalid range for /waypoint. x = -8192/8192 y = -500/500 z = -8192/8192", player);
            return;
        }
    } else {
        // If no parameters were passed to the /waypoint command use the current world position.
        waypoint_position = player->getWorldPosition();
    }

    datapad->requestNewWaypoint("Waypoint", waypoint_position, static_cast<uint16>(gWorldManager->getZoneId()), Waypoint_blue);
}
Exemple #8
0
Datapad* DatapadFactory::_createDatapad(DatabaseResult* result)
{
    if (!result->getRowCount()) {
    	return nullptr;
    }

    Datapad* datapad = new Datapad();

    // get our results
    result->getNextRow(mDatapadBinding,(void*)datapad);
    datapad->setParentId(datapad->mId - 3);

	gWorldManager->addObject(datapad, true);

	return datapad;
}
bool MissionManager::checkReconMission(MissionObject* mission)
{
	if (mission->getMissionType() != recon) return false;

    if(glm::distance(mission->getOwner()->mPosition, mission->getDestination().Coordinates) < 20)
	{
		Datapad* datapad = dynamic_cast<Datapad*>(mission->getOwner()->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
		missionComplete(mission->getOwner(),mission);
		gWorldManager->removeMissionFromProcess(mission->getTaskId());
		datapad->removeMission(mission);
		delete mission;
	}



return true;
}
void MissionManager::checkSurveyMission(PlayerObject* player,CurrentResource* resource,ResourceLocation highestDist)
{
	Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
	if(datapad->hasMission()) //player has a mission
	{
		MissionList::iterator it = datapad->getMissions()->begin();
		while(it != datapad->getMissions()->end())
		{
			MissionObject* mission = dynamic_cast<MissionObject*>(*it);
			if(mission->getMissionType() == survey)
			{
				if(mission->getTargetResource() == resource->getType())
				{
					if(mission->getDifficulty() <= (highestDist.ratio*100))
					{
                        if(glm::distance(mission->getIssuingTerminal()->mPosition, highestDist.position) > 1024)
						{
							gLogger->logMsg("PE > 500: ready to apply new BF/wound dmg");
							missionComplete(player,mission);
							it = datapad->removeMission(it);
							delete mission;
							return;
						}
						else
						{


							int8 sm[500];
							sprintf(sm,"That resource pocket is too close (%"PRIu32" meters) to the mission giver to be useful to them. Go find one at least %"PRIu32" meters away to complete your survey mission. ",
                                static_cast<uint32>(glm::distance(mission->getIssuingTerminal()->mPosition, highestDist.position)),
                                    (1024 - (int)glm::distance(mission->getIssuingTerminal()->mPosition, highestDist.position)));

							string s = BString(sm);
							s.convert(BSTRType_Unicode16);
							gMessageLib->sendSystemMessage(player,s);
						}
					}
				}
			}
			++it;
		}

	}

}
void ObjectController::_handleSetWaypointActiveStatus(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	player		= dynamic_cast<PlayerObject*>(mObject);
    WaypointObject*	waypoint	= NULL;
    Datapad* datapad			= player->getDataPad();

    waypoint = datapad->getWaypointById(targetId);

    if(waypoint)
    {
        waypoint->toggleActive();
        mDatabase->executeSqlAsync(0,0,"UPDATE %s.waypoints set active=%u WHERE waypoint_id=%" PRIu64 "",mDatabase->galaxy(),(uint8)waypoint->getActive(),targetId);
    }
    else
    {
        DLOG(info) << "ObjController::handleSetWaypointStatus: could not find waypoint " << targetId;
    }
}
Exemple #12
0
////=============================================================================
////
//// 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++;
	}
}
Exemple #14
0
void MountObject::handleObjectMenuSelect(uint8 message_type, Object* source_object) {

    PlayerObject*	player	= dynamic_cast<PlayerObject*>(source_object);

    if (!player) {
        // Verify the data passed in is what is expected. In debug mode the assert will
        // trigger and crash the server.
        assert(false && "MountObject::handleObjectMenuSelect - Menu selection requested from a non-player object.");
        return;
    }

    switch (message_type) {
    case radId_vehicleStore:
    {
        Datapad* datapad			= player->getDataPad();
        if(datapad) {
            if(VehicleController* vehicle = dynamic_cast<VehicleController*>(datapad->getDataById(mId-1))) {
                vehicle->Store();
            }
        }
    }
    break;

    case radId_serverVehicleEnter:
    case radId_serverVehicleExit:
    {
        gLogger->log(LogManager::DEBUG, "MountObject::handleObjectMenuSelect - still in radial selection");
    }
    break;

    default:
    {
        gLogger->log(LogManager::DEBUG, "MountObject::handleObjectMenuSelect - unknown radial selection: %d",message_type);
    }
    break;
    }
}
/*
 * Player aborted the mission
*/
void MissionManager::missionAbort(PlayerObject* player, uint64 mission_id)
{
	gLogger->logMsg("ABORT MISSION");
	Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

	MissionObject* mission = datapad->getMissionById(mission_id);
	if(mission)
	{
		datapad->removeMission(mission);
		gMessageLib->sendSystemMessage(player,L"","mission/mission_generic","incomplete");
		gMessageLib->sendSetWaypointActiveStatus(mission->getWaypoint(),false,player);
		gMessageLib->sendMissionAbort(mission,player);
		gMessageLib->sendContainmentMessage(mission->getId(), datapad->getId(), 4, player);
		gMessageLib->sendDestroyObject(mission_id,player);

		delete mission;
	}
	else
	{
		gLogger->logMsg("ERROR: Attempt to abort an invalid mission, with id %.8X, from the datapad.", static_cast<int>(mission_id));
	}

return;
}
Exemple #16
0
void VehicleControllerFactory::handleObjectReady(Object* object,DispatchClient* client)
{

    if(VehicleController* vehicle = dynamic_cast<VehicleController*>(object))
    {

        PlayerObject* player = gWorldManager->getPlayerByAccId(client->getAccountId());
        if(player)
        {
            vehicle->set_owner(player);
            Datapad* datapad			= player->getDataPad();
            if(datapad)
            {
                datapad->addData(vehicle);
                gWorldManager->addObject(vehicle,true);
                //spawn it in the player's datapad
                gMessageLib->sendCreateInTangible(vehicle, datapad->getId(), player);

                //now spawn it in the world
                vehicle->Call();
            }
        }
    }
}
void ObjectController::destroyObject(uint64 objectId)
{
	
	CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* playerObject = creature->GetGhost();
	Datapad*		datapad			= playerObject->getDataPad();
	Object*			object			= gWorldManager->getObjectById(objectId);

	auto equip_service = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::equipment::EquipmentService>("EquipmentService");
	auto inventory = dynamic_cast<Inventory*>(equip_service->GetEquippedObject(playerObject->GetCreature(), "inventory"));

	//could be a schematic!
	ManufacturingSchematic* schem	= datapad->getManufacturingSchematicById(objectId);

	if(schem != NULL)
	{
		//delete schematic
		datapad->removeManufacturingSchematic(objectId);

		//delete schematic object
		gObjectFactory->deleteObjectFromDB(schem);
		gMessageLib->sendDestroyObject(objectId,playerObject);

		return;
	}

	

	// or something else
	if(object == NULL)
	{
		DLOG(info) << "ObjController::destroyObject: could not find object " << objectId;
		return;
	}

	// waypoint
	if(object->getType() == ObjType_Waypoint)
	{
		// delete from db
		gObjectFactory->deleteObjectFromDB(object);
		
		if(!datapad)	{
			LOG(error) << "ObjectController::destroyObject cant get datapad to destroy waypoint : " << object->getId();
			return;
		}

		datapad->RemoveWaypoint(object->getId());

		//remove from grid and/or container
		gWorldManager->destroyObject(object);
		
	}

	//Inangible Objects
	if(object->getType() == ObjType_Intangible)
	{
		
		gObjectFactory->deleteObjectFromDB(object);
		
		//remove from grid and/or container
		gWorldManager->destroyObject(object);
		
	}


	// tangible
	else if(object->getType() == ObjType_Tangible)
	{
		TangibleObject* tangibleObject = dynamic_cast<TangibleObject*>(object);
		
		auto equip_service = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::equipment::EquipmentService>("EquipmentService");
		auto inventory = dynamic_cast<Inventory*>(equip_service->GetEquippedObject(playerObject->GetCreature(), "inventory"));

		// items
		if(Item* item = dynamic_cast<Item*>(tangibleObject))
		{
			// handle any family specifics
			switch(item->getItemFamily())
			{
				case ItemFamily_CraftingTools:	_handleDestroyCraftingTool(dynamic_cast<CraftingTool*>(item));	break;
				case ItemFamily_Instrument:		_handleDestroyInstrument(item);									break;

				default:break;
			}

		}
		
		
		// reset pending ui callbacks
		playerObject->resetUICallbacks(object);

		

		// delete from db CAVE :: mark if its an Object saved in the db!!!!
		// temporary placed instruments are not saved in the db
		gObjectFactory->deleteObjectFromDB(object);

		//remove from grid and/or container and/or World
		gWorldManager->destroyObject(object);
		
	}
}
/*
 * Player Accepted Mission
*/
void MissionManager::missionRequest(PlayerObject* player, uint64 mission_id)
{
	Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

	//Move the mission from the player's mission bag to his datapad.
	MissionBag* mission_bag = dynamic_cast<MissionBag*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_MissionBag));
	MissionObject* mission =  mission_bag->getMissionById(mission_id);
	if(mission == NULL)
	{
		gLogger->logMsgF("ERROR: Failed to retrieve mission with id %"PRIu64". Unable to accept mission!", MSG_HIGH, mission_id);
		return;
	}

	//automatically checks the datapads capacity
	if(!datapad->addMission(mission))
	{
		gMessageLib->sendSystemMessage(player,L"","mission/mission_generic","too_many_missions");
		return;
	}
	mission_bag->removeMission(mission);
	gMessageLib->sendContainmentMessage(mission->getId(), datapad->getId(), 0xffffffff, player);


	//Replace it with a new mission.
	mission_bag->spawnNAdd();

	//Send MissionGenericResponse to tell the client its been accepted
	gMessageLib->sendMissionGenericResponse(mission,player);

	//Update the name and mission waypoint
	MissionObject* updater = new MissionObject();
	updater->clear();
	updater->setId(mission->getId());
	updater->setNameFile(mission->getTitleFile().getRawData());
	updater->setName(mission->getTitle().getRawData());
	if(mission->getMissionType() != survey)
	{
		updater->getWaypoint()->setId(mission->getId()+1);
		if(mission->getMissionType() == deliver || mission->getMissionType() == crafting)
		{
			updater->getWaypoint()->setCoords(mission->getStart().Coordinates);
			updater->getWaypoint()->setPlanetCRC(mission->getStart().PlanetCRC);
		}
		else
		{
			updater->getWaypoint()->setCoords(mission->getDestination().Coordinates);
			updater->getWaypoint()->setPlanetCRC(mission->getDestination().PlanetCRC);

		}
		char name[150];
		sprintf(name, "@%s:%s",mission->getTitleFile().getRawData(),mission->getTitle().getRawData());
		updater->getWaypoint()->setName(name);
		updater->getWaypoint()->setActive(true);
	}
	else
	{
		gMessageLib->sendSystemMessage(player,L"","mission/mission_generic","survey_start");
	}

	//Accept the mission let the player know
	gMessageLib->sendPlayMusicMessage(WMSound_Mission_Accepted,player); //3887, 'sound/music_mission_accepted.snd'
	gMessageLib->sendMISO_Delta(updater,player);

	mission->sendAttributes(mission->getOwner());

	delete updater;

	if(mission->getMissionType() == recon)	mission->setTaskId(gWorldManager->addMissionToProcess(mission));


	//check if we need to inform our group
	if((mission->getMissionType() == destroy)&&(player->getGroupId() != 0))
	{
		// we are in a group and just accepted a destroy mission
		// check the missions and update the nearest waypoint
		GroupObject* group = gGroupManager->getGroupObject(player->getGroupId());
		gGroupManager->sendGroupMissionUpdate(group);

	}

return;
}
Exemple #19
0
void DatapadFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
    QueryContainerBase* asyncContainer = reinterpret_cast<QueryContainerBase*>(ref);

    switch(asyncContainer->mQueryType)
    {
    case DPFQuery_MainDatapadData:
    {
        //get the count of all Waypoints and Schematics
        Datapad* datapad = _createDatapad(result);

        QueryContainerBase* asContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,DPFQuery_ObjectCount,asyncContainer->mClient);
        asContainer->mObject = datapad;

        mDatabase->executeSqlAsync(this,asContainer,"SELECT %s.sf_getDatapadObjectCount(%" PRIu64 ")",mDatabase->galaxy(),datapad->getId());
       
    }
    break;

    case DPFQuery_ObjectCount:
    {
        Datapad* datapad = dynamic_cast<Datapad*>(asyncContainer->mObject);

        uint32 objectCount;
        DataBinding* binding = mDatabase->createDataBinding(1);

        binding->addField(DFT_uint32,0,4);
        result->getNextRow(binding,&objectCount);

        datapad->setObjectLoadCounter(objectCount);

        if(objectCount != 0)
        {
            uint64 dtpId = datapad->getId();

            datapad->setLoadState(LoadState_Loading);

            // query contents
            QueryContainerBase* asContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,DPFQuery_Objects,asyncContainer->mClient);
            asContainer->mObject = datapad;

            mDatabase->executeSqlAsync(this,asContainer,
                                       "(SELECT \'waypoints\',waypoints.waypoint_id FROM %s.waypoints WHERE owner_id = %" PRIu64 ")"
                                       " UNION (SELECT \'manschematics\',items.id FROM %s.items WHERE (parent_id=%" PRIu64 "))"
                                       " UNION (SELECT \'vehicles\',vehicles.id FROM %s.vehicles WHERE (parent=%" PRIu64 "))",
                                       mDatabase->galaxy(),dtpId-3,
                                       mDatabase->galaxy(),dtpId,
                                       mDatabase->galaxy(),dtpId);

        }
        else
        {
            datapad->setLoadState(LoadState_Loaded);
            asyncContainer->mOfCallback->handleObjectReady(datapad,asyncContainer->mClient);
        }

        mDatabase->destroyDataBinding(binding);
    }
    break;

    case DPFQuery_ItemId:
    {
        uint64 id;
        DataBinding* binding = mDatabase->createDataBinding(1);

        binding->addField(DFT_uint64,0,8);
        result->getNextRow(binding,&id);

        gTangibleFactory->requestObject(this,id,TanGroup_Item,0,asyncContainer->mClient);
        mDatabase->destroyDataBinding(binding);
    }
    break;

    case DPFQuery_MSParent:
    {
        uint64 id;
        DataBinding* binding = mDatabase->createDataBinding(1);

        binding->addField(DFT_uint64,0,8);
        result->getNextRow(binding,&id);

        PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(id-3));
        if(!player)
        {
            //factoryPanic!!!!!!!!
        	LOG(warning) << "Failed getting player to create MS";
            return;
        }

        Datapad* datapad = player->getDataPad();

        if(!datapad)
        {
            //factoryPanic!!!!!!!!
        	LOG(error) << "Failed getting datapad to create MS";
            return;
        }
        mObjectLoadMap.insert(std::make_pair(datapad->getId(),new(mILCPool.ordered_malloc()) InLoadingContainer(datapad,datapad,NULL,1)));
        gTangibleFactory->requestObject(this,asyncContainer->mId,TanGroup_Item,0,NULL);

    }
    break;

    case DPFQuery_Objects:
    {
        Datapad* datapad = dynamic_cast<Datapad*>(asyncContainer->mObject);
        datapad->mWaypointUpdateCounter = 0;
        datapad->mManSUpdateCounter = 0;

        Type1_QueryContainer queryContainer;

        DataBinding*	binding = mDatabase->createDataBinding(2);
        binding->addField(DFT_bstring,offsetof(Type1_QueryContainer,mString),64,0);
        binding->addField(DFT_uint64,offsetof(Type1_QueryContainer,mId),8,1);

        uint64 count = result->getRowCount();

        //InLoadingContainer* ilc = new(mILCPool.ordered_malloc()) InLoadingContainer(inventory,asyncContainer->mOfCallback,asyncContainer->mClient);
        //ilc->mLoadCounter = count;

        mObjectLoadMap.insert(std::make_pair(datapad->getId(),new(mILCPool.ordered_malloc()) InLoadingContainer(datapad,asyncContainer->mOfCallback,asyncContainer->mClient,static_cast<uint32>(count))));

        for(uint32 i = 0; i < count; i++)
        {
            result->getNextRow(binding,&queryContainer);

            if(strcmp(queryContainer.mString.getAnsi(),"waypoints") == 0)
            {
                ++datapad->mWaypointUpdateCounter;
                mWaypointFactory->requestObject(this,queryContainer.mId,0,0,asyncContainer->mClient);
            }

            else if(strcmp(queryContainer.mString.getAnsi(),"manschematics") == 0)
            {
                ++datapad->mManSUpdateCounter;
                gTangibleFactory->requestObject(this,queryContainer.mId,TanGroup_Item,0,asyncContainer->mClient);

            }
            else if(strcmp(queryContainer.mString.getAnsi(),"vehicles") == 0)
            {
                //datapad counter gets updated in vehicle factory
                gVehicleControllerFactory->requestObject(this,queryContainer.mId,0,0,asyncContainer->mClient);

            }

        }

        mDatabase->destroyDataBinding(binding);
    }
    break;

    default:
        break;
    }

    mQueryContainerPool.free(asyncContainer);

}
void ObjectController::destroyObject(uint64 objectId)
{
    PlayerObject*	playerObject	= dynamic_cast<PlayerObject*>(mObject);
    Datapad*		datapad			= dynamic_cast<Datapad*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
    Object*			object			= gWorldManager->getObjectById(objectId);

    //could be a schematic!
    ManufacturingSchematic* schem	= datapad->getManufacturingSchematicById(objectId);

    if(schem != NULL)
    {
        //delete schematic
        datapad->removeManufacturingSchematic(objectId);

        //delete schematic object
        gObjectFactory->deleteObjectFromDB(schem);
        gMessageLib->sendDestroyObject(objectId,playerObject);

        return;
    }

    // could be a waypoint
    if(object == NULL)
    {
        object = datapad->getWaypointById(objectId);
    }

    // or something else
    if(object == NULL)
    {
        gLogger->logMsgF("ObjController::destroyObject: could not find object %"PRIu64"",MSG_NORMAL,objectId);

        return;
    }

    // waypoint
    if(object->getType() == ObjType_Waypoint)
    {
        // update our datapad
        if(!(datapad->removeWaypoint(objectId)))
        {
            gLogger->logMsgF("ObjController::handleDestroyObject: Error removing Waypoint from datapad %"PRIu64"",MSG_NORMAL,objectId);
        }

        gMessageLib->sendUpdateWaypoint(dynamic_cast<WaypointObject*>(object),ObjectUpdateDelete,playerObject);

        // delete from db
        gObjectFactory->deleteObjectFromDB(object);

        delete(object);
    }

    //Inangible Objects
    if(object->getType() == ObjType_Intangible)
    {
        //update the datapad
        if(!(datapad->removeData(objectId)))
        {
            gLogger->logMsgF("ObjController::handleDestroyObject: Error removing Data from datapad %"PRIu64"",MSG_NORMAL,objectId);
        }

        if(Vehicle* vehicle = dynamic_cast<Vehicle*>(object))
        {
            vehicle->store();
        }

        gObjectFactory->deleteObjectFromDB(object);
        gMessageLib->sendDestroyObject(objectId,playerObject);

    }


    // tangible
    else if(object->getType() == ObjType_Tangible)
    {
        TangibleObject* tangibleObject = dynamic_cast<TangibleObject*>(object);

        // items
        if(Item* item = dynamic_cast<Item*>(tangibleObject))
        {
            // Does the item have a owner?
            /*
            if (item->getOwner() != 0)
            {
            	gLogger->logMsgF("ObjController::handleDestroyObject: OwnerId = %"PRIu64", playerId = %"PRIu64"", MSG_NORMAL, item->getOwner(), playerObject->getId());
            	// Yes, is it my item?
            	if (item->getOwner() != playerObject->getId())
            	{
            		// Not allowed to delete this item.
            		gMessageLib->sendSystemMessage(playerObject,L"","error_message","insufficient_permissions");
            		return;
            	}
            }
            */

            // handle any family specifics
            switch(item->getItemFamily())
            {
            case ItemFamily_CraftingTools:
                _handleDestroyCraftingTool(dynamic_cast<CraftingTool*>(item));
                break;
            case ItemFamily_Instrument:
                _handleDestroyInstrument(item);
                break;

            default:
                break;
            }

            // destroy it for the player
            gMessageLib->sendDestroyObject(objectId,playerObject);

            // Also update the world...if the object is not private.
            if ((item->getParentId() != playerObject->getId()) && (item->getParentId() != dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getId()))
            {
                PlayerObjectSet* inRangePlayers	= playerObject->getKnownPlayers();
                PlayerObjectSet::iterator it = inRangePlayers->begin();
                while(it != inRangePlayers->end())
                {
                    PlayerObject* targetObject = (*it);
                    gMessageLib->sendDestroyObject(tangibleObject->getId(),targetObject);
                    targetObject->removeKnownObject(tangibleObject);
                    ++it;
                }
                tangibleObject->destroyKnownObjects();
            }

            // update the equiplist, if its an equipable item
            CreatureObject* creature = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(item->getParentId()));
            if(creature)
            {
                // remove from creatures slotmap
                playerObject->getEquipManager()->removeEquippedObject(object);

                // send out the new equiplist
                gMessageLib->sendEquippedListUpdate_InRange(playerObject);

                // destroy it for players in range
                PlayerObjectSet* objList		= playerObject->getKnownPlayers();
                PlayerObjectSet::iterator it	= objList->begin();

                while(it != objList->end())
                {
                    gMessageLib->sendDestroyObject(objectId,(*it));

                    ++it;
                }
            }
        }
        else if(ResourceContainer* container = dynamic_cast<ResourceContainer*>(object))
        {
            //gLogger->logMsg("destroy ressourcecontainer");
            gMessageLib->sendDestroyObject(container->getId(),playerObject);
        }

        // reset pending ui callbacks
        playerObject->resetUICallbacks(object);

        // delete from db CAVE :: mark if its an Object saved in the db!!!!
        // temporary placed instruments are not saved in the db
        gObjectFactory->deleteObjectFromDB(object);

        // remove from inventory
        if(object->getParentId() == dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getId())
        {
            dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->deleteObject(object);
        }
        // remove from world
        else
        {
            gWorldManager->destroyObject(object);
        }
    }
}
void ObjectController::_handleGetAttributesBatch(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	playerObject	= dynamic_cast<PlayerObject*>(mObject);
    BString			requestStr;
    BStringVector	dataElements;
    BStringVector	dataElements2;
    uint16			elementCount;


    message->getStringUnicode16(requestStr);
    requestStr.convert(BSTRType_ANSI);
    requestStr.getRawData()[requestStr.getLength()] = 0;

    elementCount = requestStr.split(dataElements,' ');

    if(!elementCount)
    {
        return;
    }

    Message* newMessage;

    for(uint16 i = 0; i < elementCount; i++)
    {

        uint64 itemId	= boost::lexical_cast<uint64>(dataElements[i].getAnsi());
        Object* object	= gWorldManager->getObjectById(itemId);

        if(object == NULL)
        {
            // could be a resource
            Resource* resource = gResourceManager->getResourceById(itemId);

            if(resource != NULL)
            {
                resource->sendAttributes(playerObject);
                continue;
            }

            //could be a schematic!
            Datapad* datapad			= playerObject->getDataPad();
            ManufacturingSchematic* schem	= datapad->getManufacturingSchematicById(itemId);

            if(schem != NULL)
            {
                schem->sendAttributes(playerObject);
                continue;
            }

            MissionObject* mission			= datapad->getMissionById(itemId);
            if(mission != NULL)
            {
                mission->sendAttributes(playerObject);
                continue;
            }

            IntangibleObject* data = datapad->getDataById(itemId);
            if(data != NULL)
            {
                data->sendAttributes(playerObject);
                continue;
            }

            // TODO: check our datapad items
            if(playerObject->isConnected())
            {
                // default reply for schematics
                gMessageFactory->StartMessage();
                gMessageFactory->addUint32(opAttributeListMessage);
                gMessageFactory->addUint64(itemId);
                gMessageFactory->addUint32(0);
                //gMessageFactory->addUint16(0);
                //gMessageFactory->addUint32(40);

                newMessage = gMessageFactory->EndMessage();

                (playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(),  CR_Client, 8);
            }

            //finally, when we are crafting this could be the new item, not yet added to the worldmanager??
            if(playerObject->getCraftingSession())
            {
                if(playerObject->getCraftingSession()->getItem()&&playerObject->getCraftingSession()->getItem()->getId() == itemId)
                {
                    playerObject->getCraftingSession()->getItem()->sendAttributes(playerObject);
                }
            }
        }
        else
        {
            // Tutorial: I (Eru) have to do some hacks here, since I don't know how to get the info of what object the client has selected (by single click) in the Inventory.
            if (gWorldConfig->isTutorial())
            {
                // Let's see if the actual object is the food item "Melon" in our inventory.
                if (dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getId() == object->getParentId())
                {
                    //uint64 id = object->getId();

                    // Is it an Item?
                    Item* item = dynamic_cast<Item*>(object);

                    // Check if this item is a food item.
                    if (item)
                    {
                        if (item->getItemFamily() == ItemFamily_Foods)
                        {
                            playerObject->getTutorial()->tutorialResponse("foodSelected");
                        }
                    }
                }
            }

            object->sendAttributes(playerObject);
        }
    }
}
MissionObject* GroupManager::getZoneGroupMission(std::list<uint64>* members)
{

	// we will iterate through all onZone groupmembers and compile a list of missions
	// we will find the mission nearest to the most players
	// and set the waypoints accordingly

	MissionObject*	chosenMission		= NULL;
	uint32			chosenRubberPoints	= 0;

	if(!members->size())
		return NULL;

	MissionGroupRangeList missionRangeList;

	//compile the missionlist
	Uint64List::iterator playerListIt = members->begin();
	while(playerListIt != members->end())
	{
		PlayerObject*	groupMember = dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt)));
		
		if(!groupMember)
		{
			playerListIt++;
			continue;
		}

		Datapad* datapad = dynamic_cast<Datapad*>(groupMember->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

		MissionList* missionList = datapad->getMissions();
		MissionList::iterator missionListIt = missionList->begin();

		//add all Missions of the player to our List
		while(missionListIt != missionList->end())
		{
			//the rubber point counter will be set to 0 initially
			missionRangeList.push_back(std::make_pair((*missionListIt),0));
			missionListIt++;
		}
	
		playerListIt++;
	}

	//do we have missions in the first place ?
	if(!missionRangeList.size())
		return NULL;

	//now iterate through all players and determine their nearest mission
	playerListIt = members->begin();

	while(playerListIt != members->end())
	{
		PlayerObject*	groupMember = dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt)));
		//now check for the nearest mission - increase its counter
		
		MissionGroupRangeList::iterator missionRangeListIt = missionRangeList.begin();
		MissionGroupRangeList::iterator missionRangeListStorage = missionRangeList.begin();

		while(missionRangeListIt != missionRangeList.end())
		{
			MissionObject* nearestMission = NULL;
			float	nearestDistance = 88000.0;
			
			MissionObject* currentMission = (*missionRangeListIt).first;
            float currentDistance = glm::distance(groupMember->mPosition, currentMission->getDestination().Coordinates);

			//store the nearest Mission
			if(currentDistance < nearestDistance)
			{
				nearestDistance = currentDistance;
				nearestMission = currentMission;
				
				//store the lists iterator for future reference
				missionRangeListStorage = missionRangeListIt;

			}

			
			missionRangeListIt++;
		}
		
		//now take the nearest Mission and give it a rubberpoint
		(*missionRangeListStorage).second++;

		//does our mission have enough rubberpoints?
		if((*missionRangeListStorage).second > (uint32)(members->size() /2))
		{
			//jupp :)
			return (*missionRangeListStorage).first;
		}

		//remember the mission with the most rubberpoints anyway in case we dont have a clear winner
		if((*missionRangeListStorage).second > chosenRubberPoints)
		{
			chosenRubberPoints	= (*missionRangeListStorage).second;
			chosenMission		= (*missionRangeListStorage).first;
		}

		playerListIt++;
	}

	return chosenMission;
}
Exemple #23
0
void MovingObject::updatePosition(uint64 parentId, const glm::vec3& newPosition)
{
    // Face the direction we are moving.
    this->facePosition(newPosition);

    if (parentId == 0)
    {
        //we are to be moved (or already are) outside
        updatePositionOutside(parentId, newPosition);
    }
    else
    {
        updatePositionInCell(parentId, newPosition);
    }
    this->mPosition = newPosition;

    //TODO do we need to update our known Objects ???
    //answer YES if we are a player
    bool isPlayer = false;

    if(PlayerObject* player = dynamic_cast<PlayerObject*>(this))
    {
        isPlayer = true;
        //we cannot stop entertaining here, as the entertainermanager uses this code to move us to the placed instrument

        player->getController()->playerWorldUpdate(true);

        //dismount us if we were moved inside
        if(player->checkIfMounted() && player->getMount() && parentId)
        {
            Datapad* datapad			= player->getDataPad();

            if(datapad)
            {
                if(VehicleController* datapad_pet = dynamic_cast<VehicleController*>(datapad->getDataById(player->getMount()->controller())))
                {
                    datapad_pet->Store();
                }
            }
        }
    }

    //check whether updates are necessary before building the packet and then destroying it
    if ((!isPlayer) && this->getKnownPlayers()->empty())
    {
        return;
    }

    if (this->getParentId())
    {
        // We are inside a cell.
        //needs to be 0000000B as unknown int otherwise the datatransform gets ignored
        if(isPlayer)
            gMessageLib->sendDataTransformWithParent0B(this);
        else
        {
            this->incInMoveCount();
            gMessageLib->sendUpdateTransformMessageWithParent(this);
        }
    }
    else
    {
        if(isPlayer)
            gMessageLib->sendDataTransform0B(this);
        else
        {
            this->incInMoveCount();
            gMessageLib->sendUpdateTransformMessage(this);
        }
    }
}
Exemple #24
0
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;

}
Exemple #25
0
void Deed::handleObjectMenuSelect(uint8 messageType,Object* srcObject)
{
	if(PlayerObject* player = dynamic_cast<PlayerObject*>(srcObject))
	{
		switch(messageType)
		{
			case radId_itemUse:
			{
				if(this->getItemType() >= ItemType_Deed_X34 && this->getItemType() <= ItemType_Deed_Swoop) //landspeeder x34, speederbike, swoop
				{
					// create the vehicle and put in datapad
					Datapad*		datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

					if(datapad->getCapacity())
					{
						gVehicleFactory->createVehicle(this->getItemType(),player);

						Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
						inventory->removeObject(this);
						gMessageLib->sendDestroyObject(this->getId(),player);
						gObjectFactory->deleteObjectFromDB(this);
						gWorldManager->destroyObject(this);
					}
					else
					{
						gMessageLib->sendSystemMessage(player,L"Error datapad at max capacity. Couldn't create the vehicle.");
					}
				}
				else
				{
					//enter deed placement mode
					StructureDeedLink* data = gStructureManager->getDeedData(this->getItemType());
					if(!data)
					{
						return;
					}
					if(player->getParentId())
					{
						gMessageLib->sendSystemMessage(player,L"","player_structure","not_inside");
						return;
					}

					//check available Lots and remove ... grml
					if(!player->useLots(data->requiredLots))
					{
						gMessageLib->sendSystemMessage(player, L"","player_structure","not_enough_lots","","",L"",data->requiredLots);
						return;
					}

					//TODO
					//check for city boundaries
					
					//check if were allowed to build that structure on this planet
					if((data->placementMask&gWorldManager->getZoneId()) == gWorldManager->getZoneId())
					{
						//sadly the client wont inform us when the player hit escape
						gMessageLib->sendEnterStructurePlacement(this,data->structureObjectString,player);
						gStructureManager->UpdateCharacterLots(player->getId());
					}
					else
					{
						//we cannot differ whether its a no build planet
						//or just the house type isnt permitted here
						//wrong_planet 
						//not_permitted
						gMessageLib->sendSystemMessage(player, L"","player_structure","wrong_planet","","",L"",data->requiredLots);
						gStructureManager->UpdateCharacterLots(player->getId());
						return;
					}

				}
			}
			break;
			default: break;
		}


	}
}
bool MessageLib::sendBaselinesPLAY_8(PlayerObject* playerObject,PlayerObject* targetObject)
{
    if(!targetObject->isConnected())	{
		LOG (error) << "MessageLib::sendBaselinesPLAY_8 playerObject : " << playerObject->getId() << "not accessible";
        return(false);
	}

	Datapad* datapad							= playerObject->getDataPad();
    
    if(!datapad) {
		LOG (error) << "MessageLib::sendBaselinesPLAY_8  : No Datapad for player : " << playerObject->getId();
		return false;
	}

	XPList* xpList				= playerObject->getXpList();
	XPList::iterator xpIt		= xpList->begin();

	//start with the data
	
	mMessageFactory->StartMessage();
	mMessageFactory->addUint16(7);										//Operand Count

    // xp list
    mMessageFactory->addUint32(xpList->size());
    mMessageFactory->addUint32(playerObject->mXpUpdateCounter);

    xpIt = xpList->begin();

    while(xpIt != xpList->end())
    {
        mMessageFactory->addUint8(0);
        mMessageFactory->addString(gSkillManager->getXPTypeById((*xpIt).first));
        mMessageFactory->addInt32((*xpIt).second);
        ++xpIt;
    }

    // waypoint list
	swganh::messages::BaselinesMessage message;
    datapad->SerializeWaypoints(&message);

	mMessageFactory->addData(message.data.data(),message.data.size());

    // current force
	mMessageFactory->addUint32(playerObject->GetCurrentForcePower());

    // max force
    mMessageFactory->addUint32(playerObject->GetMaxForcePower());

    // unknown
    mMessageFactory->addUint32(5);
    mMessageFactory->addUint64(20);
    mMessageFactory->addUint8(0);
    mMessageFactory->addUint32(5);
    mMessageFactory->addUint64(14);
    mMessageFactory->addUint8(0);

    // quest list
    mMessageFactory->addUint64(0);

    mMessageFactory->addUint32(0);
    mMessageFactory->addUint64(0);
    mMessageFactory->addUint32(0);
    mMessageFactory->addUint16(0);

	Message* data = mMessageFactory->EndMessage();

	//*************************************************
    //now wrap it up

    mMessageFactory->StartMessage();
    mMessageFactory->addUint32(opBaselinesMessage);
    mMessageFactory->addUint64(playerObject->getId());
    mMessageFactory->addUint32(opPLAY);
    mMessageFactory->addUint8(8);
	mMessageFactory->addUint32(data->getSize());
	mMessageFactory->addData(data->getData(),data->getSize());
	
	data->setPendingDelete(true);
	
	
    (targetObject->getClient())->SendChannelA(mMessageFactory->EndMessage(), targetObject->getAccountId(), CR_Client, 5);

    return(true);
}
Exemple #27
0
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;

}
void ObjectFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
	OFAsyncContainer* asyncContainer = reinterpret_cast<OFAsyncContainer*>(ref);

	switch(asyncContainer->query)
	{
		case OFQuery_House:
		{
			PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
			if(!result->getRowCount())
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create house failed : no result");
				break;
			}

			uint64 requestId = 0;
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint64,0,8);
			result->GetNextRow(binding,&requestId);
			mDatabase->DestroyDataBinding(binding);

			if(!requestId)
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create house failed : result is 0");
			}
			mHouseFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);

			//now we need to update the Owners Lots				
			//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
			if(player)
			{
				gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
				Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
				Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
				
				//destroy it in the client
				gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
	
				//delete it out of the inventory
				inventory->deleteObject(deed);
				
				Datapad* thePad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
				thePad->requestNewWaypoint("Player House",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);

			}
			
			// now we need to link the deed to the factory in the db and remove it out of the inventory in the db
			int8 sql[250];
			sprintf(sql,"UPDATE items SET parent_id = %I64u WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
			mDatabase->ExecuteSqlAsync(NULL,NULL,sql);
				
		}
		break;

		case OFQuery_Factory:
		{
			PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
			if(!result->getRowCount())
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create Factory failed : no result");
				break;
			}

			uint64 requestId = 0;
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint64,0,8);
			result->GetNextRow(binding,&requestId);
			mDatabase->DestroyDataBinding(binding);

			if(!requestId)
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create Factory failed : result is 0");
			}
			mFactoryFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);

			//now we need to update the Owners Lots
				
			//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
			if(player)
			{
				gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
				Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
				Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
				
				//destroy it in the client
				gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
	
				//delete it out of the inventory
				inventory->deleteObject(deed);

				Datapad* thePad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
				thePad->requestNewWaypoint("Player Factory",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);
			}
			
			// now we need to link the deed to the factory in the db and remove it out of the inventory in the db
			int8 sql[250];
			sprintf(sql,"UPDATE items SET parent_id = %I64u WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
			mDatabase->ExecuteSqlAsync(NULL,NULL,sql);
				
		}
		break;

		case OFQuery_Harvester:
		{
			if(!result->getRowCount())
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create Harvester failed");
				break;
			}

			uint64 requestId = 0;
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint64,0,8);
			result->GetNextRow(binding,&requestId);
			mDatabase->DestroyDataBinding(binding);

			if(requestId)
			{
				mHarvesterFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);

				//now we need to update the Owners Lots
				PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
					
				//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
				if(player)
				{
					gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
					Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
					Deed* deed = dynamic_cast<Deed*>(inventory->getObjectById(asyncContainer->DeedId));
					
					//destroy it in the client
					gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
		
					//delete it out of the inventory
					inventory->deleteObject(deed);

					Datapad* thePad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
					thePad->requestNewWaypoint("Harvester",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);

				}
				
				// now we need to link the deed to the harvester in the db and remove it out of the inventory
				int8 sql[250];
				sprintf(sql,"UPDATE items SET parent_id = %I64u WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
				mDatabase->ExecuteSqlAsync(NULL,NULL,sql);
			}
			else
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create Harvester failed");
		}
		break;

		case OFQuery_WaypointCreate:
		{
			uint64 requestId = 0;
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint64,0,8);
			result->GetNextRow(binding,&requestId);
			mDatabase->DestroyDataBinding(binding);

			if(requestId)
				mWaypointFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);
			else
				gLogger->logMsg("ObjFactory::createWaypoint failed");
		}
		break;

		case OFQuery_Item:
		{
			uint64 requestId = 0;
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint64,0,8);
			result->GetNextRow(binding,&requestId);
			mDatabase->DestroyDataBinding(binding);

			if(requestId)
				mTangibleFactory->requestObject(asyncContainer->ofCallback,requestId,TanGroup_Item,0,asyncContainer->client);
			else
				gLogger->logMsg("ObjFactory::createItem failed");
		}
		break;

		case OFQuery_ResourceContainerCreate:
		{
			uint64 requestId = 0;
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint64,0,8);
			result->GetNextRow(binding,&requestId);
			mDatabase->DestroyDataBinding(binding);

			if(requestId)
				mTangibleFactory->requestObject(asyncContainer->ofCallback,requestId,TanGroup_ResourceContainer,0,asyncContainer->client);
			else
				gLogger->logMsg("ObjFactory::createResourceContainer failed");
		}
		break;

		default:
		{
			mTangibleFactory->requestObject(asyncContainer->ofCallback,asyncContainer->Id,asyncContainer->Group,0,asyncContainer->client);
		}
		break;
	}

	mDbAsyncPool.free(asyncContainer);
}
Exemple #29
0
void ObjectFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
    OFAsyncContainer* asyncContainer = reinterpret_cast<OFAsyncContainer*>(ref);

    switch(asyncContainer->query)
    {
    case OFQuery_House:
    {
        PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
        if(!result->getRowCount())
        {
        	LOG(ERROR) << "create house failed : no result";
            break;
        }

        uint64 requestId = 0;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_uint64,0,8);
        result->getNextRow(binding,&requestId);
        mDatabase->destroyDataBinding(binding);

        if(!requestId)
        {
            LOG(ERROR) << "Create house failed : result is 0";
        }
        mHouseFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);

        //now we need to update the Owners Lots
        //cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
        if(player)
        {
            gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
            Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));

            ObjectContainer* tO = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(deed->getParentId()));
            //destroy it in the client
            gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);

            //delete it out of the inventory
            tO->deleteObject(deed);

            Datapad* datapad			= player->getDataPad();
            datapad->requestNewWaypoint("Player House",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);

        }

        // now we need to link the deed to the factory in the db and remove it out of the inventory in the db
        int8 sql[250];
        sprintf(sql,"UPDATE items SET parent_id = %"PRIu64" WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
        mDatabase->executeSqlAsync(NULL,NULL,sql);

    }
    break;

    case OFQuery_Factory:
    {
        PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
        if(!result->getRowCount())
        {
        	LOG(ERROR) << "Create factory failed : no result";
            break;
        }

        uint64 requestId = 0;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_uint64,0,8);
        result->getNextRow(binding,&requestId);
        mDatabase->destroyDataBinding(binding);

        if(!requestId)
        {
        	LOG(ERROR) << "Create factor failed : result is 0";
        }
        mFactoryFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);

        //now we need to update the Owners Lots

        //cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
        if(player)
        {
            gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
            Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));

            //destroy it in the client
            gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);

            //delete it out of the container
            ObjectContainer* tO = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(deed->getParentId()));
            tO->deleteObject(deed);

            Datapad* datapad			= player->getDataPad();
            datapad->requestNewWaypoint("Player Factory",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);
        }

        // now we need to link the deed to the factory in the db and remove it out of the inventory in the db
        int8 sql[250];
        sprintf(sql,"UPDATE items SET parent_id = %"PRIu64" WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
        mDatabase->executeSqlAsync(NULL,NULL,sql);
        

    }
    break;

    case OFQuery_Harvester:
    {
        if(!result->getRowCount())
        {
        	LOG(ERROR) << "Create harvester failed : no result";
            break;
        }

        uint64 requestId = 0;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_uint64,0,8);
        result->getNextRow(binding,&requestId);
        mDatabase->destroyDataBinding(binding);

        if(requestId)
        {
            mHarvesterFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);

            //now we need to update the Owners Lots
            PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));

            //cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
            if(player)
            {
                gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);

                Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));

                //destroy it in the client
                gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);

                //delete it out of the inventory
                ObjectContainer* tO = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(deed->getParentId()));
                tO->deleteObject(deed);

                Datapad* datapad			= player->getDataPad();
                datapad->requestNewWaypoint("Harvester",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);

            }

            // now we need to link the deed to the harvester in the db and remove it out of the inventory
            int8 sql[250];
            sprintf(sql,"UPDATE items SET parent_id = %"PRIu64" WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
            mDatabase->executeSqlAsync(NULL,NULL,sql);
         
        }
        else
        	LOG(ERROR) << "Create harvester failed";
    }
    break;

    case OFQuery_WaypointCreate:
    {
        uint64 requestId = 0;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_uint64,0,8);
        result->getNextRow(binding,&requestId);
        mDatabase->destroyDataBinding(binding);

        if(requestId)
            mWaypointFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);
        else
        	LOG(ERROR) << "Create waypoint failed";
    }
    break;
    case QFQuery_WaypointUpdate:
    {
        // we're looking for a value of the waypoint that was updated
        uint32 returnId = 0;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_uint32,0,4);
        result->getNextRow(binding,&returnId);
        mDatabase->destroyDataBinding(binding);
        switch (returnId)
        {
        case 0:
        case 3:
            mWaypointFactory->requestObject(asyncContainer->ofCallback,asyncContainer->Id,0,0,asyncContainer->client);
            break;
        default:
        	LOG(ERROR) << "Update waypoint failed";
        }
    }
    break;
    case OFQuery_Item:
    {
        uint64 requestId = 0;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_uint64,0,8);
        result->getNextRow(binding,&requestId);
        mDatabase->destroyDataBinding(binding);

        if(requestId)
            mTangibleFactory->requestObject(asyncContainer->ofCallback,requestId,TanGroup_Item,0,asyncContainer->client);
        else
        	LOG(ERROR) << "Create item failed";
    }
    break;

    case OFQuery_ResourceContainerCreate:
    {
        uint64 requestId = 0;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_uint64,0,8);
        result->getNextRow(binding,&requestId);
        mDatabase->destroyDataBinding(binding);

        if(requestId)
            mTangibleFactory->requestObject(asyncContainer->ofCallback,requestId,TanGroup_ResourceContainer,0,asyncContainer->client);
        else
        	LOG(ERROR) << "Create resource container failed";
    }
    break;

    default:
    {
        mTangibleFactory->requestObject(asyncContainer->ofCallback,asyncContainer->Id,asyncContainer->Group,0,asyncContainer->client);
    }
    break;
    }

    mDbAsyncPool.free(asyncContainer);
}
Exemple #30
0
//======================================================================================================================
//
// create player
//
bool MessageLib::sendCreatePlayer(PlayerObject* playerObject,PlayerObject* targetObject)
{
    if(!_checkPlayer(targetObject))
        return(false);

    sendCreateObjectByCRC(playerObject,targetObject,false);

    if(targetObject == playerObject)
    {
        sendBaselinesCREO_1(playerObject);
        sendBaselinesCREO_4(playerObject);
    }

    sendBaselinesCREO_3(playerObject,targetObject);
    sendBaselinesCREO_6(playerObject,targetObject);

    sendCreateObjectByCRC(playerObject,targetObject,true);
    sendContainmentMessage(playerObject->getPlayerObjId(),playerObject->getId(),4,targetObject);

    sendBaselinesPLAY_3(playerObject,targetObject);
    sendBaselinesPLAY_6(playerObject,targetObject);

    if(targetObject == playerObject)
    {
        sendBaselinesPLAY_8(playerObject,targetObject);
        sendBaselinesPLAY_9(playerObject,targetObject);
    }

    //close the yalp
    sendEndBaselines(playerObject->getPlayerObjId(),targetObject);

    sendPostureMessage(playerObject,targetObject);

    if(playerObject->getParentId())
    {
        sendContainmentMessage(playerObject->getId(),playerObject->getParentId(),4,targetObject);
    }

    if(targetObject == playerObject)
    {
        // tangible objects
        if(TangibleObject* hair = dynamic_cast<TangibleObject*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Hair)))
        {
            //only create the hair as the helmet will be created at a different time
            if(hair->getTangibleType() == TanType_Hair)
            {
                sendCreateTangible(hair,targetObject);
            }
        }

        // create inventory and contents
        if(dynamic_cast<TangibleObject*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory)))
        {
            sendInventory(playerObject);
        }

        // mission bag
        if(TangibleObject* missionBag = dynamic_cast<TangibleObject*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Mission)))
        {
            gMessageLib->sendCreateTangible(missionBag,playerObject);

            //Now iterate through the missions and create them clientside
            MissionBag* mbag = dynamic_cast<MissionBag*> (missionBag);
            MissionList::iterator it = mbag->getMissions()->begin();
            while(it != mbag->getMissions()->end())
            {
                MissionObject* mission = dynamic_cast<MissionObject*>(*it);
                sendCreateObjectByCRC(mission, targetObject, false);
                sendContainmentMessage(mission->getId(), mbag->getId(), 4, targetObject);
                sendBaselinesMISO_3(mission, targetObject);
                sendBaselinesMISO_6(mission, targetObject);
                sendBaselinesMISO_8(mission, targetObject);
                sendBaselinesMISO_9(mission, targetObject);
                sendEndBaselines(mission->getId(), targetObject);
                ++it;
            }

        }

        // datapad
        Datapad* datapad			= playerObject->getDataPad();
        if(datapad)
        {
            //would be nice to use the tangibles objectcontainer for the datapad
            //need to get missionobjects intangibles, Man Schematics, waypoints and stuff in though, so better do it manually
            gMessageLib->sendCreateTangible(datapad,playerObject);

            //now iterate through the schematics and create them clientside
            Datapad* dpad = dynamic_cast<Datapad*> (datapad);

            ManufacturingSchematicList*	manufacturingSchematics = dpad->getManufacturingSchematics();
            ManufacturingSchematicList::iterator it = manufacturingSchematics->begin();

            while(it != manufacturingSchematics->end())
            {
                gMessageLib->sendCreateManufacturingSchematic((dynamic_cast<ManufacturingSchematic*>(*it)),playerObject ,false);
                ++it;
            }

            //Send player's intangibles vehicles,pets,droids...etc
            DataList* intangibles = dpad->getData();
            DataList::iterator ite = intangibles->begin();

            while(ite != intangibles->end())
            {
                if(IntangibleObject* itno = dynamic_cast<IntangibleObject*>(*ite))
                {
                    gMessageLib->sendCreateInTangible(itno, dpad->getId(), playerObject);

                    //dont add it to the MainObjectMap
                    //gWorldManager->addObject(itno,true);

                    switch(itno->getItnoGroup())
                    {
                    case ItnoGroup_Vehicle:
                    {
                        // set Owner for vehicles
                        if(VehicleController* vehicle = dynamic_cast<VehicleController*>(itno))
                        {
                            vehicle->set_owner(playerObject);
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }

                ++ite;
            }

            //Should send accepted missions here

        }
    }
    //equipped items are already in the creo6 so only send them for ourselves

    sendEndBaselines(playerObject->getId(),targetObject);

    sendUpdatePvpStatus(playerObject,targetObject);

    if(targetObject == playerObject)
    {
        // We are actually sending this info from CharacterLoginHandler::handleDispatchMessage at the opCmdSceneReady event.
        // sendFriendListPlay9(playerObject);
        // sendIgnoreListPlay9(playerObject);

        //request the GRUP baselines from chatserver if grouped
        if(playerObject->getGroupId() != 0)
        {
            gMessageLib->sendIsmGroupBaselineRequest(playerObject);
        }
    }

    //Player mounts
    if(playerObject->checkIfMountCalled())
    {
        if(playerObject->getMount())
        {
            gMessageLib->sendCreateObject(playerObject->getMount(),targetObject);
            if(playerObject->checkIfMounted())
            {
                gMessageLib->sendContainmentMessage(playerObject->getId(), playerObject->getMount()->getId(), 0xffffffff, targetObject);
            }
        }
    }

    return(true);
}