コード例 #1
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
    int VMapManager::loadMap(const char* pBasePath, unsigned int pMapId, int x, int y)
    {
		bool result = false;
		std::string dirFileName;
		if( pMapId >= MAX_MAPS )
			return false;

		if( IsTileMap( pMapId ) )
			dirFileName = getDirFileName( pMapId, x, y );
		else
			dirFileName = getDirFileName( pMapId );

		MapTree* instanceTree = m_maps[pMapId];
		if( instanceTree == NULL )
		{
			instanceTree = new MapTree( pBasePath );
			m_maps[pMapId] = instanceTree;
		}

		unsigned int mapTileIdent = MAP_TILE_IDENT(x,y);
		result = instanceTree->loadMap(dirFileName, mapTileIdent);
		if(!result)                                         // remove on fail
		{
			if(instanceTree->size() == 0)
			{
				m_maps[pMapId] = NULL;
				delete instanceTree;
			}
		}
		return(result);
    }
コード例 #2
0
ファイル: VMapManager.cpp プロジェクト: 801616/mangos
    bool VMapManager::_loadMap(const char* pBasePath, unsigned int pMapId, int x, int y, bool pForceTileLoad)
    {
        bool result = false;
        std::string dirFileName;
        if(pForceTileLoad || iMapsSplitIntoTiles.containsKey(pMapId))
        {
            dirFileName = getDirFileName(pMapId,x,y);
        }
        else
        {
            dirFileName = getDirFileName(pMapId);
        }
        MapTree* instanceTree;
        if(!iInstanceMapTrees.containsKey(pMapId))
        {
            instanceTree = new MapTree(pBasePath);
            iInstanceMapTrees.set(pMapId, instanceTree);
        }
        else
            instanceTree = iInstanceMapTrees.get(pMapId);

        unsigned int mapTileIdent = MAP_TILE_IDENT(x,y);
        result = instanceTree->loadMap(dirFileName, mapTileIdent);
        if(!result)                                         // remove on fail
        {
            if(instanceTree->size() == 0)
            {
                iInstanceMapTrees.remove(pMapId);
                delete instanceTree;
            }
        }
        return(result);
    }
コード例 #3
0
ファイル: VMapManager.cpp プロジェクト: 801616/mangos
    /**
    get the hit position and return true if we hit something
    otherwise the result pos will be the dest pos
    */
    bool VMapManager::getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float pModifyDist)
    {
        bool result = false;
        rx=x2;
        ry=y2;
        rz=z2;
        if(isLineOfSightCalcEnabled())
        {
            if(iInstanceMapTrees.containsKey(pMapId))
            {
                Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1);
                Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2);
                Vector3 resultPos;
                MapTree* mapTree = iInstanceMapTrees.get(pMapId);
                result = mapTree->getObjectHitPos(pos1, pos2, resultPos, pModifyDist);
                resultPos = convertPositionToMangosRep(resultPos.x,resultPos.y,resultPos.z);
                rx = resultPos.x;
                ry = resultPos.y;
                rz = resultPos.z;
#ifdef _VMAP_LOG_DEBUG
                Command c = Command();
                c.fillTestObjectHitCmd(pMapId, pos1, pos2, resultPos, result);
                iCommandLogger.appendCmd(c);
#endif
            }
        }
        return result;
    }
コード例 #4
0
 void ModelContainerView::showMap(int pMapId, int x, int y) {
     MapTree* mt = iVMapManager->getInstanceMapTree(pMapId);
     std::string dirFileName = iVMapManager->getDirFileName(pMapId);
     if(!mt->hasDirFile(dirFileName)) {
         dirFileName = iVMapManager->getDirFileName(pMapId, x, y);
     }
     showMap(mt,dirFileName);
     iInstanceId = pMapId;
 }
