Mercurial > mm7
comparison Indoor.cpp @ 1583:75fafd8ced59
Allocator (CMemory) bye-bye
author | Nomad |
---|---|
date | Tue, 10 Sep 2013 21:07:07 +0200 |
parents | c44db078127d |
children | ccde94f02b75 |
comparison
equal
deleted
inserted
replaced
1577:1b6217e07b26 | 1583:75fafd8ced59 |
---|---|
15 #include "Game.h" | 15 #include "Game.h" |
16 #include "Viewport.h" | 16 #include "Viewport.h" |
17 #include "Time.h" | 17 #include "Time.h" |
18 #include "Party.h" | 18 #include "Party.h" |
19 #include "Math.h" | 19 #include "Math.h" |
20 #include "Allocator.h" | |
21 #include "LOD.h" | 20 #include "LOD.h" |
22 #include "DecorationList.h" | 21 #include "DecorationList.h" |
23 #include "ObjectList.h" | 22 #include "ObjectList.h" |
24 #include "Actor.h" | 23 #include "Actor.h" |
25 #include "Chest.h" | 24 #include "Chest.h" |
1021 char *v2; // ebp@1 | 1020 char *v2; // ebp@1 |
1022 void *v3; // ST00_4@1 | 1021 void *v3; // ST00_4@1 |
1023 | 1022 |
1024 v1 = this; | 1023 v1 = this; |
1025 v2 = (char *)&this->ptr_0002B4_doors_ddata; | 1024 v2 = (char *)&this->ptr_0002B4_doors_ddata; |
1026 pAllocator->FreeChunk(this->ptr_0002B4_doors_ddata); | 1025 free(this->ptr_0002B4_doors_ddata); |
1027 *(int *)v2 = 0; | 1026 *(int *)v2 = 0; |
1028 pAllocator->FreeChunk(v1->ptr_0002B0_sector_rdata); | 1027 free(v1->ptr_0002B0_sector_rdata); |
1029 v1->ptr_0002B0_sector_rdata = 0; | 1028 v1->ptr_0002B0_sector_rdata = 0; |
1030 pAllocator->FreeChunk(v1->ptr_0002B8_sector_lrdata); | 1029 free(v1->ptr_0002B8_sector_lrdata); |
1031 v1->ptr_0002B8_sector_lrdata = 0; | 1030 v1->ptr_0002B8_sector_lrdata = 0; |
1032 pAllocator->FreeChunk(v1->pLFaces); | 1031 free(v1->pLFaces); |
1033 v1->pLFaces = 0; | 1032 v1->pLFaces = 0; |
1034 pAllocator->FreeChunk(v1->pSpawnPoints); | 1033 free(v1->pSpawnPoints); |
1035 v3 = v1->pVertices; | 1034 v3 = v1->pVertices; |
1036 v1->pSpawnPoints = 0; | 1035 v1->pSpawnPoints = 0; |
1037 v1->uNumSectors = 0; | 1036 v1->uNumSectors = 0; |
1038 v1->uNumFaces = 0; | 1037 v1->uNumFaces = 0; |
1039 v1->uNumVertices = 0; | 1038 v1->uNumVertices = 0; |
1040 v1->uNumNodes = 0; | 1039 v1->uNumNodes = 0; |
1041 v1->uNumDoors = 0; | 1040 v1->uNumDoors = 0; |
1042 v1->uNumLights = 0; | 1041 v1->uNumLights = 0; |
1043 pAllocator->FreeChunk(v3); | 1042 free(v3); |
1044 pAllocator->FreeChunk(v1->pFaces); | 1043 free(v1->pFaces); |
1045 pAllocator->FreeChunk(v1->pFaceExtras); | 1044 free(v1->pFaceExtras); |
1046 pAllocator->FreeChunk(v1->pSectors); | 1045 free(v1->pSectors); |
1047 pAllocator->FreeChunk(v1->pLights); | 1046 free(v1->pLights); |
1048 pAllocator->FreeChunk(v1->pDoors); | 1047 free(v1->pDoors); |
1049 pAllocator->FreeChunk(v1->pNodes); | 1048 free(v1->pNodes); |
1050 pAllocator->FreeChunk(v1->pMapOutlines); | 1049 free(v1->pMapOutlines); |
1051 v1->pVertices = 0; | 1050 v1->pVertices = 0; |
1052 v1->pFaces = 0; | 1051 v1->pFaces = 0; |
1053 v1->pFaceExtras = 0; | 1052 v1->pFaceExtras = 0; |
1054 v1->pSectors = 0; | 1053 v1->pSectors = 0; |
1055 v1->pLights = 0; | 1054 v1->pLights = 0; |
1060 } | 1059 } |
1061 | 1060 |
1062 //----- (00498C45) -------------------------------------------------------- | 1061 //----- (00498C45) -------------------------------------------------------- |
1063 bool IndoorLocation::Alloc() | 1062 bool IndoorLocation::Alloc() |
1064 { | 1063 { |
1065 pVertices = (Vec3_short_ *) pAllocator->AllocNamedChunk(pVertices, 15000*sizeof(Vec3_short_), "L.V");//0x15F90u | 1064 pVertices = (Vec3_short_ *) malloc(15000 * sizeof(Vec3_short_));//0x15F90u |
1066 pFaces = (BLVFace *) pAllocator->AllocNamedChunk(pFaces, 10000*sizeof(BLVFace), "L.F");//0xEA600u | 1065 pFaces = (BLVFace *) malloc(10000 * sizeof(BLVFace));//0xEA600u |
1067 pFaceExtras = (BLVFaceExtra *) pAllocator->AllocNamedChunk(pFaceExtras,5000*sizeof(BLVFaceExtra), "L.FX"); //0x2BF20u | 1066 pFaceExtras = (BLVFaceExtra *) malloc(5000 * sizeof(BLVFaceExtra)); //0x2BF20u |
1068 pSectors = (BLVSector *) pAllocator->AllocNamedChunk(pSectors, 512*sizeof(BLVSector), "L.R");//0xE800u | 1067 pSectors = (BLVSector *) malloc(512 * sizeof(BLVSector));//0xE800u |
1069 pLights = (BLVLightMM7 *) pAllocator->AllocNamedChunk(pLights, 400*sizeof(BLVLightMM7), "L.L");//0x1900u | 1068 pLights = (BLVLightMM7 *) malloc(400 * sizeof(BLVLightMM7));//0x1900u |
1070 pDoors = (BLVDoor *) pAllocator->AllocNamedChunk(pDoors, 200*sizeof(BLVDoor), "L.D");//0x3E80u | 1069 pDoors = (BLVDoor *) malloc(200 * sizeof(BLVDoor));//0x3E80u |
1071 pNodes = (BSPNode *) pAllocator->AllocNamedChunk(pNodes, 5000*sizeof(BSPNode), "L.BSP");//0x9C40u | 1070 pNodes = (BSPNode *) malloc(5000 * sizeof(BSPNode));//0x9C40u |
1072 pMapOutlines =(BLVMapOutlines *)pAllocator->AllocNamedChunk(pMapOutlines, sizeof(BLVMapOutlines), "L.Map");//0x14824u | 1071 pMapOutlines =(BLVMapOutlines *)malloc(sizeof(BLVMapOutlines));//0x14824u |
1073 if (pVertices && pFaces && pFaceExtras && pSectors && pLights && pDoors && pNodes && pMapOutlines ) | 1072 if (pVertices && pFaces && pFaceExtras && pSectors && pLights && pDoors && pNodes && pMapOutlines ) |
1074 { | 1073 { |
1075 memset(pVertices, 0, 15000*sizeof(Vec3_short_)); | 1074 memset(pVertices, 0, 15000*sizeof(Vec3_short_)); |
1076 memset(pFaces, 0, 10000*sizeof(BLVFace)); | 1075 memset(pFaces, 0, 10000*sizeof(BLVFace)); |
1077 memset(pFaceExtras,0, 5000*sizeof(BLVFaceExtra)); | 1076 memset(pFaceExtras,0, 5000*sizeof(BLVFaceExtra)); |
1343 fread(pVertices, 6u, uNumVertices, v7); | 1342 fread(pVertices, 6u, uNumVertices, v7); |
1344 fseek(v7, v209, 0); | 1343 fseek(v7, v209, 0); |
1345 fread(&uNumFaces, 4u, 1u, v7); | 1344 fread(&uNumFaces, 4u, 1u, v7); |
1346 fseek(v7, v210, 0); | 1345 fseek(v7, v210, 0); |
1347 fread(pFaces, 0x60u, uNumFaces, v7); | 1346 fread(pFaces, 0x60u, uNumFaces, v7); |
1348 v10 = pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); | 1347 v10 = malloc(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); |
1349 v202 = (int)v7; | 1348 v202 = (int)v7; |
1350 ptr_2AC = (unsigned __int16 *)v10; | 1349 ptr_2AC = (unsigned __int16 *)v10; |
1351 fread(v10, 1u, blv.uFaces_fdata_Size, (FILE *)v202); | 1350 fread(v10, 1u, blv.uFaces_fdata_Size, (FILE *)v202); |
1352 v11 = uNumFaces == 0; | 1351 v11 = uNumFaces == 0; |
1353 v12 = (uNumFaces & 0x80000000u) != 0; | 1352 v12 = (uNumFaces & 0x80000000u) != 0; |
1464 } | 1463 } |
1465 fseek(v7, v213, 0); | 1464 fseek(v7, v213, 0); |
1466 fread(&uNumSectors, 4u, 1u, v7); | 1465 fread(&uNumSectors, 4u, 1u, v7); |
1467 fseek(v7, v214, 0); | 1466 fseek(v7, v214, 0); |
1468 fread(pSectors, 0x74u, uNumSectors, v7); | 1467 fread(pSectors, 0x74u, uNumSectors, v7); |
1469 v32 = pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); | 1468 v32 = malloc(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); |
1470 v202 = (int)v7; | 1469 v202 = (int)v7; |
1471 ptr_0002B0_sector_rdata = (unsigned __int16 *)v32; | 1470 ptr_0002B0_sector_rdata = (unsigned __int16 *)v32; |
1472 fread(v32, 1u, blv.uSector_rdata_Size, (FILE *)v202); | 1471 fread(v32, 1u, blv.uSector_rdata_Size, (FILE *)v202); |
1473 v11 = uNumSectors == 0; | 1472 v11 = uNumSectors == 0; |
1474 v12 = uNumSectors < 0; | 1473 v12 = uNumSectors < 0; |
1521 *(int *)(v45 + 80) = (int)(char *)v46 + (int)pDest; | 1520 *(int *)(v45 + 80) = (int)(char *)v46 + (int)pDest; |
1522 pDest += 2 * *((short *)&pSectors[v33] - 20); | 1521 pDest += 2 * *((short *)&pSectors[v33] - 20); |
1523 } | 1522 } |
1524 while ( Argse < uNumSectors ); | 1523 while ( Argse < uNumSectors ); |
1525 } | 1524 } |
1526 v47 = pAllocator->AllocNamedChunk( | 1525 v47 = malloc( |
1527 ptr_0002B8_sector_lrdata, | 1526 ptr_0002B8_sector_lrdata, |
1528 blv.uSector_lrdata_Size, | 1527 blv.uSector_lrdata_Size, |
1529 "L.RLData"); | 1528 "L.RLData"); |
1530 v202 = (int)v7; | 1529 v202 = (int)v7; |
1531 ptr_0002B8_sector_lrdata = (unsigned __int16 *)v47; | 1530 ptr_0002B8_sector_lrdata = (unsigned __int16 *)v47; |
1552 } | 1551 } |
1553 fseek(v7, v215, 0); | 1552 fseek(v7, v215, 0); |
1554 fread(&uNumDoors, 4u, 1u, v7); | 1553 fread(&uNumDoors, 4u, 1u, v7); |
1555 fseek(v7, v216, 0); | 1554 fseek(v7, v216, 0); |
1556 fread(pDoors, 0x50u, 0xC8u, v7); | 1555 fread(pDoors, 0x50u, 0xC8u, v7); |
1557 v51 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | 1556 v51 = malloc(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); |
1558 v202 = (int)v7; | 1557 v202 = (int)v7; |
1559 ptr_0002B4_doors_ddata = (unsigned __int16 *)v51; | 1558 ptr_0002B4_doors_ddata = (unsigned __int16 *)v51; |
1560 fread(v51, 1u, blv.uDoors_ddata_Size, (FILE *)v202); | 1559 fread(v51, 1u, blv.uDoors_ddata_Size, (FILE *)v202); |
1561 v11 = uNumDoors == 0; | 1560 v11 = uNumDoors == 0; |
1562 v12 = uNumDoors < 0; | 1561 v12 = uNumDoors < 0; |
1716 fread(&uNumNodes, 4u, 1u, v7); | 1715 fread(&uNumNodes, 4u, 1u, v7); |
1717 fseek(v7, v227, 0); | 1716 fseek(v7, v227, 0); |
1718 fread(pNodes, 8u, uNumNodes, v7); | 1717 fread(pNodes, 8u, uNumNodes, v7); |
1719 fseek(v7, v230, 0); | 1718 fseek(v7, v230, 0); |
1720 fread(&uNumSpawnPoints, 4u, 1u, v7); | 1719 fread(&uNumSpawnPoints, 4u, 1u, v7); |
1721 v79 = pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); | 1720 v79 = malloc(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); |
1722 v202 = 0; | 1721 v202 = 0; |
1723 pSpawnPoints = (SpawnPointMM7 *)v79; | 1722 pSpawnPoints = (SpawnPointMM7 *)v79; |
1724 fseek(v7, v231, v202); | 1723 fseek(v7, v231, v202); |
1725 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, v7); | 1724 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, v7); |
1726 fseek(v7, v232, 0); | 1725 fseek(v7, v232, 0); |
1821 memcpy(&uNumFaces, pData += uNumVertices * sizeof(Vec3_short_), 4); | 1820 memcpy(&uNumFaces, pData += uNumVertices * sizeof(Vec3_short_), 4); |
1822 | 1821 |
1823 pGameLoadingUI_ProgressBar->Progress(); | 1822 pGameLoadingUI_ProgressBar->Progress(); |
1824 | 1823 |
1825 memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace)); | 1824 memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace)); |
1826 pLFaces = (unsigned __int16 *)pAllocator->AllocNamedChunk(pLFaces, blv.uFaces_fdata_Size, "L.FData"); | 1825 pLFaces = (unsigned __int16 *)malloc(blv.uFaces_fdata_Size); |
1827 | 1826 |
1828 memcpy(pLFaces, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size); | 1827 memcpy(pLFaces, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size); |
1829 | 1828 |
1830 for (uint i = 0, j = 0; i < uNumFaces; ++i) | 1829 for (uint i = 0, j = 0; i < uNumFaces; ++i) |
1831 { | 1830 { |
1949 memcpy(pSectors, pData + 4, uNumSectors * sizeof(BLVSector)); | 1948 memcpy(pSectors, pData + 4, uNumSectors * sizeof(BLVSector)); |
1950 pData += 4 + uNumSectors * sizeof(BLVSector); | 1949 pData += 4 + uNumSectors * sizeof(BLVSector); |
1951 | 1950 |
1952 pGameLoadingUI_ProgressBar->Progress(); | 1951 pGameLoadingUI_ProgressBar->Progress(); |
1953 | 1952 |
1954 ptr_0002B0_sector_rdata = (unsigned short *)pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); | 1953 ptr_0002B0_sector_rdata = (unsigned short *)malloc(blv.uSector_rdata_Size);//, "L.RData"); |
1955 memcpy(ptr_0002B0_sector_rdata, pData, blv.uSector_rdata_Size); | 1954 memcpy(ptr_0002B0_sector_rdata, pData, blv.uSector_rdata_Size); |
1956 pData += blv.uSector_rdata_Size; | 1955 pData += blv.uSector_rdata_Size; |
1957 | 1956 |
1958 for (uint i = 0, j = 0; i < uNumSectors; ++i) | 1957 for (uint i = 0, j = 0; i < uNumSectors; ++i) |
1959 { | 1958 { |
2032 Src = (BLVFace *)((char *)Src + 2 * *((short *)&pSectors[v118] - 20));*/ | 2031 Src = (BLVFace *)((char *)Src + 2 * *((short *)&pSectors[v118] - 20));*/ |
2033 //} | 2032 //} |
2034 //while ( v245 < uNumSectors ); | 2033 //while ( v245 < uNumSectors ); |
2035 } | 2034 } |
2036 | 2035 |
2037 ptr_0002B8_sector_lrdata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B8_sector_lrdata, blv.uSector_lrdata_Size, "L.RLData"); | 2036 ptr_0002B8_sector_lrdata = (unsigned __int16 *)malloc(blv.uSector_lrdata_Size);//, "L.RLData"); |
2038 memcpy(ptr_0002B8_sector_lrdata, pData, blv.uSector_lrdata_Size); | 2037 memcpy(ptr_0002B8_sector_lrdata, pData, blv.uSector_lrdata_Size); |
2039 pData += blv.uSector_lrdata_Size; | 2038 pData += blv.uSector_lrdata_Size; |
2040 | 2039 |
2041 pGameLoadingUI_ProgressBar->Progress(); | 2040 pGameLoadingUI_ProgressBar->Progress(); |
2042 | 2041 |
2080 | 2079 |
2081 pGameLoadingUI_ProgressBar->Progress(); | 2080 pGameLoadingUI_ProgressBar->Progress(); |
2082 pGameLoadingUI_ProgressBar->Progress(); | 2081 pGameLoadingUI_ProgressBar->Progress(); |
2083 | 2082 |
2084 memcpy(&uNumSpawnPoints, pData, 4); | 2083 memcpy(&uNumSpawnPoints, pData, 4); |
2085 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, uNumSpawnPoints * sizeof(SpawnPointMM7), "Spawn"); | 2084 pSpawnPoints = (SpawnPointMM7 *)malloc(uNumSpawnPoints * sizeof(SpawnPointMM7)); |
2086 memcpy(pSpawnPoints, pData + 4, uNumSpawnPoints * sizeof(SpawnPointMM7)); | 2085 memcpy(pSpawnPoints, pData + 4, uNumSpawnPoints * sizeof(SpawnPointMM7)); |
2087 pData += 4 + uNumSpawnPoints * sizeof(SpawnPointMM7); | 2086 pData += 4 + uNumSpawnPoints * sizeof(SpawnPointMM7); |
2088 | 2087 |
2089 pGameLoadingUI_ProgressBar->Progress(); | 2088 pGameLoadingUI_ProgressBar->Progress(); |
2090 pGameLoadingUI_ProgressBar->Progress(); | 2089 pGameLoadingUI_ProgressBar->Progress(); |
2292 memcpy(pDoors, pData, 0x3E80); | 2291 memcpy(pDoors, pData, 0x3E80); |
2293 pData += 0x3E80; | 2292 pData += 0x3E80; |
2294 | 2293 |
2295 //v201 = (const char *)blv.uDoors_ddata_Size; | 2294 //v201 = (const char *)blv.uDoors_ddata_Size; |
2296 //v200 = (size_t)ptr_0002B4_doors_ddata; | 2295 //v200 = (size_t)ptr_0002B4_doors_ddata; |
2297 //v170 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | 2296 //v170 = malloc(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); |
2298 //v171 = blv.uDoors_ddata_Size; | 2297 //v171 = blv.uDoors_ddata_Size; |
2299 ptr_0002B4_doors_ddata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | 2298 ptr_0002B4_doors_ddata = (unsigned __int16 *)malloc(blv.uDoors_ddata_Size);//, "L.DData"); |
2300 memcpy(ptr_0002B4_doors_ddata, pData, blv.uDoors_ddata_Size); | 2299 memcpy(ptr_0002B4_doors_ddata, pData, blv.uDoors_ddata_Size); |
2301 pData += blv.uDoors_ddata_Size; | 2300 pData += blv.uDoors_ddata_Size; |
2302 | 2301 |
2303 //Src = (BLVFace *)((char *)Src + v171); | 2302 //Src = (BLVFace *)((char *)Src + v171); |
2304 //v172 = 0; | 2303 //v172 = 0; |
3688 else | 3687 else |
3689 { | 3688 { |
3690 v3 = v37; | 3689 v3 = v37; |
3691 } | 3690 } |
3692 dword_6BE13C_uCurrentlyLoadedLocationID = v39; | 3691 dword_6BE13C_uCurrentlyLoadedLocationID = v39; |
3693 pAllocator->FreeChunk(ptr_6A0D08); | 3692 free(ptr_6A0D08); |
3694 ptr_6A0D08 = 0; | 3693 ptr_6A0D08 = 0; |
3695 _6A0D0C_txt_lod_loading = 0; | 3694 _6A0D0C_txt_lod_loading = 0; |
3696 TryLoadLevelFromLOD(); | 3695 TryLoadLevelFromLOD(); |
3697 pStationaryLightsStack->uNumLightsActive = 0; | 3696 pStationaryLightsStack->uNumLightsActive = 0; |
3698 v4 = pIndoor->Load(pCurrentMapName, | 3697 v4 = pIndoor->Load(pCurrentMapName, |