コード例 #1
0
ファイル: WorldManager.cpp プロジェクト: ELMERzark/mmoserver
void WorldManager::removePlayerfromAccountMap(uint64 playerID)
{
	CreatureObject* creature = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(playerID));
	if(!creature)	{
		LOG (error) << "WorldManager::removePlayerfromAccountMap : no player";
		return;
	}

	PlayerObject* player = creature->GetGhost();

    if(player)    {
        PlayerAccMap::iterator playerAccIt = mPlayerAccMap.find(player->getAccountId());

        if(playerAccIt != mPlayerAccMap.end())        {
            LOG(info) << "Player left [" << player->getId() << "] Total players on zone [" << (getPlayerAccMap()->size() -1) << "]";
            mPlayerAccMap.erase(playerAccIt);
        }
        else
        {
            LOG(error) << "Error removing player from account map [" << player->getAccountId() << "]";
        }
    }
    else
    {
        LOG(error) << "Error removing player from account map [" << player->getAccountId() << "]";
    }
}
コード例 #2
0
ファイル: WorldManager.cpp プロジェクト: ELMERzark/mmoserver
uint64 WorldManager::addObjControllerToProcess(ObjectController* objController)
{
    //make sure the Objectcontroller wont be added to the processqueue after we removed it there when logging out

    //Q: can only players be added to the process queue ???
    //A: probably yes - so put this to the playerhandlers
    if(!objController)
        return 0;

    //we get added automatically when the client sends a command to process
    if(objController->getObject()->getType() == ObjType_Player)
    {
		CreatureObject* creature = dynamic_cast<CreatureObject*>(objController->getObject());
		PlayerObject* player = creature->GetGhost();

        if ((player->getConnectionState() == PlayerConnState_LinkDead) || (player->getConnectionState() == PlayerConnState_Destroying))
            return 0;
    }
    return((mObjControllerScheduler->addTask(fastdelegate::MakeDelegate(objController,&ObjectController::process),1,125,NULL)));
}
コード例 #3
0
void	ObjectController::_handleHarvesterDeActivate(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{

    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if(!player)
    {
        return;
    }

    //do we have a valid structure ???
    uint64 id = targetId;
    Object* object = gWorldManager->getObjectById(id);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    if(!structure)
    {
        //gMessageLib->sendSystemMessage(player,L"","player_structure","command_no_building");
        return;
    }

    //is the structure in Range???
    float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
    if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
    {
        return;
    }

    HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(structure);

    harvester->setActive(false);

    //send the respective delta
    gMessageLib->sendHarvesterActive(harvester);

    //send the db update
    mDatabase->executeSqlAsync(0,0,"UPDATE %s.harvesters SET active = 0 WHERE id=%"PRIu64" ",mDatabase->galaxy(),harvester->getId());
    

}
コード例 #4
0
//======================================================================================================================
//
// provides the harvester with the current resources
//
void	ObjectController::_handleHarvesterGetResourceData(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{

    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();
    if(!player)    {
        return;
    }

    //do we have a valid structure ???
    uint64 id = targetId;
    Object* object = gWorldManager->getObjectById(id);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    if(!structure)
    {
        //gMessageLib->sendSystemMessage(player,L"","player_structure","command_no_building");
        return;
    }

    //is the structure in Range???
    float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
    if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
    {
        DLOG(info) << " ObjectController::_handleHarvesterGetResourceData Structure not in Range";
        return;
    }

    HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(structure);

    StructureAsyncCommand command;

    command.Command = Structure_Command_GetResourceData;
    command.PlayerId = player->getId();
    command.StructureId = structure->getId();

    gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);

    return;
    gMessageLib->sendHarvesterResourceData(structure,player);

    DLOG(info) << " ObjectController::_handleHarvesterGetResourceData :: hino 7 baseline";
    gMessageLib->sendBaselinesHINO_7(harvester,player);

    //add the structure to the timer so the resource amounts are updated while we look at the hopper
    //harvester->getTTS()->todo		= ttE_UpdateHopper;
    //harvester->getTTS()->playerId	= player->getId();
    //structure->getTTS()->projectedTime = 5000 + Anh_Utils::Clock::getSingleton()->getLocalTime();
    //gStructureManager->addStructureforHopperUpdate(harvester->getId());

    // this needs to be handled zoneserverside - otherwise the addition of a res will trigger a racecondition
    // between the sql write query and the sql read please note that the harvesting itself happens through stored procedures
    // and we cant keep the updatecounters synchronized


}
コード例 #5
0
//======================================================================================================================
//
// Selects the resource for extraction
//
void	ObjectController::_handleHarvesterSelectResource(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if(!player)
    {
        return;
    }

    //do we have a valid structure ???
    uint64 id = targetId;
    Object* object = gWorldManager->getObjectById(id);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    if(!structure)
    {
        //gMessageLib->sendSystemMessage(player,L"","player_structure","command_no_building");
        return;
    }

    //is the structure in Range???
    float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
    if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
    {
        DLOG(info) << " ObjectController::_handleHarvesterSelectResource Structure not in Range";
        return;
    }

    HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(structure);

    //get the relevant Resource
    BString dataStr;
    message->getStringUnicode16(dataStr);

    uint64 resourceId;
    swscanf(dataStr.getUnicode16(),L"%"WidePRIu64,&resourceId);

    Resource* tmpResource = gResourceManager->getResourceById(resourceId);

    if((!tmpResource)||(!tmpResource->getCurrent()))
    {
        DLOG(info) << " ObjectController::_handleHarvesterSelectResource No valid resource!";
        return;
    }

    harvester->setCurrentResource(resourceId);

    // update the current resource in the db
    mDatabase->executeSqlAsync(0,0,"UPDATE %s.harvesters SET ResourceID=%"PRIu64" WHERE id=%"PRIu64" ",mDatabase->galaxy(),resourceId,harvester->getId());

    CurrentResource* cR = reinterpret_cast<CurrentResource*>(tmpResource);
    //resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc()));

    float posX, posZ;
    float ratio = 0.0;

    posX	= harvester->mPosition.x;
    posZ	= harvester->mPosition.z;


    if(cR)
    {
        ratio	= cR->getDistribution((int)posX + 8192,(int)posZ + 8192);
        if(ratio > 1.0)
        {
            ratio = 1.0;
        }
    }

    float ber = harvester->getSpecExtraction();

    harvester->setCurrentExtractionRate(ber*ratio);

    // now enter the new resource in the hoppers resource list if its isnt already in there
    // TODO keep the list up to date by removing unnecessary resources
    // to this end read the list anew and delete every resource with zero amount
    // have a stored function do this

    if(!harvester->checkResourceList(resourceId))
    {
        //do *not* add to list - otherwise we get a racecondition with the asynch update from db !!!
        //harvester->getResourceList()->push_back(std::make_pair(resourceId,float(0.0)));
        //add to db
        mDatabase->executeSqlAsync(0,0,"INSERT INTO %s.harvester_resources VALUES(%"PRIu64",%"PRIu64",0,0)",mDatabase->galaxy(),harvester->getId(),resourceId);
     
    }

    // update the current extractionrate in the db for the stored procedure handling the harvesting
    mDatabase->executeSqlAsync(0,0,"UPDATE %s.harvesters SET rate=%f WHERE id=%"PRIu64" ",mDatabase->galaxy(),(ber*ratio),harvester->getId());
    

    //now send the updates
    gMessageLib->sendCurrentResourceUpdate(harvester,player);
    gMessageLib->sendCurrentExtractionRate(harvester,player);

}
コード例 #6
0
//======================================================================================================================
//
// Modifies the Admin List
//
void	ObjectController::_handleTransferStructure(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    // requirement we have the structure targeted AND give the name of the recipient on the commandline
    // OR we have the recipient targeted and stand NEXT to the structure were about to transfer

    //do we have a valid donor ?
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if(!player)
    {
        return;
    }


    // is the player online and near 30m ?
    // we get the  players id as targetid if yes, otherwise we get the name as string
    // however, we do not want players that  are not online

    //now get the target player
    PlayerObject*	recipient	= dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(targetId));

    if(!recipient)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "no_transfer_target"), player);
        return;
    }

    //do we have a valid structure ??? check our target first
    uint64 id = player->GetCreature()->getTargetId();
    Object* object = gWorldManager->getObjectById(id);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    if(!structure)
    {
        // we need to get the nearest structure that we own
        // for now dustoff
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
        return;
    }

    //is the structure in Range???
    float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Transfer_Structure_Distance",(float)8.0);
    if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
        return;
    }

    StructureAsyncCommand command;
    command.PlayerId = player->getId();
    command.StructureId = structure->getId();
    command.RecipientId = recipient->getId();
    command.PlayerStr = recipient->GetCreature()->getFirstName();
    command.Command = Structure_Command_TransferStructure;

    gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);

}
コード例 #7
0
//======================================================================================================================
//
// Modifies the Admin List
//
void	ObjectController::_handleNameStructure(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)

