コード例 #1
0
ファイル: MessageLib.cpp プロジェクト: jason83/mmoserver
//======================================================================================================================
//
// create building
//
bool MessageLib::sendCreateBuilding(BuildingObject* buildingObject,PlayerObject* playerObject)
{
    if(!_checkPlayer(playerObject))
        return(false);

    bool publicBuilding = true;

    //test buildings on house basis here
    //perhaps move to on cell basis sometime ?
    if(HouseObject* house = dynamic_cast<HouseObject*>(buildingObject))
    {
        house->checkCellPermission(playerObject);
        publicBuilding = buildingObject->getPublic();
    }

    sendCreateObjectByCRC(buildingObject,playerObject,false);

    sendBaselinesBUIO_3(buildingObject,playerObject);
    sendBaselinesBUIO_6(buildingObject,playerObject);

    uint64 buildingId = buildingObject->getId();

    CellObjectList*				cellList	= buildingObject->getCellList();
    CellObjectList::iterator	cellIt		= cellList->begin();

    uint64 cellCount = cellList->size();
    while(cellIt != cellList->end())
    {
        CellObject* cell = (*cellIt);
        uint64 cellId = cell->getId();

        uint64 count = buildingObject->getMinCellId()-1;
        sendCreateObjectByCRC(cell,playerObject,false);
        sendContainmentMessage(cellId,buildingId,0xffffffff,playerObject);

        //cell ids are id based for tutorial cells!
        if(cell->getId() <= 2203318222975)
        {
            sendBaselinesSCLT_3(cell,cellId - buildingId,playerObject);
        }
        else
        {
            sendBaselinesSCLT_3(cell,cellId - count,playerObject);
        }
        sendBaselinesSCLT_6(cell,playerObject);

        sendUpdateCellPermissionMessage(cell,publicBuilding,playerObject);	 //cellpermissions get checked by datatransform
        sendEndBaselines(cellId,playerObject);

        ++cellIt;
    }

    sendEndBaselines(buildingId,playerObject);

    return(true);
}
コード例 #2
0
ファイル: BuildingObject.cpp プロジェクト: behaart/mmoserver
//================================================================================
//
//the cells send an updated permission  to the specified player
//
void BuildingObject::updateCellPermissions(PlayerObject* player, bool access)
{
    //iterate through all the cells 
    //place players inside the world
	this->ViewObjects(nullptr, 1, false, [&](Object* object){
		if(object->getObjectType() == SWG_CELL)	{
			CellObject* cell = dynamic_cast<CellObject*>(object);

			gMessageLib->sendUpdateCellPermissionMessage(cell,access,player);

			//are we inside the cell ?
			if((player->getParentId() == cell->getId()) && (!access))
			{
				//were no longer allowed to be inside ....
				//so get going

				//TODO find outside position (sign position for example??) to place the player

				glm::vec3 playerPosition = player->mPosition;
				glm::vec3 playerWorldPosition = player->getWorldPosition();
				glm::vec3 position;

				glm::vec3 playerNewPosition;
				position.x = (0 - playerPosition.x) - 5;
				position.z = (0 - playerPosition.z) - 2;

				position.y = mPosition.y + 50;

				position.x += playerWorldPosition.x;
				//position.y += player->getWorldPosition.x;
				position.z += playerWorldPosition.z;

				player->updatePosition(0,position);
        
			}
		}
	});

}
コード例 #3
0
ファイル: CellFactory.cpp プロジェクト: ELMERzark/mmoserver
void CellFactory::handleDatabaseJobComplete(void* ref,swganh::database::DatabaseResult* result)
{
    QueryContainerBase* asyncContainer = reinterpret_cast<QueryContainerBase*>(ref);

    switch(asyncContainer->mQueryType)
    {
    case CellFQuery_MainData:
    {
        CellObject* cell = _createCell(result);
        uint64		cellId = cell->getId();

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

        mDatabase->executeSqlAsync(this,asContainer,"(SELECT \'terminals\',id FROM %s.terminals WHERE parent_id = %"PRIu64")"
               
                                   " UNION (SELECT \'ticket_collectors\',id FROM %s.ticket_collectors WHERE (parent_id=%"PRIu64"))"
                                   " UNION (SELECT \'persistent_npcs\',id FROM %s.persistent_npcs WHERE parentId=%"PRIu64")"
                                   " UNION (SELECT \'shuttles\',id FROM %s.shuttles WHERE parentId=%"PRIu64")"
                                   " UNION (SELECT \'items\',id FROM %s.items WHERE parent_id=%"PRIu64")"
                                   " UNION (SELECT \'resource_containers\',id FROM %s.resource_containers WHERE parent_id=%"PRIu64")",
                                   mDatabase->galaxy(),cellId,
                                   mDatabase->galaxy(),cellId,
                                   mDatabase->galaxy(),cellId,
                                   
                                   mDatabase->galaxy(),cellId,
                                   mDatabase->galaxy(),cellId,
                                   mDatabase->galaxy(),cellId);       
    }
    break;

    case CellFQuery_Objects:
    {
        CellObject* cell = dynamic_cast<CellObject*>(asyncContainer->mObject);
        Type1_QueryContainer queryContainer;

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

        uint64 count = result->getRowCount();

        if(count > 0)
        {
            // store us for later lookup
            mObjectLoadMap.insert(std::make_pair(cell->getId(),new(mILCPool.ordered_malloc()) InLoadingContainer(cell,asyncContainer->mOfCallback,asyncContainer->mClient)));
            cell->setLoadCount(static_cast<uint32>(count));

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

                if(strcmp(queryContainer.mString.getAnsi(),"terminals") == 0)
                    gObjectFactory->requestObject(ObjType_Tangible,TanGroup_Terminal,0,this,queryContainer.mId,asyncContainer->mClient);
                
                else if(strcmp(queryContainer.mString.getAnsi(),"ticket_collectors") == 0)
                    gObjectFactory->requestObject(ObjType_Tangible,TanGroup_TicketCollector,0,this,queryContainer.mId,asyncContainer->mClient);
                else if(strcmp(queryContainer.mString.getAnsi(),"persistent_npcs") == 0)
                    gObjectFactory->requestObject(ObjType_NPC,CreoGroup_PersistentNpc,0,this,queryContainer.mId,asyncContainer->mClient);
                else if(strcmp(queryContainer.mString.getAnsi(),"shuttles") == 0)
                    gObjectFactory->requestObject(ObjType_Creature,CreoGroup_Shuttle,0,this,queryContainer.mId,asyncContainer->mClient);
                else if(strcmp(queryContainer.mString.getAnsi(),"items") == 0)
                    gObjectFactory->requestObject(ObjType_Tangible,TanGroup_Item,0,this,queryContainer.mId,asyncContainer->mClient);
                else if(strcmp(queryContainer.mString.getAnsi(),"resource_containers") == 0)
                    gObjectFactory->requestObject(ObjType_Tangible,TanGroup_ResourceContainer,0,this,queryContainer.mId,asyncContainer->mClient);
            }
        }
        else
            asyncContainer->mOfCallback->handleObjectReady(cell,asyncContainer->mClient);

        mDatabase->destroyDataBinding(binding);
    }
    break;

    default:
        break;
    }

    mQueryContainerPool.free(asyncContainer);
}
コード例 #4
0
ファイル: CellFactory.cpp プロジェクト: ELMERzark/mmoserver
void CellFactory::handleObjectReady(Object* object,DispatchClient* client)
{
    InLoadingContainer* ilc = _getObject(object->getParentId());

    if (! ilc) {//Crashbug fix: http://paste.swganh.org/viewp.php?id=20100627114151-8f7df7f74013af71c0d0b00bc240770d
        LOG(warning) << "Could not locate InLoadingContainer for object parent id [" << object->getParentId() << "]";
        return;
    }

    CellObject*			cell = dynamic_cast<CellObject*>(ilc->mObject);

    gWorldManager->addObject(object,true);


    switch(object->getType())
    {
    case ObjType_NPC:
    case ObjType_Creature:
    {
        CreatureObject* creature = dynamic_cast<CreatureObject*>(object);

        if(creature->getCreoGroup() == CreoGroup_Shuttle)
            gWorldManager->addShuttle(dynamic_cast<Shuttle*>(creature));
    }
    break;

    case ObjType_Tangible:
    {
        PlayerStructureTerminal* terminal = dynamic_cast<PlayerStructureTerminal*>(object);
        if(terminal)
        {
            terminal->setStructure(cell->getParentId());
        }
    }
    break;

    case ObjType_Building:
    case ObjType_Cell:
    case ObjType_DraftSchematic:
    case ObjType_Structure:
    case ObjType_Intangible:
    case ObjType_Lair:
    case ObjType_Mission:
    case ObjType_None:
    case ObjType_NonPersistant:
    case ObjType_Player:
    case ObjType_Region:

    case ObjType_Waypoint:
    default:
        break;
    }

	auto permissions_objects_ = gObjectManager->GetPermissionsMap();
			
	object->SetPermissions(permissions_objects_.find(swganh::object::DEFAULT_PERMISSION)->second.get());//CREATURE_PERMISSION

	gObjectManager->LoadSlotsForObject(object);
	cell->InitializeObject(object);
	cell->incLoad();

	//LOG(info) << "cellFactory::handleObjectReady -> cell load stuff" << object->getId() << "for " << cell->getId();
	//LOG(info) << "loadcount : " << cell->getLoadCount() << " : count : " << cell->getLoad();

	if(cell->getLoadCount() == cell->getLoad())
    {
		//LOG(info) << "cellFactory::handleObjectReady -> cell done " << cell->getId();

        if(!(_removeFromObjectLoadMap(cell->getId())))
            LOG(warning) << "Failed removing object from loadmap";

        ilc->mOfCallback->handleObjectReady(cell,ilc->mClient);

        mILCPool.free(ilc);
    }
}
コード例 #5
0
ファイル: CellFactory.cpp プロジェクト: jason83/mmoserver
void CellFactory::handleObjectReady(Object* object,DispatchClient* client)
{
    InLoadingContainer* ilc = _getObject(object->getParentId());

    if (! ilc) {//Crashbug fix: http://paste.swganh.org/viewp.php?id=20100627114151-8f7df7f74013af71c0d0b00bc240770d
        gLogger->log(LogManager::WARNING,"CellFactory::handleObjectReady could not locate ILC for objectParentId:%I64u",object->getParentId());
        return;
    }

    CellObject*			cell = dynamic_cast<CellObject*>(ilc->mObject);

    gWorldManager->addObject(object,true);

    switch(object->getType())
    {
    case ObjType_NPC:
    case ObjType_Creature:
    {
        CreatureObject* creature = dynamic_cast<CreatureObject*>(object);

        if(creature->getCreoGroup() == CreoGroup_Shuttle)
            gWorldManager->addShuttle(dynamic_cast<Shuttle*>(creature));
    }
    break;

    case ObjType_Tangible:
    {
        PlayerStructureTerminal* terminal = dynamic_cast<PlayerStructureTerminal*>(object);
        if(terminal)
        {
            terminal->setStructure(cell->getParentId());
        }
    }
    break;

    case ObjType_Building:
    case ObjType_Cell:
    case ObjType_DraftSchematic:
    case ObjType_Structure:
    case ObjType_Intangible:
    case ObjType_Lair:
    case ObjType_Mission:
    case ObjType_None:
    case ObjType_NonPersistant:
    case ObjType_Player:
    case ObjType_Region:

    case ObjType_Waypoint:
    default:
        break;
    }

    cell->addObjectSecure(object);

    if(cell->getLoadCount() == cell->getObjects()->size())
    {
        if(!(_removeFromObjectLoadMap(cell->getId())))
            gLogger->log(LogManager::DEBUG,"CellFactory: Failed removing object from loadmap");

        ilc->mOfCallback->handleObjectReady(cell,ilc->mClient);

        mILCPool.free(ilc);
    }
}