コード例 #5
0
 /*
  * Loads the map for the given mapid, x and y value.
  *
  *
  *
  */
 void
 ModelContainerView::parseVMap (int pMapId, int x, int y)
 {
   MapTree* mt = iVMapManager.getInstanceMapTree (pMapId);
   std::string dirFileName = iVMapManager.getDirFileName (pMapId, x, y);
   
   if (!mt->hasDirFile (dirFileName))
     dirFileName = iVMapManager.getDirFileName (pMapId);
   // This will add all models in map.
   parseVMap (mt, dirFileName);
 }
コード例 #6
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
	bool VMapManager::isOutDoors(unsigned int mapid, float x, float y, float z)
	{
		bool result = false;
		if( m_maps[mapid] != NULL )
		{
			Vector3 pos = convertPositionToInternalRep(x,y,z);
			MapTree* mapTree = m_maps[mapid];
			result = mapTree->isOutDoors(pos);
		}
		return(result);
	}
コード例 #7
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
	bool VMapManager::isOutDoors(unsigned int mapid, LocationVector & vec)
	{
		bool result = false;
		if( m_maps[mapid] != NULL )
		{
			Vector3 pos = convertPositionToInternalRepMod(vec);
			MapTree* mapTree = m_maps[mapid];
			result = mapTree->isOutDoors(pos);
		}
		return(result);
	}
コード例 #8
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
    void VMapManager::unloadMap(unsigned int pMapId)
    {
		if( m_maps[pMapId] != NULL )
        {
            MapTree* instanceTree = m_maps[ pMapId ];
            std::string dirFileName = getDirFileName(pMapId);
            instanceTree->unloadMap(dirFileName, 0);
            if(instanceTree->size() == 0)
            {
				m_maps[pMapId]=NULL;
                delete instanceTree;
            }
        }
    }
コード例 #9
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
    bool VMapManager::isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2)
    {
        bool result = true;
		if( m_maps[pMapId] != NULL )
        {
            Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1);
            Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2);
            if(pos1 != pos2)
            {
                MapTree* mapTree = m_maps[pMapId];
                result = mapTree->isInLineOfSight(pos1, pos2);
            }
        }
        return(result);
    }
コード例 #10
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
	bool VMapManager::getObjectHitPos(unsigned int pMapId, LocationVector & v1, LocationVector & v2, LocationVector & vout, float pModifyDist)
	{
		bool result = false;
		vout = v2;
		if( m_maps[pMapId] != NULL )
		{
			Vector3 pos1 = convertPositionToInternalRepMod(v1);
			Vector3 pos2 = convertPositionToInternalRepMod(v2);
			Vector3 resultPos;
			MapTree* mapTree = m_maps[pMapId];
			result = mapTree->getObjectHitPos(pos1, pos2, resultPos, pModifyDist);
			vout = convertPositionToMangosRep(resultPos);
		}
		return result;
	}
コード例 #11
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
	bool VMapManager::isInLineOfSight(unsigned int pMapId, LocationVector & v1, LocationVector & v2)
	{
		bool result = true;
		if( m_maps[pMapId] != NULL )
		{
			Vector3 pos1 = convertPositionToInternalRepMod(v1);
			Vector3 pos2 = convertPositionToInternalRepMod(v2);
			if(pos1 != pos2)
			{
				MapTree* mapTree = m_maps[pMapId];
				result = mapTree->isInLineOfSight(pos1, pos2);
			}
		}
		return(result);
	}
コード例 #12
0
ファイル: VMapManager.cpp プロジェクト: AscNHalf/AscNHalf
 void VMapManager::unloadMap(unsigned int pMapId)
 {
     if(iInstanceMapTrees.containsKey(pMapId))
     {
         MapTree* instanceTree = iInstanceMapTrees.get(pMapId);
         std::string dirFileName = getDirFileName(pMapId);
         instanceTree->unloadMap(dirFileName, 0, true);
         if(instanceTree->size() == 0)
         {
             iInstanceMapTrees.remove(pMapId);
             delete instanceTree;
         }
         Command c = Command();
         c.fillUnloadTileCmd(pMapId);
         iCommandLogger.appendCmd(c);
     }
 }