{
    // requirement we have the structure targeted AND give the name of the recipient on the commandline
    // OR we have the recipient targeted and stand NEXT to the structure were about to transfer

    //do we have a valid donor ?
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if(!player)
    {
        return;
    }

    //do we have a valid structure ??? check our target first
    uint64 id = player->GetCreature()->getTargetId();
    Object* object = gWorldManager->getObjectById(id);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    if(!structure)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
        return;
    }

    //is the structure in Range???
    float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
    if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
        return;
    }

    //find out where our structure is
    BString dataStr;
    message->getStringUnicode16(dataStr);

    BString nameStr;

    dataStr.convert(BSTRType_ANSI);

    sscanf(dataStr.getAnsi(),"%s",nameStr.getAnsi());

    if(nameStr.getLength() > 68)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "not_valid_name"), player);
        return;
    }

    StructureAsyncCommand command;
    command.Command = Structure_Command_RenameStructure;
    command.PlayerId = player->getId();
    command.StructureId = structure->getId();

    gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);

}
コード例 #8
0
void ObjectController::_handleDiagnose(uint64 targetId, Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* Medic = creature->GetGhost();
    PlayerObject* Target = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(targetId));
    if(Target != 0)
    {
        gMedicManager->Diagnose(Medic, Target);
    } else {
        gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "healing_response_b6"), Medic);
        return;
    }
}
コード例 #9
0
//======================================================================================================================
//
// rotates an item
//
void ObjectController::HandleRotateFurniture_(
    uint64 targetId,
    Message* message,
    ObjectControllerCmdProperties* cmdProperties) {

    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if (!player)	{
        assert(false && "ObjectController::HandleRotateFurniture_ Player not found");
        return;
    }

    // Verify that there was a target passed.
    if (!targetId) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_what"), player);
        return;
    }

    Object* object = gWorldManager->getObjectById(targetId);

    if(!object)	{
        assert(false && "ObjectController::HandleRotateFurniture_ item not found");
        return;
    }

    // Verify that the item and player are in the same structure.
    CellObject* playerCell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(player->getParentId()));
    if(!playerCell)	{
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_what"), player);
        return;
    }
    uint64 playerStructure = playerCell->getParentId();

    CellObject* objectCell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(object->getParentId()));
    if(!objectCell)	{
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_what"), player);
        return;
    }
    uint64 objectStructure = objectCell->getParentId();

    if (objectStructure != playerStructure) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_what"), player);
        return;
    }

    // Verify that the player has appropriate rights on this structure.
    if (playerCell) {
        if (BuildingObject* building = dynamic_cast<BuildingObject*>(gWorldManager->getObjectById(playerCell->getParentId()))) {
            if (!building->getAdminData().check_admin(player->getId())) {
                gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "admin_move_only"), player);
                return;
            }
        }	else {
            assert(false && "ObjectController::HandleRotateFurniture_ no structure");
            return;
        }
    } else {
        //were just outside??
        return;
    }

    // Read the message out of the packet.
    BString tmp;
    message->getStringUnicode16(tmp);

    // If the string has no length the message is ill-formatted, send the
    // proper format to the client.
    if (!tmp.getLength()) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "format_rotatefurniture_degrees"), player);
        return;
    }

    // Convert the string to an ansi string for ease with the regex.
    tmp.convert(BSTRType_ANSI);
    std::string input_string(tmp.getAnsi());

    static const regex pattern("(right|left) ([0-9]+)");
    smatch result;

    regex_search(input_string, result, pattern);

    // If the pattern doesn't match all elements then send the proper format
    // to the client.
    if (result.length() < 2) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "format_rotatefurniture_degrees"), player);
        return;
    }

    // Gather the results of the pattern for validation and use.
    std::string direction(result[1]);
    float degrees = boost::lexical_cast<float>(result[2]);

    // If the the specified amount is not within the valid range notify the client.
    if (degrees < 1.0f || degrees > 180.0f) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_params"), player);
        return;
    }

    // Rotate by the necessary amount.
    if (direction.compare("left") == 0) {
        object->rotateLeft(degrees);
    } else {
        object->rotateRight(degrees);
    }

    // Update the world with the changes.
    gMessageLib->sendDataTransformWithParent053(object);
    object->updateWorldPosition();
}
コード例 #10
0
void ObjectController::handleGenericMissionRequest(Message* message)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();
    gMessageLib->SendSystemMessage(L"Missions are currently disabled, do not report this as a bug",player);
    return;
    uint64 mission_id = message->getUint64();

    gMissionManager->missionRequest(player, mission_id);

}
コード例 #11
0
//======================================================================================================================
//
// Modifies the Admin List
//
void	ObjectController::_handleModifyPermissionList(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)

