Exemplo n.º 1
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;
    }
}
Exemplo n.º 2
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);
        }
    }
}
Exemplo n.º 3
0
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);
        }
    }
}
void WorldManager::addDisconnectedPlayer(PlayerObject* playerObject)
{
    uint32 timeOut = gWorldConfig->getConfiguration<uint32>("Zone_Player_Logout",300);

    // Halt the tutorial scripts, if running.
    playerObject->stopTutorial();


    Datapad* datapad			= playerObject->getDataPad();

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

    // Delete private owned spawned objects, like npc's in the Tutorial.
    uint64 privateOwnedObjectId = ScriptSupport::Instance()->getObjectOwnedBy(playerObject->getId());
    while (privateOwnedObjectId != 0)
    {
        // Delete the object ref from script support.
        ScriptSupport::Instance()->eraseObject(privateOwnedObjectId);

        // We did have a private npc. Let us delete him/her/that.
        if (Object* object = getObjectById(privateOwnedObjectId))
        {
            // But first, remove npc from our defender list.
            playerObject->removeDefenderAndUpdateList(object->getId());

            destroyObject(object);
            // gLogger->log(LogManager::DEBUG,"WorldManager::addDisconnectedPlayer Deleted object with id  %"PRIu64"",privateOwnedObjectId);
        }

        privateOwnedObjectId = ScriptSupport::Instance()->getObjectOwnedBy(playerObject->getId());
    }

    removeObjControllerToProcess(playerObject->getController()->getTaskId());
    removeCreatureHamToProcess(playerObject->getHam()->getTaskId());
    removeCreatureStomachToProcess(playerObject->getStomach()->mDrinkTaskId);
    removeCreatureStomachToProcess(playerObject->getStomach()->mFoodTaskId);
    removeEntertainerToProcess(playerObject->getEntertainerTaskId());

    gCraftingSessionFactory->destroySession(playerObject->getCraftingSession());
    playerObject->setCraftingSession(NULL);
    gStateManager.removeActionState(playerObject, CreatureState_Crafting);

    //despawn camps ??? - every reference is over id though

    playerObject->getController()->setTaskId(0);
    playerObject->getHam()->setTaskId(0);
    playerObject->setSurveyState(false);
    playerObject->setSamplingState(false);
    playerObject->togglePlayerFlagOn(PlayerFlag_LinkDead);
    playerObject->setConnectionState(PlayerConnState_LinkDead);
    playerObject->setDisconnectTime(timeOut);

    //add to the disconnect list
    addPlayerToDisconnectedList(playerObject);

    gMessageLib->sendUpdatePlayerFlags(playerObject);
}