comparison Indoor.cpp @ 28:18f7a1b94448

Indoor::Load
author Nomad
date Tue, 16 Oct 2012 19:31:34 +0200
parents 540178ef9b18
children e62134245ab0
comparison
equal deleted inserted replaced
27:be2066176d89 28:18f7a1b94448
1 #include <assert.h>
2
1 #include "Outdoor.h" 3 #include "Outdoor.h"
2 #include "Render.h" 4 #include "Render.h"
3 #include "LayingItem.h" 5 #include "LayingItem.h"
4 #include "Events.h" 6 #include "Events.h"
5 #include "Game.h" 7 #include "Game.h"
14 #include "Actor.h" 16 #include "Actor.h"
15 #include "Chest.h" 17 #include "Chest.h"
16 #include "GUIProgressBar.h" 18 #include "GUIProgressBar.h"
17 #include "stru123.h" 19 #include "stru123.h"
18 #include "AudioPlayer.h" 20 #include "AudioPlayer.h"
21 #include "Log.h"
19 22
20 #include "mm7_data.h" 23 #include "mm7_data.h"
21 24
22 25
23 26
25 28
26 29
27 30
28 31
29 32
30 IndoorLocation *pIndoor; 33 IndoorLocation *pIndoor = new IndoorLocation;
31 BLVRenderParams *pBLVRenderParams; 34 BLVRenderParams *pBLVRenderParams = new BLVRenderParams;
32 35
33 struct DecorationList *pDecorationList; 36 struct DecorationList *pDecorationList;
34 37
35 LevelDecoration pLevelDecorations[3000]; 38 LevelDecoration pLevelDecorations[3000];
36 size_t uNumLevelDecorations; 39 size_t uNumLevelDecorations;
1814 v14 = pAllocator->AllocNamedChunk(v13, 0x9C40u, "L.BSP"); 1817 v14 = pAllocator->AllocNamedChunk(v13, 0x9C40u, "L.BSP");
1815 v15 = v1->pMapVertices; 1818 v15 = v1->pMapVertices;
1816 v1->pNodes = (BSPNode *)v14; 1819 v1->pNodes = (BSPNode *)v14;
1817 v16 = pAllocator->AllocNamedChunk(v15, 0x14824u, "L.Map"); 1820 v16 = pAllocator->AllocNamedChunk(v15, 0x14824u, "L.Map");
1818 v17 = v1->pVertices; 1821 v17 = v1->pVertices;
1819 v1->pMapVertices = (unsigned int *)v16; 1822 v1->pMapVertices = (BLVMapVertices *)v16;
1820 if ( v17 && v1->pFaces && v1->pFaceExtras && v1->pSectors && v1->pLights && v1->pDoors && v1->pNodes && v16 ) 1823 if ( v17 && v1->pFaces && v1->pFaceExtras && v1->pSectors && v1->pLights && v1->pDoors && v1->pNodes && v16 )
1821 { 1824 {
1822 memset(v17, 90000, 0); 1825 memset(v17, 90000, 0);
1823 memset(v1->pFaces, 960000, 0); 1826 memset(v1->pFaces, 960000, 0);
1824 memset(v1->pFaceExtras, 180000, 0); 1827 memset(v1->pFaceExtras, 180000, 0);
1873 } 1876 }
1874 } 1877 }
1875 1878
1876 1879
1877 //----- (00498E0A) -------------------------------------------------------- 1880 //----- (00498E0A) --------------------------------------------------------
1878 bool IndoorLocation::Load(char *pFilename, int a3, size_t i, char *pDest) 1881 bool IndoorLocation::Load(char *pFilename, int a3, size_t _i, char *pDest)
1879 { 1882 {
1880 unsigned int v5; // ebx@1 1883 /*unsigned int v5; // ebx@1
1881 IndoorLocation *v6; // esi@1 1884 //IndoorLocation *v6; // esi@1
1882 FILE *v7; // edi@3 1885 FILE *v7; // edi@3
1883 bool result; // eax@3 1886 bool result; // eax@3
1884 char *v9; // ecx@4 1887 char *v9; // ecx@4
1885 void *v10; // eax@4 1888 void *v10; // eax@4
1886 unsigned __int8 v11; // zf@4 1889 //unsigned __int8 v11; // zf@4
1887 unsigned __int8 v12; // sf@4 1890 //unsigned __int8 v12; // sf@4
1888 int v13; // eax@5 1891 int v13; // eax@5
1889 size_t v14; // ecx@6 1892 size_t v14; // ecx@6
1890 char *v15; // ecx@6 1893 char *v15; // ecx@6
1891 int v16; // edx@6 1894 int v16; // edx@6
1892 size_t v17; // ecx@6 1895 size_t v17; // ecx@6
1951 size_t v76; // eax@45 1954 size_t v76; // eax@45
1952 int j; // edx@46 1955 int j; // edx@46
1953 unsigned __int16 v78; // ax@50 1956 unsigned __int16 v78; // ax@50
1954 void *v79; // eax@52 1957 void *v79; // eax@52
1955 void **v80; // esi@52 1958 void **v80; // esi@52
1956 size_t v81; // eax@56
1957 FILE *v82; // eax@56
1958 unsigned int v83; // edi@67
1959 void *v84; // eax@67
1960 void *v85; // ebx@67
1961 const void *v86; // ebx@72
1962 const void *v87; // ebx@72
1963 const void *v88; // ebx@72
1964 void *v89; // eax@72
1965 size_t v90; // ecx@72
1966 const void *v91; // ebx@72
1967 int v92; // eax@72
1968 BLVFace *v93; // ecx@73
1969 BLVSector *v94; // ecx@73
1970 unsigned __int16 *v95; // edx@73
1971 int v96; // ecx@73
1972 BLVSector *v97; // ecx@73
1973 unsigned __int16 *v98; // edx@73
1974 unsigned __int16 *v99; // edx@73
1975 unsigned __int16 *v100; // edx@73
1976 unsigned __int16 *v101; // edx@73
1977 __int16 v102; // ax@77
1978 BLVSector *v103; // ecx@77
1979 __int16 v104; // ax@77
1980 __int16 v105; // ax@78
1981 BLVSector *v106; // ecx@78
1982 const void *v107; // ebx@82
1983 const void *v108; // ebx@82
1984 unsigned __int16 v109; // ax@86
1985 BLVFaceExtra *v110; // ecx@86
1986 int v111; // edx@86
1987 BLVFaceExtra *v112; // ecx@89
1988 const void *v113; // ebx@94
1989 const void *v114; // ebx@94
1990 void *v115; // eax@94
1991 size_t v116; // ecx@94
1992 const void *v117; // ebx@94
1993 int v118; // eax@94
1994 unsigned __int16 *v119; // edx@95
1995 int v120; // ecx@95
1996 BLVFace *v121; // ecx@95
1997 unsigned __int16 *v122; // edx@95
1998 int v123; // ecx@95
1999 BLVFace *v124; // ecx@95
2000 unsigned __int16 *v125; // edx@95
2001 unsigned __int16 *v126; // edx@95
2002 unsigned __int16 *v127; // edx@95
2003 unsigned __int16 *v128; // edx@95
2004 unsigned __int16 *v129; // edx@95
2005 int v130; // ecx@95
2006 unsigned __int16 *v131; // edx@95
2007 void *v132; // eax@96
2008 size_t v133; // ecx@96
2009 const void *v134; // ebx@96
2010 BLVSector *v135; // eax@97
2011 FILE *v136; // ecx@97
2012 unsigned __int16 *v137; // edx@99
2013 const void *v138; // ebx@100
2014 const void *v139; // ebx@100
2015 unsigned __int16 v140; // ax@102
2016 FILE *v141; // ecx@102
2017 const void *v142; // ebx@103
2018 const void *v143; // ebx@103
2019 const void *v144; // ebx@103
2020 unsigned int v145; // eax@103 1959 unsigned int v145; // eax@103
2021 void *v146; // eax@103 1960 void *v146; // eax@103
2022 unsigned int v147; // ecx@103 1961 unsigned int v147; // ecx@103
2023 int v148; // ebx@103 1962 int v148; // ebx@103
2024 unsigned int *v149; // ecx@103 1963 unsigned int *v149; // ecx@103*/
2025 size_t v150; // eax@103 1964 //size_t v150; // eax@103
2026 unsigned int v151; // ebx@109 1965 //unsigned int v151; // ebx@109
2027 unsigned int v152; // ecx@116 1966 //unsigned int v152; // ecx@116
2028 unsigned int v153; // eax@117 1967 //unsigned int v153; // eax@117
2029 size_t v154; // ebx@126 1968 //size_t v154; // ebx@126
2030 unsigned int v155; // ebx@134 1969 //unsigned int v155; // ebx@134
2031 size_t v156; // eax@140 1970 //size_t v156; // eax@140
2032 signed int v157; // ebx@142 1971 //signed int v157; // ebx@142
2033 int v158; // ebx@148 1972 //int v158; // ebx@148
2034 BLVFace *v159; // eax@149 1973 //BLVFace *v159; // eax@149
2035 BLVFaceExtra *v160; // ecx@149 1974 // BLVFaceExtra *v160; // ecx@149
2036 BLVFaceExtra *v161; // ecx@149 1975 //BLVFaceExtra *v161; // ecx@149
2037 signed int v162; // ebx@154 1976 //signed int v162; // ebx@154
2038 unsigned int v163; // ebx@157 1977 //unsigned int v163; // ebx@157
2039 unsigned int v164; // ebx@157 1978 //unsigned int v164; // ebx@157
2040 unsigned int v165; // edx@158 1979 //unsigned int v165; // edx@158
2041 char *v166; // ecx@158 1980 //char *v166; // ecx@158
2042 unsigned __int16 v167; // ax@161 1981 //unsigned __int16 v167; // ax@161
2043 __int16 v168; // ax@165 1982 //__int16 v168; // ax@165
2044 unsigned int v169; // ebx@168 1983 //unsigned int v169; // ebx@168
2045 void *v170; // eax@168 1984 //void *v170; // eax@168
2046 size_t v171; // ebx@168 1985 //size_t v171; // ebx@168
2047 int v172; // edx@168 1986 //int v172; // edx@168
2048 BLVDoor *v173; // ecx@169 1987 //BLVDoor *v173; // ecx@169
2049 int k; // eax@169 1988 //int k; // eax@169
2050 BLVDoor *v175; // ecx@172 1989 //BLVDoor *v175; // ecx@172
2051 int v176; // edx@172 1990 //int v176; // edx@172
2052 BLVDoor *v177; // ecx@172 1991 //BLVDoor *v177; // ecx@172
2053 int v178; // edx@172 1992 //int v178; // edx@172
2054 BLVDoor *v179; // ecx@172 1993 //BLVDoor *v179; // ecx@172
2055 int v180; // edx@172 1994 //int v180; // edx@172
2056 BLVDoor *v181; // ecx@172 1995 //BLVDoor *v181; // ecx@172
2057 int v182; // edx@172 1996 //int v182; // edx@172
2058 BLVDoor *v183; // ecx@172 1997 //BLVDoor *v183; // ecx@172
2059 int v184; // edx@172 1998 //int v184; // edx@172
2060 BLVDoor *v185; // ecx@172 1999 //BLVDoor *v185; // ecx@172
2061 int v186; // edx@172 2000 //int v186; // edx@172
2062 BLVDoor *v187; // ecx@172 2001 //BLVDoor *v187; // ecx@172
2063 int v188; // edx@172 2002 //int v188; // edx@172
2064 unsigned __int16 *v189; // ebx@172 2003 //unsigned __int16 *v189; // ebx@172
2065 char *v190; // edx@173 2004 //char *v190; // edx@173
2066 BLVDoor *v191; // ecx@174 2005 //BLVDoor *v191; // ecx@174
2067 BLVDoor *l; // eax@175 2006 //BLVDoor *l; // eax@175
2068 signed int v193; // ebx@176 2007 //signed int v193; // ebx@176
2069 int v194; // ecx@176 2008 //int v194; // ecx@176
2070 BLVFaceExtra *v195; // ecx@176 2009 //BLVFaceExtra *v195; // ecx@176
2071 BLVFace *v196; // ebx@178 2010 //BLVFace *v196; // ebx@178
2072 std::string v197; // [sp-18h] [bp-680h]@66 2011 //std::string v197; // [sp-18h] [bp-680h]@66
2073 void *v198; // [sp-14h] [bp-67Ch]@72 2012 //void *v198; // [sp-14h] [bp-67Ch]@72
2074 size_t v199; // [sp-10h] [bp-678h]@72 2013 //size_t v199; // [sp-10h] [bp-678h]@72
2075 size_t v200; // [sp-Ch] [bp-674h]@72 2014 //size_t v200; // [sp-Ch] [bp-674h]@72
2076 const char *v201; // [sp-8h] [bp-670h]@4 2015 //const char *v201; // [sp-8h] [bp-670h]@4
2077 int v202; // [sp-4h] [bp-66Ch]@4 2016 //int v202; // [sp-4h] [bp-66Ch]@4
2078 char v203[875]; // [sp+Ch] [bp-65Ch]@130 2017 char v203[875]; // [sp+Ch] [bp-65Ch]@130
2079 char FileName[260]; // [sp+378h] [bp-2F0h]@1 2018 char FileName[260]; // [sp+378h] [bp-2F0h]@1
2080 char DstBuf; // [sp+47Ch] [bp-1ECh]@4 2019 //char DstBuf; // [sp+47Ch] [bp-1ECh]@4
2081 __int32 Offset; // [sp+480h] [bp-1E8h]@4 2020 __int32 Offset; // [sp+480h] [bp-1E8h]@4
2082 __int32 v207; // [sp+48Ch] [bp-1DCh]@4 2021 __int32 v207; // [sp+48Ch] [bp-1DCh]@4
2083 __int32 v208; // [sp+498h] [bp-1D0h]@4 2022 __int32 v208; // [sp+498h] [bp-1D0h]@4
2084 __int32 v209; // [sp+4A4h] [bp-1C4h]@4 2023 __int32 v209; // [sp+4A4h] [bp-1C4h]@4
2085 __int32 v210; // [sp+4B0h] [bp-1B8h]@4 2024 __int32 v210; // [sp+4B0h] [bp-1B8h]@4
2105 __int32 v230; // [sp+5A0h] [bp-C8h]@52 2044 __int32 v230; // [sp+5A0h] [bp-C8h]@52
2106 __int32 v231; // [sp+5ACh] [bp-BCh]@52 2045 __int32 v231; // [sp+5ACh] [bp-BCh]@52
2107 __int32 v232; // [sp+5B8h] [bp-B0h]@52 2046 __int32 v232; // [sp+5B8h] [bp-B0h]@52
2108 __int32 v233; // [sp+5C4h] [bp-A4h]@52 2047 __int32 v233; // [sp+5C4h] [bp-A4h]@52
2109 __int32 v234; // [sp+5D0h] [bp-98h]@52 2048 __int32 v234; // [sp+5D0h] [bp-98h]@52
2110 char pName[40]; // [sp+5FCh] [bp-6Ch]@42 2049 //char pName[40]; // [sp+5FCh] [bp-6Ch]@42
2111 size_t pSource; // [sp+624h] [bp-44h]@67 2050 //size_t pSource; // [sp+624h] [bp-44h]@67
2112 char Dst[12]; // [sp+628h] [bp-40h]@9 2051 //char Dst[12]; // [sp+628h] [bp-40h]@9
2113 char *v238; // [sp+634h] [bp-34h]@38 2052 //char *v238; // [sp+634h] [bp-34h]@38
2114 ODMHeader header; // [sp+638h] [bp-30h]@61 2053 ODMHeader header; // [sp+638h] [bp-30h]@61
2115 void *ptr; // [sp+648h] [bp-20h]@66 2054 //void *ptr; // [sp+648h] [bp-20h]@66
2116 size_t Count; // [sp+64Ch] [bp-1Ch]@109 2055 //size_t Count; // [sp+64Ch] [bp-1Ch]@109
2117 int uSourceLen; // [sp+653h] [bp-15h]@66 2056 //int uSourceLen; // [sp+653h] [bp-15h]@66
2118 FILE *File; // [sp+658h] [bp-10h]@56 2057 FILE *File; // [sp+658h] [bp-10h]@56
2119 BLVSector *v244; // [sp+65Ch] [bp-Ch]@72 2058 //BLVSector *v244; // [sp+65Ch] [bp-Ch]@72
2120 int v245; // [sp+660h] [bp-8h]@72 2059 //int v245; // [sp+660h] [bp-8h]@72
2121 BLVFace *Src; // [sp+664h] [bp-4h]@73 2060 //BLVFace *Src; // [sp+664h] [bp-4h]@73
2122 signed int Argsa; // [sp+670h] [bp+8h]@4 2061 signed int Argsa; // [sp+670h] [bp+8h]@4
2123 signed int Argsb; // [sp+670h] [bp+8h]@7 2062 signed int Argsb; // [sp+670h] [bp+8h]@7
2124 signed int Argsc; // [sp+670h] [bp+8h]@15 2063 signed int Argsc; // [sp+670h] [bp+8h]@15
2125 signed int Argsd; // [sp+670h] [bp+8h]@18 2064 signed int Argsd; // [sp+670h] [bp+8h]@18
2126 int Argse; // [sp+670h] [bp+8h]@25 2065 int Argse; // [sp+670h] [bp+8h]@25
2127 int Argsf; // [sp+670h] [bp+8h]@28 2066 int Argsf; // [sp+670h] [bp+8h]@28
2128 int Argsg; // [sp+670h] [bp+8h]@32 2067 int Argsg; // [sp+670h] [bp+8h]@32
2129 int Argsh; // [sp+670h] [bp+8h]@35 2068 int Argsh; // [sp+670h] [bp+8h]@35
2130 signed int Argsi; // [sp+670h] [bp+8h]@40 2069 signed int Argsi; // [sp+670h] [bp+8h]@40
2131 signed int Argsj; // [sp+670h] [bp+8h]@45 2070 signed int Argsj; // [sp+670h] [bp+8h]@45
2132 int Argsk; // [sp+670h] [bp+8h]@143 2071 //int Argsk; // [sp+670h] [bp+8h]@143
2133 void *Argsl; // [sp+670h] [bp+8h]@155 2072 //void *Argsl; // [sp+670h] [bp+8h]@155
2134 signed int Argsm; // [sp+670h] [bp+8h]@161 2073 //signed int Argsm; // [sp+670h] [bp+8h]@161
2135 signed int Argsn; // [sp+670h] [bp+8h]@175 2074 //signed int Argsn; // [sp+670h] [bp+8h]@175
2136 2075
2137 v5 = 0; 2076 //v5 = 0;
2138 v6 = this; 2077 //v6 = this;
2139 _6807E0_num_decorations_6807B8 = 0; 2078 _6807E0_num_decorations_6807B8 = 0;
2140 sprintfex(FileName, "levels\\%s", pFilename); 2079
2080 #pragma region "loading from txt"
2081 /*sprintf(FileName, "levels\\%s", pFilename);
2141 if ( GetFileAttributesA(FileName) != -1 ) 2082 if ( GetFileAttributesA(FileName) != -1 )
2142 { 2083 {
2143 v6->Release(); 2084 Release();
2144 if ( v6->Alloc() ) 2085 if ( Alloc() )
2145 { 2086 {
2146 v7 = fopen(FileName, "rb"); 2087 v7 = fopen(FileName, "rb");
2147 result = 1; 2088 result = 1;
2148 if ( !v7 ) 2089 if ( !v7 )
2149 return result; 2090 return result;
2150 v9 = pDest; 2091 v9 = pDest;
2151 v6->bLoaded = 1; 2092 bLoaded = 1;
2152 v202 = (int)v7; 2093 v202 = (int)v7;
2153 v201 = (const char *)1; 2094 v201 = (const char *)1;
2154 *(int *)v9 = 1; 2095 *(int *)v9 = 1;
2155 fread(&DstBuf, 0x180u, (size_t)v201, (FILE *)v202); 2096 fread(&DstBuf, 0x180u, (size_t)v201, (FILE *)v202);
2156 fseek(v7, Offset, 0); 2097 fseek(v7, Offset, 0);
2157 fread(&v6->blv, 0x88u, 1u, v7); 2098 fread(&blv, 0x88u, 1u, v7);
2158 fseek(v7, v207, 0); 2099 fseek(v7, v207, 0);
2159 fread(&v6->uNumVertices, 1u, 4u, v7); 2100 fread(&uNumVertices, 1u, 4u, v7);
2160 fseek(v7, v208, 0); 2101 fseek(v7, v208, 0);
2161 fread(v6->pVertices, 6u, v6->uNumVertices, v7); 2102 fread(pVertices, 6u, uNumVertices, v7);
2162 fseek(v7, v209, 0); 2103 fseek(v7, v209, 0);
2163 fread(&v6->uNumFaces, 4u, 1u, v7); 2104 fread(&uNumFaces, 4u, 1u, v7);
2164 fseek(v7, v210, 0); 2105 fseek(v7, v210, 0);
2165 fread(v6->pFaces, 0x60u, v6->uNumFaces, v7); 2106 fread(pFaces, 0x60u, uNumFaces, v7);
2166 v10 = pAllocator->AllocNamedChunk(v6->ptr_2AC, v6->blv.uFaces_fdata_Size, "L.FData"); 2107 v10 = pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData");
2167 v202 = (int)v7; 2108 v202 = (int)v7;
2168 v6->ptr_2AC = (unsigned __int16 *)v10; 2109 ptr_2AC = (unsigned __int16 *)v10;
2169 fread(v10, 1u, v6->blv.uFaces_fdata_Size, (FILE *)v202); 2110 fread(v10, 1u, blv.uFaces_fdata_Size, (FILE *)v202);
2170 v11 = v6->uNumFaces == 0; 2111 v11 = uNumFaces == 0;
2171 v12 = (v6->uNumFaces & 0x80000000u) != 0; 2112 v12 = (uNumFaces & 0x80000000u) != 0;
2172 pDest = 0; 2113 pDest = 0;
2173 Argsa = 0; 2114 Argsa = 0;
2174 if ( !(v12 | v11) ) 2115 if ( !(v12 | v11) )
2175 { 2116 {
2176 v13 = 0; 2117 v13 = 0;
2177 do 2118 do
2178 { 2119 {
2179 v6->pFaces[v13].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)v6->ptr_2AC]; 2120 pFaces[v13].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)ptr_2AC];
2180 v14 = (size_t)&v6->pFaces[v13]; 2121 v14 = (size_t)&pFaces[v13];
2181 i = v14; 2122 i = v14;
2182 v15 = &pDest[2 * *(char *)(v14 + 93) + 2]; 2123 v15 = &pDest[2 * *(char *)(v14 + 93) + 2];
2183 v16 = (int)&v15[(unsigned int)v6->ptr_2AC]; 2124 v16 = (int)&v15[(unsigned int)ptr_2AC];
2184 pDest = v15; 2125 pDest = v15;
2185 *(int *)(i + 52) = v16; 2126 *(int *)(i + 52) = v16;
2186 v17 = (size_t)&v6->pFaces[v13]; 2127 v17 = (size_t)&pFaces[v13];
2187 i = v17; 2128 i = v17;
2188 v18 = &pDest[2 * *(char *)(v17 + 93) + 2]; 2129 v18 = &pDest[2 * *(char *)(v17 + 93) + 2];
2189 v19 = (int)&v18[(unsigned int)v6->ptr_2AC]; 2130 v19 = (int)&v18[(unsigned int)ptr_2AC];
2190 pDest = v18; 2131 pDest = v18;
2191 *(int *)(i + 56) = v19; 2132 *(int *)(i + 56) = v19;
2192 i = (size_t)&v6->pFaces[v13]; 2133 i = (size_t)&pFaces[v13];
2193 v20 = v6->ptr_2AC; 2134 v20 = ptr_2AC;
2194 pDest += 2 * *(char *)(i + 93) + 2; 2135 pDest += 2 * *(char *)(i + 93) + 2;
2195 *(int *)(i + 60) = (int)(char *)v20 + (int)pDest; 2136 *(int *)(i + 60) = (int)(char *)v20 + (int)pDest;
2196 i = (size_t)&v6->pFaces[v13]; 2137 i = (size_t)&pFaces[v13];
2197 v21 = v6->ptr_2AC; 2138 v21 = ptr_2AC;
2198 pDest += 2 * *(char *)(i + 93) + 2; 2139 pDest += 2 * *(char *)(i + 93) + 2;
2199 *(int *)(i + 64) = (int)(char *)v21 + (int)pDest; 2140 *(int *)(i + 64) = (int)(char *)v21 + (int)pDest;
2200 i = (size_t)&v6->pFaces[v13]; 2141 i = (size_t)&pFaces[v13];
2201 ++v13; 2142 ++v13;
2202 v22 = v6->ptr_2AC; 2143 v22 = ptr_2AC;
2203 pDest += 2 * *(char *)(i + 93) + 2; 2144 pDest += 2 * *(char *)(i + 93) + 2;
2204 ++Argsa; 2145 ++Argsa;
2205 *(int *)(i + 68) = (int)(char *)v22 + (int)pDest; 2146 *(int *)(i + 68) = (int)(char *)v22 + (int)pDest;
2206 pDest += 2 * *((char *)&v6->pFaces[v13] - 3) + 2; 2147 pDest += 2 * *((char *)&pFaces[v13] - 3) + 2;
2207 } 2148 }
2208 while ( Argsa < (signed int)v6->uNumFaces ); 2149 while ( Argsa < (signed int)uNumFaces );
2209 } 2150 }
2210 Argsb = 0; 2151 Argsb = 0;
2211 if ( (signed int)v6->uNumFaces > 0 ) 2152 if ( (signed int)uNumFaces > 0 )
2212 { 2153 {
2213 pDest = 0; 2154 pDest = 0;
2214 do 2155 do
2215 { 2156 {
2216 fread(Dst, 1u, 0xAu, v7); 2157 fread(Dst, 1u, 0xAu, v7);
2217 if ( pDest[(unsigned int)v6->pFaces + 45] & 0x40 ) 2158 if ( pDest[(unsigned int)pFaces + 45] & 0x40 )
2218 { 2159 {
2219 v23 = pTextureFrameTable->FindTextureByName(Dst); 2160 v23 = pTextureFrameTable->FindTextureByName(Dst);
2220 v24 = pDest; 2161 v24 = pDest;
2221 *(short *)&pDest[(unsigned int)v6->pFaces + 74] = v23; 2162 *(short *)&pDest[(unsigned int)pFaces + 74] = v23;
2222 v25 = *(short *)&v24[(unsigned int)v6->pFaces + 74]; 2163 v25 = *(short *)&v24[(unsigned int)pFaces + 74];
2223 if ( v25 ) 2164 if ( v25 )
2224 { 2165 {
2225 pTextureFrameTable->LoadAnimationSequenceAndPalettes(v25); 2166 pTextureFrameTable->LoadAnimationSequenceAndPalettes(v25);
2226 } 2167 }
2227 else 2168 else
2228 { 2169 {
2229 v26 = pBitmaps_LOD->LoadTexture(Dst); 2170 v26 = pBitmaps_LOD->LoadTexture(Dst);
2230 v27 = pDest; 2171 v27 = pDest;
2231 *(short *)&pDest[(unsigned int)v6->pFaces + 74] = v26; 2172 *(short *)&pDest[(unsigned int)pFaces + 74] = v26;
2232 v27[(unsigned int)v6->pFaces + 45] &= 0xBFu; 2173 v27[(unsigned int)pFaces + 45] &= 0xBFu;
2233 } 2174 }
2234 } 2175 }
2235 else 2176 else
2236 { 2177 {
2237 *(short *)&pDest[(unsigned int)v6->pFaces + 74] = pBitmaps_LOD->LoadTexture(Dst); 2178 *(short *)&pDest[(unsigned int)pFaces + 74] = pBitmaps_LOD->LoadTexture(Dst);
2238 } 2179 }
2239 ++Argsb; 2180 ++Argsb;
2240 pDest += 96; 2181 pDest += 96;
2241 } 2182 }
2242 while ( Argsb < (signed int)v6->uNumFaces ); 2183 while ( Argsb < (signed int)uNumFaces );
2243 } 2184 }
2244 fseek(v7, v211, 0); 2185 fseek(v7, v211, 0);
2245 fread(&v6->uNumFaceExtras, 4u, 1u, v7); 2186 fread(&uNumFaceExtras, 4u, 1u, v7);
2246 fseek(v7, v212, 0); 2187 fseek(v7, v212, 0);
2247 fread(v6->pFaceExtras, 0x24u, v6->uNumFaceExtras, v7); 2188 fread(pFaceExtras, 0x24u, uNumFaceExtras, v7);
2248 Argsc = 0; 2189 Argsc = 0;
2249 if ( (signed int)v6->uNumFaceExtras > 0 ) 2190 if ( (signed int)uNumFaceExtras > 0 )
2250 { 2191 {
2251 pDest = 0; 2192 pDest = 0;
2252 do 2193 do
2253 { 2194 {
2254 fread(Dst, 1u, 0xAu, v7); 2195 fread(Dst, 1u, 0xAu, v7);
2255 v28 = pBitmaps_LOD->LoadTexture(Dst); 2196 v28 = pBitmaps_LOD->LoadTexture(Dst);
2256 v29 = v6->pFaceExtras; 2197 v29 = pFaceExtras;
2257 v30 = pDest; 2198 v30 = pDest;
2258 ++Argsc; 2199 ++Argsc;
2259 pDest += 36; 2200 pDest += 36;
2260 *(unsigned __int16 *)((char *)&v29->uAdditionalBitmapID + (int)v30) = v28; 2201 *(unsigned __int16 *)((char *)&v29->uAdditionalBitmapID + (int)v30) = v28;
2261 } 2202 }
2262 while ( Argsc < (signed int)v6->uNumFaceExtras ); 2203 while ( Argsc < (signed int)uNumFaceExtras );
2263 } 2204 }
2264 Argsd = 0; 2205 Argsd = 0;
2265 if ( (signed int)v6->uNumFaces > 0 ) 2206 if ( (signed int)uNumFaces > 0 )
2266 { 2207 {
2267 pDest = 0; 2208 pDest = 0;
2268 do 2209 do
2269 { 2210 {
2270 v31 = (int)&v6->pFaceExtras[*(short *)&pDest[(unsigned int)v6->pFaces + 72]]; 2211 v31 = (int)&pFaceExtras[*(short *)&pDest[(unsigned int)pFaces + 72]];
2271 if ( *(short *)(v31 + 26) ) 2212 if ( *(short *)(v31 + 26) )
2272 { 2213 {
2273 if ( ((BLVFaceExtra *)v31)->HasEventint() ) 2214 if ( ((BLVFaceExtra *)v31)->HasEventint() )
2274 pDest[(unsigned int)v6->pFaces + 46] |= 0x10u; 2215 pDest[(unsigned int)pFaces + 46] |= 0x10u;
2275 else 2216 else
2276 pDest[(unsigned int)v6->pFaces + 46] &= 0xEFu; 2217 pDest[(unsigned int)pFaces + 46] &= 0xEFu;
2277 } 2218 }
2278 ++Argsd; 2219 ++Argsd;
2279 pDest += 96; 2220 pDest += 96;
2280 } 2221 }
2281 while ( Argsd < (signed int)v6->uNumFaces ); 2222 while ( Argsd < (signed int)uNumFaces );
2282 } 2223 }
2283 fseek(v7, v213, 0); 2224 fseek(v7, v213, 0);
2284 fread(&v6->uNumSectors, 4u, 1u, v7); 2225 fread(&uNumSectors, 4u, 1u, v7);
2285 fseek(v7, v214, 0); 2226 fseek(v7, v214, 0);
2286 fread(v6->pSectors, 0x74u, v6->uNumSectors, v7); 2227 fread(pSectors, 0x74u, uNumSectors, v7);
2287 v32 = pAllocator->AllocNamedChunk(v6->ptr_0002B0_sector_rdata, v6->blv.uSector_rdata_Size, "L.RData"); 2228 v32 = pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData");
2288 v202 = (int)v7; 2229 v202 = (int)v7;
2289 v6->ptr_0002B0_sector_rdata = (unsigned __int16 *)v32; 2230 ptr_0002B0_sector_rdata = (unsigned __int16 *)v32;
2290 fread(v32, 1u, v6->blv.uSector_rdata_Size, (FILE *)v202); 2231 fread(v32, 1u, blv.uSector_rdata_Size, (FILE *)v202);
2291 v11 = v6->uNumSectors == 0; 2232 v11 = uNumSectors == 0;
2292 v12 = v6->uNumSectors < 0; 2233 v12 = uNumSectors < 0;
2293 pDest = 0; 2234 pDest = 0;
2294 Argse = 0; 2235 Argse = 0;
2295 if ( !(v12 | v11) ) 2236 if ( !(v12 | v11) )
2296 { 2237 {
2297 v33 = 0; 2238 v33 = 0;
2298 do 2239 do
2299 { 2240 {
2300 v6->pSectors[v33].pFloors = (unsigned __int16 *)&pDest[(unsigned int)v6->ptr_0002B0_sector_rdata]; 2241 pSectors[v33].pFloors = (unsigned __int16 *)&pDest[(unsigned int)ptr_0002B0_sector_rdata];
2301 i = (size_t)&v6->pSectors[v33]; 2242 i = (size_t)&pSectors[v33];
2302 v34 = v6->ptr_0002B0_sector_rdata; 2243 v34 = ptr_0002B0_sector_rdata;
2303 pDest += 2 * *(short *)(i + 4); 2244 pDest += 2 * *(short *)(i + 4);
2304 *(int *)(i + 16) = (int)(char *)v34 + (int)pDest; 2245 *(int *)(i + 16) = (int)(char *)v34 + (int)pDest;
2305 v35 = (size_t)&v6->pSectors[v33]; 2246 v35 = (size_t)&pSectors[v33];
2306 i = v35; 2247 i = v35;
2307 v36 = &pDest[2 * *(short *)(v35 + 12)]; 2248 v36 = &pDest[2 * *(short *)(v35 + 12)];
2308 v37 = (int)&v36[(unsigned int)v6->ptr_0002B0_sector_rdata]; 2249 v37 = (int)&v36[(unsigned int)ptr_0002B0_sector_rdata];
2309 pDest = v36; 2250 pDest = v36;
2310 *(int *)(i + 24) = v37; 2251 *(int *)(i + 24) = v37;
2311 v38 = (size_t)&v6->pSectors[v33]; 2252 v38 = (size_t)&pSectors[v33];
2312 i = v38; 2253 i = v38;
2313 v39 = &pDest[2 * *(short *)(v38 + 20)]; 2254 v39 = &pDest[2 * *(short *)(v38 + 20)];
2314 v40 = (int)&v39[(unsigned int)v6->ptr_0002B0_sector_rdata]; 2255 v40 = (int)&v39[(unsigned int)ptr_0002B0_sector_rdata];
2315 pDest = v39; 2256 pDest = v39;
2316 *(int *)(i + 32) = v40; 2257 *(int *)(i + 32) = v40;
2317 i = (size_t)&v6->pSectors[v33]; 2258 i = (size_t)&pSectors[v33];
2318 v41 = v6->ptr_0002B0_sector_rdata; 2259 v41 = ptr_0002B0_sector_rdata;
2319 pDest += 2 * *(short *)(i + 28); 2260 pDest += 2 * *(short *)(i + 28);
2320 *(int *)(i + 40) = (int)(char *)v41 + (int)pDest; 2261 *(int *)(i + 40) = (int)(char *)v41 + (int)pDest;
2321 i = (size_t)&v6->pSectors[v33]; 2262 i = (size_t)&pSectors[v33];
2322 v42 = v6->ptr_0002B0_sector_rdata; 2263 v42 = ptr_0002B0_sector_rdata;
2323 pDest += 2 * *(short *)(i + 36); 2264 pDest += 2 * *(short *)(i + 36);
2324 *(int *)(i + 48) = (int)(char *)v42 + (int)pDest; 2265 *(int *)(i + 48) = (int)(char *)v42 + (int)pDest;
2325 i = (size_t)&v6->pSectors[v33]; 2266 i = (size_t)&pSectors[v33];
2326 v43 = v6->ptr_0002B0_sector_rdata; 2267 v43 = ptr_0002B0_sector_rdata;
2327 pDest += 2 * *(short *)(i + 44); 2268 pDest += 2 * *(short *)(i + 44);
2328 *(int *)(i + 64) = (int)(char *)v43 + (int)pDest; 2269 *(int *)(i + 64) = (int)(char *)v43 + (int)pDest;
2329 i = (size_t)&v6->pSectors[v33]; 2270 i = (size_t)&pSectors[v33];
2330 v44 = v6->ptr_0002B0_sector_rdata; 2271 v44 = ptr_0002B0_sector_rdata;
2331 pDest += 2 * *(short *)(i + 60); 2272 pDest += 2 * *(short *)(i + 60);
2332 *(int *)(i + 72) = (int)(char *)v44 + (int)pDest; 2273 *(int *)(i + 72) = (int)(char *)v44 + (int)pDest;
2333 v45 = (size_t)&v6->pSectors[v33]; 2274 v45 = (size_t)&pSectors[v33];
2334 ++v33; 2275 ++v33;
2335 i = v45; 2276 i = v45;
2336 v46 = v6->ptr_0002B0_sector_rdata; 2277 v46 = ptr_0002B0_sector_rdata;
2337 pDest += 2 * *(short *)(v45 + 68); 2278 pDest += 2 * *(short *)(v45 + 68);
2338 ++Argse; 2279 ++Argse;
2339 *(int *)(v45 + 80) = (int)(char *)v46 + (int)pDest; 2280 *(int *)(v45 + 80) = (int)(char *)v46 + (int)pDest;
2340 pDest += 2 * *((short *)&v6->pSectors[v33] - 20); 2281 pDest += 2 * *((short *)&pSectors[v33] - 20);
2341 } 2282 }
2342 while ( Argse < v6->uNumSectors ); 2283 while ( Argse < uNumSectors );
2343 } 2284 }
2344 v47 = pAllocator->AllocNamedChunk( 2285 v47 = pAllocator->AllocNamedChunk(
2345 v6->ptr_0002B8_sector_lrdata, 2286 ptr_0002B8_sector_lrdata,
2346 v6->blv.uSector_lrdata_Size, 2287 blv.uSector_lrdata_Size,
2347 "L.RLData"); 2288 "L.RLData");
2348 v202 = (int)v7; 2289 v202 = (int)v7;
2349 v6->ptr_0002B8_sector_lrdata = (unsigned __int16 *)v47; 2290 ptr_0002B8_sector_lrdata = (unsigned __int16 *)v47;
2350 fread(v47, 1u, v6->blv.uSector_lrdata_Size, (FILE *)v202); 2291 fread(v47, 1u, blv.uSector_lrdata_Size, (FILE *)v202);
2351 v11 = v6->uNumSectors == 0; 2292 v11 = uNumSectors == 0;
2352 v12 = v6->uNumSectors < 0; 2293 v12 = uNumSectors < 0;
2353 pDest = 0; 2294 pDest = 0;
2354 Argsf = 0; 2295 Argsf = 0;
2355 if ( !(v12 | v11) ) 2296 if ( !(v12 | v11) )
2356 { 2297 {
2357 v48 = v6->pSectors; 2298 v48 = pSectors;
2358 v49 = 0; 2299 v49 = 0;
2359 for ( i = 0; ; v49 = i ) 2300 for ( i = 0; ; v49 = i )
2360 { 2301 {
2361 v50 = v6->ptr_0002B8_sector_lrdata; 2302 v50 = ptr_0002B8_sector_lrdata;
2362 i += 116; 2303 i += 116;
2363 ++Argsf; 2304 ++Argsf;
2364 *(BLVLightMM7 **)((char *)&v48->pLights + v49) = (BLVLightMM7 *)((char *)v50 + (int)pDest); 2305 *(BLVLightMM7 **)((char *)&v48->pLights + v49) = (BLVLightMM7 *)((char *)v50 + (int)pDest);
2365 v48 = v6->pSectors; 2306 v48 = pSectors;
2366 pDest += 2 * *(__int16 *)((char *)&v48->uNumLights + v49); 2307 pDest += 2 * *(__int16 *)((char *)&v48->uNumLights + v49);
2367 if ( Argsf >= v6->uNumSectors ) 2308 if ( Argsf >= uNumSectors )
2368 break; 2309 break;
2369 } 2310 }
2370 } 2311 }
2371 fseek(v7, v215, 0); 2312 fseek(v7, v215, 0);
2372 fread(&v6->uNumDoors, 4u, 1u, v7); 2313 fread(&uNumDoors, 4u, 1u, v7);
2373 fseek(v7, v216, 0); 2314 fseek(v7, v216, 0);
2374 fread(v6->pDoors, 0x50u, 0xC8u, v7); 2315 fread(pDoors, 0x50u, 0xC8u, v7);
2375 v51 = pAllocator->AllocNamedChunk(v6->ptr_0002B4_doors_ddata, v6->blv.uDoors_ddata_Size, "L.DData"); 2316 v51 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData");
2376 v202 = (int)v7; 2317 v202 = (int)v7;
2377 v6->ptr_0002B4_doors_ddata = (unsigned __int16 *)v51; 2318 ptr_0002B4_doors_ddata = (unsigned __int16 *)v51;
2378 fread(v51, 1u, v6->blv.uDoors_ddata_Size, (FILE *)v202); 2319 fread(v51, 1u, blv.uDoors_ddata_Size, (FILE *)v202);
2379 v11 = v6->uNumDoors == 0; 2320 v11 = uNumDoors == 0;
2380 v12 = v6->uNumDoors < 0; 2321 v12 = uNumDoors < 0;
2381 pDest = 0; 2322 pDest = 0;
2382 Argsg = 0; 2323 Argsg = 0;
2383 if ( !(v12 | v11) ) 2324 if ( !(v12 | v11) )
2384 { 2325 {
2385 v52 = 0; 2326 v52 = 0;
2386 do 2327 do
2387 { 2328 {
2388 v6->pDoors[v52].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)v6->ptr_0002B4_doors_ddata]; 2329 pDoors[v52].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)ptr_0002B4_doors_ddata];
2389 i = (size_t)&v6->pDoors[v52]; 2330 i = (size_t)&pDoors[v52];
2390 v53 = v6->ptr_0002B4_doors_ddata; 2331 v53 = ptr_0002B4_doors_ddata;
2391 pDest += 2 * *(short *)(i + 68); 2332 pDest += 2 * *(short *)(i + 68);
2392 *(int *)(i + 40) = (int)(char *)v53 + (int)pDest; 2333 *(int *)(i + 40) = (int)(char *)v53 + (int)pDest;
2393 v54 = (size_t)&v6->pDoors[v52]; 2334 v54 = (size_t)&pDoors[v52];
2394 i = v54; 2335 i = v54;
2395 v55 = &pDest[2 * *(short *)(v54 + 70)]; 2336 v55 = &pDest[2 * *(short *)(v54 + 70)];
2396 v56 = (int)&v55[(unsigned int)v6->ptr_0002B4_doors_ddata]; 2337 v56 = (int)&v55[(unsigned int)ptr_0002B4_doors_ddata];
2397 pDest = v55; 2338 pDest = v55;
2398 *(int *)(i + 44) = v56; 2339 *(int *)(i + 44) = v56;
2399 v57 = (size_t)&v6->pDoors[v52]; 2340 v57 = (size_t)&pDoors[v52];
2400 i = v57; 2341 i = v57;
2401 v58 = &pDest[2 * *(short *)(v57 + 72)]; 2342 v58 = &pDest[2 * *(short *)(v57 + 72)];
2402 v59 = (int)&v58[(unsigned int)v6->ptr_0002B4_doors_ddata]; 2343 v59 = (int)&v58[(unsigned int)ptr_0002B4_doors_ddata];
2403 pDest = v58; 2344 pDest = v58;
2404 *(int *)(i + 48) = v59; 2345 *(int *)(i + 48) = v59;
2405 i = (size_t)&v6->pDoors[v52]; 2346 i = (size_t)&pDoors[v52];
2406 v60 = v6->ptr_0002B4_doors_ddata; 2347 v60 = ptr_0002B4_doors_ddata;
2407 pDest += 2 * *(short *)(i + 70); 2348 pDest += 2 * *(short *)(i + 70);
2408 *(int *)(i + 52) = (int)(char *)v60 + (int)pDest; 2349 *(int *)(i + 52) = (int)(char *)v60 + (int)pDest;
2409 i = (size_t)&v6->pDoors[v52]; 2350 i = (size_t)&pDoors[v52];
2410 v61 = v6->ptr_0002B4_doors_ddata; 2351 v61 = ptr_0002B4_doors_ddata;
2411 pDest += 2 * *(short *)(i + 70); 2352 pDest += 2 * *(short *)(i + 70);
2412 *(int *)(i + 56) = (int)(char *)v61 + (int)pDest; 2353 *(int *)(i + 56) = (int)(char *)v61 + (int)pDest;
2413 i = (size_t)&v6->pDoors[v52]; 2354 i = (size_t)&pDoors[v52];
2414 v62 = v6->ptr_0002B4_doors_ddata; 2355 v62 = ptr_0002B4_doors_ddata;
2415 pDest += 2 * *(short *)(i + 74); 2356 pDest += 2 * *(short *)(i + 74);
2416 *(int *)(i + 60) = (int)(char *)v62 + (int)pDest; 2357 *(int *)(i + 60) = (int)(char *)v62 + (int)pDest;
2417 i = (size_t)&v6->pDoors[v52]; 2358 i = (size_t)&pDoors[v52];
2418 v63 = v6->ptr_0002B4_doors_ddata; 2359 v63 = ptr_0002B4_doors_ddata;
2419 pDest += 2 * *(short *)(i + 74); 2360 pDest += 2 * *(short *)(i + 74);
2420 *(int *)(i + 64) = (int)(char *)v63 + (int)pDest; 2361 *(int *)(i + 64) = (int)(char *)v63 + (int)pDest;
2421 ++Argsg; 2362 ++Argsg;
2422 v64 = v6->pDoors[v52].uNumOffsets; 2363 v64 = pDoors[v52].uNumOffsets;
2423 ++v52; 2364 ++v52;
2424 pDest += 2 * v64; 2365 pDest += 2 * v64;
2425 } 2366 }
2426 while ( Argsg < v6->uNumDoors ); 2367 while ( Argsg < uNumDoors );
2427 } 2368 }
2428 Argsh = 0; 2369 Argsh = 0;
2429 if ( v6->uNumDoors > 0 ) 2370 if ( uNumDoors > 0 )
2430 { 2371 {
2431 v65 = v6->pDoors; 2372 v65 = pDoors;
2432 pDest = 0; 2373 pDest = 0;
2433 do 2374 do
2434 { 2375 {
2435 i = 0; 2376 i = 0;
2436 v66 = &pDest[(int)v65]; 2377 v66 = &pDest[(int)v65];
2439 do 2380 do
2440 { 2381 {
2441 v67 = *((int *)v66 + 10); 2382 v67 = *((int *)v66 + 10);
2442 a3 = 2 * i; 2383 a3 = 2 * i;
2443 v68 = *(short *)(v67 + 2 * i); 2384 v68 = *(short *)(v67 + 2 * i);
2444 v69 = v6->pFaces; 2385 v69 = pFaces;
2445 ++i; 2386 ++i;
2446 v70 = (int)&v6->pFaceExtras[v69[v68].uFaceExtraID]; 2387 v70 = (int)&pFaceExtras[v69[v68].uFaceExtraID];
2447 v71 = *((int *)v66 + 12); 2388 v71 = *((int *)v66 + 12);
2448 v72 = a3; 2389 v72 = a3;
2449 v238 = (char *)v70; 2390 v238 = (char *)v70;
2450 *(short *)(a3 + v71) = *(short *)(v70 + 20); 2391 *(short *)(a3 + v71) = *(short *)(v70 + 20);
2451 *(__int16 *)(*(char **)((char *)&v6->pDoors->pDeltaVs + (unsigned int)pDest) + v72) = *((short *)v238 + 11); 2392 *(__int16 *)(*(char **)((char *)&pDoors->pDeltaVs + (unsigned int)pDest) + v72) = *((short *)v238 + 11);
2452 v65 = v6->pDoors; 2393 v65 = pDoors;
2453 v66 = &pDest[(int)v65]; 2394 v66 = &pDest[(int)v65];
2454 } 2395 }
2455 while ( (signed int)i < *(short *)&pDest[(int)v65 + 70] ); 2396 while ( (signed int)i < *(short *)&pDest[(int)v65 + 70] );
2456 } 2397 }
2457 ++Argsh; 2398 ++Argsh;
2458 pDest += 80; 2399 pDest += 80;
2459 } 2400 }
2460 while ( Argsh < v6->uNumDoors ); 2401 while ( Argsh < uNumDoors );
2461 } 2402 }
2462 fseek(v7, v217, 0); 2403 fseek(v7, v217, 0);
2463 fread(&uNumLevelDecorations, 4u, 1u, v7); 2404 fread(&uNumLevelDecorations, 4u, 1u, v7);
2464 fseek(v7, v218, 0); 2405 fseek(v7, v218, 0);
2465 fread(pLevelDecorations, 0x20u, uNumLevelDecorations, v7); 2406 fread(pLevelDecorations, 0x20u, uNumLevelDecorations, v7);
2525 fseek(v7, v228, 0); 2466 fseek(v7, v228, 0);
2526 fread(&uNumChests, 4u, 1u, v7); 2467 fread(&uNumChests, 4u, 1u, v7);
2527 fseek(v7, v229, 0); 2468 fseek(v7, v229, 0);
2528 fread(pChests, 0x14CCu, uNumChests, v7); 2469 fread(pChests, 0x14CCu, uNumChests, v7);
2529 fseek(v7, v224, 0); 2470 fseek(v7, v224, 0);
2530 fread(&v6->uNumLights, 4u, 1u, v7); 2471 fread(&uNumLights, 4u, 1u, v7);
2531 fseek(v7, v225, 0); 2472 fseek(v7, v225, 0);
2532 fread(v6->pLights, 0x10u, v6->uNumLights, v7); 2473 fread(pLights, 0x10u, uNumLights, v7);
2533 fseek(v7, v226, 0); 2474 fseek(v7, v226, 0);
2534 fread(&v6->uNumNodes, 4u, 1u, v7); 2475 fread(&uNumNodes, 4u, 1u, v7);
2535 fseek(v7, v227, 0); 2476 fseek(v7, v227, 0);
2536 fread(v6->pNodes, 8u, v6->uNumNodes, v7); 2477 fread(pNodes, 8u, uNumNodes, v7);
2537 fseek(v7, v230, 0); 2478 fseek(v7, v230, 0);
2538 fread(&v6->uNumSpawnPoints, 4u, 1u, v7); 2479 fread(&uNumSpawnPoints, 4u, 1u, v7);
2539 v79 = pAllocator->AllocNamedChunk(v6->pSpawnPoints, 24 * v6->uNumSpawnPoints, "Spawn"); 2480 v79 = pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn");
2540 v202 = 0; 2481 v202 = 0;
2541 v6->pSpawnPoints = (SpawnPointMM7 *)v79; 2482 pSpawnPoints = (SpawnPointMM7 *)v79;
2542 fseek(v7, v231, v202); 2483 fseek(v7, v231, v202);
2543 fread(v6->pSpawnPoints, 0x18u, v6->uNumSpawnPoints, v7); 2484 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, v7);
2544 fseek(v7, v232, 0); 2485 fseek(v7, v232, 0);
2545 fread(&v6->dlv, 0x28u, 1u, v7); 2486 fread(&dlv, 0x28u, 1u, v7);
2546 fseek(v7, v233, 0); 2487 fseek(v7, v233, 0);
2547 fread(&stru_5E4C90, 1u, 0xC8u, v7); 2488 fread(&stru_5E4C90, 1u, 0xC8u, v7);
2548 fseek(v7, v234, 0); 2489 fseek(v7, v234, 0);
2549 fread(&v6->uLastVisitDay, 1u, 0x38u, v7); 2490 fread(&uLastVisitDay, 1u, 0x38u, v7);
2550 fseek(v7, v223, 0); 2491 fseek(v7, v223, 0);
2551 v80 = (void **)&v6->pMapVertices; 2492 v80 = (void **)&pMapVertices;
2552 fread(*v80, 4u, 1u, v7); 2493 fread(*v80, 4u, 1u, v7);
2553 fread((char *)*v80 + 4, 0xCu, *(int *)*v80, v7); 2494 fread((char *)*v80 + 4, 0xCu, *(int *)*v80, v7);
2554 fclose(v7); 2495 fclose(v7);
2555 goto LABEL_179; 2496 goto LABEL_179;
2556 } 2497 }
2557 return 4; 2498 return 4;
2558 } 2499 }*/
2500 #pragma endregion
2501
2502 if (bLoaded)
2503 {
2504 Log::Warning(L"BLV is already loaded");
2505 return 3;
2506 }
2507
2559 if ( !pGames_LOD->DoesContainerExist(pFilename) ) 2508 if ( !pGames_LOD->DoesContainerExist(pFilename) )
2560 Abortf("Unable to find %s in Games.LOD", pFilename); 2509 Abortf("Unable to find %s in Games.LOD", pFilename);
2561 v238 = pFilename - 4; 2510
2562 v81 = strlen(pFilename); 2511 //v238 = pFilename - 4;
2563 strcpy(&v238[v81], ".blv"); 2512 //v81 = strlen(pFilename);
2564 v82 = pGames_LOD->FindContainer(pFilename, 1); 2513 strcpy(this->pFilename, pFilename);
2565 v11 = v6->bLoaded == 0; 2514 strcpy(&pFilename[strlen(pFilename) - 4], ".blv");
2566 File = v82; 2515 File = pGames_LOD->FindContainer(pFilename, 1);
2567 if ( !v11 ) 2516 //File = v82;
2568 return 3;
2569 2517
2570 Release(); 2518 Release();
2571 if ( !Alloc() ) 2519 if ( !Alloc() )
2572 return 4; 2520 return 4;
2573 2521
2522 header.uVersion = 91969;
2574 header.pMagic[0] = 'm'; 2523 header.pMagic[0] = 'm';
2575 header.uVersion = 91969;
2576 header.pMagic[1] = 'v'; 2524 header.pMagic[1] = 'v';
2577 header.pMagic[2] = 'i'; 2525 header.pMagic[2] = 'i';
2578 header.pMagic[3] = 'i'; 2526 header.pMagic[3] = 'i';
2579 header.uCompressedSize = 0; 2527 header.uCompressedSize = 0;
2580 header.uDecompressedSize = 0; 2528 header.uDecompressedSize = 0;
2581 fread(&header, 0x10u, 1u, File); 2529 fread(&header, sizeof(ODMHeader), 1u, File);
2582 if ( header.uVersion != 91969 2530 if (header.uVersion != 91969 ||
2583 || header.pMagic[0] != 'm' 2531 header.pMagic[0] != 'm' ||
2584 || header.pMagic[1] != 'v' 2532 header.pMagic[1] != 'v' ||
2585 || header.pMagic[2] != 'i' 2533 header.pMagic[2] != 'i' ||
2586 || header.pMagic[3] != 'i' ) 2534 header.pMagic[3] != 'i' )
2587 { 2535 {
2588 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:792", 0); 2536 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:792", 0);
2589 } 2537 }
2590 v83 = header.uCompressedSize; 2538 //v83 = header.uCompressedSize;
2591 pSource = header.uDecompressedSize; 2539 //pSource = header.uDecompressedSize;
2592 v84 = malloc(header.uDecompressedSize); 2540 //v84 = malloc(header.uDecompressedSize);
2593 v85 = v84; 2541 //v85 = v84;
2594 ptr = v84; 2542 //ptr = v84;
2595 if ( v83 <= pSource ) 2543 auto pRawBLV = malloc(header.uDecompressedSize);
2596 { 2544 memset(pRawBLV, 0, header.uDecompressedSize);
2597 if ( v83 == pSource ) 2545
2546 if (header.uCompressedSize == header.uDecompressedSize)
2547 fread(pRawBLV, header.uDecompressedSize, 1, File);
2548 else if (header.uCompressedSize < header.uDecompressedSize)
2549 {
2550 auto pTmpMem = malloc(header.uCompressedSize);
2598 { 2551 {
2599 fread(v84, pSource, 1u, File); 2552 fread(pTmpMem, header.uCompressedSize, 1, File);
2553
2554 uint uDecompressedSize = header.uDecompressedSize;
2555 zlib::MemUnzip(pRawBLV, &uDecompressedSize, pTmpMem, header.uCompressedSize);
2556
2557 if (uDecompressedSize != header.uDecompressedSize)
2558 Log::Warning(L"uDecompressedSize != header.uDecompressedSize in BLV");
2600 } 2559 }
2601 else 2560 free(pTmpMem);
2602 {
2603 *(int *)((char *)&uSourceLen + 1) = (int)malloc(v83);
2604 fread(*(void **)((char *)&uSourceLen + 1), v83, 1u, File);
2605 zlib::MemUnzip(v85, &pSource, *(const void **)((char *)&uSourceLen + 1), v83);
2606 free(*(void **)((char *)&uSourceLen + 1));
2607 }
2608 } 2561 }
2609 else 2562 else
2610 { 2563 {
2611 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:803", 0); 2564 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:803", 0);
2612 } 2565 return 0;
2613 strcpy(v6->pFilename, pFilename); 2566 }
2614 v200 = 136; 2567
2615 v199 = (size_t)v85; 2568 assert(sizeof(Vec3_short_) == 6);
2616 v198 = &v6->blv; 2569 assert(sizeof(BLVFace) == 96);
2617 v6->bLoaded = 1; 2570 assert(sizeof(BLVFaceExtra) == 36);
2618 memcpy(v198, (const void *)v199, v200); 2571 assert(sizeof(BLVSector) == 116);
2619 v86 = (char *)v85 + 136; 2572 assert(sizeof(LevelDecoration) == 32);
2573 assert(sizeof(BLVLightMM7) == 16);
2574 assert(sizeof(BSPNode) == 8);
2575 assert(sizeof(SpawnPointMM7) == 24);
2576 assert(sizeof(DDM_DLV_Header) == 40);
2577 assert(sizeof(Actor) == 836);
2578 assert(sizeof(LayingItem) == 112);
2579 assert(sizeof(Chest) == 5324);
2580 assert(sizeof(stru123) == 0xC8);
2581
2582 bLoaded = true;
2583
2584 auto pData = (char *)pRawBLV;
2585
2620 pGameLoadingUI_ProgressBar->Progress(); 2586 pGameLoadingUI_ProgressBar->Progress();
2621 memcpy(&v6->uNumVertices, v86, 4u); 2587
2622 v86 = (char *)v86 + 4; 2588 memcpy(&blv, pData, 136);
2589 memcpy(&uNumVertices, pData += 136, 4);
2590 memcpy(pVertices, pData += 4, uNumVertices * sizeof(Vec3_short_));
2591
2623 pGameLoadingUI_ProgressBar->Progress(); 2592 pGameLoadingUI_ProgressBar->Progress();
2624 v202 = 6 * v6->uNumVertices; 2593
2625 v201 = (const char *)v86; 2594 memcpy(&uNumFaces, pData += uNumVertices * sizeof(Vec3_short_), 4);
2626 v200 = (size_t)v6->pVertices; 2595
2627 v245 = v202;
2628 memcpy((void *)v200, v86, v202);
2629 v87 = (char *)v86 + v245;
2630 pGameLoadingUI_ProgressBar->Progress(); 2596 pGameLoadingUI_ProgressBar->Progress();
2631 memcpy(&v6->uNumFaces, v87, 4u); 2597
2632 v87 = (char *)v87 + 4; 2598 memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace));
2633 pGameLoadingUI_ProgressBar->Progress(); 2599 ptr_2AC = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData");
2634 v202 = 96 * v6->uNumFaces; 2600
2635 v201 = (const char *)v87; 2601 memcpy(ptr_2AC, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size);
2636 v200 = (size_t)v6->pFaces; 2602
2637 v245 = v202; 2603 for (uint i = 0, j = 0; i < uNumFaces; ++i)
2638 memcpy((void *)v200, v87, v202); 2604 {
2639 v88 = (char *)v87 + v245; 2605 auto pFace = pFaces + i;
2640 v202 = (int)"L.FData"; 2606
2641 v201 = (const char *)v6->blv.uFaces_fdata_Size; 2607 pFace->pVertexIDs = ptr_2AC + j;
2642 v200 = (size_t)v6->ptr_2AC; 2608
2643 v89 = pAllocator->AllocNamedChunk((const void *)v200, (unsigned int)v201, "L.FData"); 2609 j += pFace->uNumVertices + 1;
2644 v90 = v6->blv.uFaces_fdata_Size; 2610 pFace->pXInterceptDisplacements = ptr_2AC + j;
2645 v6->ptr_2AC = (unsigned __int16 *)v89; 2611
2646 v245 = v90; 2612 j += pFace->uNumVertices + 1;
2647 memcpy(v89, v88, v90); 2613 pFace->pYInterceptDisplacements = ptr_2AC + j;
2648 v91 = (char *)v88 + v245; 2614
2649 v92 = 0; 2615 j += pFace->uNumVertices + 1;
2650 v11 = v6->uNumFaces == 0; 2616 pFace->pZInterceptDisplacements = ptr_2AC + j;
2651 v12 = (v6->uNumFaces & 0x80000000u) != 0; 2617
2652 v244 = 0; 2618 j += pFace->uNumVertices + 1;
2653 v245 = 0; 2619 pFace->pVertexUIDs = ptr_2AC + j;
2654 if ( !(v12 | v11) ) 2620
2655 { 2621 j += pFace->uNumVertices + 1;
2656 do 2622 pFace->pVertexVIDs = ptr_2AC + j;
2657 { 2623
2658 v6->pFaces[v92].pVertexIDs = (unsigned __int16 *)((char *)v244 + (unsigned int)v6->ptr_2AC); 2624 j += pFace->uNumVertices + 1;
2659 v93 = &v6->pFaces[v92]; 2625 /*v93 = &pFaces[v92];
2660 Src = v93; 2626 Src = v93;
2661 v94 = (BLVSector *)((char *)v244 + 2 * v93->uNumVertices + 2); 2627 v94 = (BLVSector *)((char *)v244 + 2 * v93->uNumVertices + 2);
2662 v95 = (unsigned __int16 *)((char *)v94 + (unsigned int)v6->ptr_2AC); 2628 v95 = (unsigned __int16 *)((char *)v94 + (unsigned int)ptr_2AC);
2663 v244 = v94; 2629 v244 = v94;
2664 Src->pXInterceptDisplacements = v95; 2630 Src->pXInterceptDisplacements = v95;
2665 v96 = (int)&v6->pFaces[v92]; 2631 v96 = (int)&pFaces[v92];
2666 Src = (BLVFace *)v96; 2632 Src = (BLVFace *)v96;
2667 v97 = (BLVSector *)((char *)v244 + 2 * *(char *)(v96 + 93) + 2); 2633 v97 = (BLVSector *)((char *)v244 + 2 * *(char *)(v96 + 93) + 2);
2668 v98 = (unsigned __int16 *)((char *)v97 + (unsigned int)v6->ptr_2AC); 2634 v98 = (unsigned __int16 *)((char *)v97 + (unsigned int)ptr_2AC);
2669 v244 = v97; 2635 v244 = v97;
2670 Src->pYInterceptDisplacements = v98; 2636 Src->pYInterceptDisplacements = v98;
2671 Src = &v6->pFaces[v92]; 2637 Src = &pFaces[v92];
2672 v99 = v6->ptr_2AC; 2638 v99 = ptr_2AC;
2673 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); 2639 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2);
2674 Src->pZInterceptDisplacements = (unsigned __int16 *)((char *)v99 + (int)v244); 2640 Src->pZInterceptDisplacements = (unsigned __int16 *)((char *)v99 + (int)v244);
2675 Src = &v6->pFaces[v92]; 2641 Src = &pFaces[v92];
2676 v100 = v6->ptr_2AC; 2642 v100 = ptr_2AC;
2677 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); 2643 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2);
2678 Src->pVertexUIDs = (unsigned __int16 *)((char *)v100 + (int)v244); 2644 Src->pVertexUIDs = (unsigned __int16 *)((char *)v100 + (int)v244);
2679 Src = &v6->pFaces[v92]; 2645 Src = &pFaces[v92];
2680 ++v92; 2646 ++v92;
2681 v101 = v6->ptr_2AC; 2647 v101 = ptr_2AC;
2682 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); 2648 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2);
2683 ++v245; 2649 ++v245;
2684 Src->pVertexVIDs = (unsigned __int16 *)((char *)v101 + (int)v244); 2650 Src->pVertexVIDs = (unsigned __int16 *)((char *)v101 + (int)v244);
2685 v244 = (BLVSector *)((char *)v244 + 2 * *((char *)&v6->pFaces[v92] - 3) + 2); 2651 v244 = (BLVSector *)((char *)v244 + 2 * *((char *)&pFaces[v92] - 3) + 2);*/
2686 } 2652 }
2687 while ( v245 < (signed int)v6->uNumFaces ); 2653
2688 } 2654 pGameLoadingUI_ProgressBar->Progress();
2689 v11 = v6->uNumFaces == 0; 2655
2690 v12 = (v6->uNumFaces & 0x80000000u) != 0; 2656 pData += blv.uFaces_fdata_Size;
2691 v245 = 0; 2657
2692 if ( !(v12 | v11) ) 2658 for (uint i = 0; i < uNumFaces; ++i)
2693 { 2659 {
2694 v244 = 0; 2660 auto pFace = pFaces + i;
2695 do 2661
2662 char pTexName[16];
2663 strncpy(pTexName, pData, 10);
2664 pData += 10;
2665
2666 if (pFace->uAttributes & 0x4000)
2696 { 2667 {
2697 memcpy(Dst, v91, 0xAu); 2668 pFace->uBitmapID = pTextureFrameTable->FindTextureByName(pTexName);
2698 v91 = (char *)v91 + 10; 2669 if (pFace->uBitmapID)
2699 if ( *((char *)&v244->field_2C + (unsigned int)v6->pFaces + 1) & 0x40 ) 2670 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pFace->uBitmapID);
2700 {
2701 v102 = pTextureFrameTable->FindTextureByName(Dst);
2702 v103 = v244;
2703 *(short *)((char *)&v244->pDecorationIDs + (unsigned int)v6->pFaces + 2) = v102;
2704 v104 = *(short *)((char *)&v103->pDecorationIDs + (unsigned int)v6->pFaces + 2);
2705 if ( v104 )
2706 {
2707 pTextureFrameTable->LoadAnimationSequenceAndPalettes(v104);
2708 }
2709 else
2710 {
2711 v105 = pBitmaps_LOD->LoadTexture(Dst);
2712 v106 = v244;
2713 *(short *)((char *)&v244->pDecorationIDs + (unsigned int)v6->pFaces + 2) = v105;
2714 *((char *)&v106->field_2C + (unsigned int)v6->pFaces + 1) &= 0xBFu;
2715 }
2716 }
2717 else 2671 else
2718 { 2672 {
2719 *(short *)((char *)&v244->pDecorationIDs + (unsigned int)v6->pFaces + 2) = pBitmaps_LOD->LoadTexture(Dst); 2673 pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName);
2674 pFace->uAttributes &= ~0x4000;
2720 } 2675 }
2721 ++v245;
2722 v244 = (BLVSector *)((char *)v244 + 96);
2723 } 2676 }
2724 while ( v245 < (signed int)v6->uNumFaces ); 2677 else
2725 } 2678 pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName);
2679 }
2680
2726 pGameLoadingUI_ProgressBar->Progress(); 2681 pGameLoadingUI_ProgressBar->Progress();
2727 memcpy(&v6->uNumFaceExtras, v91, 4u); 2682
2728 v107 = (char *)v91 + 4; 2683 memcpy(&uNumFaceExtras, pData, 4u);
2684 memcpy(pFaceExtras, pData += 4, uNumFaceExtras * sizeof(BLVFaceExtra));
2685 pData += uNumFaceExtras * sizeof(BLVFaceExtra);
2686
2729 pGameLoadingUI_ProgressBar->Progress(); 2687 pGameLoadingUI_ProgressBar->Progress();
2730 v202 = 36 * v6->uNumFaceExtras; 2688
2731 v201 = (const char *)v107; 2689 //v108 = (char *)v107 + 36 * uNumFaceExtras;
2732 v200 = (size_t)v6->pFaceExtras; 2690 //v245 = 0;
2733 v245 = v202; 2691 //*(int *)((char *)&uSourceLen + 1) = 0;
2734 memcpy((void *)v200, v107, v202); 2692 for (uint i = 0; i < uNumFaceExtras; ++i)
2735 v108 = (char *)v107 + v245; 2693 {
2736 v245 = 0; 2694 char pTexName[32];
2737 if ( (signed int)v6->uNumFaceExtras > 0 ) 2695 strncpy(pTexName, pData, 10);
2738 { 2696 pData += 10;
2739 *(int *)((char *)&uSourceLen + 1) = 0; 2697
2740 do 2698 if (!strcmp(pTexName, ""))
2699 pFaceExtras[i].uAdditionalBitmapID = -1;
2700 else
2701 pFaceExtras[i].uAdditionalBitmapID = pBitmaps_LOD->LoadTexture(pTexName);
2702 }
2703
2704
2705 for (uint i = 0; i < uNumFaces; ++i)
2706 {
2707 auto pFace = pFaces + i;
2708 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID;
2709
2710 if (pFaceExtra->uEventID)
2741 { 2711 {
2742 memcpy(Dst, v108, 0xAu); 2712 if (pFaceExtra->HasEventint())
2743 v108 = (char *)v108 + 10; 2713 pFace->uAttributes |= 0x100000;
2744 if ( !_strcmpi(Dst, nullstring) ) 2714 else
2745 *(unsigned __int16 *)((char *)&v6->pFaceExtras->uAdditionalBitmapID + *(int *)((char *)&uSourceLen + 1)) = -1; 2715 pFace->uAttributes &= ~0x100000;
2746 v109 = pBitmaps_LOD->LoadTexture(Dst);
2747 v110 = v6->pFaceExtras;
2748 v111 = *(int *)((char *)&uSourceLen + 1);
2749 ++v245;
2750 *(int *)((char *)&uSourceLen + 1) += 36;
2751 *(unsigned __int16 *)((char *)&v110->uAdditionalBitmapID + v111) = v109;
2752 } 2716 }
2753 while ( v245 < (signed int)v6->uNumFaceExtras ); 2717 }
2754 } 2718
2755 v11 = v6->uNumFaces == 0;
2756 v12 = (v6->uNumFaces & 0x80000000u) != 0;
2757 v245 = 0;
2758 if ( !(v12 | v11) )
2759 {
2760 v244 = 0;
2761 do
2762 {
2763 v112 = &v6->pFaceExtras[*(short *)((char *)&v244->pDecorationIDs + (unsigned int)v6->pFaces)];
2764 if ( v112->uEventID )
2765 {
2766 if ( v112->HasEventint() )
2767 *((char *)&v244->uNumNonBSPFaces + (unsigned int)v6->pFaces) |= 0x10u;
2768 else
2769 *((char *)&v244->uNumNonBSPFaces + (unsigned int)v6->pFaces) &= 0xEFu;
2770 }
2771 ++v245;
2772 v244 = (BLVSector *)((char *)v244 + 96);
2773 }
2774 while ( v245 < (signed int)v6->uNumFaces );
2775 }
2776 pGameLoadingUI_ProgressBar->Progress(); 2719 pGameLoadingUI_ProgressBar->Progress();
2777 memcpy(&v6->uNumSectors, v108, 4u); 2720
2778 v113 = (char *)v108 + 4; 2721 memcpy(&uNumSectors, pData, 4);
2722 memcpy(pSectors, pData + 4, uNumSectors * sizeof(BLVSector));
2723 pData += 4 + uNumSectors * sizeof(BLVSector);
2724
2779 pGameLoadingUI_ProgressBar->Progress(); 2725 pGameLoadingUI_ProgressBar->Progress();
2780 v202 = 116 * v6->uNumSectors; 2726
2781 v201 = (const char *)v113; 2727 ptr_0002B0_sector_rdata = (unsigned short *)pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData");
2782 v200 = (size_t)v6->pSectors; 2728 memcpy(ptr_0002B0_sector_rdata, pData, blv.uSector_rdata_Size);
2783 v245 = v202; 2729 pData += blv.uSector_rdata_Size;
2784 memcpy((void *)v200, v113, v202); 2730
2785 v114 = (char *)v113 + v245; 2731 for (uint i = 0, j = 0; i < uNumSectors; ++i)
2786 v202 = (int)"L.RData"; 2732 {
2787 v201 = (const char *)v6->blv.uSector_rdata_Size; 2733 auto pSector = pSectors + i;
2788 v200 = (size_t)v6->ptr_0002B0_sector_rdata; 2734
2789 v115 = pAllocator->AllocNamedChunk((const void *)v200, (unsigned int)v201, "L.RData"); 2735 pSector->pFloors = ptr_0002B0_sector_rdata + j;
2790 v116 = v6->blv.uSector_rdata_Size; 2736 j += pSector->field_4;
2791 v6->ptr_0002B0_sector_rdata = (unsigned __int16 *)v115; 2737
2792 v245 = v116; 2738 pSector->pWalls = ptr_0002B0_sector_rdata + j;
2793 memcpy(v115, v114, v116); 2739 j += pSector->field_C;
2794 v117 = (char *)v114 + v245; 2740
2795 v118 = 0; 2741 pSector->pCeilings = ptr_0002B0_sector_rdata + j;
2796 v11 = v6->uNumSectors == 0; 2742 j += pSector->field_14;
2797 v12 = v6->uNumSectors < 0; 2743
2798 Src = 0; 2744 pSector->pFluids = ptr_0002B0_sector_rdata + j;
2799 v245 = 0; 2745 j += pSector->field_1C;
2800 if ( !(v12 | v11) ) 2746
2801 { 2747 pSector->pPortals = ptr_0002B0_sector_rdata + j;
2802 do 2748 j += pSector->uNumPortals;
2803 { 2749
2804 v6->pSectors[v118].pFloors = (unsigned __int16 *)((char *)Src + (unsigned int)v6->ptr_0002B0_sector_rdata); 2750 pSector->pFaceIDs = ptr_0002B0_sector_rdata + j;
2805 v244 = &v6->pSectors[v118]; 2751 j += pSector->field_2C;
2806 v119 = v6->ptr_0002B0_sector_rdata; 2752
2753 pSector->pCogs = ptr_0002B0_sector_rdata + j;
2754 j += pSector->field_3C;
2755
2756 pSector->pDecorationIDs = ptr_0002B0_sector_rdata + j;
2757 j += pSector->uNumDecorations;
2758
2759 pSector->pMarkers = ptr_0002B0_sector_rdata + j;
2760 j += pSector->field_4C;
2761
2762
2763 //do
2764 //{
2765 /*pSectors[v118].pFloors = (unsigned __int16 *)((char *)Src + (unsigned int)ptr_0002B0_sector_rdata);
2766 v244 = &pSectors[v118];
2767 v119 = ptr_0002B0_sector_rdata;
2807 Src = (BLVFace *)((char *)Src + 2 * v244->field_4); 2768 Src = (BLVFace *)((char *)Src + 2 * v244->field_4);
2808 v244->pWalls = (unsigned __int16 *)((char *)v119 + (int)Src); 2769 v244->pWalls = (unsigned __int16 *)((char *)v119 + (int)Src);
2809 v120 = (int)&v6->pSectors[v118]; 2770 v120 = (int)&pSectors[v118];
2810 v244 = (BLVSector *)v120; 2771 v244 = (BLVSector *)v120;
2811 v121 = (BLVFace *)((char *)Src + 2 * *(short *)(v120 + 12)); 2772 v121 = (BLVFace *)((char *)Src + 2 * *(short *)(v120 + 12));
2812 v122 = (unsigned __int16 *)((char *)v121 + (unsigned int)v6->ptr_0002B0_sector_rdata); 2773 v122 = (unsigned __int16 *)((char *)v121 + (unsigned int)ptr_0002B0_sector_rdata);
2813 Src = v121; 2774 Src = v121;
2814 v244->pCeilings = v122; 2775 v244->pCeilings = v122;
2815 v123 = (int)&v6->pSectors[v118]; 2776 v123 = (int)&pSectors[v118];
2816 v244 = (BLVSector *)v123; 2777 v244 = (BLVSector *)v123;
2817 v124 = (BLVFace *)((char *)Src + 2 * *(short *)(v123 + 20)); 2778 v124 = (BLVFace *)((char *)Src + 2 * *(short *)(v123 + 20));
2818 v125 = (unsigned __int16 *)((char *)v124 + (unsigned int)v6->ptr_0002B0_sector_rdata); 2779 v125 = (unsigned __int16 *)((char *)v124 + (unsigned int)ptr_0002B0_sector_rdata);
2819 Src = v124; 2780 Src = v124;
2820 v244->pFluids = v125; 2781 v244->pFluids = v125;
2821 v244 = &v6->pSectors[v118]; 2782 v244 = &pSectors[v118];
2822 v126 = v6->ptr_0002B0_sector_rdata; 2783 v126 = ptr_0002B0_sector_rdata;
2823 Src = (BLVFace *)((char *)Src + 2 * v244->field_1C); 2784 Src = (BLVFace *)((char *)Src + 2 * v244->field_1C);
2824 v244->pPortals = (unsigned __int16 *)((char *)v126 + (int)Src); 2785 v244->pPortals = (unsigned __int16 *)((char *)v126 + (int)Src);
2825 v244 = &v6->pSectors[v118]; 2786 v244 = &pSectors[v118];
2826 v127 = v6->ptr_0002B0_sector_rdata; 2787 v127 = ptr_0002B0_sector_rdata;
2827 Src = (BLVFace *)((char *)Src + 2 * v244->uNumPortals); 2788 Src = (BLVFace *)((char *)Src + 2 * v244->uNumPortals);
2828 v244->pFaceIDs = (unsigned __int16 *)((char *)v127 + (int)Src); 2789 v244->pFaceIDs = (unsigned __int16 *)((char *)v127 + (int)Src);
2829 v244 = &v6->pSectors[v118]; 2790 v244 = &pSectors[v118];
2830 v128 = v6->ptr_0002B0_sector_rdata; 2791 v128 = ptr_0002B0_sector_rdata;
2831 Src = (BLVFace *)((char *)Src + 2 * v244->field_2C); 2792 Src = (BLVFace *)((char *)Src + 2 * v244->field_2C);
2832 v244->pCogs = (unsigned __int16 *)((char *)v128 + (int)Src); 2793 v244->pCogs = (unsigned __int16 *)((char *)v128 + (int)Src);
2833 v244 = &v6->pSectors[v118]; 2794 v244 = &pSectors[v118];
2834 v129 = v6->ptr_0002B0_sector_rdata; 2795 v129 = ptr_0002B0_sector_rdata;
2835 Src = (BLVFace *)((char *)Src + 2 * v244->field_3C); 2796 Src = (BLVFace *)((char *)Src + 2 * v244->field_3C);
2836 v244->pDecorationIDs = (unsigned __int16 *)((char *)v129 + (int)Src); 2797 v244->pDecorationIDs = (unsigned __int16 *)((char *)v129 + (int)Src);
2837 v130 = (int)&v6->pSectors[v118]; 2798 v130 = (int)&pSectors[v118];
2838 ++v118; 2799 ++v118;
2839 v244 = (BLVSector *)v130; 2800 v244 = (BLVSector *)v130;
2840 v131 = v6->ptr_0002B0_sector_rdata; 2801 v131 = ptr_0002B0_sector_rdata;
2841 Src = (BLVFace *)((char *)Src + 2 * *(short *)(v130 + 68)); 2802 Src = (BLVFace *)((char *)Src + 2 * *(short *)(v130 + 68));
2842 ++v245; 2803 ++v245;
2843 *(int *)(v130 + 80) = (int)(char *)v131 + (int)Src; 2804 *(int *)(v130 + 80) = (int)(char *)v131 + (int)Src;
2844 Src = (BLVFace *)((char *)Src + 2 * *((short *)&v6->pSectors[v118] - 20)); 2805 Src = (BLVFace *)((char *)Src + 2 * *((short *)&pSectors[v118] - 20));*/
2845 } 2806 //}
2846 while ( v245 < v6->uNumSectors ); 2807 //while ( v245 < uNumSectors );
2847 } 2808 }
2848 v202 = (int)"L.RLData"; 2809
2849 v201 = (const char *)v6->blv.uSector_lrdata_Size; 2810 ptr_0002B8_sector_lrdata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B8_sector_lrdata, blv.uSector_lrdata_Size, "L.RLData");
2850 v200 = (size_t)v6->ptr_0002B8_sector_lrdata; 2811 memcpy(ptr_0002B8_sector_lrdata, pData, blv.uSector_lrdata_Size);
2851 v132 = pAllocator->AllocNamedChunk((const void *)v200, (unsigned int)v201, "L.RLData"); 2812 pData += blv.uSector_lrdata_Size;
2852 v133 = v6->blv.uSector_lrdata_Size; 2813
2853 v6->ptr_0002B8_sector_lrdata = (unsigned __int16 *)v132;
2854 v245 = v133;
2855 memcpy(v132, v117, v133);
2856 v134 = (char *)v117 + v245;
2857 pGameLoadingUI_ProgressBar->Progress(); 2814 pGameLoadingUI_ProgressBar->Progress();
2858 v11 = v6->uNumSectors == 0; 2815
2859 v12 = v6->uNumSectors < 0; 2816 for (uint i = 0, j = 0; i < uNumSectors; ++i)
2860 Src = 0; 2817 {
2861 v245 = 0; 2818 pSectors->pLights = (BLVLightMM7 *)(ptr_0002B8_sector_lrdata + j);
2862 if ( !(v12 | v11) ) 2819 j += pSectors->uNumLights;
2863 { 2820 }
2864 v135 = v6->pSectors; 2821
2865 v136 = 0; 2822 pGameLoadingUI_ProgressBar->Progress();
2866 for ( File = 0; ; v136 = File ) 2823
2824 memcpy(&uNumDoors, pData, 4);
2825 pData += 4;
2826
2827 pGameLoadingUI_ProgressBar->Progress();
2828 pGameLoadingUI_ProgressBar->Progress();
2829
2830 memcpy(&uNumLevelDecorations, pData, 4);
2831 memcpy(pLevelDecorations, pData + 4, uNumLevelDecorations * sizeof(LevelDecoration));
2832 pData += 4 + uNumLevelDecorations * sizeof(LevelDecoration);
2833
2834 for (uint i = 0; i < uNumLevelDecorations; ++i)
2835 {
2836 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pData);
2837
2838 pData += 32;
2839 }
2840
2841 pGameLoadingUI_ProgressBar->Progress();
2842
2843 memcpy(&uNumLights, pData, 4);
2844 memcpy(pLights, pData + 4, uNumLights * sizeof(BLVLightMM7));
2845 pData += 4 + uNumLights * sizeof(BLVLightMM7);
2846
2847 pGameLoadingUI_ProgressBar->Progress();
2848 pGameLoadingUI_ProgressBar->Progress();
2849
2850 memcpy(&uNumNodes, pData, 4);
2851 memcpy(pNodes, pData + 4, uNumNodes * sizeof(BSPNode));
2852 pData += 4 + uNumNodes * sizeof(BSPNode);
2853
2854 pGameLoadingUI_ProgressBar->Progress();
2855 pGameLoadingUI_ProgressBar->Progress();
2856
2857 memcpy(&uNumSpawnPoints, pData, 4);
2858 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, uNumSpawnPoints * sizeof(SpawnPointMM7), "Spawn");
2859 memcpy(pSpawnPoints, pData + 4, uNumSpawnPoints * sizeof(SpawnPointMM7));
2860 pData += 4 + uNumSpawnPoints * sizeof(SpawnPointMM7);
2861
2862 pGameLoadingUI_ProgressBar->Progress();
2863 pGameLoadingUI_ProgressBar->Progress();
2864
2865 //v201 = (const char *)v148;
2866 //v200 = (size_t)pMapVertices;
2867 memcpy(&pMapVertices->uNumVertices, pData, 4);
2868 memcpy(pMapVertices->pVertices, pData + 4, pMapVertices->uNumVertices * sizeof(Vec3_int_));
2869 //v149 = pMapVertices;
2870 //v199 = 12 * *v149;
2871 //memcpy(v149 + 1, (const void *)(v148 + 4), v199);
2872 free(pRawBLV);
2873 pRawBLV = nullptr;
2874
2875 void *pRawDLV = nullptr;
2876 strcpy(&pFilename[strlen(pFilename) - 4], ".dlv");
2877 File = pNew_LOD->FindContainer(pFilename, 1);
2878 fread(&header, 0x10u, 1u, File);//(FILE *)v245);
2879 bool _v244 = false;
2880 if (header.uVersion != 91969 ||
2881 header.pMagic[0] != 'm' ||
2882 header.pMagic[1] != 'v' ||
2883 header.pMagic[2] != 'i' ||
2884 header.pMagic[3] != 'i' )
2885 {
2886 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1090", 0);
2887 _v244 = true;
2888 }
2889 else
2890 {
2891 pRawDLV = malloc(header.uDecompressedSize);
2892 if (header.uCompressedSize == header.uDecompressedSize)
2893 fread(pRawDLV, 1, header.uCompressedSize, File);
2894 else if (header.uCompressedSize < header.uDecompressedSize)
2867 { 2895 {
2868 v137 = v6->ptr_0002B8_sector_lrdata; 2896 auto pTmpMem = malloc(header.uCompressedSize);
2869 File = (FILE *)((char *)File + 116);
2870 ++v245;
2871 *(int *)((char *)&v136[2]._bufsiz + (int)v135) = (int)((char *)v137 + (int)Src);
2872 v135 = v6->pSectors;
2873 Src = (BLVFace *)((char *)Src + 2 * *(short *)((char *)&v136[2]._charbuf + (int)v135));
2874 if ( v245 >= v6->uNumSectors )
2875 break;
2876 }
2877 }
2878 pGameLoadingUI_ProgressBar->Progress();
2879 memcpy(&v6->uNumDoors, v134, 4u);
2880 v138 = (char *)v134 + 4;
2881 pGameLoadingUI_ProgressBar->Progress();
2882 memcpy(&uNumLevelDecorations, v138, 4u);
2883 v138 = (char *)v138 + 4;
2884 pGameLoadingUI_ProgressBar->Progress();
2885 v245 = 32 * uNumLevelDecorations;
2886 memcpy(pLevelDecorations, v138, 32 * uNumLevelDecorations);
2887 v139 = (char *)v138 + v245;
2888 v245 = 0;
2889 if ( (signed int)uNumLevelDecorations > 0 )
2890 {
2891 File = (FILE *)pLevelDecorations;
2892 do
2893 {
2894 memcpy(pName, v139, 0x20u);
2895 v139 = (char *)v139 + 32;
2896 v140 = pDecorationList->GetDecorIdByName(pName);
2897 v141 = File;
2898 ++v245;
2899 ++File;
2900 LOWORD(v141->_ptr) = v140;
2901 }
2902 while ( v245 < (signed int)uNumLevelDecorations );
2903 }
2904 pGameLoadingUI_ProgressBar->Progress();
2905 memcpy(&v6->uNumLights, v139, 4u);
2906 v142 = (char *)v139 + 4;
2907 pGameLoadingUI_ProgressBar->Progress();
2908 v202 = 16 * v6->uNumLights;
2909 v201 = (const char *)v142;
2910 v200 = (size_t)v6->pLights;
2911 v245 = v202;
2912 memcpy((void *)v200, v142, v202);
2913 v143 = (char *)v142 + v245;
2914 pGameLoadingUI_ProgressBar->Progress();
2915 memcpy(&v6->uNumNodes, v143, 4u);
2916 v143 = (char *)v143 + 4;
2917 pGameLoadingUI_ProgressBar->Progress();
2918 v202 = 8 * v6->uNumNodes;
2919 v201 = (const char *)v143;
2920 v200 = (size_t)v6->pNodes;
2921 v245 = v202;
2922 memcpy((void *)v200, v143, v202);
2923 v144 = (char *)v143 + v245;
2924 pGameLoadingUI_ProgressBar->Progress();
2925 memcpy(&v6->uNumSpawnPoints, v144, 4u);
2926 v144 = (char *)v144 + 4;
2927 pGameLoadingUI_ProgressBar->Progress();
2928 v145 = v6->uNumSpawnPoints;
2929 v202 = (int)"Spawn";
2930 v201 = (const char *)(24 * v145);
2931 v200 = (size_t)v6->pSpawnPoints;
2932 v146 = pAllocator->AllocNamedChunk((const void *)v200, 24 * v145, "Spawn");
2933 v147 = v6->uNumSpawnPoints;
2934 v6->pSpawnPoints = (SpawnPointMM7 *)v146;
2935 v245 = 24 * v147;
2936 memcpy(v146, v144, 24 * v147);
2937 v148 = (int)((char *)v144 + v245);
2938 pGameLoadingUI_ProgressBar->Progress();
2939 v202 = 4;
2940 v201 = (const char *)v148;
2941 v200 = (size_t)v6->pMapVertices;
2942 memcpy((void *)v200, (const void *)v148, 4u);
2943 v149 = v6->pMapVertices;
2944 v199 = 12 * *v149;
2945 memcpy(v149 + 1, (const void *)(v148 + 4), v199);
2946 free(ptr);
2947 v202 = (int)".dlv";
2948 v150 = strlen(pFilename);
2949 strcpy(&v238[v150], (const char *)v202);
2950 v245 = (int)pNew_LOD->FindContainer(pFilename, 1);
2951 fread(&header, 0x10u, 1u, (FILE *)v245);
2952 v244 = 0;
2953 if ( header.uVersion != 91969
2954 || header.pMagic[0] != 'm'
2955 || header.pMagic[1] != 'v'
2956 || header.pMagic[2] != 'i'
2957 || header.pMagic[3] != 'i' )
2958 {
2959 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1090", 0);
2960 v244 = (BLVSector *)1;
2961 }
2962 v151 = header.uCompressedSize;
2963 Count = header.uDecompressedSize;
2964 Src = 0;
2965 File = 0;
2966 if ( !v244 )
2967 {
2968 Src = (BLVFace *)malloc(header.uDecompressedSize);
2969 File = (FILE *)Src;
2970 if ( v151 <= Count )
2971 {
2972 if ( v151 == Count )
2973 { 2897 {
2974 fread(Src, 1u, Count, (FILE *)v245); 2898 fread(pTmpMem, header.uCompressedSize, 1, File);
2899
2900 uint uDecompressedSize = header.uDecompressedSize;
2901 zlib::MemUnzip(pRawDLV, &uDecompressedSize, pTmpMem, header.uCompressedSize);
2902
2903 if (uDecompressedSize != header.uDecompressedSize)
2904 Log::Warning(L"uDecompressedSize != header.uDecompressedSize in DLV");
2975 } 2905 }
2976 else 2906 free(pTmpMem);
2977 {
2978 *(int *)((char *)&uSourceLen + 1) = (int)malloc(v151);
2979 fread(*(void **)((char *)&uSourceLen + 1), v151, 1u, (FILE *)v245);
2980 zlib::MemUnzip(Src, &Count, *(const void **)((char *)&uSourceLen + 1), v151);
2981 free(*(void **)((char *)&uSourceLen + 1));
2982 }
2983 } 2907 }
2984 else 2908 else
2909 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1108", 0);
2910
2911 pData = (char *)pRawDLV;
2912 }
2913
2914 memcpy(&dlv, pData, 40);
2915 pData += 40;
2916
2917 //v152 = dlv.uNumFacesInBModels;
2918 if (dlv.uNumFacesInBModels)
2919 {
2920 //v153 = dlv.uNumDecorations;
2921 if (dlv.uNumDecorations)
2985 { 2922 {
2986 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1108", 0); 2923 if (dlv.uNumFacesInBModels != uNumFaces ||
2924 dlv.uNumDecorations != uNumLevelDecorations)
2925 _v244 = true;
2987 } 2926 }
2988 memcpy(&v6->dlv, Src, 0x28u); 2927 }
2989 Src = (BLVFace *)((char *)Src + 40); 2928
2990 } 2929 if (dword_6BE364_game_settings_1 & 0x2000 )
2991 v152 = v6->dlv.uNumFacesInBModels; 2930 _i = 29030400;
2992 if ( v152 ) 2931 bool _a = false;
2993 { 2932 if ( a3 - dlv.uLastRepawnDay >= _i && strcmpi(pCurrentMapName, "d29.dlv") )
2994 v153 = v6->dlv.uNumDecorations; 2933 _a = true;
2995 if ( v153 ) 2934
2996 { 2935 //v154 = 875;
2997 if ( v152 != pIndoor->uNumFaces || v153 != uNumLevelDecorations ) 2936 if (_v244)
2998 v244 = (BLVSector *)1; 2937 {
2999 } 2938 memset(v203, 0, 0x36B);
3000 }
3001 if ( BYTE1(dword_6BE364_game_settings_1) & 0x20 )
3002 i = 29030400;
3003 *(int *)((char *)&uSourceLen + 1) = 0;
3004 if ( a3 - v6->dlv.uLastRepawnDay >= i && _strcmpi(pCurrentMapName, "d29.dlv") )
3005 *(int *)((char *)&uSourceLen + 1) = 1;
3006 v154 = 875;
3007 if ( v244 )
3008 {
3009 memset(v203, 0, 0x36Bu);
3010 goto LABEL_132; 2939 goto LABEL_132;
3011 } 2940 }
3012 if ( *(int *)((char *)&uSourceLen + 1) || !v6->dlv.uLastRepawnDay ) 2941 if (_a || !dlv.uLastRepawnDay )
3013 { 2942 {
3014 memcpy(v203, Src, 0x36Bu); 2943 memcpy(v203, pData, 0x36B);
3015 LABEL_132: 2944 LABEL_132:
3016 free(File); 2945 free(File);
3017 v11 = v244 == (BLVSector *)1; 2946 dlv.uLastRepawnDay = a3;
3018 v6->dlv.uLastRepawnDay = a3; 2947 if (_v244)
3019 if ( v11 ) 2948 ++dlv.uNumRespawns;
3020 ++v6->dlv.uNumRespawns; 2949 //v201 = pFilename;
3021 v202 = 0;
3022 v201 = pFilename;
3023 *(int *)pDest = 1; 2950 *(int *)pDest = 1;
3024 v245 = (int)pGames_LOD->FindContainer(v201, v202); 2951 File = pGames_LOD->FindContainer(pFilename, 0);
3025 fread(&header, 0x10u, 1u, (FILE *)v245); 2952 fread(&header, 0x10u, 1u, File);
3026 v155 = header.uCompressedSize; 2953 auto v155 = header.uCompressedSize;
3027 Count = header.uDecompressedSize; 2954 auto Count = header.uDecompressedSize;
3028 Src = (BLVFace *)malloc(header.uDecompressedSize); 2955 auto Src = (BLVFace *)malloc(header.uDecompressedSize);
3029 File = (FILE *)Src; 2956 File = (FILE *)Src;
3030 if ( v155 <= Count ) 2957 if ( v155 <= Count )
3031 { 2958 {
3032 if ( v155 == Count ) 2959 if ( v155 == Count )
3033 { 2960 {
3034 fread(Src, 1u, Count, (FILE *)v245); 2961 fread(Src, 1u, Count, File);
3035 } 2962 }
3036 else 2963 else
3037 { 2964 {
3038 *(int *)((char *)&uSourceLen + 1) = (int)malloc(v155); 2965 auto _uSourceLen = malloc(v155);
3039 fread(*(void **)((char *)&uSourceLen + 1), v155, 1u, (FILE *)v245); 2966 fread(_uSourceLen, v155, 1u, File);
3040 zlib::MemUnzip(Src, &Count, *(const void **)((char *)&uSourceLen + 1), v155); 2967 zlib::MemUnzip(Src, &Count, _uSourceLen, v155);
3041 free(*(void **)((char *)&uSourceLen + 1)); 2968 free(_uSourceLen);
3042 } 2969 }
3043 } 2970 }
3044 else 2971 else
3045 { 2972 {
3046 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0); 2973 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0);
3047 } 2974 }
3048 Src = (BLVFace *)((char *)Src + 40); 2975 pData = ((char *)Src + 40);
3049 v154 = 875; 2976 //v154 = 875;
3050 goto LABEL_140; 2977 goto LABEL_140;
3051 } 2978 }
3052 *(int *)pDest = 0; 2979 *(int *)pDest = 0;
3053 LABEL_140: 2980 LABEL_140:
3054 v202 = (int)".blv"; 2981 //v202 = (int)".blv";
3055 v156 = strlen(pFilename); 2982 //v156 = strlen(pFilename);
3056 strcpy(&v238[v156], (const char *)v202); 2983 strcpy(&pFilename[strlen(pFilename) - 4], ".blv");
3057 memcpy(v6->_visible_outlines, Src, v154); 2984 memcpy(_visible_outlines, pData, 875);
3058 Src = (BLVFace *)((char *)Src + v154); 2985 pData += 875;
2986
3059 if ( *(int *)pDest ) 2987 if ( *(int *)pDest )
3060 memcpy(v6->_visible_outlines, v203, v154); 2988 memcpy(_visible_outlines, v203, 875);
3061 v157 = 0; 2989
3062 if ( (signed int)*pIndoor->pMapVertices > 0 ) 2990 for (uint i = 0; i < pMapVertices->uNumVertices; ++i)
3063 { 2991 {
3064 Argsk = 0; 2992 auto pVertex = pMapVertices->pVertices + i;
3065 do 2993 if ((unsigned __int8)(1 << (7 - i % 8)) & _visible_outlines[i / 8])
2994 pVertex->uFlags |= 1;
2995 }
2996
2997
2998 for (uint i = 0; i < uNumFaces; ++i)
2999 {
3000 auto pFace = pFaces + i;
3001 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID;
3002
3003 memcpy(&pFace->uAttributes, pData, 4);
3004 pData += 4;
3005
3006 if (pFaceExtra->uEventID)
3066 { 3007 {
3067 if ( (unsigned __int8)(1 << (7 - v157 % 8)) & v6->_visible_outlines[v157 / 8] ) 3008 if (pFaceExtra->HasEventint())
3068 BYTE2(v6->pMapVertices[Argsk + 3]) |= 1u; 3009 pFace->uAttributes |= 0x100000;
3069 Argsk += 3; 3010 else
3070 ++v157; 3011 pFace->uAttributes &= ~0x100000;
3071 } 3012 }
3072 while ( v157 < (signed int)*pIndoor->pMapVertices ); 3013 }
3073 } 3014
3074 v245 = 0; 3015 pGameLoadingUI_ProgressBar->Progress();
3075 if ( (signed int)v6->uNumFaces > 0 ) 3016
3076 { 3017 for (uint i = 0; i < uNumLevelDecorations; ++i)
3077 v158 = 0; 3018 {
3078 do 3019 memcpy(&pLevelDecorations[i].field_2, pData, 2);
3020 pData += 2;
3021 }
3022
3023 pGameLoadingUI_ProgressBar->Progress();
3024
3025 memcpy(&uNumActors, pData, 4);
3026 memcpy(pActors, pData + 4, uNumActors * sizeof(Actor));
3027 pData += 4 + uNumActors * sizeof(Actor);
3028
3029 pGameLoadingUI_ProgressBar->Progress();
3030 pGameLoadingUI_ProgressBar->Progress();
3031
3032 memcpy(&uNumLayingItems, pData, 4);
3033 memcpy(pLayingItems, pData + 4, uNumLayingItems * sizeof(LayingItem));
3034 pData += 4 + uNumLayingItems * sizeof(LayingItem);
3035
3036 pGameLoadingUI_ProgressBar->Progress();
3037
3038 for (uint i = 0; i < uNumLayingItems; ++i)
3039 {
3040 auto pItem = pLayingItems + i;
3041
3042 if (pItem->stru_24.uItemID && !(pItem->uAttributes & 0x0100))
3079 { 3043 {
3080 v200 = (size_t)&v6->pFaces[v158].uAttributes; 3044 pItem->uItemType = pItemsTable->pItems[pItem->stru_24.uItemID - 1].uSpriteID;
3081 memcpy((void *)v200, Src, 4u); 3045
3082 v159 = v6->pFaces; 3046 uint uObjectID = 0;
3083 v160 = v6->pFaceExtras; 3047 for (uint j = 0; j < pObjectList->uNumObjects; ++j)
3084 Src = (BLVFace *)((char *)Src + 4); 3048 if (pItem->uItemType == pObjectList->pObjects[j].uObjectID)
3085 v161 = &v160[v159[v158].uFaceExtraID]; 3049 {
3086 if ( v161->uEventID ) 3050 pItem->uObjectDescID = j;
3087 { 3051 break;
3088 if ( v161->HasEventint() ) 3052 }
3089 BYTE2(v6->pFaces[v158].uAttributes) |= 0x10u;
3090 else
3091 BYTE2(v6->pFaces[v158].uAttributes) &= 0xEFu;
3092 }
3093 ++v245;
3094 ++v158;
3095 } 3053 }
3096 while ( v245 < (signed int)v6->uNumFaces ); 3054 }
3097 } 3055
3098 pGameLoadingUI_ProgressBar->Progress(); 3056 pGameLoadingUI_ProgressBar->Progress();
3099 v162 = 0; 3057
3100 if ( (signed int)uNumLevelDecorations > 0 ) 3058 memcpy(&uNumChests, pData, 4);
3101 { 3059 memcpy(pChests, pData + 4, uNumChests * sizeof(Chest));
3102 Argsl = &pLevelDecorations[0].field_2; 3060 pData += 4 + uNumChests * sizeof(Chest);
3103 do 3061
3104 {
3105 memcpy(Argsl, Src, 2u);
3106 Src = (BLVFace *)((char *)Src + 2);
3107 Argsl = (char *)Argsl + 32;
3108 ++v162;
3109 }
3110 while ( v162 < (signed int)uNumLevelDecorations );
3111 }
3112 pGameLoadingUI_ProgressBar->Progress(); 3062 pGameLoadingUI_ProgressBar->Progress();
3113 memcpy(&uNumActors, Src, 4u);
3114 Src = (BLVFace *)((char *)Src + 4);
3115 pGameLoadingUI_ProgressBar->Progress(); 3063 pGameLoadingUI_ProgressBar->Progress();
3116 v163 = 836 * uNumActors; 3064
3117 memcpy(pActors, Src, 836 * uNumActors); 3065 memcpy(pDoors, pData, 0x3E80);
3118 Src = (BLVFace *)((char *)Src + v163); 3066 pData += 0x3E80;
3119 pGameLoadingUI_ProgressBar->Progress(); 3067
3120 memcpy(&uNumLayingItems, Src, 4u); 3068 //v201 = (const char *)blv.uDoors_ddata_Size;
3121 Src = (BLVFace *)((char *)Src + 4); 3069 //v200 = (size_t)ptr_0002B4_doors_ddata;
3122 pGameLoadingUI_ProgressBar->Progress(); 3070 //v170 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData");
3123 v164 = 112 * uNumLayingItems; 3071 //v171 = blv.uDoors_ddata_Size;
3124 memcpy(pLayingItems, Src, 112 * uNumLayingItems); 3072 ptr_0002B4_doors_ddata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData");
3125 Src = (BLVFace *)((char *)Src + v164); 3073 memcpy(ptr_0002B4_doors_ddata, pData, blv.uDoors_ddata_Size);
3126 if ( (signed int)uNumLayingItems > 0 ) 3074 pData += blv.uDoors_ddata_Size;
3127 { 3075
3128 v165 = pObjectList->uNumObjects; 3076 //Src = (BLVFace *)((char *)Src + v171);
3129 v166 = (char *)&pLayingItems[0].stru_24; 3077 //v172 = 0;
3130 i = uNumLayingItems; 3078 //v245 = 0;
3131 do 3079 //if (uNumDoors > 0)
3132 { 3080 for (uint i = 0, j = 0; i < uNumDoors; ++i)
3133 if ( *(int *)v166 && !(*(v166 - 9) & 1) ) 3081 {
3134 { 3082 auto pDoor = pDoors + i;
3135 Argsm = 0; 3083
3136 v167 = pItemsTable->pItems[*(int *)v166].uSpriteID; 3084 pDoor->pVertexIDs = ptr_0002B4_doors_ddata + j;
3137 *((short *)v166 - 18) = v167; 3085 j += pDoor->uNumVertices;
3138 if ( (signed int)v165 <= 0 ) 3086
3139 { 3087 pDoor->pFaceIDs = ptr_0002B4_doors_ddata + j;
3140 LABEL_165: 3088 j += pDoor->uNumFaces;
3141 v168 = 0; 3089
3142 } 3090 pDoor->pSectorIDs = ptr_0002B4_doors_ddata + j;
3143 else 3091 j += pDoor->field_48;
3144 { 3092
3145 pDest = (char *)&pObjectList->pObjects->uObjectID; 3093 pDoor->pDeltaUs = (short *)(ptr_0002B4_doors_ddata + j);
3146 while ( v167 != *(short *)pDest ) 3094 j += pDoor->uNumFaces;
3147 { 3095
3148 ++Argsm; 3096 pDoor->pDeltaVs = (short *)(ptr_0002B4_doors_ddata + j);
3149 pDest += 56; 3097 j += pDoor->uNumFaces;
3150 if ( Argsm >= (signed int)v165 ) 3098
3151 goto LABEL_165; 3099 pDoor->pXOffsets = ptr_0002B4_doors_ddata + j;
3152 } 3100 j += pDoor->uNumOffsets;
3153 v168 = Argsm; 3101
3154 } 3102 pDoor->pYOffsets = ptr_0002B4_doors_ddata + j;
3155 *((short *)v166 - 17) = v168; 3103 j += pDoor->uNumOffsets;
3156 } 3104
3157 v166 += 112; 3105 pDoor->pZOffsets = ptr_0002B4_doors_ddata + j;
3158 --i; 3106 j += pDoor->uNumOffsets;
3159 } 3107 /*v173 = pDoors;
3160 while ( i );
3161 }
3162 pGameLoadingUI_ProgressBar->Progress();
3163 memcpy(&uNumChests, Src, 4u);
3164 Src = (BLVFace *)((char *)Src + 4);
3165 pGameLoadingUI_ProgressBar->Progress();
3166 v169 = 5324 * uNumChests;
3167 memcpy(pChests, Src, 5324 * uNumChests);
3168 Src = (BLVFace *)((char *)Src + v169);
3169 pGameLoadingUI_ProgressBar->Progress();
3170 v202 = 16000;
3171 v201 = (const char *)Src;
3172 v200 = (size_t)v6->pDoors;
3173 memcpy((void *)v200, Src, 0x3E80u);
3174 Src = (BLVFace *)((char *)Src + 16000);
3175 v202 = (int)"L.DData";
3176 v201 = (const char *)v6->blv.uDoors_ddata_Size;
3177 v200 = (size_t)v6->ptr_0002B4_doors_ddata;
3178 v170 = pAllocator->AllocNamedChunk((const void *)v200, (unsigned int)v201, "L.DData");
3179 v171 = v6->blv.uDoors_ddata_Size;
3180 v6->ptr_0002B4_doors_ddata = (unsigned __int16 *)v170;
3181 memcpy(v170, Src, v171);
3182 Src = (BLVFace *)((char *)Src + v171);
3183 v172 = 0;
3184 v11 = v6->uNumDoors == 0;
3185 v12 = v6->uNumDoors < 0;
3186 v245 = 0;
3187 if ( !(v12 | v11) )
3188 {
3189 v173 = v6->pDoors;
3190 for ( k = 0; ; v172 = v188 + 2 * *((short *)&v173[k] - 3) ) 3108 for ( k = 0; ; v172 = v188 + 2 * *((short *)&v173[k] - 3) )
3191 { 3109 {
3192 v173[k].pVertexIDs = (unsigned __int16 *)((char *)v6->ptr_0002B4_doors_ddata + v172); 3110 v173[k].pVertexIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v172);
3193 v175 = &v6->pDoors[k]; 3111 v175 = &pDoors[k];
3194 v176 = v172 + 2 * v175->uNumVertices; 3112 v176 = v172 + 2 * v175->uNumVertices;
3195 v175->pFaceIDs = (unsigned __int16 *)((char *)v6->ptr_0002B4_doors_ddata + v176); 3113 v175->pFaceIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v176);
3196 v177 = &v6->pDoors[k]; 3114 v177 = &pDoors[k];
3197 v178 = v176 + 2 * v177->uNumFaces; 3115 v178 = v176 + 2 * v177->uNumFaces;
3198 v177->pSectorIDs = (unsigned __int16 *)((char *)v6->ptr_0002B4_doors_ddata + v178); 3116 v177->pSectorIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v178);
3199 v179 = &v6->pDoors[k]; 3117 v179 = &pDoors[k];
3200 v180 = v178 + 2 * v179->field_48; 3118 v180 = v178 + 2 * v179->field_48;
3201 v179->pDeltaUs = (__int16 *)((char *)v6->ptr_0002B4_doors_ddata + v180); 3119 v179->pDeltaUs = (__int16 *)((char *)ptr_0002B4_doors_ddata + v180);
3202 v181 = &v6->pDoors[k]; 3120 v181 = &pDoors[k];
3203 v182 = v180 + 2 * v181->uNumFaces; 3121 v182 = v180 + 2 * v181->uNumFaces;
3204 v181->pDeltaVs = (__int16 *)((char *)v6->ptr_0002B4_doors_ddata + v182); 3122 v181->pDeltaVs = (__int16 *)((char *)ptr_0002B4_doors_ddata + v182);
3205 v183 = &v6->pDoors[k]; 3123 v183 = &pDoors[k];
3206 v184 = v182 + 2 * v183->uNumFaces; 3124 v184 = v182 + 2 * v183->uNumFaces;
3207 v183->pXOffsets = (unsigned __int16 *)((char *)v6->ptr_0002B4_doors_ddata + v184); 3125 v183->pXOffsets = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v184);
3208 v185 = &v6->pDoors[k]; 3126 v185 = &pDoors[k];
3209 v186 = v184 + 2 * v185->uNumOffsets; 3127 v186 = v184 + 2 * v185->uNumOffsets;
3210 v185->pYOffsets = (unsigned __int16 *)((char *)v6->ptr_0002B4_doors_ddata + v186); 3128 v185->pYOffsets = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v186);
3211 v187 = &v6->pDoors[k]; 3129 v187 = &pDoors[k];
3212 ++k; 3130 ++k;
3213 v188 = v186 + 2 * v187->uNumOffsets; 3131 v188 = v186 + 2 * v187->uNumOffsets;
3214 v189 = (unsigned __int16 *)((char *)v6->ptr_0002B4_doors_ddata + v188); 3132 v189 = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v188);
3215 ++v245; 3133 ++v245;
3216 v187->pZOffsets = v189; 3134 v187->pZOffsets = v189;
3217 v173 = v6->pDoors; 3135 v173 = pDoors;
3218 if ( v245 >= v6->uNumDoors ) 3136 if ( v245 >= uNumDoors )
3219 break; 3137 break;
3138 }*/
3139 }
3140 //v190 = 0;
3141 //v245 = 0;
3142 for (uint i = 0; i < uNumDoors; ++i)
3143 {
3144 auto pDoor = pDoors + i;
3145
3146 for (uint j = 0; j < pDoor->uNumFaces; ++j)
3147 {
3148 auto pFace = pFaces + pDoor->pFaceIDs[j];
3149 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID;
3150
3151 pDoor->pDeltaUs[j] = pFaceExtra->sTextureDeltaU;
3152 pDoor->pDeltaVs[j] = pFaceExtra->sTextureDeltaV;
3220 } 3153 }
3221 } 3154 //v191 = pDoors;
3222 v190 = 0; 3155 //pDest = 0;
3223 v11 = v6->uNumDoors == 0; 3156 //do
3224 v12 = v6->uNumDoors < 0; 3157 // {
3225 v245 = 0; 3158 /*Argsn = 0;
3226 if ( !(v12 | v11) )
3227 {
3228 v191 = v6->pDoors;
3229 pDest = 0;
3230 do
3231 {
3232 Argsn = 0;
3233 for ( l = (BLVDoor *)&v190[(int)v191]; 3159 for ( l = (BLVDoor *)&v190[(int)v191];
3234 Argsn < *(short *)&v190[(int)v191 + 70]; 3160 Argsn < *(short *)&v190[(int)v191 + 70];
3235 l = (BLVDoor *)&v190[(int)v191] ) 3161 l = (BLVDoor *)&v190[(int)v191] )
3236 { 3162 {
3237 v193 = Argsn; 3163 v193 = Argsn;
3238 v194 = l->pFaceIDs[Argsn++]; 3164 v194 = l->pFaceIDs[Argsn++];
3239 v195 = &v6->pFaceExtras[v6->pFaces[v194].uFaceExtraID]; 3165 v195 = &pFaceExtras[pFaces[v194].uFaceExtraID];
3240 l->pDeltaUs[v193] = v195->sTextureDeltaU; 3166 l->pDeltaUs[v193] = v195->sTextureDeltaU;
3241 v190 = pDest; 3167 v190 = pDest;
3242 *(short *)(v193 * 2 + *(int *)&pDest[(unsigned int)v6->pDoors + 52]) = v195->sTextureDeltaV; 3168 *(short *)(v193 * 2 + *(int *)&pDest[(unsigned int)pDoors + 52]) = v195->sTextureDeltaV;
3243 v191 = v6->pDoors; 3169 v191 = pDoors;
3244 } 3170 }
3245 ++v245; 3171 ++v245;
3246 v190 += 80; 3172 v190 += 80;
3247 pDest = v190; 3173 pDest = v190;*/
3248 } 3174 //}
3249 while ( v245 < v6->uNumDoors ); 3175 //while ( v245 < uNumDoors );
3250 } 3176 }
3177
3178
3251 pGameLoadingUI_ProgressBar->Progress(); 3179 pGameLoadingUI_ProgressBar->Progress();
3252 v196 = Src; 3180
3253 memcpy(&stru_5E4C90, Src, 0xC8u); 3181 memcpy(&stru_5E4C90, pData, 0xC8);
3182 pData += 0xC8;
3183
3254 pGameLoadingUI_ProgressBar->Progress(); 3184 pGameLoadingUI_ProgressBar->Progress();
3255 memcpy(&v6->uLastVisitDay, &v196[2].pFacePlane.vNormal.z, 0x38u); 3185
3256 free(File); 3186 memcpy(&stru1, pData, 0x38u);
3257 v5 = 0; 3187 pData += 0x38;
3258 LABEL_179: 3188
3259 pSoundList->_4A9A67(64, v5); 3189 free(pRawDLV);
3260 pSoundList->_4A9A67(103, v5); 3190 //v5 = 0;
3261 pSoundList->_4A9A67(63, v5); 3191
3262 pSoundList->_4A9A67(102, v5); 3192 pSoundList->_4A9A67(64, 0);
3263 pSoundList->_4A9A67(50, v5); 3193 pSoundList->_4A9A67(103, 0);
3264 pSoundList->_4A9A67(89, v5); 3194 pSoundList->_4A9A67(63, 0);
3195 pSoundList->_4A9A67(102, 0);
3196 pSoundList->_4A9A67(50, 0);
3197 pSoundList->_4A9A67(89, 0);
3198
3265 return 0; 3199 return 0;
3266 } 3200 }
3267 3201
3268 3202
3269 //----- (0049AC17) -------------------------------------------------------- 3203 //----- (0049AC17) --------------------------------------------------------