From 51d6670ad924db4750211e039428e937d68d442f Mon Sep 17 00:00:00 2001 From: GreYFoXGTi Date: Wed, 22 Sep 2010 14:32:19 +0300 Subject: [PATCH] general enhancements Signed-off-by: GreYFoXGTi --- src/game/collision.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/game/collision.cpp b/src/game/collision.cpp index f46d55859..21eb94629 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -100,6 +100,7 @@ void CCollision::Init(class CLayers *pLayers) int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos) { float d = distance(PrevPos, Pos); + int End(d+1); if(!d) { @@ -109,11 +110,11 @@ int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos) 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_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) || + 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_THROUGH && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) || + (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_TELEOUT)) || + (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)) { return ny*m_Width+nx; @@ -125,15 +126,15 @@ int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos) int nx = 0; int ny = 0; - for(float f = 0; f < d; f++) + for(int i = 0; i < End; i++) { - a = f/d; + 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_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) || + 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_THROUGH && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) || + (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))