mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Implemented Max Indices ( If needed in the future )
Removed Old Unused Functions Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
18700326ef
commit
65fa246352
|
@ -108,61 +108,6 @@ int CCollision::GetPureMapIndex(vec2 Pos)
|
||||||
return ny*m_Width+nx;
|
return ny*m_Width+nx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos)
|
|
||||||
{
|
|
||||||
float d = distance(PrevPos, Pos);
|
|
||||||
int End(d+1);
|
|
||||||
|
|
||||||
if(!d)
|
|
||||||
{
|
|
||||||
int nx = clamp((int)Pos.x/32, 0, m_Width-1);
|
|
||||||
int ny = clamp((int)Pos.y/32, 0, m_Height-1);
|
|
||||||
/*if (m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN)) dbg_msg("m_pTele && TELEIN","ny*m_Width+nx %d",ny*m_Width+nx);
|
|
||||||
else if (m_pTele && m_pTele[ny*m_Width+nx].m_Type==TILE_TELEOUT) dbg_msg("TELEOUT","ny*m_Width+nx %d",ny*m_Width+nx);
|
|
||||||
else dbg_msg("GetMapIndex(","ny*m_Width+nx %d",ny*m_Width+nx);//REMOVE */
|
|
||||||
|
|
||||||
if(
|
|
||||||
(m_pTiles[ny*m_Width+nx].m_Index >= TILE_FREEZE && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
|
||||||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
|
||||||
(m_pFront && (m_pFront[ny*m_Width+nx].m_Index >= TILE_FREEZE && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) ||
|
|
||||||
(m_pFront && ((m_pFront[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pFront[ny*m_Width+nx].m_Index <= TILE_NPH))) ||
|
|
||||||
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEINEVIL || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
|
||||||
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0) ||
|
|
||||||
(m_pDoor && m_pDoor[ny*m_Width+nx].m_Index)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ny*m_Width+nx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float a = 0.0f;
|
|
||||||
vec2 Tmp = vec2(0, 0);
|
|
||||||
int nx = 0;
|
|
||||||
int ny = 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < End; i++)
|
|
||||||
{
|
|
||||||
a = i/d;
|
|
||||||
Tmp = mix(PrevPos, Pos, a);
|
|
||||||
nx = clamp((int)Tmp.x/32, 0, m_Width-1);
|
|
||||||
ny = clamp((int)Tmp.y/32, 0, m_Height-1);
|
|
||||||
if(
|
|
||||||
(m_pTiles[ny*m_Width+nx].m_Index >= TILE_FREEZE && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
|
||||||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
|
||||||
(m_pFront && (m_pFront[ny*m_Width+nx].m_Index >= TILE_FREEZE && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) ||
|
|
||||||
(m_pFront && ((m_pFront[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pFront[ny*m_Width+nx].m_Index <= TILE_NPH))) ||
|
|
||||||
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEINEVIL || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
|
||||||
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0) ||
|
|
||||||
(m_pDoor && m_pDoor[ny*m_Width+nx].m_Index)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ny*m_Width+nx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<int> CCollision::GetMapIndices(vec2 PrevPos, vec2 Pos, int MaxIndices)
|
std::list<int> CCollision::GetMapIndices(vec2 PrevPos, vec2 Pos, int MaxIndices)
|
||||||
{
|
{
|
||||||
std::list< int > Indices;
|
std::list< int > Indices;
|
||||||
|
@ -213,6 +158,7 @@ std::list<int> CCollision::GetMapIndices(vec2 PrevPos, vec2 Pos, int MaxIndices)
|
||||||
(m_pDoor && m_pDoor[ny*m_Width+nx].m_Index)
|
(m_pDoor && m_pDoor[ny*m_Width+nx].m_Index)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if(MaxIndices && Indices.size() > MaxIndices) return Indices;
|
||||||
Indices.push_back(ny*m_Width+nx);
|
Indices.push_back(ny*m_Width+nx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,7 @@ public:
|
||||||
int Entity(int x, int y, bool Front);
|
int Entity(int x, int y, bool Front);
|
||||||
//DDRace
|
//DDRace
|
||||||
int GetPureMapIndex(vec2 Pos);
|
int GetPureMapIndex(vec2 Pos);
|
||||||
int GetMapIndex(vec2 PrevPos, vec2 Pos);
|
std::list<int> GetMapIndices(vec2 PrevPos, vec2 Pos, int MaxIndices = 0);
|
||||||
std::list<int> GetMapIndices(vec2 PrevPos, vec2 Pos, int MaxIndices);
|
|
||||||
vec2 GetPos(int Index);
|
vec2 GetPos(int Index);
|
||||||
int GetTileIndex(int Index);
|
int GetTileIndex(int Index);
|
||||||
int GetFTileIndex(int Index);
|
int GetFTileIndex(int Index);
|
||||||
|
|
|
@ -671,7 +671,7 @@ void CCharacter::HandleFly()
|
||||||
void CCharacter::Tick()
|
void CCharacter::Tick()
|
||||||
{
|
{
|
||||||
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
|
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
|
||||||
std::list < int > Indices = GameServer()->Collision()->GetMapIndices(m_PrevPos, m_Pos, 5);
|
std::list < int > Indices = GameServer()->Collision()->GetMapIndices(m_PrevPos, m_Pos);
|
||||||
if(m_pPlayer->m_ForceBalanced)
|
if(m_pPlayer->m_ForceBalanced)
|
||||||
{
|
{
|
||||||
char Buf[128];
|
char Buf[128];
|
||||||
|
|
Loading…
Reference in a new issue