void GroupManager::sendGroupMissionUpdate(GroupObject* group)
{
	// this procedure ensures, that in case of a change in the mission pool of the group
	// all players get updated Mission waypoints
	// it concerns all players of the group on the zone, but not on other zones


	//get us the mission nearest to the most players on the Zone
	MissionObject* mission = getZoneGroupMission(group->getPlayerList());

	if(!mission)
		return;

	//now set the GroupWaypoint for all onZone groupmembers
	Uint64List::iterator playerListIt = group->getPlayerList()->begin();
	while(playerListIt != group->getPlayerList()->end())
	{
		PlayerObject*	player		= dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt)));
		Datapad*		datapad		= dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
		WaypointObject*	waypoint	= datapad->getWaypointByName("@group:groupwaypoint");

		// remove the old one
		if(waypoint)
		{
			gMessageLib->sendUpdateWaypoint(waypoint,ObjectUpdateAdd,player);
			datapad->removeWaypoint(waypoint);
			gObjectFactory->deleteObjectFromDB(waypoint);

		}
		else
		// create a new one
		if(datapad->getCapacity())
		{
			datapad->requestNewWaypoint("@group:groupwaypoint",mission->getDestination().Coordinates,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
			gMessageLib->sendSystemMessage(player,L"","group","groupwaypoint");
		}

		
		playerListIt++;
	}
}
void 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);
        }
    }
}
Exemple #3
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);
        }
        else if (count == 0)
        {
            // First time, no tutorial data saved.
            mSubState = 1;
            mState = 1;

            // Save the state.
            (gWorldManager->getDatabase())->executeSqlAsync(0,0,"INSERT INTO %s.character_tutorial VALUES (%" PRIu64 ",%u,%u)",gWorldManager->getDatabase()->galaxy(),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);

            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
        {
        }
    }
    break;

    default:
    {
    }
    break;
    }
    delete asyncContainer;

}
Exemple #4
0
void ObjectController::destroyObject(uint64 objectId)
{
    PlayerObject*	playerObject	= dynamic_cast<PlayerObject*>(mObject);
    Datapad* datapad				= playerObject->getDataPad();
    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->log(LogManager::DEBUG,"ObjController::destroyObject: could not find object %"PRIu64"",objectId);

        return;
    }

    // waypoint
    if(object->getType() == ObjType_Waypoint)
    {
        // update our datapad
        if(!(datapad->removeWaypoint(objectId)))
        {
            gLogger->log(LogManager::DEBUG,"ObjController::handleDestroyObject: Error removing Waypoint from datapad %"PRIu64"",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->log(LogManager::DEBUG,"ObjController::handleDestroyObject: Error removing Data from datapad %"PRIu64"",objectId);
        }

        if(VehicleController* vehicle = dynamic_cast<VehicleController*>(object))
        {
            vehicle->Store();
        }

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

        delete(object);

    }


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

        BuildingObject* building = dynamic_cast<BuildingObject*>(tangibleObject->getObjectMainParent(tangibleObject));
        if(building)
        {
            if(!building->hasAdminRights(playerObject->getId()))
            {
                return;
            }
        }

        if(tangibleObject->getParentId() == 0)
        {
            return;
        }

        Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_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;
            }

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

                //unequip it
                object->setParentId(inventory->getId());
                gMessageLib->sendContainmentMessage_InRange(object->getId(),inventory->getId(),0xffffffff,creature);

                // send out the new equiplist
                gMessageLib->sendEquippedListUpdate_InRange(creature);
            }
        }
        //tangible includes items and resourcecontainers
        if(tangibleObject)
        {
            //if(tangible->getObjectMainParent(object) != inventory->getId())
            if(tangibleObject->getKnownPlayers()->size())
            {
                //this automatically destroys the object for the players in its vicinity
                tangibleObject->destroyKnownObjects();
            }
            else
            {
                // destroy it for the player
                gMessageLib->sendDestroyObject(objectId,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);

        //it might be in a cell or in a container or in the inventory :)
        ObjectContainer* oc = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(object->getParentId()));
        if(oc)
        {
            oc->deleteObject(object);
        }
        else
        {
            gWorldManager->destroyObject(object);
        }

    }
}