Ejemplo n.º 1
0
void DCMAPAPI CPlanetManager::SetCurrentPlanet(dcmapDBREF const* pref,int x,int y,int show)
{
	x = WrapCoord(x);
	y = WrapCoord(y);

	dcmapDBREF ref;

	if((!pref || !pref->Valid()))
	{
		if(m_pPlanets->SelectCoord(x,y))
		{
			ref = *m_pPlanets->GetID();
		}		
		
		if(!ref.Valid() && (m_iCurrentX != x || m_iCurrentY != y))
		{
			m_iCurrentX = x;
			m_iCurrentY = y;

			m_CurrentPlanet.Invalidate();
			m_pWorkspace->BroadcastMessage(DCMM_PLANET_CHANGED,ref.id,ref.age,0);
            if(show)m_pWorkspace->BroadcastMessage(DCMM_SHOW_CELL,dcmapMAKELONG(x,y),show-1,0);
			return;
		}
        else if(show)
        {
            m_pWorkspace->BroadcastMessage(DCMM_SHOW_CELL,dcmapMAKELONG(x,y),show-1,0);
        }
	}
	else ref = *pref;

   	if(ref == m_CurrentPlanet) 
    {
        if(show)
        {
            m_pWorkspace->BroadcastMessage(DCMM_SHOW_CELL,dcmapMAKELONG(m_iCurrentX,m_iCurrentY),show-1,0);
        }
        return;
    }

	if(m_pPlanets->SelectID(ref))
	{
		m_CurrentPlanet = ref;
		m_iCurrentX	= m_pPlanets->GetData()->x;
		m_iCurrentY	= m_pPlanets->GetData()->y;
		m_pWorkspace->BroadcastMessage(DCMM_PLANET_CHANGED,ref.id,ref.age,0);
		if(show)m_pWorkspace->BroadcastMessage(DCMM_SHOW_CELL,dcmapMAKELONG(m_iCurrentX,m_iCurrentY),show-1,0);
	}
}
Ejemplo n.º 2
0
bool Base_Ocean::GridExists(float xx, float yy){
	WrapCoord(xx);
	WrapCoord(yy);
	int x((int)xx), y((int)yy);
	vec3 t( static_cast<float>((x/Grid_Size)*Grid_Size)   , 0,static_cast<float>((y/Grid_Size)*Grid_Size)); // make sure that this is on a 64 boundary

	int arrx(x/static_cast<int>(Grid_Size)), arry(y/static_cast<int>(Grid_Size));// this is the index for each dimension

	int bitindex(arrx/8);
	bitindex=arrx - (bitindex*8);
	int biter = (int)bitindex;	
	unsigned char bitstoshift = (1<<((unsigned char)bitindex));// shift a bit down to the correct index
	arrx/=8;
	const int jump = static_cast<int>(((World_Size/Grid_Size)/8.0f));
	return (Ocean_Grid_bits[arrx + arry* jump] & bitstoshift) != 0;
}
Ejemplo n.º 3
0
bool Base_Ocean::AddGrid(vec3 tlpos){// each grid is a fixed size of 64x64 and this function ensures that all input is in that format
	// the casts below preform a floor by casting to an unsigned int, then dividing, then multiplying
	WrapCoord(tlpos.x, tlpos.y, tlpos.z);
	int x((int)tlpos.x), y((int)tlpos.z);
	vec3 t( static_cast<float>((x/Grid_Size)*Grid_Size), 0,static_cast<float>((y/Grid_Size)*Grid_Size)); // make sure that this is on a 64 boundary
	
	int arrx(x/static_cast<int>(Grid_Size)), arry(y/static_cast<int>(Grid_Size));// this is the index for each dimension

	int bitindex(arrx/8);
	bitindex=arrx - (bitindex*8);
	int biter = (int)bitindex;	
	unsigned char bitstoshift = (1<<((unsigned char)bitindex));// shift a bit down to the correct index
	arrx/=8;
	const int jump = static_cast<int>(((World_Size/Grid_Size)/8.0f));
	if((Ocean_Grid_bits[arrx + arry* jump ] & bitstoshift) == 0){// the slot is empty.. go ahead with the insert
		Ocean_Grid_bits[arrx + arry* jump] |= bitstoshift;// set the bit
		tlpos = t;
		return true;
	} // else already inserted
	return false;
}