Exemplo n.º 1
0
/*
 * 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;
}
Exemplo n.º 2
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();
            }
        }
    }
}
Exemplo n.º 3
0
/*
 * 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;
}
Exemplo n.º 4
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);

}
Exemplo n.º 5
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);
}