{

    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if(!player)
    {
        DLOG(info) << " ObjectController::_handleModifyPermissionList Player not found";
        return;
    }

    //find out where our structure is
    BString dataStr;
    message->getStringUnicode16(dataStr);

    BString playerStr,list,action;

    dataStr.convert(BSTRType_ANSI);

    int8 s1[64],s2[32],s3[32];
    sscanf(dataStr.getAnsi(),"%32s %16s %16s",s1, s2, s3);
    playerStr = s1;
    list = s2;
    action = s3;

    if(playerStr.getLength() > 40)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "permission_40_char"), player);
        return;
    }

    //TODO is target a structure?? used when using the commandline option
    uint64 id = player->GetCreature()->getTargetId();
    Object* object = gWorldManager->getObjectById(id);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    //if we have no structure that way, see whether we have a structure were we just used the adminlist
    if(!structure)
    {
        id = player->getStructurePermissionId();
        Object* object = gWorldManager->getObjectById(id);
        structure = dynamic_cast<PlayerStructure*>(object);
    }

    if(!structure)
    {
        return;
    }

    //is the structure in Range???
    float fAdminListDistance = gWorldConfig->getConfiguration<float>("Player_Admin_List_Distance",(float)32.0);

    if(player->getParentId())
    {
        if(CellObject* cell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(player->getParentId())))
        {
            if(HouseObject* house = dynamic_cast<HouseObject*>(gWorldManager->getObjectById(cell->getParentId())))
            {
                if(house->getId() != structure->getId())
                {
                    gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
                    return;
                }
            }
        }

    }
    else if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fAdminListDistance)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
        return;
    }

    player->setStructurePermissionId(0);

    StructureAsyncCommand command;
    command.PlayerId = player->getId();
    command.StructureId = structure->getId();
    command.List = list;
	command.PlayerStr = playerStr.getAnsi();

    if(action == "add")
    {
        command.Command = Structure_Command_AddPermission;
        gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);
		//addNametoPermissionList(command.StructureId, command.PlayerId, command.PlayerStr, command.List);
    }

    if(action == "remove")
    {
        command.Command = Structure_Command_RemovePermission;
        gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);
    }

}
コード例 #12
0
void ObjectController::handleMissionListRequest(Message* message)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();
    gMessageLib->SendSystemMessage(L"Missions are currently disabled, do not report this as a bug",player);
    return;

    /*uint8           unknown     = */
    message->getUint8();
    uint8           stale_flag  = message->getUint8();
    uint64          terminal_id = message->getUint64();

    gMissionManager->listRequest(player, terminal_id,stale_flag);
}
コード例 #13
0
void ObjectController::handleMissionCreateRequest(Message* message)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();
    gMessageLib->SendSystemMessage(L"Missions are currently disabled, do not report this as a bug",player);
    return;

    gMissionManager->createRequest(player);

}
コード例 #14
0
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);
		
	}
}
コード例 #15
0
void ObjectController::_handleHealWound(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* Medic = creature->GetGhost();
    PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic));

    std::string messageResponse = gMedicManager->handleMessage(message,"(action|constitution|health|quickness|stamina|strength)");
    if (messageResponse.length() == 0)
    {
        //you must specify a valid wound type
        gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "healing_response_65"), Medic);
    }
    else
    {
        //check Medic has enough Mind
		auto ham = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::ham::HamService>("HamService");

        if(!ham->checkMainPool(Medic->GetCreature(), HamBar_Mind, 140))        {
			gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic);
			return;
		}
            
		if (gMedicManager->CheckMedicine(Medic, Target, cmdProperties, messageResponse))
        {
            //call the event
            gMedicManager->startWoundTreatmentEvent(Medic);
            return;
        }    

    }
}
コード例 #16
0
void ObjectController::_handleHealDamage(uint64 targetId, Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* Medic = creature->GetGhost();
    PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic));

    mHandlerCompleted = gMedicManager->CheckMedicine(Medic, Target, cmdProperties, stim);
    if (mHandlerCompleted)
    {
        //call the event
        gMedicManager->startInjuryTreatmentEvent(Medic);
    }
}
コード例 #17
0
//======================================================================================================================
//
// Discards the contents of a harvesters Hopper
//
void	ObjectController::_handleDiscardHopper(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{

    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if(!player)
    {
        return;
    }

    //do we have a valid structure ???
    uint64 id = targetId;
    Object* object = gWorldManager->getObjectById(id);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    if(!structure)
    {
        //gMessageLib->sendSystemMessage(player,L"","player_structure","command_no_building");
        return;
    }

    //is the structure in Range???
    float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
    if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
    {
        return;
    }

    StructureAsyncCommand command;

    command.Command = Structure_Command_DiscardHopper;
    command.PlayerId = player->getId();
    command.StructureId = structure->getId();

    gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);


}
コード例 #18
0
void ObjectController::_handleTendWound(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* Medic = creature->GetGhost();
    PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic));
    //TODO:: add medic droid
    /*EMLocationType loc = Medic->getPlayerLocation();
    if(loc != EMLocation_Cantina || loc != EMLocation_Camp || loc != EMLocation_PlayerStructure)
    {
        return;
    }*/
    std::string messageResponse = gMedicManager->handleMessage(message,"(action|constitution|health|quickness|stamina|strength)");
    if (messageResponse.length() == 0)    {
        //you must specify a valid wound type
        gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "healing_response_65"), Medic);
		return;
    }
    
    //check Medic has enough Mind
    auto ham = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::ham::HamService>("HamService");
    if(!ham->checkMainPools(Medic->GetCreature(), 0, 0, 500))    {
		gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic);
		return;
	}
        
	if (gMedicManager->HealWound(Medic, Target, 0, cmdProperties, messageResponse + "tendwound"))
    {
        ham->ApplyWound(Medic->GetCreature(), HamBar_Focus, 5);
        ham->ApplyWound(Medic->GetCreature(), HamBar_Willpower, 5);
		Medic->GetCreature()->AddBattleFatigue(2);
        //call the event
        gMedicManager->startWoundTreatmentEvent(Medic);
        return;
	}

}
コード例 #19
0
void	ObjectController::handleResourceEmptyHopper(Message* message)
{
    uint64 playerId;
    uint64 harvesterId;

    message->getUint64(playerId);
    message->getUint64(harvesterId);

    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if(!player)
    {
        return;
    }

    //do we have a valid structure ???
    Object* object = gWorldManager->getObjectById(harvesterId);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    if(!structure)
    {
        //gMessageLib->sendSystemMessage(player,L"","player_structure","command_no_building");
        return;
    }

    //is the structure in Range???
    float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
    if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
    {
        return;
    }

    uint64 resourceId;
    uint32 amount;
    uint8 b1, b2;

    message->getUint64(resourceId);
    message->getUint32(amount);
    message->getUint8(b1);
    message->getUint8(b2);

    StructureAsyncCommand command;

    if(b1 == 0)
    {
        command.Command		=	Structure_Command_RetrieveResource;
        command.PlayerId	=	player->getId();
        command.StructureId =	structure->getId();
        command.ResourceId	=	resourceId;
        command.Amount		=	amount;
        command.b1 = b1;
        command.b2 = b2;
    }
    if(b1 == 1)
    {
        command.Command		=	Structure_Command_DiscardResource;
        command.PlayerId	=	player->getId();
        command.StructureId =	structure->getId();
        command.ResourceId	=	resourceId;
        command.Amount		=	amount;
        command.b1 = b1;
        command.b2 = b2;

    }

    gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"HOPPER",command);

}
コード例 #20
0
void ObjectController::_handleQuickHeal(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* Medic = creature->GetGhost();
    PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic));

    //check Medic has enough Mind
    auto ham = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::ham::HamService>("HamService");
    if(!ham->checkMainPools(Medic->GetCreature(), 0, 0, cmdProperties->mMindCost))    {
		gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic);
		return;
	}
    
	if (gMedicManager->HealDamage(Medic, Target, 0, cmdProperties, "quickHeal"))
    {
        ham->ApplyWound(Medic->GetCreature(), HamBar_Focus, 5);
        ham->ApplyWound(Medic->GetCreature(), HamBar_Willpower, 5);
		Medic->GetCreature()->AddBattleFatigue(2);
        //call the event
        gMedicManager->startQuickHealInjuryTreatmentEvent(Medic);
        return;
    }
       
}
コード例 #21
0
//======================================================================================================================
//
// rotates an item	 90d to right
//
void	ObjectController::HandleItemRotateRight_(
    uint64 targetId,
    Message* message,
    ObjectControllerCmdProperties* cmdProperties) {

    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if (!player)	{
        assert(false && "ObjectController::HandleItemRotateRight_ Player not found");
        return;
    }

    // Verify that there was a target passed.
    if (!targetId) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_what"), player);
        return;
    }

    Object* object = gWorldManager->getObjectById(targetId);

    if(!object)	{
        assert(false && "ObjectController::HandleItemRotateRight_ item not found");
        return;
    }

    // Verify that the item and player are in the same structure.
    // Verify that the item and player are in the same structure.
    CellObject* playerCell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(player->getParentId()));
    if(!playerCell)	{
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_what"), player);
        return;
    }
    uint64 playerStructure = playerCell->getParentId();

    CellObject* objectCell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(object->getParentId()));
    if(!objectCell)	{
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_what"), player);
        return;
    }
    uint64 objectStructure = objectCell->getParentId();

    if (objectStructure != playerStructure) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "rotate_what"), player);
        return;
    }

    // Verify that the player has appropriate rights on this structure.
    if (playerCell) {
        if (BuildingObject* building = dynamic_cast<BuildingObject*>(gWorldManager->getObjectById(playerCell->getParentId()))) {
            if (!building->getAdminData().check_admin(player->getId())) {
                gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "admin_move_only"), player);
                return;
            }
        }	else {
            assert(false && "ObjectController::HandleItemRotateRight_ no structure");
            return;
        }
    } else {
        //were just outside
        return;
    }

    // Rotate the object 90 degree's to the right
    object->rotateRight(ROTATE_INCREMENT);

    gMessageLib->sendDataTransformWithParent053(object);
    object->updateWorldPosition();
}
コード例 #22
0
void ObjectController::_handleMedicalForage(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();
    if(player)
        gForageManager->startForage(player, ForageClass_Medic);
}