| 48 | } |
| 49 | |
| 50 | void CCollision::Init(class CLayers *pLayers) |
| 51 | { |
| 52 | Unload(); |
| 53 | |
| 54 | m_pLayers = pLayers; |
| 55 | m_Width = m_pLayers->GameLayer()->m_Width; |
| 56 | m_Height = m_pLayers->GameLayer()->m_Height; |
| 57 | m_pTiles = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->GameLayer()->m_Data)); |
| 58 | |
| 59 | if(m_pLayers->TeleLayer()) |
| 60 | { |
| 61 | unsigned int Size = m_pLayers->Map()->GetDataSize(m_pLayers->TeleLayer()->m_Tele); |
| 62 | if(Size >= (size_t)m_Width * m_Height * sizeof(CTeleTile)) |
| 63 | m_pTele = static_cast<CTeleTile *>(m_pLayers->Map()->GetData(m_pLayers->TeleLayer()->m_Tele)); |
| 64 | } |
| 65 | |
| 66 | if(m_pLayers->SpeedupLayer()) |
| 67 | { |
| 68 | unsigned int Size = m_pLayers->Map()->GetDataSize(m_pLayers->SpeedupLayer()->m_Speedup); |
| 69 | if(Size >= (size_t)m_Width * m_Height * sizeof(CSpeedupTile)) |
| 70 | m_pSpeedup = static_cast<CSpeedupTile *>(m_pLayers->Map()->GetData(m_pLayers->SpeedupLayer()->m_Speedup)); |
| 71 | } |
| 72 | |
| 73 | if(m_pLayers->SwitchLayer()) |
| 74 | { |
| 75 | unsigned int Size = m_pLayers->Map()->GetDataSize(m_pLayers->SwitchLayer()->m_Switch); |
| 76 | if(Size >= (size_t)m_Width * m_Height * sizeof(CSwitchTile)) |
| 77 | m_pSwitch = static_cast<CSwitchTile *>(m_pLayers->Map()->GetData(m_pLayers->SwitchLayer()->m_Switch)); |
| 78 | |
| 79 | m_pDoor = new CDoorTile[m_Width * m_Height]; |
| 80 | mem_zero(m_pDoor, (size_t)m_Width * m_Height * sizeof(CDoorTile)); |
| 81 | } |
| 82 | |
| 83 | if(m_pLayers->TuneLayer()) |
| 84 | { |
| 85 | unsigned int Size = m_pLayers->Map()->GetDataSize(m_pLayers->TuneLayer()->m_Tune); |
| 86 | if(Size >= (size_t)m_Width * m_Height * sizeof(CTuneTile)) |
| 87 | m_pTune = static_cast<CTuneTile *>(m_pLayers->Map()->GetData(m_pLayers->TuneLayer()->m_Tune)); |
| 88 | } |
| 89 | |
| 90 | if(m_pLayers->FrontLayer()) |
| 91 | { |
| 92 | unsigned int Size = m_pLayers->Map()->GetDataSize(m_pLayers->FrontLayer()->m_Front); |
| 93 | if(Size >= (size_t)m_Width * m_Height * sizeof(CTile)) |
| 94 | m_pFront = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->FrontLayer()->m_Front)); |
| 95 | } |
| 96 | |
| 97 | for(int i = 0; i < m_Width * m_Height; i++) |
| 98 | { |
| 99 | int Index; |
| 100 | if(m_pSwitch) |
| 101 | { |
| 102 | if(m_pSwitch[i].m_Number > m_HighestSwitchNumber) |
| 103 | m_HighestSwitchNumber = m_pSwitch[i].m_Number; |
| 104 | |
| 105 | if(m_pSwitch[i].m_Number) |
| 106 | m_pDoor[i].m_Number = m_pSwitch[i].m_Number; |
| 107 | else |
nothing calls this directly
no test coverage detected