Fix loading of old maps

This commit is contained in:
Ravomavain 2011-08-26 13:46:22 +02:00 committed by GreYFoX
parent 15d0a40825
commit e8229f537f
2 changed files with 11 additions and 18 deletions

View file

@ -39,6 +39,15 @@ void CLayers::Init(class IKernel *pKernel)
if(pLayer->m_Type == LAYERTYPE_TILES)
{
CMapItemLayerTilemap *pTilemap = reinterpret_cast<CMapItemLayerTilemap *>(pLayer);
if(pTilemap->m_Version <= 2)
{
pTilemap->m_Switch = *((int*)(pTilemap) + 18);
pTilemap->m_Front = *((int*)(pTilemap) + 17);
pTilemap->m_Speedup = *((int*)(pTilemap) + 16);
pTilemap->m_Tele = *((int*)(pTilemap) + 15);
}
if(pTilemap->m_Flags&TILESLAYERFLAG_GAME)
{
m_pGameLayer = pTilemap;
@ -62,29 +71,13 @@ void CLayers::Init(class IKernel *pKernel)
//break;
}
if(pTilemap->m_Flags&TILESLAYERFLAG_TELE)
{
if(pTilemap->m_Version <= 2)
pTilemap->m_Tele = *((int*)(pTilemap) + 15);
m_pTeleLayer = pTilemap;
}
if(pTilemap->m_Flags&TILESLAYERFLAG_SPEEDUP)
{
if(pTilemap->m_Version <= 2)
pTilemap->m_Speedup = *((int*)(pTilemap) + 16);
m_pSpeedupLayer = pTilemap;
}
if(pTilemap->m_Flags&TILESLAYERFLAG_FRONT)
{
if(pTilemap->m_Version <= 2)
pTilemap->m_Front = *((int*)(pTilemap) + 17);
m_pFrontLayer = pTilemap;
}
if(pTilemap->m_Flags&TILESLAYERFLAG_SWITCH)
{
if(pTilemap->m_Version <= 2)
pTilemap->m_Switch = *((int*)(pTilemap) + 18);
m_pSwitchLayer = pTilemap;
}
}
}
}

View file

@ -1728,9 +1728,9 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
CTile *pFront = 0;
CSwitchTile *pSwitch = 0;
if(m_Layers.FrontLayer())
pFront = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Front);
pFront = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(m_Layers.FrontLayer()->m_Front);
if(m_Layers.SwitchLayer())
pSwitch = (CSwitchTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Switch);
pSwitch = (CSwitchTile *)Kernel()->RequestInterface<IMap>()->GetData(m_Layers.SwitchLayer()->m_Switch);
for(int y = 0; y < pTileMap->m_Height; y++)
{