comparison Indoor.cpp @ 1026:6afa77761a00

Слияние
author Ritor1
date Tue, 21 May 2013 12:43:08 +0600
parents 8b492d4722d4 9ac94d00012e
children b79139c3b5c8
comparison
equal deleted inserted replaced
1025:8b492d4722d4 1026:6afa77761a00
1 #include <assert.h> 1 #include <assert.h>
2 2
3 #include "LightmapBuilder.h"
4 #include "DecalBuilder.h"
5 #include "ParticleEngine.h"
6 #include "stru9.h"
7 #include "stru10.h"
8
9 #include "BSPModel.h"
3 #include "Outdoor.h" 10 #include "Outdoor.h"
4 #include "Render.h"
5 #include "SpriteObject.h" 11 #include "SpriteObject.h"
6 #include "Events.h" 12 #include "Events.h"
7 #include "Game.h" 13 #include "Game.h"
8 #include "Viewport.h" 14 #include "Viewport.h"
9 #include "Time.h" 15 #include "Time.h"
21 #include "Log.h" 27 #include "Log.h"
22 #include "TurnEngine.h" 28 #include "TurnEngine.h"
23 #include "PaletteManager.h" 29 #include "PaletteManager.h"
24 #include "MapInfo.h" 30 #include "MapInfo.h"
25 #include "IndoorCamera.h" 31 #include "IndoorCamera.h"
26 #include "GUIWindow.h"
27 #include "GUIFont.h"
28 32
29 #include "mm7_data.h" 33 #include "mm7_data.h"
30 #include "MM7.h" 34 #include "MM7.h"
31 35
32 36
66 306, 302, 408, 304, 300, 300, 300, 300, 300, 300, 300, 300, 300, 70 306, 302, 408, 304, 300, 300, 300, 300, 300, 300, 300, 300, 300,
67 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 404, 304, 71 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 404, 304,
68 400, 300, 300, 404, 304, 400, 300, 300, 404, 304, 400, 300, 300 72 400, 300, 300, 404, 304, 400, 300, 300, 404, 304, 400, 300, 300
69 }; 73 };
70 74
75
76 const char *_4E6BDC_loc_names[11]=
77 {
78 "mdt12.blv",
79 "d18.blv",
80 "mdt14.blv",
81 "d37.blv",
82 "mdk01.blv",
83 "mdt01.blv",
84 "mdr01.blv",
85 "mdt10.blv",
86 "mdt09.blv",
87 "mdt15.blv",
88 "mdt11.blv"
89 };
71 90
72 91
73 //----- (0043F39E) -------------------------------------------------------- 92 //----- (0043F39E) --------------------------------------------------------
74 void __fastcall PrepareDrawLists_BLV(IndoorLocation_drawstru *_this) 93 void __fastcall PrepareDrawLists_BLV(IndoorLocation_drawstru *_this)
75 { 94 {
143 162
144 //----- (004407D9) -------------------------------------------------------- 163 //----- (004407D9) --------------------------------------------------------
145 int BLVRenderParams::Reset(IndoorLocation_drawstru *a2) 164 int BLVRenderParams::Reset(IndoorLocation_drawstru *a2)
146 { 165 {
147 IndoorLocation_drawstru *v2; // ebx@1 166 IndoorLocation_drawstru *v2; // ebx@1
148 BLVRenderParams *v3; // esi@1
149 int v4; // ST08_4@1 167 int v4; // ST08_4@1
150 int v5; // ST04_4@1 168 int v5; // ST04_4@1
151 int v6; // ST00_4@1 169 int v6; // ST00_4@1
152 int v7; // eax@1 170 int v7; // eax@1
153 int v8; // ST08_4@2 171 int v8; // ST08_4@2
172 signed int v27; // eax@6 190 signed int v27; // eax@6
173 int result; // eax@6 191 int result; // eax@6
174 int v29; // [sp+24h] [bp+8h]@5 192 int v29; // [sp+24h] [bp+8h]@5
175 193
176 v2 = a2; 194 v2 = a2;
177 v3 = this;
178 this->field_0_timer_ = a2->field_0_timer; 195 this->field_0_timer_ = a2->field_0_timer;
179 this->uFlags = a2->uFlags; 196 this->uFlags = a2->uFlags;
180 this->vPartyPos.x = a2->vPosition.x; 197 this->vPartyPos.x = a2->vPosition.x;
181 this->vPartyPos.y = a2->vPosition.y; 198 this->vPartyPos.y = a2->vPosition.y;
182 this->vPartyPos.z = a2->vPosition.z; 199 this->vPartyPos.z = a2->vPosition.z;
184 v5 = this->vPartyPos.y; 201 v5 = this->vPartyPos.y;
185 this->sPartyRotY = a2->sRotationY; 202 this->sPartyRotY = a2->sRotationY;
186 v6 = this->vPartyPos.x; 203 v6 = this->vPartyPos.x;
187 this->sPartyRotX = a2->sRotationX; 204 this->sPartyRotX = a2->sRotationX;
188 v7 = pIndoor->GetSector(v6, v5, v4); 205 v7 = pIndoor->GetSector(v6, v5, v4);
189 v3->uPartySectorID = v7; 206 this->uPartySectorID = v7;
190 if ( !v7 ) 207 if ( !v7 )
191 { 208 {
192 v8 = v3->vPartyPos.z; 209 v8 = this->vPartyPos.z;
193 v3->vPartyPos.x = pParty->vPosition.x; 210 this->vPartyPos.x = pParty->vPosition.x;
194 v9 = pParty->vPosition.y; 211 v9 = pParty->vPosition.y;
195 v10 = v3->vPartyPos.x; 212 v10 = this->vPartyPos.x;
196 v3->vPartyPos.y = pParty->vPosition.y; 213 this->vPartyPos.y = pParty->vPosition.y;
197 v3->uPartySectorID = pIndoor->GetSector(v10, v9, v8); 214 this->uPartySectorID = pIndoor->GetSector(v10, v9, v8);
198 } 215 }
199 if ( pRenderer->pRenderD3D ) 216 if ( pRenderer->pRenderD3D )
200 { 217 {
201 v3->sCosineY = stru_5C6E00->Cos(v3->sPartyRotY); 218 this->sCosineY = stru_5C6E00->Cos(this->sPartyRotY);
202 v3->sSineY = stru_5C6E00->Sin(v3->sPartyRotY); 219 this->sSineY = stru_5C6E00->Sin(this->sPartyRotY);
203 v3->sCosineNegX = stru_5C6E00->Cos(-v3->sPartyRotX); 220 this->sCosineNegX = stru_5C6E00->Cos(-this->sPartyRotX);
204 v3->sSineNegX = stru_5C6E00->Sin(-v3->sPartyRotX); 221 this->sSineNegX = stru_5C6E00->Sin(-this->sPartyRotX);
205 v3->fCosineY = cos((3.141592653589793 + 3.141592653589793) * (double)v3->sPartyRotY * 0.00048828125); 222 this->fCosineY = cos((3.141592653589793 + 3.141592653589793) * (double)this->sPartyRotY * 0.00048828125);
206 v3->fSineY = sin((3.141592653589793 + 3.141592653589793) * (double)v3->sPartyRotY * 0.00048828125); 223 this->fSineY = sin((3.141592653589793 + 3.141592653589793) * (double)this->sPartyRotY * 0.00048828125);
207 v3->fCosineNegX = cos((3.141592653589793 + 3.141592653589793) * (double)-v3->sPartyRotX * 0.00048828125); 224 this->fCosineNegX = cos((3.141592653589793 + 3.141592653589793) * (double)-this->sPartyRotX * 0.00048828125);
208 v3->fSineNegX = sin((3.141592653589793 + 3.141592653589793) * (double)-v3->sPartyRotX * 0.00048828125); 225 this->fSineNegX = sin((3.141592653589793 + 3.141592653589793) * (double)-this->sPartyRotX * 0.00048828125);
209 v3->field_64 = a2->field_3C; 226 this->field_64 = a2->field_3C;
210 v11 = v3->uViewportW; 227 v11 = this->uViewportW;
211 v12 = v3->uViewportX; 228 v12 = this->uViewportX;
212 v13 = v3->uViewportZ - v12; 229 v13 = this->uViewportZ - v12;
213 v14 = v3->uViewportZ + v12; 230 v14 = this->uViewportZ + v12;
214 v3->field_70 = v13 + 1; 231 this->field_70 = v13 + 1;
215 v15 = v3->uViewportY; 232 v15 = this->uViewportY;
216 v3->uViewportHeight = v11 - v15 + 1; 233 this->uViewportHeight = v11 - v15 + 1;
217 v16 = v3->uViewportW; 234 v16 = this->uViewportW;
218 v3->uViewportCenterX = v14 >> 1; 235 this->uViewportCenterX = v14 >> 1;
219 v3->uViewportCenterY = (signed int)(v16 + v15) >> 1; 236 this->uViewportCenterY = (signed int)(v16 + v15) >> 1;
220 } 237 }
221 else 238 else
222 { 239 {
223 v3->sCosineY = stru_5C6E00->Cos(-v3->sPartyRotY); 240 this->sCosineY = stru_5C6E00->Cos(-this->sPartyRotY);
224 v3->sSineY = stru_5C6E00->Sin(-v3->sPartyRotY); 241 this->sSineY = stru_5C6E00->Sin(-this->sPartyRotY);
225 v3->sCosineNegX = stru_5C6E00->Cos(-v3->sPartyRotX); 242 this->sCosineNegX = stru_5C6E00->Cos(-this->sPartyRotX);
226 v3->sSineNegX = stru_5C6E00->Sin(-v3->sPartyRotX); 243 this->sSineNegX = stru_5C6E00->Sin(-this->sPartyRotX);
227 v17 = cos((double)-v3->sPartyRotY * 0.0030664064); 244 v17 = cos((double)-this->sPartyRotY * 0.0030664064);
228 v18 = v3->sPartyRotY; 245 v18 = this->sPartyRotY;
229 v3->fCosineY = v17; 246 this->fCosineY = v17;
230 v19 = sin((double)-v18 * 0.0030664064); 247 v19 = sin((double)-v18 * 0.0030664064);
231 v20 = v3->sPartyRotX; 248 v20 = this->sPartyRotX;
232 v3->fSineY = v19; 249 this->fSineY = v19;
233 v21 = cos((double)-v20 * 0.0030664064); 250 v21 = cos((double)-v20 * 0.0030664064);
234 v22 = v3->sPartyRotX; 251 v22 = this->sPartyRotX;
235 v3->fCosineNegX = v21; 252 this->fCosineNegX = v21;
236 v3->fSineNegX = sin((double)-v22 * 0.0030664064); 253 this->fSineNegX = sin((double)-v22 * 0.0030664064);
237 v23 = v3->uViewportX; 254 v23 = this->uViewportX;
238 v3->field_64 = a2->field_3C; 255 this->field_64 = a2->field_3C;
239 v24 = v3->uViewportZ; 256 v24 = this->uViewportZ;
240 v3->field_70 = v3->uViewportZ - v23 + 1; 257 this->field_70 = this->uViewportZ - v23 + 1;
241 v25 = v3->uViewportW - v3->uViewportY + 1; 258 v25 = this->uViewportW - this->uViewportY + 1;
242 v3->uViewportHeight = v25; 259 this->uViewportHeight = v25;
243 v29 = v25; 260 v29 = v25;
244 v26 = v3->field_64; 261 v26 = this->field_64;
245 v3->uViewportCenterX = (signed int)(v24 + v23) >> 1; 262 this->uViewportCenterX = (signed int)(v24 + v23) >> 1;
246 v3->uViewportCenterY = v3->uViewportW - ((unsigned __int64)(v26 * (signed __int64)v29) >> 16); 263 this->uViewportCenterY = this->uViewportW - ((unsigned __int64)(v26 * (signed __int64)v29) >> 16);
247 } 264 }
248 v27 = (unsigned int)(signed __int64)((double)v3->field_70 * 0.5 / tan((double)(v2->field_1C_mb_fov >> 1) * 0.01745329) 265 v27 = (unsigned int)(signed __int64)((double)this->field_70 * 0.5 / tan((double)(v2->field_1C_mb_fov >> 1) * 0.01745329)
249 + 0.5) << 16; 266 + 0.5) << 16;
250 v3->field_40 = v27; 267 this->field_40 = v27;
251 LODWORD(v3->field_44) = 4294967296i64 / v27; 268 this->field_44 = 0x100000000i64 / v27;
252 v3->pRenderTarget = v2->pRenderTarget; 269 this->pRenderTarget = v2->pRenderTarget;
253 v3->uTargetWidth = v2->uTargetWidth; 270 this->uTargetWidth = v2->uTargetWidth;
254 v3->uTargetHeight = v2->uTargetHeight; 271 this->uTargetHeight = v2->uTargetHeight;
255 v3->uViewportX = v2->uViewportX; 272 this->uViewportX = v2->uViewportX;
256 v3->uViewportY = v2->uViewportY; 273 this->uViewportY = v2->uViewportY;
257 v3->uViewportZ = v2->uViewportZ; 274 this->uViewportZ = v2->uViewportZ;
258 v3->uViewportW = v2->uViewportW; 275 this->uViewportW = v2->uViewportW;
259 v3->pTargetZBuffer = v2->pTargetZ; 276 this->pTargetZBuffer = v2->pTargetZ;
260 result = 0; 277 result = 0;
261 v3->field_8C = 0; 278 this->field_8C = 0;
262 v3->field_84 = 0; 279 this->field_84 = 0;
263 v3->uNumFacesRenderedThisFrame = 0; 280 this->uNumFacesRenderedThisFrame = 0;
264 v3->field_88 = 0; 281 this->field_88 = 0;
265 pBLVRenderParams->field_90 = 64; 282 pBLVRenderParams->field_90 = 64;
266 pBLVRenderParams->field_94 = 6; 283 pBLVRenderParams->field_94 = 6;
267 return result; 284 return result;
268 } 285 }
269 286
508 { 525 {
509 if (pGame->pIndoorCameraD3D->CalcPortalShape(static_vertices_F7C228, &uNumVerticesa, 526 if (pGame->pIndoorCameraD3D->CalcPortalShape(static_vertices_F7C228, &uNumVerticesa,
510 static_vertices_F7B628, pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum, 4, false, 0) != 1 || uNumVerticesa ) 527 static_vertices_F7B628, pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum, 4, false, 0) != 1 || uNumVerticesa )
511 { 528 {
512 a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel); 529 a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel);
513 v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8); 530 v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel))
531 | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8);
514 sub_4B0E07(uFaceID); 532 sub_4B0E07(uFaceID);
515 pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID); 533 pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID);
516 pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID); 534 pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID);
517 pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28); 535 pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28);
518 pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0); 536 pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0);
1636 *(int *)v2 = 0; 1654 *(int *)v2 = 0;
1637 pAllocator->FreeChunk(v1->ptr_0002B0_sector_rdata); 1655 pAllocator->FreeChunk(v1->ptr_0002B0_sector_rdata);
1638 v1->ptr_0002B0_sector_rdata = 0; 1656 v1->ptr_0002B0_sector_rdata = 0;
1639 pAllocator->FreeChunk(v1->ptr_0002B8_sector_lrdata); 1657 pAllocator->FreeChunk(v1->ptr_0002B8_sector_lrdata);
1640 v1->ptr_0002B8_sector_lrdata = 0; 1658 v1->ptr_0002B8_sector_lrdata = 0;
1641 pAllocator->FreeChunk(v1->ptr_2AC); 1659 pAllocator->FreeChunk(v1->pLFaces);
1642 v1->ptr_2AC = 0; 1660 v1->pLFaces = 0;
1643 pAllocator->FreeChunk(v1->pSpawnPoints); 1661 pAllocator->FreeChunk(v1->pSpawnPoints);
1644 v3 = v1->pVertices; 1662 v3 = v1->pVertices;
1645 v1->pSpawnPoints = 0; 1663 v1->pSpawnPoints = 0;
1646 v1->uNumSectors = 0; 1664 v1->uNumSectors = 0;
1647 v1->uNumFaces = 0; 1665 v1->uNumFaces = 0;
2433 memcpy(&uNumFaces, pData += uNumVertices * sizeof(Vec3_short_), 4); 2451 memcpy(&uNumFaces, pData += uNumVertices * sizeof(Vec3_short_), 4);
2434 2452
2435 pGameLoadingUI_ProgressBar->Progress(); 2453 pGameLoadingUI_ProgressBar->Progress();
2436 2454
2437 memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace)); 2455 memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace));
2438 ptr_2AC = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); 2456 pLFaces = (unsigned __int16 *)pAllocator->AllocNamedChunk(pLFaces, blv.uFaces_fdata_Size, "L.FData");
2439 2457
2440 memcpy(ptr_2AC, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size); 2458 memcpy(pLFaces, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size);
2441 2459
2442 for (uint i = 0, j = 0; i < uNumFaces; ++i) 2460 for (uint i = 0, j = 0; i < uNumFaces; ++i)
2443 { 2461 {
2444 auto pFace = pFaces + i; 2462 auto pFace = pFaces + i;
2445 2463
2446 pFace->pVertexIDs = ptr_2AC + j; 2464 pFace->pVertexIDs = pLFaces + j;
2447 2465
2448 j += pFace->uNumVertices + 1; 2466 j += pFace->uNumVertices + 1;
2449 pFace->pXInterceptDisplacements = (short *)(ptr_2AC + j); 2467 pFace->pXInterceptDisplacements = (short *)(pLFaces + j);
2450 2468
2451 j += pFace->uNumVertices + 1; 2469 j += pFace->uNumVertices + 1;
2452 pFace->pYInterceptDisplacements = (short *)(ptr_2AC + j); 2470 pFace->pYInterceptDisplacements = (short *)(pLFaces + j);
2453 2471
2454 j += pFace->uNumVertices + 1; 2472 j += pFace->uNumVertices + 1;
2455 pFace->pZInterceptDisplacements = (short *)(ptr_2AC + j); 2473 pFace->pZInterceptDisplacements = (short *)(pLFaces + j);
2456 2474
2457 j += pFace->uNumVertices + 1; 2475 j += pFace->uNumVertices + 1;
2458 pFace->pVertexUIDs = (__int16 *)(ptr_2AC + j); 2476 pFace->pVertexUIDs = (__int16 *)(pLFaces + j);
2459 2477
2460 j += pFace->uNumVertices + 1; 2478 j += pFace->uNumVertices + 1;
2461 pFace->pVertexVIDs = (__int16 *)(ptr_2AC + j); 2479 pFace->pVertexVIDs = (__int16 *)(pLFaces + j);
2462 2480
2463 j += pFace->uNumVertices + 1; 2481 j += pFace->uNumVertices + 1;
2464 /*v93 = &pFaces[v92]; 2482 /*v93 = &pFaces[v92];
2465 Src = v93; 2483 Src = v93;
2466 v94 = (BLVSector *)((char *)v244 + 2 * v93->uNumVertices + 2); 2484 v94 = (BLVSector *)((char *)v244 + 2 * v93->uNumVertices + 2);