From ae12a2b04d86e5fb98f487e2ac31d765745af693 Mon Sep 17 00:00:00 2001 From: HMH Date: Wed, 12 Mar 2014 23:12:50 +0100 Subject: [PATCH] added Tunelayer function to return the tunetilenumber and merged Tunelayer into CCollision --- src/game/collision.cpp | 27 +++++++++++++++++++++++++++ src/game/collision.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 737203a96..0cba99e68 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -27,6 +27,7 @@ CCollision::CCollision() m_pSwitch = 0; m_pDoor = 0; m_pSwitchers = 0; + m_pTune = 0; } void CCollision::Init(class CLayers *pLayers) @@ -68,6 +69,13 @@ void CCollision::Init(class CLayers *pLayers) m_pSwitchers = 0; } + if(m_pLayers->TuneLayer()) + { + unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->TuneLayer()->m_Tune); + if (Size >= m_Width*m_Height*sizeof(CTuneTile)) + m_pTune = static_cast(m_pLayers->Map()->GetData(m_pLayers->TuneLayer()->m_Tune)); + } + if(m_pLayers->FrontLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->FrontLayer()->m_Front); @@ -455,6 +463,7 @@ void CCollision::Dest() m_pSpeedup = 0; m_pFront = 0; m_pSwitch = 0; + m_pTune = 0; m_pDoor = 0; m_pSwitchers = 0; } @@ -587,6 +596,17 @@ int CCollision::IsSpeedup(int Index) return 0; } +int CCollision::IsTune(int Index) +{ + if(Index < 0 || !m_pTune) + return -1; + + if(m_pTune[Index].m_Type) + return m_pTune[Index].m_Number; + + return -1; +} + void CCollision::GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed) { if(Index < 0 || !m_pSpeedup) @@ -705,6 +725,8 @@ bool CCollision::TileExists(int Index) return true; if(m_pSwitch && m_pSwitch[Index].m_Type) return true; + if(m_pTune && m_pTune[Index].m_Type) + return true; return TileExistsNext(Index); } @@ -953,6 +975,9 @@ int CCollision::Entity(int x, int y, int Layer) case LAYER_SPEEDUP: str_format(aBuf,sizeof(aBuf), "Speedup"); break; + case LAYER_TUNE: + str_format(aBuf,sizeof(aBuf), "Tune"); + break; default: str_format(aBuf,sizeof(aBuf), "Unknown"); } @@ -971,6 +996,8 @@ int CCollision::Entity(int x, int y, int Layer) return m_pTele[y*m_Width+x].m_Type - ENTITY_OFFSET; case LAYER_SPEEDUP: return m_pSpeedup[y*m_Width+x].m_Type - ENTITY_OFFSET; + case LAYER_TUNE: + return m_pTune[y*m_Width+x].m_Type - ENTITY_OFFSET; default: return 0; break; diff --git a/src/game/collision.h b/src/game/collision.h index 68b91b33f..af6e638b0 100644 --- a/src/game/collision.h +++ b/src/game/collision.h @@ -84,6 +84,7 @@ public: int IsTCheckpoint(int Index); //int IsCheckpoint(int Index); int IsSpeedup(int Index); + int IsTune(int Index); void GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed); int IsSwitch(int Index); int GetSwitchNumber(int Index); @@ -103,6 +104,7 @@ public: class CTeleTile *TeleLayer() { return m_pTele; } class CSwitchTile *SwitchLayer() { return m_pSwitch; } + class CTuneTile *TuneLayer() { return m_pTune; } class CLayers *Layers() { return m_pLayers; } int m_NumSwitchers; @@ -112,6 +114,7 @@ private: class CSpeedupTile *m_pSpeedup; class CTile *m_pFront; class CSwitchTile *m_pSwitch; + class CTuneTile *m_pTune; class CDoorTile *m_pDoor; struct SSwitchers {