コード例 #13
0
ファイル: VMapManager.cpp プロジェクト: AscNHalf/AscNHalf
 //int gGetHeightCounter = 0;
 float VMapManager::getHeight(unsigned int pMapId, float x, float y, float z)
 {
     float height = VMAP_INVALID_HEIGHT;                 //no height
     if(isHeightCalcEnabled() && iInstanceMapTrees.containsKey(pMapId))
     {
         Vector3 pos = convertPositionToInternalRep(x,y,z);
         MapTree* mapTree = iInstanceMapTrees.get(pMapId);
         height = mapTree->getHeight(pos);
         if(!(height < inf()))
         {
             height = VMAP_INVALID_HEIGHT;               //no height
         }
         Command c = Command();
         c.fillTestHeightCmd(pMapId,Vector3(x,y,z),height);
         iCommandLogger.appendCmd(c);
     }
     return(height);
 }
コード例 #14
0
ファイル: VMapManager.cpp プロジェクト: AscNHalf/AscNHalf
 bool VMapManager::isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2)
 {
     bool result = true;
     if(isLineOfSightCalcEnabled() && iInstanceMapTrees.containsKey(pMapId))
     {
         Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1);
         Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2);
         if(pos1 != pos2)
         {
             MapTree* mapTree = iInstanceMapTrees.get(pMapId);
             result = mapTree->isInLineOfSight(pos1, pos2);
             Command c = Command();
                                                         // save the orig vectors
             c.fillTestVisCmd(pMapId,Vector3(x1,y1,z1),Vector3(x2,y2,z2),result);
             iCommandLogger.appendCmd(c);
         }
     }
     return(result);
 }
コード例 #15
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
    /**
    get the hit position and return true if we hit something
    otherwise the result pos will be the dest pos
    */
    bool VMapManager::getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float pModifyDist)
    {
        bool result = false;
        rx=x2;
        ry=y2;
        rz=z2;
		if( m_maps[pMapId] != NULL )
		{
                Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1);
                Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2);
                Vector3 resultPos;
                MapTree* mapTree = m_maps[pMapId];
                result = mapTree->getObjectHitPos(pos1, pos2, resultPos, pModifyDist);
                resultPos = convertPositionToMangosRep(resultPos.x,resultPos.y,resultPos.z);
                rx = resultPos.x;
                ry = resultPos.y;
                rz = resultPos.z;
        }
        return result;
    }
コード例 #16
0
ファイル: VMapManager.cpp プロジェクト: AegisEmu/AegisEmu
    void VMapManager::unloadMap(unsigned int pMapId, int x, int y)
    {
		if( m_maps[pMapId] != NULL )
		{
			MapTree * instanceTree = m_maps[pMapId];
			std::string dirFileName;

			if( IsTileMap( pMapId ) )
				dirFileName = getDirFileName( pMapId, x, y );
			else
				dirFileName = getDirFileName( pMapId );

			unsigned int mapTileIdent = MAP_TILE_IDENT(x,y);
			instanceTree->unloadMap(dirFileName, mapTileIdent);
			if(instanceTree->size() == 0)
			{
				m_maps[ pMapId ] = NULL;
				delete instanceTree;
			}
		}
    }
コード例 #17
0
ファイル: VMapManager.cpp プロジェクト: 801616/mangos
 void VMapManager::_unloadMap(unsigned int  pMapId, int x, int y)
 {
     if(iInstanceMapTrees.containsKey(pMapId))
     {
         MapTree* instanceTree = iInstanceMapTrees.get(pMapId);
         std::string dirFileName;
         if(iMapsSplitIntoTiles.containsKey(pMapId))
         {
             dirFileName = getDirFileName(pMapId,x,y);
         }
         else
         {
             dirFileName = getDirFileName(pMapId);
         }
         unsigned int mapTileIdent = MAP_TILE_IDENT(x,y);
         instanceTree->unloadMap(dirFileName, mapTileIdent);
         if(instanceTree->size() == 0)
         {
             iInstanceMapTrees.remove(pMapId);
             delete instanceTree;
         }
     }
 }