Mercurial > mm7
diff Chest.cpp @ 1477:7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Added support for most of mm6 resources, placeholders for mm8 resources.
Fixed few C4258
author | Nomad |
---|---|
date | Wed, 28 Aug 2013 18:43:07 +0200 |
parents | 934074e7fcc1 |
children | c4ab816fcc5e |
line wrap: on
line diff
--- a/Chest.cpp Wed Aug 28 14:39:01 2013 +0600 +++ b/Chest.cpp Wed Aug 28 18:43:07 2013 +0200 @@ -80,7 +80,7 @@ if ( !uActiveCharacter ) return false; flag_shout = false; - pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); + pMapID = pMapStats->GetMapInfo(pCurrentMapName); if ( chest->Trapped() && pMapID ) { if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[pMapID].LockX5 ) @@ -419,11 +419,11 @@ item_in_chest_count = CountChestItems(uChestID); if ( item_in_chest_count == -1 ) return 0; - for( int i = 0; i < v5; i++) + for( int _i = 0; _i < v5; _i++) { - if ( Chest::CanPlaceItemAt(i, v4->uItemID, pChestWindow->par1C) ) + if ( Chest::CanPlaceItemAt(_i, v4->uItemID, pChestWindow->par1C) ) { - v21 = i; + v21 = _i; } } if ( v22 == v5 ) @@ -625,11 +625,20 @@ //----- (00458B4F) -------------------------------------------------------- -void ChestList::FromFile(void *pSerialized) +void ChestList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) { - uNumChests = *(int *)pSerialized; - pChests = (ChestDesc *)pAllocator->AllocNamedChunk(pChests, 36 * uNumChests, "Chest Descrip"); - memcpy(pChests, (char *)pSerialized + 4, 36 * uNumChests); + uint num_mm6_chests = data_mm6 ? *(int *)data_mm6 : 0, + num_mm7_chests = data_mm7 ? *(int *)data_mm7 : 0, + num_mm8_chests = data_mm8 ? *(int *)data_mm8 : 0; + + uNumChests = num_mm6_chests + num_mm7_chests + num_mm8_chests; + assert(uNumChests); + assert(!num_mm8_chests); + + pChests = (ChestDesc *)pAllocator->AllocNamedChunk(pChests, uNumChests * sizeof(ChestDesc), "Chest Descrip"); + memcpy(pChests, (char *)data_mm7 + 4, num_mm7_chests * sizeof(ChestDesc)); + memcpy(pChests + num_mm7_chests, (char *)data_mm6 + 4, num_mm6_chests * sizeof(ChestDesc)); + memcpy(pChests + num_mm6_chests + num_mm7_chests, (char *)data_mm8 + 4, num_mm8_chests * sizeof(ChestDesc)); }