Mercurial > might-and-magic-trilogy
comparison Outdoor.cpp @ 127:9eac46182d8f
Слияние
author | Ritor1 |
---|---|
date | Sun, 04 Nov 2012 09:37:39 +0600 |
parents | 2331a331d36a 6305c1cd9f6e |
children | 32805a956f49 |
comparison
equal
deleted
inserted
replaced
126:2331a331d36a | 127:9eac46182d8f |
---|---|
1 #include <assert.h> | |
2 | |
1 #include "Outdoor.h" | 3 #include "Outdoor.h" |
2 #include "Party.h" | 4 #include "Party.h" |
3 #include "LayingItem.h" | 5 #include "LayingItem.h" |
4 #include "LOD.h" | 6 #include "LOD.h" |
5 #include "Render.h" | 7 #include "Render.h" |
1090 v1->pOMAP = 0; | 1092 v1->pOMAP = 0; |
1091 v4 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); | 1093 v4 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); |
1092 v1->pOMAP = (unsigned int *)v4; | 1094 v1->pOMAP = (unsigned int *)v4; |
1093 memset(v4, 0, 0x10000u); | 1095 memset(v4, 0, 0x10000u); |
1094 v5 = v1->pFaceIDLIST; | 1096 v5 = v1->pFaceIDLIST; |
1095 v1->field_DC = 0; | 1097 v1->numFaceIDListElems = 0; |
1096 pAllocator->FreeChunk(v5); | 1098 pAllocator->FreeChunk(v5); |
1097 v1->pFaceIDLIST = 0; | 1099 v1->pFaceIDLIST = 0; |
1098 v6 = pAllocator->AllocNamedChunk(0, 2u, "IDLIST"); | 1100 v6 = pAllocator->AllocNamedChunk(0, 2u, "IDLIST"); |
1099 v1->pFaceIDLIST = (unsigned __int16 *)v6; | 1101 v1->pFaceIDLIST = (unsigned __int16 *)v6; |
1100 *(short *)v6 = 0; | 1102 *(short *)v6 = 0; |
1171 } | 1173 } |
1172 | 1174 |
1173 //----- (0047D0A6) -------------------------------------------------------- | 1175 //----- (0047D0A6) -------------------------------------------------------- |
1174 bool OutdoorLocation::Load(char *pFilename, ODMFace *File, size_t pNumItems, int thisa) | 1176 bool OutdoorLocation::Load(char *pFilename, ODMFace *File, size_t pNumItems, int thisa) |
1175 { | 1177 { |
1176 OutdoorLocation *pOutdoorLocation; // esi@1 | 1178 //OutdoorLocation *pOutdoorLocation; // esi@1 |
1177 bool result; // eax@9 | 1179 /*bool result; // eax@9 |
1178 bool v7; // ebx@9 | 1180 bool v7; // ebx@9 |
1179 size_t v8; // eax@10 | 1181 size_t v8; // eax@10 |
1180 void *v9; // eax@10 | 1182 void *v9; // eax@10 |
1181 void *v10; // eax@10 | 1183 void *v10; // eax@10 |
1182 void *v11; // eax@10 | 1184 void *v11; // eax@10 |
1191 __int16 v20; // ax@16 | 1193 __int16 v20; // ax@16 |
1192 int v21; // ecx@16 | 1194 int v21; // ecx@16 |
1193 ODMFace *v22; // ebx@26 | 1195 ODMFace *v22; // ebx@26 |
1194 LayingItem *pItems; // ecx@27 | 1196 LayingItem *pItems; // ecx@27 |
1195 unsigned int v24; // eax@28 | 1197 unsigned int v24; // eax@28 |
1196 unsigned __int8 v25; // zf@28 | 1198 //unsigned __int8 v25; // zf@28 |
1197 unsigned __int8 v26; // sf@28 | 1199 //unsigned __int8 v26; // sf@28 |
1198 ODMFace *v27; // eax@28 | 1200 ODMFace *v27; // eax@28 |
1199 const char *i; // edx@29 | 1201 const char *i; // edx@29 |
1200 unsigned __int16 v29; // ax@33 | 1202 unsigned __int16 v29; // ax@33 |
1201 unsigned __int16 v30; // ax@37 | 1203 unsigned __int16 v30; // ax@37 |
1202 int v31; // ecx@37 | 1204 int v31; // ecx@37 |
1203 int v32; // eax@38 | 1205 int v32; // eax@38 |
1204 void *v33; // eax@38 | 1206 void *v33; // eax@38 |
1205 TileDesc *v34; // eax@43 | 1207 TileDesc *v34; // eax@43 |
1206 unsigned int v35; // eax@43 | 1208 unsigned int v35; // eax@43 |
1207 unsigned int v36; // edi@43 | 1209 unsigned int v36; // edi@43 |
1208 unsigned int v37; // edi@45 | 1210 unsigned int v37; // edi@45*/ |
1209 size_t v38; // eax@50 | 1211 //size_t v38; // eax@50 |
1210 FILE *v39; // eax@50 | 1212 FILE *v39; // eax@50 |
1211 unsigned int v40; // edi@56 | 1213 //unsigned int v40; // edi@56 |
1212 void *v41; // eax@56 | 1214 //void *v41; // eax@56 |
1213 void *v42; // ebx@56 | 1215 //void *v42; // ebx@56 |
1214 const void *v43; // ebx@59 | 1216 //const void *v43; // ebx@59 |
1215 const void *v44; // ebx@59 | 1217 //const void *v44; // ebx@59 |
1216 unsigned int v45; // eax@59 | 1218 //unsigned int v45; // eax@59 |
1217 BSPModel *v46; // eax@59 | 1219 //BSPModel *v46; // eax@59 |
1218 unsigned int v47; // ecx@59 | 1220 //unsigned int v47; // ecx@59 |
1219 int v48; // ebx@60 | 1221 //int v48; // ebx@60 |
1220 BSPModel *v49; // eax@61 | 1222 //BSPModel *v49; // eax@61 |
1221 BSPModel *v50; // eax@61 | 1223 //BSPModel *v50; // eax@61 |
1222 BSPModel *v51; // eax@61 | 1224 //BSPModel *v51; // eax@61 |
1223 BSPModel *v52; // eax@61 | 1225 //BSPModel *v52; // eax@61 |
1224 BSPModel *v53; // eax@61 | 1226 //BSPModel *v53; // eax@61 |
1225 BSPModel *v54; // ecx@61 | 1227 //BSPModel *v54; // ecx@61 |
1226 BSPModel *v55; // ecx@61 | 1228 //BSPModel *v55; // ecx@61 |
1227 BSPModel *v56; // ecx@61 | 1229 //BSPModel *v56; // ecx@61 |
1228 void *v57; // ST24_4@61 | 1230 //void *v57; // ST24_4@61 |
1229 BSPModel *v58; // ecx@61 | 1231 //BSPModel *v58; // ecx@61 |
1230 void *v59; // ST18_4@61 | 1232 //void *v59; // ST18_4@61 |
1231 BSPModel *v60; // eax@61 | 1233 //BSPModel *v60; // eax@61 |
1232 __int16 v61; // ax@64 | 1234 //__int16 v61; // ax@64 |
1233 unsigned __int16 v62; // ax@65 | 1235 unsigned __int16 v62; // ax@65 |
1234 ODMFace *v63; // ecx@65 | 1236 //ODMFace *v63; // ecx@65 |
1235 unsigned __int16 v64; // ax@80 | 1237 //unsigned __int16 v64; // ax@80 |
1236 const char *v65; // ecx@80 | 1238 //const char *v65; // ecx@80 |
1237 int v66; // eax@81 | 1239 //int v66; // eax@81 |
1238 void *v67; // eax@81 | 1240 //void *v67; // eax@81 |
1239 int v68; // ecx@81 | 1241 //int v68; // ecx@81 |
1240 void *v69; // eax@81 | 1242 //void *v69; // eax@81 |
1241 unsigned int v70; // eax@81 | 1243 //unsigned int v70; // eax@81 |
1242 SpawnPointMM7 *v71; // eax@81 | 1244 //SpawnPointMM7 *v71; // eax@81 |
1243 unsigned int v72; // ecx@81 | 1245 //unsigned int v72; // ecx@81 |
1244 size_t v73; // eax@81 | 1246 //size_t v73; // eax@81 |
1245 int v74; // edi@87 | 1247 //int v74; // edi@87 |
1246 void *v75; // edi@88 | 1248 //void *v75; // edi@88 |
1247 unsigned int v76; // edx@94 | 1249 //unsigned int v76; // edx@94 |
1248 int v77; // ecx@94 | 1250 //int v77; // ecx@94 |
1249 char *v78; // eax@95 | 1251 //char *v78; // eax@95 |
1250 unsigned int v79; // edx@97 | 1252 //unsigned int v79; // edx@97 |
1251 unsigned int v80; // eax@99 | 1253 //unsigned int v80; // eax@99 |
1252 int v81; // eax@107 | 1254 //int v81; // eax@107 |
1253 void *v82; // edi@114 | 1255 //void *v82; // edi@114 |
1254 size_t v83; // eax@120 | 1256 //size_t v83; // eax@120 |
1255 const void *v84; // edi@120 | 1257 //const void *v84; // edi@120 |
1256 const void *v85; // edi@120 | 1258 //const void *v85; // edi@120 |
1257 BSPModel *v86; // eax@124 | 1259 //BSPModel *v86; // eax@124 |
1258 unsigned int v87; // eax@124 | 1260 //unsigned int v87; // eax@124 |
1259 BSPModel *v88; // eax@126 | 1261 //BSPModel *v88; // eax@126 |
1260 BSPModel *v89; // eax@127 | 1262 //BSPModel *v89; // eax@127 |
1261 ODMFace *v90; // eax@129 | 1263 //ODMFace *v90; // eax@129 |
1262 const void *v91; // edi@138 | 1264 //const void *v91; // edi@138 |
1263 const void *v92; // edi@141 | 1265 //const void *v92; // edi@141 |
1264 const void *v93; // edi@141 | 1266 //const void *v93; // edi@141 |
1265 const void *v94; // edi@144 | 1267 //const void *v94; // edi@144 |
1266 const void *v95; // edi@144 | 1268 //const void *v95; // edi@144 |
1267 const char *v96; // edi@147 | 1269 //const char *v96; // edi@147 |
1268 unsigned int v97; // eax@147 | 1270 //unsigned int v97; // eax@147 |
1269 TileDesc *v98; // eax@147 | 1271 //TileDesc *v98; // eax@147 |
1270 unsigned int v99; // eax@147 | 1272 //unsigned int v99; // eax@147 |
1271 int v100; // ecx@150 | 1273 //int v100; // ecx@150 |
1272 unsigned int v101; // eax@157 | 1274 //unsigned int v101; // eax@157 |
1273 int v102; // edi@159 | 1275 int v102; // edi@159 |
1274 void *v103; // [sp-14h] [bp-B94h]@55 | 1276 //void *v103; // [sp-14h] [bp-B94h]@55 |
1275 void *v104; // [sp-10h] [bp-B90h]@59 | 1277 //void *v104; // [sp-10h] [bp-B90h]@59 |
1276 size_t v105; // [sp-Ch] [bp-B8Ch]@59 | 1278 //size_t v105; // [sp-Ch] [bp-B8Ch]@59 |
1277 char *v106; // [sp-8h] [bp-B88h]@59 | 1279 //char *v106; // [sp-8h] [bp-B88h]@59 |
1278 int v107; // [sp-4h] [bp-B84h]@12 | 1280 int v107; // [sp-4h] [bp-B84h]@12 |
1279 int v108; // [sp+0h] [bp-B80h]@10 | 1281 int v108; // [sp+0h] [bp-B80h]@10 |
1280 char Src[968]; // [sp+10h] [bp-B70h]@110 | 1282 char Src[968]; // [sp+10h] [bp-B70h]@110 |
1281 char Dst[968]; // [sp+3D8h] [bp-7A8h]@50 | 1283 char Dst[968]; // [sp+3D8h] [bp-7A8h]@50 |
1282 char Str[256]; // [sp+7A0h] [bp-3E0h]@50 | 1284 /*char Str[256]; // [sp+7A0h] [bp-3E0h]@50 |
1283 char DstBuf; // [sp+8A0h] [bp-2E0h]@10 | 1285 char DstBuf; // [sp+8A0h] [bp-2E0h]@10 |
1284 __int32 Offset; // [sp+8A4h] [bp-2DCh]@10 | 1286 __int32 Offset; // [sp+8A4h] [bp-2DCh]@10 |
1285 __int32 v114; // [sp+8B0h] [bp-2D0h]@10 | 1287 __int32 v114; // [sp+8B0h] [bp-2D0h]@10 |
1286 __int32 v115; // [sp+8BCh] [bp-2C4h]@10 | 1288 __int32 v115; // [sp+8BCh] [bp-2C4h]@10 |
1287 __int32 v116; // [sp+8C8h] [bp-2B8h]@10 | 1289 __int32 v116; // [sp+8C8h] [bp-2B8h]@10 |
1302 __int32 v131; // [sp+97Ch] [bp-204h]@38 | 1304 __int32 v131; // [sp+97Ch] [bp-204h]@38 |
1303 __int32 v132; // [sp+988h] [bp-1F8h]@38 | 1305 __int32 v132; // [sp+988h] [bp-1F8h]@38 |
1304 __int32 v133; // [sp+994h] [bp-1ECh]@38 | 1306 __int32 v133; // [sp+994h] [bp-1ECh]@38 |
1305 __int32 v134; // [sp+9A0h] [bp-1E0h]@38 | 1307 __int32 v134; // [sp+9A0h] [bp-1E0h]@38 |
1306 __int32 v135; // [sp+9ACh] [bp-1D4h]@38 | 1308 __int32 v135; // [sp+9ACh] [bp-1D4h]@38 |
1307 __int32 v136; // [sp+9D0h] [bp-1B0h]@10 | 1309 __int32 v136; // [sp+9D0h] [bp-1B0h]@10*/ |
1308 char FileName[32]; // [sp+A20h] [bp-160h]@8 | 1310 //char FileName[8]; // [sp+A20h] [bp-160h]@8 |
1309 //char v138; // [sp+A28h] [bp-158h]@12 | 1311 //char v138; // [sp+A28h] [bp-158h]@12 |
1310 //char v139; // [sp+B1Ch] [bp-64h]@10 | 1312 //int v139; // [sp+B1Ch] [bp-64h]@10 |
1311 char pContainer[32]; // [sp+B20h] [bp-60h]@1 | 1313 //char pContainer[32]; // [sp+B20h] [bp-60h]@1 |
1312 //char *v141; // [sp+B40h] [bp-40h]@50 | 1314 //int *v141; // [sp+B40h] [bp-40h]@50 |
1313 __int64 v142; // [sp+B44h] [bp-3Ch]@55 | 1315 //__int64 v142; // [sp+B44h] [bp-3Ch]@55 |
1314 size_t pSource; // [sp+B4Ch] [bp-34h]@56 | 1316 //size_t pSource; // [sp+B4Ch] [bp-34h]@56 |
1315 int v144; // [sp+B50h] [bp-30h]@61 | 1317 //int v144; // [sp+B50h] [bp-30h]@61 |
1316 int v145; // [sp+B54h] [bp-2Ch]@68 | 1318 //int v145; // [sp+B54h] [bp-2Ch]@68 |
1317 ODMHeader header; // [sp+B58h] [bp-28h]@50 | 1319 ODMHeader header; // [sp+B58h] [bp-28h]@50 |
1318 unsigned int pDestLen; // [sp+B68h] [bp-18h]@13 | 1320 //unsigned int pDestLen; // [sp+B68h] [bp-18h]@13 |
1319 FILE *ptr; // [sp+B6Ch] [bp-14h]@12 | 1321 //FILE *ptr; // [sp+B6Ch] [bp-14h]@12 |
1320 void *v149; // [sp+B70h] [bp-10h]@19 | 1322 //void *v149; // [sp+B70h] [bp-10h]@19 |
1321 char *Str2; // [sp+B74h] [bp-Ch]@12 | 1323 char *Str2; // [sp+B74h] [bp-Ch]@12 |
1322 int v151; // [sp+B78h] [bp-8h]@59 | 1324 //int v151; // [sp+B78h] [bp-8h]@59 |
1323 void *uSourceLen; // [sp+B7Ch] [bp-4h]@59 | 1325 //void *uSourceLen; // [sp+B7Ch] [bp-4h]@59 |
1324 | 1326 |
1325 pOutdoorLocation = this; | 1327 //pOutdoorLocation = this; |
1326 strcpy(pContainer, pFilename); | 1328 //strcpy(pContainer, pFilename); |
1327 if ( bUnderwater ) | 1329 |
1328 { | 1330 if (bUnderwater) |
1329 pPaletteManager->field_267AD3 = 0x10u; | 1331 { |
1330 pPaletteManager->field_267AD4 = 0xC2u; | 1332 pPaletteManager->pPalette_tintColor[0] = 0x10; |
1331 pPaletteManager->field_267AD5 = 0x99u; | 1333 pPaletteManager->pPalette_tintColor[1] = 0xC2; |
1332 pPaletteManager->field_267AD0 = 0x25u; | 1334 pPaletteManager->pPalette_tintColor[2] = 0x99; |
1333 pPaletteManager->field_267AD1 = 0x8Fu; | 1335 pPaletteManager->pPalette_mistColor[0] = 0x25; |
1334 pPaletteManager->field_267AD2 = 0x5Cu; | 1336 pPaletteManager->pPalette_mistColor[1] = 0x8F; |
1335 LABEL_7: | 1337 pPaletteManager->pPalette_mistColor[2] = 0x5C; |
1336 pPaletteManager->RecalculateAll(); | 1338 } |
1337 goto LABEL_8; | 1339 else |
1338 } | 1340 { |
1339 pPaletteManager->field_267AD3 = 0; | 1341 pPaletteManager->pPalette_tintColor[0] = 0; |
1340 pPaletteManager->field_267AD4 = 0; | 1342 pPaletteManager->pPalette_tintColor[1] = 0; |
1341 pPaletteManager->field_267AD5 = 0; | 1343 pPaletteManager->pPalette_tintColor[2] = 0; |
1342 if ( pPaletteManager->field_267AD0 != 0x80u | 1344 if (pPaletteManager->pPalette_mistColor[0] != 0x80 || |
1343 || pPaletteManager->field_267AD1 != 0x80u | 1345 pPaletteManager->pPalette_mistColor[1] != 0x80 || |
1344 || pPaletteManager->field_267AD2 != 0x80u ) | 1346 pPaletteManager->pPalette_mistColor[2] != 0x80) |
1345 { | 1347 { |
1346 pPaletteManager->field_267AD0 = 0x80u; | 1348 pPaletteManager->pPalette_mistColor[0] = 0x80; |
1347 pPaletteManager->field_267AD1 = 0x80u; | 1349 pPaletteManager->pPalette_mistColor[1] = 0x80; |
1348 pPaletteManager->field_267AD2 = 0x80u; | 1350 pPaletteManager->pPalette_mistColor[2] = 0x80; |
1349 goto LABEL_7; | 1351 pPaletteManager->RecalculateAll(); |
1350 } | 1352 } |
1351 LABEL_8: | 1353 } |
1352 pNumSoundDecorations = 0; | 1354 |
1353 sprintf(FileName, "levels\\%s", pContainer); | 1355 _6807E0_num_decorations_with_sounds_6807B8 = 0; |
1356 /*sprintf(FileName, "levels\\%s", pContainer); | |
1354 if ( GetFileAttributesA(FileName) != -1 ) | 1357 if ( GetFileAttributesA(FileName) != -1 ) |
1355 { | 1358 { |
1356 result = (bool)fopen(FileName, "rb"); | 1359 result = (bool)fopen(FileName, "rb"); |
1357 v7 = result; | 1360 v7 = result; |
1358 File = (ODMFace *)result; | 1361 File = (ODMFace *)result; |
1359 if ( !result ) | 1362 if ( !result ) |
1360 return result; | 1363 return result; |
1361 *(int *)thisa = 1; | 1364 *(int *)thisa = 1; |
1362 v8 = strlen(pContainer); | 1365 v8 = strlen(pContainer); |
1363 v108 = 2; | 1366 v108 = 2; |
1364 *((char *)&pContainer[-4] + v8) = 0; | 1367 *((char *)&v139 + v8) = 0; |
1365 viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pContainer, (enum TEXTURE_TYPE)v108); | 1368 viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pContainer, (enum TEXTURE_TYPE)v108); |
1366 fread(&DstBuf, 0x180u, 1u, (FILE *)v7); | 1369 fread(&DstBuf, 0x180u, 1u, (FILE *)v7); |
1367 fseek((FILE *)v7, Offset, 0); | 1370 fseek((FILE *)v7, Offset, 0); |
1368 fread(pOutdoorLocation, 0xB0u, 1u, (FILE *)v7); | 1371 fread(this, 0xB0u, 1u, (FILE *)v7); |
1369 pOutdoorLocation->LoadTileGroupIds(); | 1372 LoadTileGroupIds(); |
1370 pOutdoorLocation->_47F3EA(); | 1373 _47F3EA(); |
1371 strcpy(pOutdoorLocation->pGroundTileset, "grastyl"); | 1374 strcpy(pGroundTileset, "grastyl"); |
1372 fseek((FILE *)v7, v114, 0); | 1375 fseek((FILE *)v7, v114, 0); |
1373 fread(&pOutdoorLocation->uNumBModels, 4u, 1u, (FILE *)v7); | 1376 fread(&uNumBModels, 4u, 1u, (FILE *)v7); |
1374 fseek((FILE *)v7, v115, 0); | 1377 fseek((FILE *)v7, v115, 0); |
1375 fread(&uNumLayingItems, 4u, 1u, (FILE *)v7); | 1378 fread(&uNumLayingItems, 4u, 1u, (FILE *)v7); |
1376 fseek((FILE *)v7, v116, 0); | 1379 fseek((FILE *)v7, v116, 0); |
1377 fread(&uNumLevelDecorations, 4u, 1u, (FILE *)v7); | 1380 fread(&uNumLevelDecorations, 4u, 1u, (FILE *)v7); |
1378 fseek((FILE *)v7, v117, 0); | 1381 fseek((FILE *)v7, v117, 0); |
1379 fread(&uNumActors, 4u, 1u, (FILE *)v7); | 1382 fread(&uNumActors, 4u, 1u, (FILE *)v7); |
1380 fseek((FILE *)v7, v118, 0); | 1383 fseek((FILE *)v7, v118, 0); |
1381 fread(&uNumChests, 4u, 1u, (FILE *)v7); | 1384 fread(&uNumChests, 4u, 1u, (FILE *)v7); |
1382 pOutdoorLocation->pTerrain.Initialize(); | 1385 pTerrain.Initialize(); |
1383 fseek((FILE *)v7, v119, 0); | 1386 fseek((FILE *)v7, v119, 0); |
1384 fread(pOutdoorLocation->pTerrain.pHeightmap, 1u, 0x4000u, (FILE *)v7); | 1387 fread(pTerrain.pHeightmap, 1u, 0x4000u, (FILE *)v7); |
1385 fseek((FILE *)v7, v120, 0); | 1388 fseek((FILE *)v7, v120, 0); |
1386 fread(pOutdoorLocation->pTerrain.pTilemap, 1u, 0x4000u, (FILE *)v7); | 1389 fread(pTerrain.pTilemap, 1u, 0x4000u, (FILE *)v7); |
1387 fseek((FILE *)v7, v121, 0); | 1390 fseek((FILE *)v7, v121, 0); |
1388 fread(pOutdoorLocation->pTerrain.pAttributemap, 1u, 0x4000u, (FILE *)v7); | 1391 fread(pTerrain.pAttributemap, 1u, 0x4000u, (FILE *)v7); |
1389 pOutdoorLocation->pTerrain._47C80A(0, 0, 128, 128); | 1392 pTerrain._47C80A(0, 0, 128, 128); |
1390 pAllocator->FreeChunk(pOutdoorLocation->ptr_D4); | 1393 pAllocator->FreeChunk(ptr_D4); |
1391 pOutdoorLocation->ptr_D4 = 0; | 1394 ptr_D4 = 0; |
1392 v9 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); | 1395 v9 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); |
1393 v108 = (int)pOutdoorLocation->pOMAP; | 1396 v108 = (int)pOMAP; |
1394 pOutdoorLocation->ptr_D4 = v9; | 1397 ptr_D4 = v9; |
1395 pAllocator->FreeChunk((void *)v108); | 1398 pAllocator->FreeChunk((void *)v108); |
1396 pOutdoorLocation->pOMAP = 0; | 1399 pOMAP = 0; |
1397 v10 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); | 1400 v10 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); |
1398 v108 = 0; | 1401 v108 = 0; |
1399 pOutdoorLocation->pOMAP = (unsigned int *)v10; | 1402 pOMAP = (unsigned int *)v10; |
1400 fseek((FILE *)v7, v136, v108); | 1403 fseek((FILE *)v7, v136, v108); |
1401 fread(&uNumTerrainNormals, 4u, 1u, (FILE *)v7); | 1404 fread(&uNumTerrainNormals, 4u, 1u, (FILE *)v7); |
1402 fread(pTerrainSomeOtherData, 1u, 0x20000u, (FILE *)v7); | 1405 fread(pTerrainSomeOtherData, 1u, 0x20000u, (FILE *)v7); |
1403 fread(pTerrainNormalIndices, 1u, 0x10000u, (FILE *)v7); | 1406 fread(pTerrainNormalIndices, 1u, 0x10000u, (FILE *)v7); |
1404 pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); | 1407 pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); |
1405 fread(pTerrainNormals, 1u, 12 * uNumTerrainNormals, (FILE *)v7); | 1408 fread(pTerrainNormals, 1u, 12 * uNumTerrainNormals, (FILE *)v7); |
1406 v11 = pAllocator->AllocNamedChunk(pOutdoorLocation->pBModels, 188 * pOutdoorLocation->uNumBModels, "BDdata"); | 1409 v11 = pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata"); |
1407 v108 = 0; | 1410 v108 = 0; |
1408 pOutdoorLocation->pBModels = (BSPModel *)v11; | 1411 pBModels = (BSPModel *)v11; |
1409 fseek((FILE *)v7, v122, v108); | 1412 fseek((FILE *)v7, v122, v108); |
1410 fread(pOutdoorLocation->pBModels, 0xBCu, pOutdoorLocation->uNumBModels, (FILE *)v7); | 1413 fread(pBModels, 0xBCu, uNumBModels, (FILE *)v7); |
1411 fseek((FILE *)v7, v123, 0); | 1414 fseek((FILE *)v7, v123, 0); |
1412 pNumItems = 0; | 1415 pNumItems = 0; |
1413 if ( (signed int)pOutdoorLocation->uNumBModels > 0 ) | 1416 if ( (signed int)uNumBModels > 0 ) |
1414 { | 1417 { |
1415 v12 = 0; | 1418 v12 = 0; |
1416 while ( 1 ) | 1419 while ( 1 ) |
1417 { | 1420 { |
1418 pOutdoorLocation->pBModels[v12].pVertices.pVertices = 0; | 1421 pBModels[v12].pVertices.pVertices = 0; |
1419 pOutdoorLocation->pBModels[v12].pFaces = 0; | 1422 pBModels[v12].pFaces = 0; |
1420 pOutdoorLocation->pBModels[v12].pFacesOrdering = 0; | 1423 pBModels[v12].pFacesOrdering = 0; |
1421 pOutdoorLocation->pBModels[v12].pNodes = 0; | 1424 pBModels[v12].pNodes = 0; |
1422 FileName[0] = 0; | 1425 FileName[0] = 0; |
1423 v108 = (int)&pOutdoorLocation->pBModels[v12]; | 1426 v108 = (int)&pBModels[v12]; |
1424 sprintf(FileName, "%s", v108); | 1427 sprintfex(FileName, "%s", v108); |
1425 v13 = pOutdoorLocation->pBModels; | 1428 v13 = pBModels; |
1426 FileName[8] = 0; | 1429 v138 = 0; |
1427 v108 = (int)FileName; | 1430 pBModels[v12].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices, |
1428 pOutdoorLocation->pBModels[v12].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices, | |
1429 FileName); | 1431 FileName); |
1430 pOutdoorLocation->pBModels[v12].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(pOutdoorLocation->pBModels[v12].pFaces, 308 * pOutdoorLocation->pBModels[v12].uNumFaces, | 1432 pBModels[v12].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(pBModels[v12].pFaces, 308 * pBModels[v12].uNumFaces, |
1431 FileName); | 1433 FileName); |
1432 pOutdoorLocation->pBModels[v12].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(pOutdoorLocation->pBModels[v12].pFacesOrdering, | 1434 pBModels[v12].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(pBModels[v12].pFacesOrdering, |
1433 2 * pOutdoorLocation->pBModels[v12].uNumFaces, FileName); | 1435 2 * pBModels[v12].uNumFaces, FileName); |
1434 v14 = pAllocator->AllocNamedChunk(pOutdoorLocation->pBModels[v12].pNodes, 8 * pOutdoorLocation->pBModels[v12].uNumNodes, FileName); | 1436 v14 = pAllocator->AllocNamedChunk(pBModels[v12].pNodes, 8 * pBModels[v12].uNumNodes, FileName); |
1435 v15 = pOutdoorLocation->pBModels; | 1437 v15 = pBModels; |
1436 v108 = (int)File; | 1438 v108 = (int)File; |
1437 v15[v12].pNodes = (BSPNode *)v14; | 1439 v15[v12].pNodes = (BSPNode *)v14; |
1438 fread(pOutdoorLocation->pBModels[v12].pVertices.pVertices, 0xCu, pOutdoorLocation->pBModels[v12].pVertices.uNumVertices, (FILE *)v108); | 1440 fread(pBModels[v12].pVertices.pVertices, 0xCu, pBModels[v12].pVertices.uNumVertices, (FILE *)v108); |
1439 fread(pOutdoorLocation->pBModels[v12].pFaces, 0x134u, pOutdoorLocation->pBModels[v12].uNumFaces, (FILE *)File); | 1441 fread(pBModels[v12].pFaces, 0x134u, pBModels[v12].uNumFaces, (FILE *)File); |
1440 fread(pOutdoorLocation->pBModels[v12].pFacesOrdering, 2u, pOutdoorLocation->pBModels[v12].uNumFaces, (FILE *)File); | 1442 fread(pBModels[v12].pFacesOrdering, 2u, pBModels[v12].uNumFaces, (FILE *)File); |
1441 fread(pOutdoorLocation->pBModels[v12].pNodes, 8u, pOutdoorLocation->pBModels[v12].uNumNodes, (FILE *)File); | 1443 fread(pBModels[v12].pNodes, 8u, pBModels[v12].uNumNodes, (FILE *)File); |
1442 v16 = malloc(10 * pOutdoorLocation->pBModels[v12].uNumFaces); | 1444 v16 = malloc(10 * pBModels[v12].uNumFaces); |
1443 v107 = (int)File; | 1445 v107 = (int)File; |
1444 v17 = pOutdoorLocation->pBModels; | 1446 v17 = pBModels; |
1445 ptr = (FILE *)v16; | 1447 ptr = (FILE *)v16; |
1446 fread(v16, 0xAu, v17[v12].uNumFaces, (FILE *)File); | 1448 fread(v16, 0xAu, v17[v12].uNumFaces, (FILE *)File); |
1447 v18 = pOutdoorLocation->pBModels; | 1449 v18 = pBModels; |
1448 Str2 = 0; | 1450 Str2 = 0; |
1449 if ( (signed int)v18[v12].uNumFaces > 0 ) | 1451 if ( (signed int)v18[v12].uNumFaces > 0 ) |
1450 break; | 1452 break; |
1451 LABEL_25: | 1453 LABEL_25: |
1452 free(ptr); | 1454 free(ptr); |
1453 ++pNumItems; | 1455 ++pNumItems; |
1454 ++v12; | 1456 ++v12; |
1455 if ( (signed int)pNumItems >= (signed int)pOutdoorLocation->uNumBModels ) | 1457 if ( (signed int)pNumItems >= (signed int)uNumBModels ) |
1456 goto LABEL_26; | 1458 goto LABEL_26; |
1457 } | 1459 } |
1458 pDestLen = 0; | 1460 pDestLen = 0; |
1459 pFilename = (char *)ptr; | 1461 pFilename = (char *)ptr; |
1460 while ( 1 ) | 1462 while ( 1 ) |
1475 auto pTex = (Texture *)v149; | 1477 auto pTex = (Texture *)v149; |
1476 if (pTex) | 1478 if (pTex) |
1477 pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1); | 1479 pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1); |
1478 goto LABEL_20; | 1480 goto LABEL_20; |
1479 } | 1481 } |
1480 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(unsigned __int16 *)((char *)&pOutdoorLocation->pBModels[v12].pFaces->uTextureID + pDestLen)); | 1482 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(unsigned __int16 *)((char *)&pBModels[v12].pFaces->uTextureID + pDestLen)); |
1481 LABEL_20: | 1483 LABEL_20: |
1482 if ( *(short *)(thisa + 292) ) | 1484 if ( *(short *)(thisa + 292) ) |
1483 { | 1485 { |
1484 if ( ((ODMFace *)thisa)->HasEventHint() ) | 1486 if ( ((ODMFace *)thisa)->HasEventHint() ) |
1485 *(char *)(thisa + 30) |= 0x10u; | 1487 *(char *)(thisa + 30) |= 0x10u; |
1486 else | 1488 else |
1487 *(char *)(thisa + 30) &= 0xEFu; | 1489 *(char *)(thisa + 30) &= 0xEFu; |
1488 } | 1490 } |
1489 ++Str2; | 1491 ++Str2; |
1490 v18 = pOutdoorLocation->pBModels; | 1492 v18 = pBModels; |
1491 pDestLen += 308; | 1493 pDestLen += 308; |
1492 pFilename += 10; | 1494 pFilename += 10; |
1493 if ( (signed int)Str2 >= (signed int)v18[v12].uNumFaces ) | 1495 if ( (signed int)Str2 >= (signed int)v18[v12].uNumFaces ) |
1494 goto LABEL_25; | 1496 goto LABEL_25; |
1495 } | 1497 } |
1558 fseek((FILE *)v22, v126, 0); | 1560 fseek((FILE *)v22, v126, 0); |
1559 fread(pActors, 0x344u, uNumActors, (FILE *)v22); | 1561 fread(pActors, 0x344u, uNumActors, (FILE *)v22); |
1560 fseek((FILE *)v22, v127, 0); | 1562 fseek((FILE *)v22, v127, 0); |
1561 fread(pChests, 0x14CCu, uNumChests, (FILE *)v22); | 1563 fread(pChests, 0x14CCu, uNumChests, (FILE *)v22); |
1562 fseek((FILE *)v22, v128, 0); | 1564 fseek((FILE *)v22, v128, 0); |
1563 fread(&pOutdoorLocation->field_DC, 4u, 1u, (FILE *)v22); | 1565 fread(&field_DC, 4u, 1u, (FILE *)v22); |
1564 pAllocator->FreeChunk(pOutdoorLocation->pFaceIDLIST); | 1566 pAllocator->FreeChunk(pFaceIDLIST); |
1565 v32 = pOutdoorLocation->field_DC; | 1567 v32 = field_DC; |
1566 pOutdoorLocation->pFaceIDLIST = 0; | 1568 pFaceIDLIST = 0; |
1567 v33 = pAllocator->AllocNamedChunk(0, 2 * v32, "IDLIST"); | 1569 v33 = pAllocator->AllocNamedChunk(0, 2 * v32, "IDLIST"); |
1568 v108 = (int)v22; | 1570 v108 = (int)v22; |
1569 pOutdoorLocation->pFaceIDLIST = (unsigned __int16 *)v33; | 1571 pFaceIDLIST = (unsigned __int16 *)v33; |
1570 fread(v33, 2u, pOutdoorLocation->field_DC, (FILE *)v108); | 1572 fread(v33, 2u, field_DC, (FILE *)v108); |
1571 fseek((FILE *)v22, v129, 0); | 1573 fseek((FILE *)v22, v129, 0); |
1572 fread(pOutdoorLocation->pOMAP, 4u, 0x4000u, (FILE *)v22); | 1574 fread(pOMAP, 4u, 0x4000u, (FILE *)v22); |
1573 fseek((FILE *)v22, v130, 0); | 1575 fseek((FILE *)v22, v130, 0); |
1574 fread(&pOutdoorLocation->uNumSpawnPoints, 4u, 1u, (FILE *)v22); | 1576 fread(&uNumSpawnPoints, 4u, 1u, (FILE *)v22); |
1575 pOutdoorLocation->pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pOutdoorLocation->pSpawnPoints, 24 * pOutdoorLocation->uNumSpawnPoints, "Spawn"); | 1577 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); |
1576 fseek((FILE *)v22, v131, 0); | 1578 fseek((FILE *)v22, v131, 0); |
1577 fread(pOutdoorLocation->pSpawnPoints, 0x18u, pOutdoorLocation->uNumSpawnPoints, (FILE *)v22); | 1579 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, (FILE *)v22); |
1578 fseek((FILE *)v22, v132, 0); | 1580 fseek((FILE *)v22, v132, 0); |
1579 fread(&pOutdoorLocation->ddm, 0x28u, 1u, (FILE *)v22); | 1581 fread(&ddm, 0x28u, 1u, (FILE *)v22); |
1580 fseek((FILE *)v22, v133, 0); | 1582 fseek((FILE *)v22, v133, 0); |
1581 fread(&stru_5E4C90, 1u, 0xC8u, (FILE *)v22); | 1583 fread(&stru_5E4C90, 1u, 0xC8u, (FILE *)v22); |
1582 fseek((FILE *)v22, v134, 0); | 1584 fseek((FILE *)v22, v134, 0); |
1583 fread(&pOutdoorLocation->uLastVisitDay, 1u, 0x38u, (FILE *)v22); | 1585 fread(&uLastVisitDay, 1u, 0x38u, (FILE *)v22); |
1584 fseek((FILE *)v22, v135, 0); | 1586 fseek((FILE *)v22, v135, 0); |
1585 fread(&pOutdoorLocation->uLastVisitDay, 1u, 4u, (FILE *)v22); | 1587 fread(&uLastVisitDay, 1u, 4u, (FILE *)v22); |
1586 thisa = (int)pOutdoorLocation->pTileTypes; | 1588 thisa = (int)pTileTypes; |
1587 pTileTable->InitializeTileset(4); | 1589 pTileTable->InitializeTileset(4); |
1588 pTileTable->InitializeTileset(pOutdoorLocation->pTileTypes[0].uTileGroup); | 1590 pTileTable->InitializeTileset(pTileTypes[0].uTileGroup); |
1589 pTileTable->InitializeTileset(pOutdoorLocation->pTileTypes[1].uTileGroup); | 1591 pTileTable->InitializeTileset(pTileTypes[1].uTileGroup); |
1590 pTileTable->InitializeTileset(pOutdoorLocation->pTileTypes[2].uTileGroup); | 1592 pTileTable->InitializeTileset(pTileTypes[2].uTileGroup); |
1591 pTileTable->InitializeTileset(pOutdoorLocation->pTileTypes[3].uTileGroup); | 1593 pTileTable->InitializeTileset(pTileTypes[3].uTileGroup); |
1592 if ( pOutdoorLocation != (OutdoorLocation *)-96 && pOutdoorLocation->pSkyTextureName[0] ) | 1594 if ( this != (OutdoorLocation *)-96 && pSkyTextureName[0] ) |
1593 { | 1595 { |
1594 v108 = 0; | 1596 v108 = 0; |
1595 v107 = (int)pOutdoorLocation->pSkyTextureName; | 1597 v107 = (int)pSkyTextureName; |
1596 } | 1598 } |
1597 else | 1599 else |
1598 { | 1600 { |
1599 v108 = 0; | 1601 v108 = 0; |
1600 v107 = (int)pDefaultSkyTexture; | 1602 v107 = (int)pDefaultSkyTexture; |
1601 } | 1603 } |
1602 pOutdoorLocation->uSky_TextureID = pBitmaps_LOD->LoadTexture((const char *)v107, (enum TEXTURE_TYPE)v108); | 1604 uSky_TextureID = pBitmaps_LOD->LoadTexture((const char *)v107, (enum TEXTURE_TYPE)v108); |
1603 strcpy(pOutdoorLocation->pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); | 1605 strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); |
1604 v34 = pTileTable->GetTileById(pOutdoorLocation->pTileTypes[0].uTileID); | 1606 v34 = pTileTable->GetTileById(pTileTypes[0].uTileID); |
1605 v35 = pBitmaps_LOD->LoadTexture(v34->pTileName); | 1607 v35 = pBitmaps_LOD->LoadTexture(v34->pTileName); |
1606 v36 = pOutdoorLocation->uSky_TextureID; | 1608 v36 = uSky_TextureID; |
1607 pOutdoorLocation->uMainTile_BitmapID = v35; | 1609 uMainTile_BitmapID = v35; |
1608 if ( v36 != -1 ) | 1610 if ( v36 != -1 ) |
1609 pBitmaps_LOD->pTextures[v36].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v36].palette_id1); | 1611 pBitmaps_LOD->pTextures[v36].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v36].palette_id1); |
1610 | 1612 |
1611 v37 = pOutdoorLocation->uMainTile_BitmapID; | 1613 v37 = uMainTile_BitmapID; |
1612 if ( v37 != -1 ) | 1614 if ( v37 != -1 ) |
1613 pBitmaps_LOD->pTextures[v37].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v37].palette_id1); | 1615 pBitmaps_LOD->pTextures[v37].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v37].palette_id1); |
1614 | 1616 |
1615 pOutdoorLocation->_47F0E2(); | 1617 _47F0E2(); |
1616 pGameLoadingUI_ProgressBar->Progress(); | 1618 pGameLoadingUI_ProgressBar->Progress(); |
1617 fclose((FILE *)v22); | 1619 fclose((FILE *)v22); |
1618 goto LABEL_150; | 1620 goto LABEL_150; |
1619 } | 1621 }*/ |
1620 if ( !pGames_LOD->DoesContainerExist(pContainer) ) | 1622 |
1621 Abortf("Unable to find %s in Games.LOD", pContainer); | 1623 assert(sizeof(BSPModel) == 188); |
1622 strcpy(FileName, pContainer); | 1624 |
1623 strcpy(Str, pContainer); | 1625 if (!pGames_LOD->DoesContainerExist(pFilename)) |
1624 Dst[strlen(Str) + 964] = 0; | 1626 Abortf("Unable to find %s in Games.LOD", pFilename); |
1627 | |
1628 //strcpy(FileName, pContainer); | |
1629 strcpy(Str, pFilename); | |
1630 strcpy(Str + strlen(Str) - 4, ".odm"); | |
1625 viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(Str, TEXTURE_16BIT_PALETTE); | 1631 viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(Str, TEXTURE_16BIT_PALETTE); |
1626 //v141 = &pContainer[-4]; | 1632 //v141 = &v139; |
1627 //v38 = strlen(pContainer); | 1633 //v38 = strlen(pFilename); |
1628 strcpy((char *)&pContainer[strlen(pContainer) - 4], ".odm"); | 1634 //strcpy((char *)&v139 + v38, ".odm"); |
1629 v39 = pGames_LOD->FindContainer(pContainer, 1); | 1635 v39 = pGames_LOD->FindContainer(Str, 1); |
1636 //Str[strlen(Str) - 4] = 0; | |
1637 | |
1630 header.uCompressedSize = 0; | 1638 header.uCompressedSize = 0; |
1631 header.uDecompressedSize = 0; | 1639 header.uDecompressedSize = 0; |
1632 ptr = v39; | 1640 //ptr = v39; |
1633 header.uVersion = 91969; | 1641 header.uVersion = 91969; |
1634 header.pMagic[0] = 'm'; | 1642 header.pMagic[0] = 'm'; |
1635 header.pMagic[1] = 'v'; | 1643 header.pMagic[1] = 'v'; |
1636 header.pMagic[2] = 'i'; | 1644 header.pMagic[2] = 'i'; |
1637 header.pMagic[3] = 'i'; | 1645 header.pMagic[3] = 'i'; |
1638 fread(&header, 0x10u, 1u, v39); | 1646 fread(&header, 0x10u, 1u, v39); |
1639 if ( header.uVersion != 91969 | 1647 if (header.uVersion != 91969 || |
1640 || header.pMagic[0] != 'm' | 1648 header.pMagic[0] != 'm' || |
1641 || header.pMagic[1] != 'v' | 1649 header.pMagic[1] != 'v' || |
1642 || header.pMagic[2] != 'i' | 1650 header.pMagic[2] != 'i' || |
1643 || header.pMagic[3] != 'i' ) | 1651 header.pMagic[3] != 'i') |
1644 { | 1652 { |
1645 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:507", 0); | 1653 MessageBoxW(nullptr, L"Can't load file!", |
1646 } | 1654 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:507", 0); |
1647 v40 = header.uCompressedSize; | 1655 } |
1648 pSource = header.uDecompressedSize; | 1656 //v40 = header.uCompressedSize; |
1649 v41 = malloc(header.uDecompressedSize); | 1657 //pSource = header.uDecompressedSize; |
1650 v42 = v41; | 1658 //v41 = malloc(header.uDecompressedSize); |
1651 HIDWORD(v142) = (uint32)v41; | 1659 auto pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); |
1652 if ( v40 < pSource ) | 1660 auto pSrc = pSrcMem; |
1653 { | 1661 //v42 = v41; |
1654 pFilename = (char *)malloc(v40); | 1662 //HIDWORD(v142) = (uint32)pSrc; |
1655 fread((void *)pFilename, v40, 1u, ptr); | 1663 if (header.uCompressedSize < header.uDecompressedSize) |
1656 zlib::MemUnzip(v42, &pSource, pFilename, v40); | 1664 { |
1657 free((void *)pFilename); | 1665 auto pComressedSrc = (char *)malloc(header.uCompressedSize); |
1666 fread(pComressedSrc, header.uCompressedSize, 1, v39); | |
1667 | |
1668 uint actualDecompressedSize = header.uDecompressedSize; | |
1669 zlib::MemUnzip(pSrc, &actualDecompressedSize, pComressedSrc, header.uCompressedSize); | |
1670 free(pComressedSrc); | |
1658 } | 1671 } |
1659 else | 1672 else |
1660 { | 1673 { |
1661 fread(v41, pSource, 1u, ptr); | 1674 fread(pSrc, header.uDecompressedSize, 1, v39); |
1662 } | 1675 } |
1663 memcpy(pOutdoorLocation, v42, 0xB0u); | 1676 |
1664 v43 = (char *)v42 + 176; | 1677 memcpy(pLevelFilename, pSrc, 0x20); |
1665 pOutdoorLocation->LoadTileGroupIds(); | 1678 memcpy(pLocationFileName, pSrc + 0x20, 0x20); |
1666 pOutdoorLocation->_47F3EA(); | 1679 memcpy(pLocationFileDescription, pSrc + 0x40, 0x20); |
1667 strcpy(pOutdoorLocation->pGroundTileset, "grastyl"); | 1680 memcpy(pSkyTextureName, pSrc + 0x60, 0x20); |
1681 memcpy(pGroundTileset, pSrc + 0x80, 0x20); | |
1682 memcpy(pTileTypes, pSrc + 0xA0, 0x10); | |
1683 pSrc += 0xB0; | |
1684 | |
1685 //v43 = (char *)pSrc + 176; | |
1686 LoadTileGroupIds(); | |
1687 _47F3EA(); | |
1688 strcpy(pGroundTileset, "grastyl"); | |
1668 pGameLoadingUI_ProgressBar->Progress(); | 1689 pGameLoadingUI_ProgressBar->Progress(); |
1669 pOutdoorLocation->pTerrain.Initialize(); | 1690 pTerrain.Initialize(); |
1670 v108 = 16384; | 1691 //v108 = 16384; |
1671 v107 = (int)v43; | 1692 //v107 = (int)v43; |
1672 v106 = (char *)pOutdoorLocation->pTerrain.pHeightmap; | 1693 //v106 = (char *)pTerrain.pHeightmap; |
1673 memcpy(v106, v43, 0x4000u); | 1694 memcpy(pTerrain.pHeightmap, pSrc, 0x4000); |
1674 v43 = (char *)v43 + 16384; | 1695 pSrc += 0x4000; |
1675 v105 = 16384; | 1696 |
1676 v104 = (void *)v43; | 1697 //v43 = (char *)v43 + 16384; |
1677 v103 = pOutdoorLocation->pTerrain.pTilemap; | 1698 //v105 = 16384; |
1678 memcpy(v103, v43, 0x4000u); | 1699 //v104 = (void *)v43; |
1679 v43 = (char *)v43 + 16384; | 1700 //v103 = pTerrain.pTilemap; |
1680 memcpy(pOutdoorLocation->pTerrain.pAttributemap, v43, 0x4000u); | 1701 memcpy(pTerrain.pTilemap, pSrc, 0x4000); |
1681 v43 = (char *)v43 + 16384; | 1702 pSrc += 0x4000; |
1682 v108 = (int)pOutdoorLocation->ptr_D4; | 1703 |
1683 pAllocator->FreeChunk((void *)v108); | 1704 //v43 = (char *)v43 + 16384; |
1684 pOutdoorLocation->ptr_D4 = 0; | 1705 memcpy(pTerrain.pAttributemap, pSrc, 0x4000); |
1685 pOutdoorLocation->ptr_D4 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); | 1706 pSrc += 0x4000; |
1686 pOutdoorLocation->pTerrain._47C80A(0, 0, 128, 128); | 1707 |
1708 //v43 = (char *)v43 + 16384; | |
1709 //v108 = (int)ptr_D4; | |
1710 if (ptr_D4) | |
1711 { | |
1712 pAllocator->FreeChunk(ptr_D4); | |
1713 ptr_D4 = nullptr; | |
1714 } | |
1715 ptr_D4 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); | |
1716 pTerrain._47C80A(0, 0, 128, 128); | |
1717 | |
1687 pGameLoadingUI_ProgressBar->Progress(); | 1718 pGameLoadingUI_ProgressBar->Progress(); |
1688 memcpy(&uNumTerrainNormals, v43, 4u); | 1719 memcpy(&uNumTerrainNormals, pSrc, 4); |
1689 v43 = (char *)v43 + 4; | 1720 //v43 = (char *)v43 + 4; |
1690 memcpy(pTerrainSomeOtherData, v43, 0x20000u); | 1721 memcpy(pTerrainSomeOtherData, pSrc + 4, 0x20000); |
1691 v43 = (char *)v43 + 131072; | 1722 pSrc += 4 + 0x20000; |
1692 memcpy(pTerrainNormalIndices, v43, 0x10000u); | 1723 //v43 = (char *)v43 + 131072; |
1693 v43 = (char *)v43 + 65536; | 1724 memcpy(pTerrainNormalIndices, pSrc, 0x10000); |
1694 pFilename = (char *)(12 * uNumTerrainNormals); | 1725 pSrc += 0x10000; |
1726 //v43 = (char *)v43 + 65536; | |
1727 | |
1728 //pFilename = (char *)(12 * uNumTerrainNormals); | |
1695 pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); | 1729 pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); |
1696 memcpy(pTerrainNormals, v43, (size_t)pFilename); | 1730 memcpy(pTerrainNormals, pSrc, 12 * uNumTerrainNormals); |
1697 v44 = (char *)v43 + (int)pFilename; | 1731 pSrc += 12 * uNumTerrainNormals; |
1698 memcpy(&pOutdoorLocation->uNumBModels, v44, 4u); | 1732 //v44 = (char *)v43 + (int)pFilename; |
1699 v44 = (char *)v44 + 4; | 1733 //v44 = (char *)v44 + 4; |
1734 //v45 = uNumBModels; | |
1735 //v108 = (int)"BDdata"; | |
1736 | |
1700 pGameLoadingUI_ProgressBar->Progress(); | 1737 pGameLoadingUI_ProgressBar->Progress(); |
1701 v45 = pOutdoorLocation->uNumBModels; | 1738 |
1702 v108 = (int)"BDdata"; | 1739 //v107 = 188 * v45; |
1703 v107 = 188 * v45; | 1740 //v106 = (char *)pBModels; |
1704 v106 = (char *)pOutdoorLocation->pBModels; | 1741 //v46 = (BSPModel *)pAllocator->AllocNamedChunk(v106, 188 * v45, "BDdata"); |
1705 v46 = (BSPModel *)pAllocator->AllocNamedChunk(v106, 188 * v45, "BDdata"); | 1742 //v47 = uNumBModels; |
1706 v47 = pOutdoorLocation->uNumBModels; | 1743 memcpy(&uNumBModels, pSrc, 4); |
1707 pOutdoorLocation->pBModels = v46; | 1744 pBModels = (BSPModel *)pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata"); |
1708 pFilename = (char *)(188 * v47); | 1745 //pFilename = (char *)(188 * v47); |
1709 memcpy(v46, v44, 188 * v47); | 1746 memcpy(pBModels, pSrc + 4, 188 * uNumBModels); |
1710 uSourceLen = (char *)v44 + (int)pFilename; | 1747 pSrc += 4 + 188 * uNumBModels; |
1748 | |
1711 pGameLoadingUI_ProgressBar->Progress(); | 1749 pGameLoadingUI_ProgressBar->Progress(); |
1712 v151 = 0; | 1750 |
1713 if ( (signed int)pOutdoorLocation->uNumBModels > 0 ) | 1751 //uSourceLen = (char *)v44 + (int)pFilename; |
1714 { | 1752 //v151 = 0; |
1715 v48 = 0; | 1753 for (uint i = 0; i < uNumBModels; ++i) |
1716 while ( 1 ) | 1754 { |
1717 { | 1755 //v48 = 0; |
1718 pOutdoorLocation->pBModels[v48].pVertices.pVertices = 0; | 1756 auto model = pBModels + i; |
1719 pOutdoorLocation->pBModels[v48].pFaces = 0; | 1757 |
1720 pOutdoorLocation->pBModels[v48].pFacesOrdering = 0; | 1758 model->pVertices.pVertices = nullptr; |
1721 pOutdoorLocation->pBModels[v48].pNodes = 0; | 1759 model->pFaces = nullptr; |
1722 FileName[0] = 0; | 1760 model->pFacesOrdering = nullptr; |
1723 v108 = (int)&pOutdoorLocation->pBModels[v48]; | 1761 model->pNodes = nullptr; |
1724 sprintf(FileName, "%s", v108); | 1762 //FileName[0] = 0; |
1725 v49 = pOutdoorLocation->pBModels; | 1763 //v108 = (int)&pBModels[i]; |
1726 FileName[8] = 0; | 1764 //sprintf(FileName, "%s", v108); |
1727 v50 = &v49[v48]; | 1765 //v49 = pBModels; |
1728 v108 = (int)FileName; | 1766 //v138 = 0; |
1729 v107 = 12 * v50->pVertices.uNumVertices; | 1767 //v50 = &pBModels[v48]; |
1730 v106 = (char *)v50->pVertices.pVertices; | 1768 //v108 = (int)FileName; |
1731 pOutdoorLocation->pBModels[v48].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v106, v107, FileName); | 1769 //v107 = 12 * v50->pVertices.uNumVertices; |
1732 v51 = &pOutdoorLocation->pBModels[v48]; | 1770 //v106 = (char *)v50->pVertices.pVertices; |
1733 v108 = (int)FileName; | 1771 assert(sizeof(Vec3_int_) == 12); |
1734 v107 = 308 * v51->uNumFaces; | 1772 uint verticesSize = model->pVertices.uNumVertices * sizeof(Vec3_int_); |
1735 v106 = (char *)v51->pFaces; | 1773 model->pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(model->pVertices.pVertices, verticesSize, ""); |
1736 pOutdoorLocation->pBModels[v48].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(v106, v107, FileName); | 1774 memcpy(model->pVertices.pVertices, pSrc, verticesSize); |
1737 v52 = &pOutdoorLocation->pBModels[v48]; | 1775 pSrc += verticesSize; |
1738 v108 = (int)FileName; | 1776 //v51 = &pBModels[v48]; |
1739 v107 = 2 * v52->uNumFaces; | 1777 //v108 = (int)FileName; |
1740 v106 = (char *)v52->pFacesOrdering; | 1778 //v107 = 308 * v51->uNumFaces; |
1741 pOutdoorLocation->pBModels[v48].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(v106, v107, FileName); | 1779 //v106 = (char *)v51->pFaces; |
1742 v53 = &pOutdoorLocation->pBModels[v48]; | 1780 assert(sizeof(ODMFace) == 308); |
1743 v108 = (int)FileName; | 1781 uint facesSize = model->uNumFaces * sizeof(ODMFace); |
1744 v107 = 8 * v53->uNumNodes; | 1782 model->pFaces = (ODMFace *)pAllocator->AllocNamedChunk(model->pFaces, facesSize, ""); |
1745 v106 = (char *)v53->pNodes; | 1783 memcpy(model->pFaces, pSrc, facesSize); |
1746 pOutdoorLocation->pBModels[v48].pNodes = (BSPNode *)pAllocator->AllocNamedChunk(v106, v107, FileName); | 1784 pSrc += facesSize; |
1747 v54 = &pOutdoorLocation->pBModels[v48]; | 1785 //v52 = &pBModels[v48]; |
1748 v108 = 12 * v54->pVertices.uNumVertices; | 1786 //v108 = (int)FileName; |
1749 pFilename = (char *)v108; | 1787 //v107 = 2 * v52->uNumFaces; |
1750 v107 = (int)uSourceLen; | 1788 //v106 = (char *)v52->pFacesOrdering; |
1751 v106 = (char *)v54->pVertices.pVertices; | 1789 uint facesOrderingSize = model->uNumFaces * sizeof(short); |
1752 memcpy(v106, uSourceLen, v108); | 1790 model->pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(model->pFacesOrdering, facesOrderingSize, ""); |
1753 uSourceLen = (char *)uSourceLen + (int)pFilename; | 1791 memcpy(model->pFacesOrdering, pSrc, facesOrderingSize); |
1754 v55 = &pOutdoorLocation->pBModels[v48]; | 1792 pSrc += facesOrderingSize; |
1755 v105 = 308 * v55->uNumFaces; | 1793 //v53 = &pBModels[v48]; |
1756 v104 = uSourceLen; | 1794 //v108 = (int)FileName; |
1757 v103 = v55->pFaces; | 1795 //v107 = 8 * v53->uNumNodes; |
1758 pFilename = (char *)v105; | 1796 //v106 = (char *)v53->pNodes; |
1759 memcpy(v103, uSourceLen, v105); | 1797 assert(sizeof(BSPNode) == 8); |
1760 v56 = &pOutdoorLocation->pBModels[v48]; | 1798 uint nodesSize = model->uNumNodes * sizeof(BSPNode); |
1761 uSourceLen = (char *)uSourceLen + (int)pFilename; | 1799 model->pNodes = (BSPNode *)pAllocator->AllocNamedChunk(model->pNodes, nodesSize, ""); |
1762 v57 = v56->pFacesOrdering; | 1800 memcpy(model->pNodes, pSrc, nodesSize); |
1763 pFilename = (char *)(2 * v56->uNumFaces); | 1801 pSrc += nodesSize; |
1764 memcpy(v57, uSourceLen, (size_t)pFilename); | 1802 //v54 = &pBModels[v48]; |
1765 v58 = &pOutdoorLocation->pBModels[v48]; | 1803 //v108 = 12 * v54->pVertices.uNumVertices; |
1766 uSourceLen = (char *)uSourceLen + (int)pFilename; | 1804 //pFilename = (char *)v108; |
1767 v59 = v58->pNodes; | 1805 //v107 = (int)uSourceLen; |
1768 pFilename = (char *)(8 * v58->uNumNodes); | 1806 //v106 = (char *)v54->pVertices.pVertices; |
1769 memcpy(v59, uSourceLen, (size_t)pFilename); | 1807 //memcpy(v106, uSourceLen, v108); |
1770 uSourceLen = (char *)uSourceLen + (int)pFilename; | 1808 //uSourceLen = (char *)uSourceLen + (int)pFilename; |
1771 ptr = (FILE *)malloc(10 * pOutdoorLocation->pBModels[v48].uNumFaces); | 1809 //v55 = &pBModels[v48]; |
1772 pFilename = (char *)(10 * pOutdoorLocation->pBModels[v48].uNumFaces); | 1810 //v105 = 308 * v55->uNumFaces; |
1773 memcpy(ptr, uSourceLen, (size_t)pFilename); | 1811 //v104 = uSourceLen; |
1774 v144 = 0; | 1812 //v103 = v55->pFaces; |
1775 uSourceLen = (char *)uSourceLen + (int)pFilename; | 1813 //pFilename = (char *)v105; |
1776 v60 = pOutdoorLocation->pBModels; | 1814 //memcpy(v103, uSourceLen, v105); |
1777 if ( (signed int)v60[v48].uNumFaces > 0 ) | 1815 //v56 = &pBModels[v48]; |
1778 break; | 1816 //uSourceLen = (char *)uSourceLen + (int)pFilename; |
1779 LABEL_74: | 1817 //v57 = v56->pFacesOrdering; |
1780 free(ptr); | 1818 //pFilename = (char *)(2 * v56->uNumFaces); |
1781 ++v151; | 1819 //memcpy(v57, uSourceLen, (size_t)pFilename); |
1782 ++v48; | 1820 //v58 = &pBModels[v48]; |
1783 if ( v151 >= (signed int)pOutdoorLocation->uNumBModels ) | 1821 //uSourceLen = (char *)uSourceLen + (int)pFilename; |
1784 goto LABEL_75; | 1822 //v59 = v58->pNodes; |
1785 } | 1823 //pFilename = (char *)(8 * v58->uNumNodes); |
1786 v149 = 0; | 1824 //memcpy(v59, uSourceLen, (size_t)pFilename); |
1787 Str2 = (char *)ptr; | 1825 //uSourceLen = (char *)uSourceLen + (int)pFilename; |
1788 while ( 1 ) | 1826 //ptr = (FILE *)malloc(10 * model->uNumFaces); |
1789 { | 1827 auto textureFilenames = (const char *)malloc(10 * model->uNumFaces); |
1790 pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces; | 1828 //pFilename = (char *)(10 * pBModels[v48].uNumFaces); |
1791 if ( !(pFilename[29] & 0x40) ) | 1829 memcpy((char *)textureFilenames, pSrc, 10 * model->uNumFaces); |
1792 break; | 1830 pSrc += 10 * model->uNumFaces; |
1793 v61 = pTextureFrameTable->FindTextureByName(Str2); | 1831 //v144 = 0; |
1794 *((short *)pFilename + 136) = v61; | 1832 //uSourceLen = (char *)uSourceLen + (int)pFilename; |
1795 if ( !v61 ) | 1833 //v60 = pBModels; |
1796 { | 1834 for (uint j = 0; j < model->uNumFaces; ++j) |
1797 v62 = pBitmaps_LOD->LoadTexture(Str2); | 1835 { |
1798 v63 = (ODMFace *)pFilename; | 1836 auto texFilename = textureFilenames + j * 10; |
1799 BYTE1(v63->uAttributes) &= 0xBFu; | 1837 //v149 = 0; |
1838 //Str2 = (char *)ptr; | |
1839 | |
1840 auto face = model->pFaces + j; | |
1841 //pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces; | |
1842 if (~face->uAttributes & 0x40) | |
1843 { | |
1844 v62 = pBitmaps_LOD->LoadTexture(texFilename); | |
1845 // v63 = (ODMFace *)pFilename; | |
1846 goto LABEL_68; | |
1847 } | |
1848 //v61 = pTextureFrameTable->FindTextureByName(texFilename); | |
1849 face->uTextureID = pTextureFrameTable->FindTextureByName(texFilename); | |
1850 if (!face->uTextureID) | |
1851 { | |
1852 v62 = pBitmaps_LOD->LoadTexture(texFilename); | |
1853 //v63 = (ODMFace *)pFilename; | |
1854 BYTE1(face->uAttributes) &= 0xBFu; | |
1800 LABEL_68: | 1855 LABEL_68: |
1801 v63->uTextureID = v62; | 1856 face->uTextureID = v62; |
1802 v145 = (signed __int16)v62 != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62] : 0; | 1857 //v145 = (signed __int16)v62 != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62] : 0; |
1803 v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36); | 1858 //v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36); |
1804 if ((signed __int16)v62 != -1) | 1859 if ((signed __int16)v62 != -1) |
1805 pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(v108); | 1860 pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v62].palette_id1); |
1806 goto LABEL_69; | 1861 goto LABEL_69; |
1807 } | 1862 } |
1808 v108 = *(unsigned __int16 *)((char *)&pOutdoorLocation->pBModels[v48].pFaces->uTextureID + (unsigned int)v149); | 1863 pTextureFrameTable->LoadAnimationSequenceAndPalettes(face->uTextureID); |
1809 pTextureFrameTable->LoadAnimationSequenceAndPalettes(v108); | |
1810 LABEL_69: | 1864 LABEL_69: |
1811 if ( *((short *)pFilename + 146) ) | 1865 if (face->sCogTriggeredID) |
1812 { | 1866 { |
1813 if ( ((ODMFace *)pFilename)->HasEventHint() ) | 1867 if (face->HasEventHint()) |
1814 pFilename[30] |= 0x10u; | 1868 BYTE2(face->uAttributes) |= 0x10u; |
1815 else | 1869 else |
1816 pFilename[30] &= 0xEFu; | 1870 BYTE2(face->uAttributes) &= 0xEFu; |
1817 } | 1871 } |
1818 ++v144; | 1872 //++v144; |
1819 v60 = pOutdoorLocation->pBModels; | 1873 //v60 = pBModels; |
1820 v149 = (char *)v149 + 308; | 1874 //v149 = (char *)v149 + 308; |
1821 Str2 += 10; | 1875 //Str2 += 10; |
1822 if ( v144 >= (signed int)v60[v48].uNumFaces ) | 1876 //if ( v144 >= (signed int)v60[v48].uNumFaces ) |
1823 goto LABEL_74; | 1877 //goto LABEL_74; |
1824 } | 1878 } |
1825 v62 = pBitmaps_LOD->LoadTexture(Str2); | 1879 |
1826 v63 = (ODMFace *)pFilename; | 1880 //LABEL_74: |
1827 goto LABEL_68; | 1881 free((void *)textureFilenames); |
1828 } | 1882 // ++v151; |
1829 LABEL_75: | 1883 // ++v48; |
1884 // if ( v151 >= (signed int)uNumBModels ) | |
1885 // goto LABEL_75; | |
1886 } | |
1887 //LABEL_75: | |
1830 pGameLoadingUI_ProgressBar->Progress(); | 1888 pGameLoadingUI_ProgressBar->Progress(); |
1831 memcpy(&uNumLevelDecorations, uSourceLen, 4u); | 1889 |
1832 uSourceLen = (char *)uSourceLen + 4; | 1890 memcpy(&uNumLevelDecorations, pSrc, 4u); |
1833 if ( (uNumLevelDecorations & 0x80000000u) != 0 || (signed int)uNumLevelDecorations > 3000 ) | 1891 //uSourceLen = (char *)uSourceLen + 4; |
1834 { | 1892 if (uNumLevelDecorations > 3000) |
1835 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:678", 0); | 1893 MessageBoxW(nullptr, L"Can't load file!", |
1836 } | 1894 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:678", 0); |
1895 | |
1896 assert(sizeof(LevelDecoration) == 32); | |
1897 //pFilename = (char *)(32 * uNumLevelDecorations); | |
1898 memcpy(pLevelDecorations, pSrc + 4, uNumLevelDecorations * sizeof(LevelDecoration)); | |
1899 pSrc += 4 + 32 * uNumLevelDecorations; | |
1900 | |
1837 pGameLoadingUI_ProgressBar->Progress(); | 1901 pGameLoadingUI_ProgressBar->Progress(); |
1838 pFilename = (char *)(32 * uNumLevelDecorations); | 1902 |
1839 memcpy(pLevelDecorations, uSourceLen, 32 * uNumLevelDecorations); | 1903 //v151 = 0; |
1840 v151 = 0; | 1904 //uSourceLen = (char *)uSourceLen + (int)pFilename; |
1841 uSourceLen = (char *)uSourceLen + (int)pFilename; | 1905 for (uint i = 0; i < uNumLevelDecorations; ++i) |
1842 if ( (signed int)uNumLevelDecorations > 0 ) | 1906 { |
1843 { | 1907 char name[256]; |
1844 pFilename = (char *)pLevelDecorations; | 1908 memcpy(name, pSrc, 32); |
1845 do | 1909 pSrc += 32; |
1846 { | 1910 |
1847 memcpy(FileName, uSourceLen, 0x20u); | 1911 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(name); |
1848 uSourceLen = (char *)uSourceLen + 32; | 1912 } |
1849 v64 = pDecorationList->GetDecorIdByName(FileName); | 1913 |
1850 v65 = pFilename; | |
1851 ++v151; | |
1852 pFilename += 32; | |
1853 *(short *)v65 = v64; | |
1854 } | |
1855 while ( v151 < (signed int)uNumLevelDecorations ); | |
1856 } | |
1857 pGameLoadingUI_ProgressBar->Progress(); | 1914 pGameLoadingUI_ProgressBar->Progress(); |
1858 memcpy(&pOutdoorLocation->field_DC, uSourceLen, 4u); | 1915 |
1859 uSourceLen = (char *)uSourceLen + 4; | 1916 memcpy(&numFaceIDListElems, pSrc, 4); |
1860 v108 = (int)pOutdoorLocation->pFaceIDLIST; | 1917 |
1861 pAllocator->FreeChunk((void *)v108); | 1918 //uSourceLen = (char *)uSourceLen + 4; |
1862 v66 = pOutdoorLocation->field_DC; | 1919 //v108 = (int)pFaceIDLIST; |
1863 pOutdoorLocation->pFaceIDLIST = 0; | 1920 if (pFaceIDLIST) |
1864 v67 = pAllocator->AllocNamedChunk(0, 2 * v66, "IDLIST"); | 1921 { |
1865 v68 = pOutdoorLocation->field_DC; | 1922 pAllocator->FreeChunk(pFaceIDLIST); |
1866 pOutdoorLocation->pFaceIDLIST = (unsigned __int16 *)v67; | 1923 pFaceIDLIST = nullptr; |
1867 pFilename = (char *)(2 * v68); | 1924 } |
1868 memcpy(v67, uSourceLen, 2 * v68); | 1925 //v66 = field_DC; |
1869 uSourceLen = (char *)uSourceLen + (int)pFilename; | 1926 //pFaceIDLIST = 0; |
1927 //v67 = pAllocator->AllocNamedChunk(0, 2 * v66, "IDLIST"); | |
1928 uint faceIDListSize = 2 * numFaceIDListElems; | |
1929 pFaceIDLIST = (unsigned short *)pAllocator->AllocNamedChunk(0, faceIDListSize, "IDLIST"); | |
1930 //v68 = field_DC; | |
1931 //pFaceIDLIST = (unsigned __int16 *)v67; | |
1932 //pFilename = (char *)(2 * v68); | |
1933 memcpy(pFaceIDLIST, pSrc + 4, faceIDListSize); | |
1934 pSrc += 4 + faceIDListSize; | |
1935 | |
1936 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1870 pGameLoadingUI_ProgressBar->Progress(); | 1937 pGameLoadingUI_ProgressBar->Progress(); |
1871 v108 = (int)pOutdoorLocation->pOMAP; | 1938 |
1872 pAllocator->FreeChunk((void *)v108); | 1939 //v108 = (int)pOMAP; |
1873 pOutdoorLocation->pOMAP = 0; | 1940 //pAllocator->FreeChunk((void *)v108); |
1874 v69 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); | 1941 //pOMAP = 0; |
1875 v108 = 65536; | 1942 if (pOMAP) |
1876 pOutdoorLocation->pOMAP = (unsigned int *)v69; | 1943 { |
1877 memcpy(v69, uSourceLen, v108); | 1944 pAllocator->FreeChunk(pOMAP); |
1878 uSourceLen = (char *)uSourceLen + 65536; | 1945 pOMAP = nullptr; |
1946 } | |
1947 //v69 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); | |
1948 pOMAP = (unsigned int *)pAllocator->AllocNamedChunk(0, 0x10000, "OMAP"); | |
1949 //v108 = 65536; | |
1950 //pOMAP = (unsigned int *)v69; | |
1951 memcpy(pOMAP, pSrc, 65536); | |
1952 pSrc += 65536; | |
1953 | |
1954 //uSourceLen = (char *)uSourceLen + 65536; | |
1879 pGameLoadingUI_ProgressBar->Progress(); | 1955 pGameLoadingUI_ProgressBar->Progress(); |
1880 memcpy(&pOutdoorLocation->uNumSpawnPoints, uSourceLen, 4u); | 1956 |
1881 uSourceLen = (char *)uSourceLen + 4; | 1957 memcpy(&uNumSpawnPoints, pSrc, 4); |
1958 //uSourceLen = (char *)uSourceLen + 4; | |
1882 pGameLoadingUI_ProgressBar->Progress(); | 1959 pGameLoadingUI_ProgressBar->Progress(); |
1883 v70 = pOutdoorLocation->uNumSpawnPoints; | 1960 //v70 = uNumSpawnPoints; |
1884 v108 = (int)"Spawn"; | 1961 //v108 = (int)"Spawn"; |
1885 v107 = 24 * v70; | 1962 //v107 = 24 * v70; |
1886 v106 = (char *)pOutdoorLocation->pSpawnPoints; | 1963 //v106 = (char *)pSpawnPoints; |
1887 v71 = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(v106, 24 * v70, "Spawn"); | 1964 assert(sizeof(SpawnPointMM7) == 24); |
1888 v72 = pOutdoorLocation->uNumSpawnPoints; | 1965 uint spawnPointsSize = uNumSpawnPoints * sizeof(SpawnPointMM7); |
1889 pOutdoorLocation->pSpawnPoints = v71; | 1966 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, spawnPointsSize, "Spawn"); |
1890 memcpy(v71, uSourceLen, 24 * v72); | 1967 //v72 = uNumSpawnPoints; |
1968 //pSpawnPoints = v71; | |
1969 memcpy(pSpawnPoints, pSrc + 4, spawnPointsSize); | |
1970 pSrc += 4 + spawnPointsSize; | |
1971 | |
1891 pGameLoadingUI_ProgressBar->Progress(); | 1972 pGameLoadingUI_ProgressBar->Progress(); |
1892 free((void *)HIDWORD(v142)); | 1973 |
1974 free(pSrcMem); | |
1975 | |
1976 //v108 = (int)".ddm"; | |
1893 //v73 = strlen(pContainer); | 1977 //v73 = strlen(pContainer); |
1894 strcpy(&pContainer[strlen(pContainer) - 4], ".ddm"); | 1978 strcpy(Str + strlen(Str) - 4, ".ddm"); |
1895 v151 = (int)pNew_LOD->FindContainer(pContainer, 1);// | 1979 //strcpy((char *)v141 + v73, (const char *)v108); |
1896 fread(&header, 0x10u, 1u, (FILE *)v151); | 1980 v39 = pNew_LOD->FindContainer(Str, 1);// |
1981 fread(&header, 0x10u, 1u, v39); | |
1897 Str2 = 0; | 1982 Str2 = 0; |
1898 if ( header.uVersion != 91969 | 1983 if (header.uVersion != 91969 || |
1899 || header.pMagic[0] != 'm' | 1984 header.pMagic[0] != 'm' || |
1900 || header.pMagic[1] != 'v' | 1985 header.pMagic[1] != 'v' || |
1901 || header.pMagic[2] != 'i' | 1986 header.pMagic[2] != 'i' || |
1902 || header.pMagic[3] != 'i' ) | 1987 header.pMagic[3] != 'i' ) |
1903 { | 1988 { |
1904 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0); | 1989 MessageBoxW(nullptr, L"Can't load file!", |
1990 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0); | |
1905 Str2 = (char *)1; | 1991 Str2 = (char *)1; |
1906 } | 1992 } |
1907 v74 = 0; | 1993 //v74 = 0; |
1908 pFilename = (char *)header.uCompressedSize; | 1994 //pFilename = (char *)header.uCompressedSize; |
1909 v149 = 0; | 1995 //v149 = 0; |
1910 pDestLen = header.uDecompressedSize; | 1996 //pDestLen = header.uDecompressedSize; |
1911 if ( !Str2 ) | 1997 if ( !Str2 ) |
1912 { | 1998 { |
1913 v75 = malloc(header.uDecompressedSize); | 1999 pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); |
1914 v149 = v75; | 2000 pSrc = pSrcMem; |
1915 if ( (unsigned int)pFilename <= pDestLen ) | 2001 //v149 = v75; |
1916 { | 2002 if (header.uCompressedSize == header.uDecompressedSize) |
1917 if ( pFilename == (const char *)pDestLen ) | 2003 fread(pSrc, header.uDecompressedSize, 1u, v39); |
1918 { | 2004 else if (header.uCompressedSize < header.uDecompressedSize) |
1919 fread(v75, pDestLen, 1u, (FILE *)v151); | 2005 { |
1920 } | 2006 auto compressedMem = malloc(header.uCompressedSize); |
1921 else | 2007 fread(compressedMem, header.uCompressedSize, 1, v39); |
1922 { | 2008 |
1923 uSourceLen = malloc((size_t)pFilename); | 2009 uint actualDecompressedSize = header.uDecompressedSize; |
1924 fread(uSourceLen, (size_t)pFilename, 1u, (FILE *)v151); | 2010 zlib::MemUnzip(pSrc, &actualDecompressedSize, compressedMem, header.uCompressedSize); |
1925 zlib::MemUnzip(v75, &pDestLen, uSourceLen, (unsigned int)pFilename); | 2011 free(compressedMem); |
1926 free(uSourceLen); | |
1927 } | |
1928 } | 2012 } |
1929 else | 2013 else |
1930 { | 2014 MessageBoxW(nullptr, L"Can't load file!", |
1931 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:765", 0); | 2015 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:765", 0); |
1932 } | 2016 |
1933 memcpy(&pOutdoorLocation->ddm, v75, 0x28u); | 2017 assert(sizeof(DDM_DLV_Header) == 0x28); |
1934 v74 = (int)((char *)v75 + 40); | 2018 memcpy(&ddm, pSrc, sizeof(DDM_DLV_Header)); |
1935 } | 2019 pSrc += sizeof(DDM_DLV_Header); |
1936 v76 = pOutdoorLocation->uNumBModels; | 2020 //v74 = (int)((char *)v75 + 40); |
1937 v77 = 0; | 2021 } |
1938 if ( (signed int)v76 > 0 ) | 2022 //v76 = uNumBModels; |
1939 { | 2023 //v77 = actualNumFacesInLevel = 0; |
1940 v78 = (char *)&pOutdoorLocation->pBModels->uNumFaces; | 2024 uint actualNumFacesInLevel = 0; |
1941 do | 2025 for (uint i = 0; i < uNumBModels; ++i) |
1942 { | 2026 actualNumFacesInLevel += pBModels[i].uNumFaces; |
1943 v77 += *(int *)v78; | 2027 |
1944 v78 += 188; | 2028 //v79 = ddm.uNumFacesInBModels; |
1945 --v76; | 2029 if (ddm.uNumFacesInBModels) |
1946 } | 2030 { |
1947 while ( v76 ); | 2031 if ( ddm.uNumBModels ) |
1948 } | 2032 { |
1949 v79 = pOutdoorLocation->ddm.uNumFacesInBModels; | 2033 //v80 = ddm.uNumDecorations; |
1950 if ( v79 ) | 2034 if (ddm.uNumDecorations) |
1951 { | 2035 { |
1952 if ( pOutdoorLocation->ddm.uNumBModels ) | 2036 if (ddm.uNumFacesInBModels != actualNumFacesInLevel || |
1953 { | 2037 ddm.uNumBModels != uNumBModels || |
1954 v80 = pOutdoorLocation->ddm.uNumDecorations; | 2038 ddm.uNumDecorations != uNumLevelDecorations ) |
1955 if ( v80 ) | |
1956 { | |
1957 if ( v79 != v77 || pOutdoorLocation->ddm.uNumBModels != pOutdoorLocation->uNumBModels || v80 != uNumLevelDecorations ) | |
1958 Str2 = (char *)1; | 2039 Str2 = (char *)1; |
1959 } | 2040 } |
1960 } | 2041 } |
1961 } | 2042 } |
2043 | |
1962 if ( BYTE1(dword_6BE364_game_settings_1) & 0x20 ) | 2044 if ( BYTE1(dword_6BE364_game_settings_1) & 0x20 ) |
1963 pNumItems = 29030400; | 2045 pNumItems = 29030400; |
1964 if ( Str2 ) | 2046 if ( Str2 ) |
1965 { | 2047 { |
1966 memset(Dst, 0, 0x3C8u); | 2048 __debugbreak(); |
1967 memset(Src, 0, 0x3C8u); | 2049 //memset(Dst, 0, 0x3C8u); |
1968 goto LABEL_112; | 2050 //memset(Src, 0, 0x3C8u); |
1969 } | 2051 //goto LABEL_112; |
1970 v81 = pOutdoorLocation->ddm.uLastRepawnDay; | 2052 } |
1971 if ( (unsigned int)((char *)File - v81) >= pNumItems || !v81 ) | 2053 //v81 = ddm.uLastRepawnDay; |
1972 { | 2054 if ( (unsigned int)((char *)File - ddm.uLastRepawnDay) >= pNumItems || !ddm.uLastRepawnDay ) |
1973 memcpy(Dst, (const void *)v74, 0x3C8u); | 2055 { |
1974 memcpy(Src, (const void *)(v74 + 968), 0x3C8u); | 2056 __debugbreak(); |
2057 /* | |
2058 memcpy(Dst, pSrc, 0x3C8u); | |
2059 memcpy(Src, pSrc + 968, 0x3C8u); | |
1975 LABEL_112: | 2060 LABEL_112: |
1976 free(v149); | 2061 free(pSrcMem); |
1977 v25 = Str2 == 0; | 2062 v25 = Str2 == 0; |
1978 pOutdoorLocation->ddm.uLastRepawnDay = (int)File; | 2063 ddm.uLastRepawnDay = (int)File; |
1979 if ( v25 ) | 2064 if ( v25 ) |
1980 ++pOutdoorLocation->ddm.uNumRespawns; | 2065 ++ddm.uNumRespawns; |
1981 v108 = 0; | 2066 v108 = 0; |
1982 *(int *)thisa = 1; | 2067 *(int *)thisa = 1; |
1983 v151 = (int)pGames_LOD->FindContainer(pContainer, v108); | 2068 v151 = (int)pGames_LOD->FindContainer(pContainer, v108); |
1984 fread(&header, 0x10u, 1u, (FILE *)v151); | 2069 fread(&header, 0x10u, 1u, (FILE *)v151); |
1985 pFilename = (char *)header.uCompressedSize; | 2070 pFilename = (char *)header.uCompressedSize; |
2004 { | 2089 { |
2005 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:857", 0); | 2090 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:857", 0); |
2006 } | 2091 } |
2007 v74 = (int)((char *)v82 + 40); | 2092 v74 = (int)((char *)v82 + 40); |
2008 goto LABEL_120; | 2093 goto LABEL_120; |
2094 */ | |
2009 } | 2095 } |
2010 *(int *)thisa = 0; | 2096 *(int *)thisa = 0; |
2011 LABEL_120: | 2097 LABEL_120: |
2098 //v108 = (int)".odm"; | |
2012 //v83 = strlen(pContainer); | 2099 //v83 = strlen(pContainer); |
2013 strcpy(&pContainer[strlen(pContainer) - 4], ".odm"); | 2100 //strcpy((char *)v141 + v83, (const char *)v108); |
2014 memcpy(pOutdoorLocation->array_528, (const void *)v74, 0x3C8u); | 2101 memcpy(array_528, pSrc, 0x3C8); |
2015 v84 = (const void *)(v74 + 968); | 2102 //v84 = (const void *)(v74 + 968); |
2016 memcpy(pOutdoorLocation->array_8F0, v84, 0x3C8u); | 2103 memcpy(array_8F0, pSrc + 0x3C8, 0x3C8); |
2017 v85 = (char *)v84 + 968; | 2104 pSrc += 2 * 0x3C8; |
2105 //v85 = (char *)v84 + 968; | |
2106 | |
2018 pGameLoadingUI_ProgressBar->Progress(); | 2107 pGameLoadingUI_ProgressBar->Progress(); |
2108 | |
2019 if ( *(int *)thisa ) | 2109 if ( *(int *)thisa ) |
2020 { | 2110 { |
2021 memcpy(pOutdoorLocation->array_528, Dst, 0x3C8u); | 2111 __debugbreak(); |
2022 memcpy(pOutdoorLocation->array_8F0, Src, 0x3C8u); | 2112 memcpy(array_528, Dst, 0x3C8u); |
2023 } | 2113 memcpy(array_8F0, Src, 0x3C8u); |
2024 v25 = pOutdoorLocation->uNumBModels == 0; | 2114 } |
2025 v26 = (pOutdoorLocation->uNumBModels & 0x80000000u) != 0; | 2115 |
2026 v151 = 0; | 2116 //v25 = uNumBModels == 0; |
2027 if ( !(v26 | v25) ) | 2117 //v26 = (uNumBModels & 0x80000000u) != 0; |
2028 { | 2118 //v151 = 0; |
2029 pNumItems = 0; | 2119 for (uint i = 0; i < uNumBModels; ++i) |
2030 do | 2120 { |
2031 { | 2121 auto model = pBModels + i; |
2032 v86 = pOutdoorLocation->pBModels; | 2122 //pNumItems = 0; |
2033 thisa = 0; | 2123 //do |
2034 v87 = (unsigned int)((char *)v86 + pNumItems); | 2124 //{ |
2035 if ( *(int *)(v87 + 76) > 0 ) | 2125 //v86 = pBModels; |
2036 { | 2126 //thisa = 0; |
2037 File = 0; | 2127 //v87 = (unsigned int)((char *)v86 + pNumItems); |
2038 do | 2128 for (uint j = 0; j < model->uNumFaces; ++j) |
2039 { | 2129 { |
2040 v106 = (char *)&File->uAttributes + *(int *)(v87 + 84); | 2130 auto face = model->pFaces + j; |
2041 memcpy(v106, v85, 4u); | 2131 |
2042 v88 = pOutdoorLocation->pBModels; | 2132 //if ( *(int *)(v87 + 76) > 0 ) |
2043 ++File; | 2133 //{ |
2044 v85 = (char *)v85 + 4; | 2134 //File = 0; |
2045 ++thisa; | 2135 //do |
2046 v87 = (unsigned int)((char *)v88 + pNumItems); | 2136 //{ |
2047 } | 2137 //v106 = (char *)&File->uAttributes + *(int *)(v87 + 84); |
2048 while ( thisa < *(int *)(v87 + 76) ); | 2138 memcpy(&face->uAttributes, pSrc, 4); |
2049 } | 2139 pSrc += 4; |
2050 v89 = pOutdoorLocation->pBModels; | 2140 //v88 = pBModels; |
2051 thisa = 0; | 2141 //++File; |
2052 if ( *(signed int *)((char *)&v89->uNumFaces + pNumItems) > 0 ) | 2142 //v85 = (char *)v85 + 4; |
2053 { | 2143 //++thisa; |
2054 pFilename = 0; | 2144 //v87 = (unsigned int)((char *)v88 + pNumItems); |
2055 do | 2145 //} |
2056 { | 2146 //while ( thisa < *(int *)(v87 + 76) ); |
2057 v90 = (ODMFace *)&pFilename[*(unsigned int *)((char *)&v89->pFaces + pNumItems)]; | 2147 } |
2058 File = v90; | 2148 |
2059 if ( v90->sCogTriggeredID ) | 2149 //v89 = pBModels; |
2060 { | 2150 //thisa = 0; |
2061 if ( v90->HasEventHint() ) | 2151 for (uint j = 0; j < model->uNumFaces; ++j) |
2062 BYTE2(File->uAttributes) |= 0x10u; | 2152 { |
2063 else | 2153 auto face = model->pFaces + j; |
2064 BYTE2(File->uAttributes) &= 0xEFu; | 2154 //pFilename = 0; |
2065 } | 2155 //do |
2066 ++thisa; | 2156 //{ |
2067 v89 = pOutdoorLocation->pBModels; | 2157 //v90 = (ODMFace *)&pFilename[*(unsigned int *)((char *)&v89->pFaces + pNumItems)]; |
2068 pFilename += 308; | 2158 //File = v90; |
2069 } | 2159 if (face->sCogTriggeredID) |
2070 while ( thisa < *(signed int *)((char *)&v89->uNumFaces + pNumItems) ); | 2160 { |
2071 } | 2161 if (face->HasEventHint()) |
2072 ++v151; | 2162 BYTE2(face->uAttributes) |= 0x10u; |
2073 pNumItems += 188; | 2163 else |
2074 } | 2164 BYTE2(face->uAttributes) &= 0xEFu; |
2075 while ( v151 < (signed int)pOutdoorLocation->uNumBModels ); | 2165 } |
2076 } | 2166 //++thisa; |
2167 //v89 = pBModels; | |
2168 //pFilename += 308; | |
2169 //} | |
2170 //while ( thisa < *(signed int *)((char *)&v89->uNumFaces + pNumItems) ); | |
2171 } | |
2172 //++v151; | |
2173 //pNumItems += 188; | |
2174 //} | |
2175 //while ( v151 < (signed int)uNumBModels ); | |
2176 } | |
2177 | |
2077 pGameLoadingUI_ProgressBar->Progress(); | 2178 pGameLoadingUI_ProgressBar->Progress(); |
2078 v151 = 0; | 2179 |
2079 if ( (signed int)uNumLevelDecorations > 0 ) | 2180 //v151 = 0; |
2080 { | 2181 for (uint i = 0; i < uNumLevelDecorations; ++i) |
2081 thisa = (int)&pLevelDecorations[0].field_2; | 2182 { |
2082 do | 2183 //thisa = (int)&pLevelDecorations[0].field_2; |
2083 { | 2184 //do |
2084 memcpy((void *)thisa, v85, 2u); | 2185 //{ |
2085 thisa += 32; | 2186 memcpy(&pLevelDecorations[i].field_2, pSrc, 2); |
2086 v85 = (char *)v85 + 2; | 2187 pSrc += 2; |
2087 ++v151; | 2188 //thisa += 32; |
2088 } | 2189 //v85 = (char *)v85 + 2; |
2089 while ( v151 < (signed int)uNumLevelDecorations ); | 2190 //++v151; |
2090 } | 2191 //} |
2192 //while ( v151 < (signed int)uNumLevelDecorations ); | |
2193 } | |
2194 | |
2091 pGameLoadingUI_ProgressBar->Progress(); | 2195 pGameLoadingUI_ProgressBar->Progress(); |
2092 memcpy(&uNumActors, v85, 4u); | 2196 |
2093 v91 = (char *)v85 + 4; | 2197 memcpy(&uNumActors, pSrc, 4); |
2094 if ( (uNumActors & 0x80000000u) != 0 || (signed int)uNumActors > 500 ) | 2198 //v91 = (char *)v85 + 4; |
2095 { | 2199 if (uNumActors > 500) |
2096 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:939", 0); | 2200 MessageBoxW(nullptr, L"Can't load file!", |
2097 } | 2201 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:939", 0); |
2202 | |
2098 pGameLoadingUI_ProgressBar->Progress(); | 2203 pGameLoadingUI_ProgressBar->Progress(); |
2099 pFilename = (char *)(836 * uNumActors); | 2204 |
2100 memcpy(pActors, v91, 836 * uNumActors); | 2205 assert(sizeof(Actor) == 836); |
2101 v92 = (char *)v91 + (int)pFilename; | 2206 //pFilename = (char *)(836 * uNumActors); |
2207 memcpy(pActors, pSrc + 4, uNumActors * sizeof(Actor)); | |
2208 pSrc += 4 + uNumActors * sizeof(Actor); | |
2209 //v92 = (char *)v91 + (int)pFilename; | |
2102 pGameLoadingUI_ProgressBar->Progress(); | 2210 pGameLoadingUI_ProgressBar->Progress(); |
2103 memcpy(&uNumLayingItems, v92, 4u); | 2211 |
2104 v93 = (char *)v92 + 4; | 2212 memcpy(&uNumLayingItems, pSrc, 4); |
2105 if ( (uNumLayingItems & 0x80000000u) != 0 || (signed int)uNumLayingItems > 1000 ) | 2213 //v93 = (char *)v92 + 4; |
2106 { | 2214 if (uNumLayingItems > 1000) |
2107 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:954", 0); | 2215 MessageBoxW(nullptr, L"Can't load file!", |
2108 } | 2216 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:954", 0); |
2217 | |
2109 pGameLoadingUI_ProgressBar->Progress(); | 2218 pGameLoadingUI_ProgressBar->Progress(); |
2110 pFilename = (char *)(112 * uNumLayingItems); | 2219 |
2111 memcpy(pLayingItems, v93, 112 * uNumLayingItems); | 2220 assert(sizeof(LayingItem) == 112); |
2112 v94 = (char *)v93 + (int)pFilename; | 2221 //pFilename = (char *)(112 * uNumLayingItems); |
2222 memcpy(pLayingItems, pSrc + 4, uNumLayingItems * sizeof(LayingItem)); | |
2223 pSrc += 4 + uNumLayingItems * sizeof(LayingItem); | |
2224 | |
2225 //v94 = (char *)v93 + (int)pFilename; | |
2113 pGameLoadingUI_ProgressBar->Progress(); | 2226 pGameLoadingUI_ProgressBar->Progress(); |
2114 memcpy(&uNumChests, v94, 4u); | 2227 |
2115 v95 = (char *)v94 + 4; | 2228 memcpy(&uNumChests, pSrc, 4); |
2116 if ( (uNumChests & 0x80000000u) != 0 || (signed int)uNumChests > 20 ) | 2229 //v95 = (char *)v94 + 4; |
2117 { | 2230 if (uNumChests > 20) |
2118 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:968", 0); | 2231 MessageBoxW(nullptr, L"Can't load file!", |
2119 } | 2232 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:968", 0); |
2233 | |
2120 pGameLoadingUI_ProgressBar->Progress(); | 2234 pGameLoadingUI_ProgressBar->Progress(); |
2121 pFilename = (char *)(5324 * uNumChests); | 2235 |
2122 memcpy(pChests, v95, 5324 * uNumChests); | 2236 assert(sizeof(Chest) == 5324); |
2123 v96 = (char *)v95 + (int)pFilename; | 2237 //pFilename = (char *)(5324 * uNumChests); |
2238 memcpy(pChests, pSrc + 4 , uNumChests * sizeof(Chest)); | |
2239 pSrc += 4 + uNumChests * sizeof(Chest); | |
2240 //v96 = (char *)v95 + (int)pFilename; | |
2124 pGameLoadingUI_ProgressBar->Progress(); | 2241 pGameLoadingUI_ProgressBar->Progress(); |
2125 memcpy(&stru_5E4C90, v96, 0xC8u); | 2242 |
2243 memcpy(&stru_5E4C90, pSrc, 0xC8); | |
2244 pSrc += 0xC8; | |
2245 | |
2126 pGameLoadingUI_ProgressBar->Progress(); | 2246 pGameLoadingUI_ProgressBar->Progress(); |
2127 memcpy(&pOutdoorLocation->uLastVisitDay, v96 + 200, 0x38u); | 2247 memcpy(&uLastVisitDay, pSrc, 0x38u); |
2128 free(v149); | 2248 |
2249 free(pSrcMem); | |
2250 | |
2129 pTileTable->InitializeTileset(4); | 2251 pTileTable->InitializeTileset(4); |
2130 thisa = (int)pOutdoorLocation->pTileTypes; | 2252 //thisa = (int)pTileTypes; |
2131 v108 = pOutdoorLocation->pTileTypes[0].uTileGroup; | 2253 //v108 = pTileTypes[0].uTileGroup; |
2132 pTileTable->InitializeTileset(v108); | 2254 pTileTable->InitializeTileset(pTileTypes[0].uTileGroup); |
2133 v108 = pOutdoorLocation->pTileTypes[1].uTileGroup; | 2255 //v108 = pTileTypes[1].uTileGroup; |
2134 pTileTable->InitializeTileset(v108); | 2256 pTileTable->InitializeTileset(pTileTypes[1].uTileGroup); |
2135 v108 = pOutdoorLocation->pTileTypes[2].uTileGroup; | 2257 //v108 = pTileTypes[2].uTileGroup; |
2136 pTileTable->InitializeTileset(v108); | 2258 pTileTable->InitializeTileset(pTileTypes[2].uTileGroup); |
2137 v108 = pOutdoorLocation->pTileTypes[3].uTileGroup; | 2259 //v108 = pTileTypes[3].uTileGroup; |
2138 pTileTable->InitializeTileset(v108); | 2260 pTileTable->InitializeTileset(pTileTypes[3].uTileGroup); |
2139 strcpy(pOutdoorLocation->pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); | 2261 strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); |
2140 v97 = pOutdoorLocation->pTileTypes[0].uTileID; | 2262 //v97 = pTileTypes[0].uTileID; |
2141 v108 = 0; | 2263 //v108 = 0; |
2142 v98 = pTileTable->GetTileById(v97); | 2264 auto v98 = pTileTable->GetTileById(pTileTypes[0].uTileID); |
2143 v99 = pBitmaps_LOD->LoadTexture(v98->pTileName, (enum TEXTURE_TYPE)v108); | 2265 //v99 = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT); |
2144 pOutdoorLocation->uMainTile_BitmapID = v99; | 2266 uMainTile_BitmapID = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT); |
2145 if ( v99 != -1 ) | 2267 if (uMainTile_BitmapID != -1) |
2146 { | 2268 pBitmaps_LOD->pTextures[uMainTile_BitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uMainTile_BitmapID].palette_id1); |
2147 v108 = (v99 != -1 ? pBitmaps_LOD->pTextures[v99].palette_id1 : 36); | 2269 |
2148 if (v99 != -1) | 2270 _47F0E2(); |
2149 pBitmaps_LOD->pTextures[v99].palette_id2 = pPaletteManager->LoadPalette(v108); | 2271 |
2150 } | |
2151 pOutdoorLocation->_47F0E2(); | |
2152 LABEL_150: | 2272 LABEL_150: |
2153 v100 = HIDWORD(pOutdoorLocation->uLastVisitDay); | 2273 //v100 = HIDWORD(uLastVisitDay); |
2154 LODWORD(v142) = LODWORD(pOutdoorLocation->uLastVisitDay); | 2274 //LODWORD(v142) = LODWORD(uLastVisitDay); |
2155 HIDWORD(v142) = v100; | 2275 //HIDWORD(v142) = v100; |
2156 if ( v100 | (unsigned int)v142 ) | 2276 if (uLastVisitDay) |
2157 { | 2277 { |
2158 v108 = 28; | 2278 auto v108 = 28; |
2159 if ( (signed int)((signed int)(signed __int64)((double)v142 * 0.234375) / 60 / 60 / 0x18u) % 28 != pParty->uDaysPlayed ) | 2279 if ( (signed int)((signed int)(signed __int64)((double)uLastVisitDay * 0.234375) / 60 / 60 / 0x18u) % 28 != pParty->uDaysPlayed ) |
2160 { | 2280 { |
2161 if ( rand() % 100 >= 20 ) | 2281 if ( rand() % 100 >= 20 ) |
2162 v108 = dword_4EC268[rand() % dword_4EC2A8]; | 2282 v108 = dword_4EC268[rand() % dword_4EC2A8]; |
2163 else | 2283 else |
2164 v108 = dword_4EC28C[rand() % dword_4EC2AC]; | 2284 v108 = dword_4EC28C[rand() % dword_4EC2AC]; |
2165 sprintf(pOutdoorLocation->field_4F8, "plansky%d", v108); | 2285 sprintf(field_4F8, "plansky%d", v108); |
2166 } | 2286 } |
2167 } | 2287 } |
2168 else | 2288 else |
2169 { | 2289 { |
2170 strcpy(pOutdoorLocation->field_4F8, "plansky3"); | 2290 strcpy(field_4F8, "plansky3"); |
2171 } | 2291 } |
2172 v101 = pBitmaps_LOD->LoadTexture(pOutdoorLocation->field_4F8); | 2292 //v101 = pBitmaps_LOD->LoadTexture(field_4F8); |
2173 pOutdoorLocation->uSky_TextureID = v101; | 2293 uSky_TextureID = pBitmaps_LOD->LoadTexture(field_4F8); |
2174 if ( v101 != -1 ) | 2294 if (uSky_TextureID != -1) |
2175 { | 2295 pBitmaps_LOD->pTextures[uSky_TextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uSky_TextureID].palette_id1); |
2176 v108 = (v101 != -1 ? pBitmaps_LOD->pTextures[v101].palette_id1 : 36); | 2296 |
2177 if (v101 != -1) | |
2178 pBitmaps_LOD->pTextures[v101].palette_id2 = pPaletteManager->LoadPalette(v108); | |
2179 } | |
2180 pPaletteManager->RecalculateAll(); | 2297 pPaletteManager->RecalculateAll(); |
2181 pSoundList->_4A9A67(53, 0); | 2298 pSoundList->_4A9A67(53, 0); |
2182 pSoundList->_4A9A67(92, 0); | 2299 pSoundList->_4A9A67(92, 0); |
2183 pSoundList->_4A9A67(57, 0); | 2300 pSoundList->_4A9A67(57, 0); |
2184 pSoundList->_4A9A67(96, 0); | 2301 pSoundList->_4A9A67(96, 0); |
2236 LABEL_175: | 2353 LABEL_175: |
2237 v102 += 4; | 2354 v102 += 4; |
2238 --thisa; | 2355 --thisa; |
2239 } | 2356 } |
2240 while ( thisa ); | 2357 while ( thisa ); |
2241 return 1; | 2358 return true; |
2242 } | 2359 } |
2243 // 4EC268: using guessed type int dword_4EC268[]; | |
2244 // 4EC28C: using guessed type int dword_4EC28C[]; | |
2245 // 4EC2A8: using guessed type int dword_4EC2A8; | |
2246 // 4EC2AC: using guessed type int dword_4EC2AC; | |
2247 // 6807E0: using guessed type int _6807E0_num_decorations_6807B8; | |
2248 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
2249 // 6BE3C4: using guessed type char bUnderwater; | |
2250 | 2360 |
2251 //----- (0047ECC1) -------------------------------------------------------- | 2361 //----- (0047ECC1) -------------------------------------------------------- |
2252 int OutdoorLocation::_47ECC1(signed int a2) | 2362 int OutdoorLocation::_47ECC1(signed int a2) |
2253 { | 2363 { |
2254 signed int result; // eax@2 | 2364 signed int result; // eax@2 |
2583 v3 = pLevelDecorations; | 2693 v3 = pLevelDecorations; |
2584 do | 2694 do |
2585 { | 2695 { |
2586 pDecorationList->InitializeDecorationSprite(v3->uDecorationDescID); | 2696 pDecorationList->InitializeDecorationSprite(v3->uDecorationDescID); |
2587 v4 = pDecorationList->pDecorations[v3->uDecorationDescID].uSoundID; | 2697 v4 = pDecorationList->pDecorations[v3->uDecorationDescID].uSoundID; |
2588 if ( v4 && pNumSoundDecorations < 9 ) | 2698 if ( v4 && _6807E0_num_decorations_with_sounds_6807B8 < 9 ) |
2589 { | 2699 { |
2590 pSoundList->_4A9A67(v4, 0); | 2700 pSoundList->_4A9A67(v4, 0); |
2591 v5 = pNumSoundDecorations++; | 2701 v5 = _6807E0_num_decorations_with_sounds_6807B8++; |
2592 _6807B8_level_decorations_ids[v5] = v2; | 2702 _6807B8_level_decorations_ids[v5] = v2; |
2593 } | 2703 } |
2594 if ( v8 && v3->uCog == 20 ) | 2704 if ( v8 && v3->uCog == 20 ) |
2595 LOBYTE(v3->field_2) |= 0x40u; | 2705 LOBYTE(v3->field_2) |= 0x40u; |
2596 if ( !v3->field_16_event_id ) | 2706 if ( !v3->field_16_event_id ) |
2731 } | 2841 } |
2732 | 2842 |
2733 //----- (0047F420) -------------------------------------------------------- | 2843 //----- (0047F420) -------------------------------------------------------- |
2734 bool OutdoorLocation::LoadTileGroupIds() | 2844 bool OutdoorLocation::LoadTileGroupIds() |
2735 { | 2845 { |
2736 char *v1; // esi@1 | 2846 for (uint i = 0; i < 3; ++i) |
2737 signed int v2; // edi@1 | 2847 pTileTypes[i].uTileID = pTileTable->method_487ED6(pTileTypes[i].uTileGroup, 1); |
2738 | 2848 |
2739 v1 = (char *)&this->pTileTypes[0].uTileID; | 2849 return true; |
2740 v2 = 3; | |
2741 do | |
2742 { | |
2743 *(short *)v1 = pTileTable->method_487ED6(*((short *)v1 - 1), 1); | |
2744 v1 += 4; | |
2745 --v2; | |
2746 } | |
2747 while ( v2 ); | |
2748 return 1; | |
2749 } | 2850 } |
2750 | 2851 |
2751 //----- (0047B42C) -------------------------------------------------------- | 2852 //----- (0047B42C) -------------------------------------------------------- |
2752 unsigned int OutdoorLocation::DrawActors() | 2853 unsigned int OutdoorLocation::DrawActors() |
2753 { | 2854 { |