Mercurial > mm7
annotate Indoor.cpp @ 795:472ca68386d4
more stru10 & stru9
author | Nomad |
---|---|
date | Mon, 25 Mar 2013 14:23:40 +0200 |
parents | 4a00901e063c |
children | e95389c8680a |
rev | line source |
---|---|
0 | 1 #include <assert.h> |
2 | |
3 #include "Outdoor.h" | |
4 #include "Render.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
5 #include "SpriteObject.h" |
0 | 6 #include "Events.h" |
7 #include "Game.h" | |
8 #include "Viewport.h" | |
9 #include "Time.h" | |
10 #include "Party.h" | |
11 #include "Math.h" | |
12 #include "Allocator.h" | |
13 #include "LOD.h" | |
14 #include "DecorationList.h" | |
15 #include "ObjectList.h" | |
16 #include "Actor.h" | |
17 #include "Chest.h" | |
18 #include "GUIProgressBar.h" | |
19 #include "stru123.h" | |
20 #include "AudioPlayer.h" | |
21 #include "Log.h" | |
22 #include "TurnEngine.h" | |
23 #include "PaletteManager.h" | |
24 #include "MapInfo.h" | |
186 | 25 #include "IndoorCamera.h" |
791 | 26 #include "GUIWindow.h" |
27 #include "GUIButton.h" | |
28 #include "GUIFont.h" | |
0 | 29 |
30 #include "mm7_data.h" | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 IndoorLocation *pIndoor = new IndoorLocation; | |
41 BLVRenderParams *pBLVRenderParams = new BLVRenderParams; | |
42 | |
43 struct DecorationList *pDecorationList; | |
44 | |
45 LevelDecoration pLevelDecorations[3000]; | |
46 size_t uNumLevelDecorations; | |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
47 LevelDecoration* activeLevelDecoration; |
0 | 48 |
49 LEVEL_TYPE uCurrentlyLoadedLevelType = LEVEL_null; | |
50 | |
51 stru320 stru_F8AD28; // idb | |
52 stru337 stru_F81018; | |
53 stru167_wrap array_5118E8; | |
54 BspRenderer_stru2 stru_F8A590; | |
55 BspRenderer *pBspRenderer = new BspRenderer; // idb | |
56 stru141 stru_721530; | |
57 stru352 stru_F83B80[480]; | |
58 | |
59 | |
60 | |
61 unsigned __int16 pDoorSoundIDsByLocationID[78] = | |
62 { | |
63 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, | |
64 300, 300, 300, 404, 302, 306, 308, 304, 308, 302, 400, 302, 300, | |
65 308, 308, 306, 308, 308, 304, 300, 404, 406, 300, 400, 406, 404, | |
66 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, | |
68 400, 300, 300, 404, 304, 400, 300, 300, 404, 304, 400, 300, 300 | |
69 }; | |
70 | |
71 | |
72 | |
73 //----- (0043F39E) -------------------------------------------------------- | |
74 void __fastcall PrepareDrawLists_BLV(IndoorLocation_drawstru *_this) | |
75 { | |
76 //int *v1; // ecx@1 | |
77 //double v2; // ST30_8@3 | |
78 //double v3; // ST30_8@6 | |
79 //double v4; // ST28_8@6 | |
80 int v5; // eax@4 | |
707 | 81 //int v6; // eax@7 |
0 | 82 unsigned int v7; // ebx@8 |
83 BLVSector *v8; // esi@8 | |
707 | 84 //unsigned __int16 *v9; // edi@8 |
85 //int i; // [sp+18h] [bp-8h]@7 | |
0 | 86 //unsigned __int8 v11; // [sp+1Ch] [bp-4h]@3 |
707 | 87 //signed int v12; // [sp+1Ch] [bp-4h]@8 |
0 | 88 |
89 pBLVRenderParams->Reset(_this); | |
90 pMobileLightsStack->uNumLightsActive = 0; | |
91 //uNumMobileLightsApplied = 0; | |
92 uNumDecorationsDrawnThisFrame = 0; | |
93 _unused000 = 0; | |
94 uNumSpritesDrawnThisFrame = 0; | |
95 uNumBillboardsToDraw = 0; | |
707 | 96 |
97 if ( !byte_4D864C || !(pGame->uFlags & 0x1000) ) // lightspot around party | |
0 | 98 { |
99 //v2 = pParty->flt_TorchlightColorB + 6.7553994e15; | |
100 //v11 = LOBYTE(v2); | |
101 v5 = 800; | |
102 if (pParty->TorchlightActive()) | |
707 | 103 v5 *= pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; |
0 | 104 //LOBYTE(v1) = byte_4E94D0; |
105 //v4 = pParty->flt_TorchlightColorR + 6.7553994e15; | |
106 //v3 = pParty->flt_TorchlightColorG + 6.7553994e15; | |
707 | 107 pMobileLightsStack->AddLight(pBLVRenderParams->vPartyPos.x, |
108 pBLVRenderParams->vPartyPos.y, | |
109 pBLVRenderParams->vPartyPos.z, | |
110 pBLVRenderParams->uPartySectorID, | |
111 v5, | |
112 floorf(pParty->flt_TorchlightColorR + 0.5f), | |
113 floorf(pParty->flt_TorchlightColorG + 0.5f), | |
114 floorf(pParty->flt_TorchlightColorB + 0.5f), | |
115 byte_4E94D0); | |
0 | 116 } |
117 PrepareBspRenderList_BLV(); | |
118 PrepareItemsRenderList_BLV(); | |
119 PrepareActorRenderList_BLV(); | |
707 | 120 |
121 //v6 = 0; | |
122 for (uint i = 0; i < pBspRenderer->uNumVisibleNotEmptySectors; ++i) | |
0 | 123 { |
707 | 124 v7 = pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[i]; |
125 //v12 = 0; | |
126 v8 = &pIndoor->pSectors[pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[i]]; | |
127 //v9 = v8->pDecorationIDs; | |
128 | |
129 for (uint j = 0; j < v8->uNumDecorations; ++j) | |
130 //if ( v8->uNumDecorations > 0 ) | |
0 | 131 { |
707 | 132 // do |
133 PrepareDecorationsRenderList_BLV(v8->pDecorationIDs[j], v7); | |
134 // while ( v12 < v8->uNumDecorations ); | |
0 | 135 } |
707 | 136 //v6 = i + 1; |
0 | 137 } |
657 | 138 FindBillboardsLightLevels_BLV(); |
0 | 139 pGame->PrepareBloodsplats(); |
140 } | |
141 | |
142 | |
143 | |
144 //----- (004407D9) -------------------------------------------------------- | |
145 int BLVRenderParams::Reset(IndoorLocation_drawstru *a2) | |
146 { | |
147 IndoorLocation_drawstru *v2; // ebx@1 | |
148 BLVRenderParams *v3; // esi@1 | |
149 int v4; // ST08_4@1 | |
150 int v5; // ST04_4@1 | |
151 int v6; // ST00_4@1 | |
152 int v7; // eax@1 | |
153 int v8; // ST08_4@2 | |
154 int v9; // ST04_4@2 | |
155 int v10; // ST00_4@2 | |
156 unsigned int v11; // edi@4 | |
157 unsigned int v12; // ecx@4 | |
158 int v13; // edx@4 | |
159 signed int v14; // ecx@4 | |
160 unsigned int v15; // edx@4 | |
161 unsigned int v16; // eax@4 | |
162 double v17; // st7@5 | |
163 int v18; // eax@5 | |
164 double v19; // st7@5 | |
165 int v20; // eax@5 | |
166 double v21; // st7@5 | |
167 int v22; // eax@5 | |
168 unsigned int v23; // edx@5 | |
169 unsigned int v24; // ecx@5 | |
170 int v25; // eax@5 | |
171 int v26; // eax@5 | |
172 signed int v27; // eax@6 | |
173 int result; // eax@6 | |
174 int v29; // [sp+24h] [bp+8h]@5 | |
175 | |
176 v2 = a2; | |
177 v3 = this; | |
178 this->field_0_timer_ = a2->field_0_timer; | |
179 this->uFlags = a2->uFlags; | |
180 this->vPartyPos.x = a2->vPosition.x; | |
181 this->vPartyPos.y = a2->vPosition.y; | |
182 this->vPartyPos.z = a2->vPosition.z; | |
183 v4 = this->vPartyPos.z; | |
184 v5 = this->vPartyPos.y; | |
185 this->sPartyRotY = a2->sRotationY; | |
186 v6 = this->vPartyPos.x; | |
187 this->sPartyRotX = a2->sRotationX; | |
188 v7 = pIndoor->GetSector(v6, v5, v4); | |
189 v3->uPartySectorID = v7; | |
190 if ( !v7 ) | |
191 { | |
192 v8 = v3->vPartyPos.z; | |
193 v3->vPartyPos.x = pParty->vPosition.x; | |
194 v9 = pParty->vPosition.y; | |
195 v10 = v3->vPartyPos.x; | |
196 v3->vPartyPos.y = pParty->vPosition.y; | |
197 v3->uPartySectorID = pIndoor->GetSector(v10, v9, v8); | |
198 } | |
199 if ( pRenderer->pRenderD3D ) | |
200 { | |
323 | 201 v3->sCosineY = stru_5C6E00->Cos(v3->sPartyRotY); |
202 v3->sSineY = stru_5C6E00->Sin(v3->sPartyRotY); | |
203 v3->sCosineNegX = stru_5C6E00->Cos(-v3->sPartyRotX); | |
204 v3->sSineNegX = stru_5C6E00->Sin(-v3->sPartyRotX); | |
0 | 205 v3->fCosineY = cos((3.141592653589793 + 3.141592653589793) * (double)v3->sPartyRotY * 0.00048828125); |
206 v3->fSineY = sin((3.141592653589793 + 3.141592653589793) * (double)v3->sPartyRotY * 0.00048828125); | |
207 v3->fCosineNegX = cos((3.141592653589793 + 3.141592653589793) * (double)-v3->sPartyRotX * 0.00048828125); | |
208 v3->fSineNegX = sin((3.141592653589793 + 3.141592653589793) * (double)-v3->sPartyRotX * 0.00048828125); | |
209 v3->field_64 = a2->field_3C; | |
210 v11 = v3->uViewportW; | |
211 v12 = v3->uViewportX; | |
212 v13 = v3->uViewportZ - v12; | |
213 v14 = v3->uViewportZ + v12; | |
214 v3->field_70 = v13 + 1; | |
215 v15 = v3->uViewportY; | |
216 v3->uViewportHeight = v11 - v15 + 1; | |
217 v16 = v3->uViewportW; | |
218 v3->uViewportCenterX = v14 >> 1; | |
219 v3->uViewportCenterY = (signed int)(v16 + v15) >> 1; | |
220 } | |
221 else | |
222 { | |
323 | 223 v3->sCosineY = stru_5C6E00->Cos(-v3->sPartyRotY); |
224 v3->sSineY = stru_5C6E00->Sin(-v3->sPartyRotY); | |
225 v3->sCosineNegX = stru_5C6E00->Cos(-v3->sPartyRotX); | |
226 v3->sSineNegX = stru_5C6E00->Sin(-v3->sPartyRotX); | |
0 | 227 v17 = cos((double)-v3->sPartyRotY * 0.0030664064); |
228 v18 = v3->sPartyRotY; | |
229 v3->fCosineY = v17; | |
230 v19 = sin((double)-v18 * 0.0030664064); | |
231 v20 = v3->sPartyRotX; | |
232 v3->fSineY = v19; | |
233 v21 = cos((double)-v20 * 0.0030664064); | |
234 v22 = v3->sPartyRotX; | |
235 v3->fCosineNegX = v21; | |
236 v3->fSineNegX = sin((double)-v22 * 0.0030664064); | |
237 v23 = v3->uViewportX; | |
238 v3->field_64 = a2->field_3C; | |
239 v24 = v3->uViewportZ; | |
240 v3->field_70 = v3->uViewportZ - v23 + 1; | |
241 v25 = v3->uViewportW - v3->uViewportY + 1; | |
242 v3->uViewportHeight = v25; | |
243 v29 = v25; | |
244 v26 = v3->field_64; | |
245 v3->uViewportCenterX = (signed int)(v24 + v23) >> 1; | |
246 v3->uViewportCenterY = v3->uViewportW - ((unsigned __int64)(v26 * (signed __int64)v29) >> 16); | |
247 } | |
248 v27 = (unsigned int)(signed __int64)((double)v3->field_70 * 0.5 / tan((double)(v2->field_1C_mb_fov >> 1) * 0.01745329) | |
249 + 0.5) << 16; | |
250 v3->field_40 = v27; | |
251 LODWORD(v3->field_44) = 4294967296i64 / v27; | |
252 v3->pRenderTarget = v2->pRenderTarget; | |
253 v3->uTargetWidth = v2->uTargetWidth; | |
254 v3->uTargetHeight = v2->uTargetHeight; | |
255 v3->uViewportX = v2->uViewportX; | |
256 v3->uViewportY = v2->uViewportY; | |
257 v3->uViewportZ = v2->uViewportZ; | |
258 v3->uViewportW = v2->uViewportW; | |
259 v3->pTargetZBuffer = v2->pTargetZ; | |
260 result = 0; | |
261 v3->field_8C = 0; | |
262 v3->field_84 = 0; | |
263 v3->uNumFacesRenderedThisFrame = 0; | |
264 v3->field_88 = 0; | |
265 pBLVRenderParams->field_90 = 64; | |
266 pBLVRenderParams->field_94 = 6; | |
267 return result; | |
268 } | |
269 | |
270 //----- (00440B44) -------------------------------------------------------- | |
271 void IndoorLocation::ExecDraw(bool bD3D) | |
272 { | |
273 int v2; // eax@3 | |
795 | 274 //IndoorCameraD3D_Vec4 *v3; // edx@4 |
275 //unsigned int v5; // ecx@9 | |
276 //RenderVertexSoft *v6; // [sp-4h] [bp-8h]@4 | |
0 | 277 |
278 if (bD3D) | |
279 { | |
280 pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
281 for (uint i = 0; i < pBspRenderer->num_faces; ++i) |
0 | 282 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
283 v2 = pBspRenderer->faces[i].uNodeID; |
795 | 284 if (pBspRenderer->nodes[v2].viewing_portal_id == -1) |
285 IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, nullptr, 4, nullptr); | |
0 | 286 else |
795 | 287 IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, pBspRenderer->nodes[v2].std__vector_0007AC, 4, pBspRenderer->nodes[v2].pPortalBounding); |
0 | 288 } |
289 } | |
795 | 290 else for (uint j = 0; j < pBspRenderer->num_faces; ++j ) |
0 | 291 { |
795 | 292 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].field_C; |
293 IndoorLocation::ExecDraw_sw(pBspRenderer->faces[j].uFaceID); | |
0 | 294 } |
295 } | |
296 | |
297 //----- (00440BED) -------------------------------------------------------- | |
298 void __fastcall sub_440BED(IndoorLocation_drawstru *_this) | |
299 { | |
300 unsigned __int16 *v1; // edi@7 | |
301 char *v2; // esi@8 | |
302 int v3; // ecx@9 | |
303 unsigned int v4; // edx@9 | |
304 char *v5; // eax@10 | |
305 signed int v6; // [sp+8h] [bp-8h]@7 | |
306 int v7; // [sp+Ch] [bp-4h]@8 | |
307 | |
308 PrepareDrawLists_BLV(_this); | |
309 if (pBLVRenderParams->uPartySectorID) | |
310 IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0); | |
311 pRenderer->DrawBillboardList_BLV(); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
312 |
0 | 313 if ( !pRenderer->pRenderD3D ) |
314 { | |
486 | 315 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_D3D_OUTLINES) |
316 pBspRenderer->DrawFaceOutlines(); | |
317 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | |
0 | 318 { |
319 v1 = pBLVRenderParams->pRenderTarget; | |
320 v6 = 0; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
321 if ( (signed int)pBspRenderer->num_nodes > 0 ) |
0 | 322 { |
323 v7 = 0; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
324 v2 = (char *)&pBspRenderer->nodes[0].field_C._viewport_space_w; |
0 | 325 do |
326 { | |
327 v3 = *((int *)v2 - 1); | |
328 v4 = pRenderer->uTargetSurfacePitch * *((int *)v2 - 1); | |
329 if ( v3 <= *(int *)v2 ) | |
330 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
331 v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[v3 + v7]; |
0 | 332 do |
333 { | |
334 v1[v4 + *((short *)v5 - 480)] = 255; | |
335 ++v3; | |
336 v1[v4 + *(short *)v5] = 255; | |
337 v4 += pRenderer->uTargetSurfacePitch; | |
338 v5 += 2; | |
339 } | |
340 while ( v3 <= *(int *)v2 ); | |
341 } | |
342 ++v6; | |
343 v7 += 1126; | |
344 v2 += 2252; | |
345 } | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
346 while ( v6 < (signed int)pBspRenderer->num_nodes ); |
0 | 347 } |
348 } | |
349 } | |
350 } | |
351 | |
352 | |
353 | |
354 | |
355 | |
356 //----- (00441BD4) -------------------------------------------------------- | |
357 void IndoorLocation::Draw() | |
358 { | |
186 | 359 //int v0; // eax@1 |
0 | 360 IndoorLocation_drawstru _this; // [sp+0h] [bp-4Ch]@5 |
361 int v2; // [sp+44h] [bp-8h]@5 | |
362 int v3; // [sp+48h] [bp-4h]@5 | |
363 | |
186 | 364 _this.uFlags = 0; |
365 if (viewparams->draw_sw_outlines) | |
366 _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES; | |
367 if (viewparams->draw_d3d_outlines) | |
368 _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; | |
369 | |
791 | 370 _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; |
371 _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES; | |
372 //INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES | |
373 | |
0 | 374 _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed; |
375 _this.field_1C_mb_fov = 65; | |
791 | 376 _this.vPosition.x = pParty->vPosition.x - fixpoint_mul(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); |
377 _this.vPosition.y = pParty->vPosition.y - fixpoint_mul(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); | |
581 | 378 _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel; |
379 _this.sRotationX = pParty->sRotationX; | |
0 | 380 _this.sRotationY = pParty->sRotationY; |
381 _this.pRenderTarget = pRenderer->pTargetSurface; | |
692 | 382 _this.uViewportX = pViewport->uScreen_TL_X; |
383 _this.uViewportY = pViewport->uScreen_TL_Y; | |
384 _this.uViewportZ = pViewport->uScreen_BR_X; | |
385 _this.uViewportW = pViewport->uScreen_BR_Y; | |
0 | 386 _this.field_3C = pViewport->field_30; |
581 | 387 |
0 | 388 _this.uTargetWidth = 640; |
389 _this.uTargetHeight = 480; | |
390 _this.pTargetZ = pRenderer->pActiveZBuffer; | |
391 sub_440BED(&_this); | |
569 | 392 pParty->uFlags &= ~2; |
0 | 393 pGame->DrawParticles(); |
394 array_5118E8._440F07(); | |
395 } | |
396 | |
397 //----- (004C0EF2) -------------------------------------------------------- | |
398 void BLVFace::FromODM(ODMFace *a2) | |
399 { | |
400 this->pFacePlane_old.vNormal.x = a2->pFacePlane.vNormal.x; | |
401 this->pFacePlane_old.vNormal.y = a2->pFacePlane.vNormal.y; | |
402 this->pFacePlane_old.vNormal.z = a2->pFacePlane.vNormal.z; | |
403 this->pFacePlane_old.dist = a2->pFacePlane.dist; | |
404 this->pFacePlane.vNormal.x = (double)(a2->pFacePlane.vNormal.x & 0xFFFF) * 0.000015259022 | |
405 + (double)(a2->pFacePlane.vNormal.x >> 16); | |
406 this->pFacePlane.vNormal.y = (double)(a2->pFacePlane.vNormal.y & 0xFFFF) * 0.000015259022 | |
407 + (double)(a2->pFacePlane.vNormal.y >> 16); | |
408 this->pFacePlane.vNormal.z = (double)(a2->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022 | |
409 + (double)(a2->pFacePlane.vNormal.z >> 16); | |
410 this->pFacePlane.dist = (double)(a2->pFacePlane.dist & 0xFFFF) * 0.000015259022 + (double)(a2->pFacePlane.dist >> 16); | |
411 this->uAttributes = a2->uAttributes; | |
412 this->pBounding.x1 = a2->pBoundingBox.x1; | |
413 this->pBounding.y1 = a2->pBoundingBox.y1; | |
414 this->pBounding.z1 = a2->pBoundingBox.z1; | |
415 this->pBounding.x2 = a2->pBoundingBox.x2; | |
416 this->pBounding.y2 = a2->pBoundingBox.y2; | |
417 this->pBounding.z2 = a2->pBoundingBox.z2; | |
418 this->zCalc1 = a2->zCalc1; | |
419 this->zCalc2 = a2->zCalc2; | |
420 this->zCalc3 = a2->zCalc3; | |
421 this->pXInterceptDisplacements = a2->pXInterceptDisplacements; | |
422 this->pYInterceptDisplacements = a2->pYInterceptDisplacements; | |
423 this->pZInterceptDisplacements = a2->pZInterceptDisplacements; | |
424 this->uPolygonType = (PolygonType)a2->uPolygonType; | |
425 this->uNumVertices = a2->uNumVertices; | |
426 this->uBitmapID = a2->uTextureID; | |
427 this->pVertexIDs = a2->pVertexIDs; | |
428 } | |
429 | |
430 //----- (004B0A25) -------------------------------------------------------- | |
794 | 431 void IndoorLocation::ExecDraw_d3d(unsigned int uFaceID, IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, RenderVertexSoft *pPortalBounding) |
0 | 432 { |
433 //unsigned int v4; // esi@1 | |
434 char *v5; // eax@4 | |
435 signed int v6; // ecx@4 | |
436 char *v7; // eax@8 | |
437 signed int v8; // ecx@8 | |
438 //BLVFace *v9; // esi@13 | |
439 //IndoorCameraD3D *v10; // edi@16 | |
440 //int v11; // ebx@17 | |
441 //Vec3_short_ *v12; // ecx@18 | |
442 //char *v13; // edx@18 | |
443 //int v14; // eax@19 | |
444 //unsigned __int8 v15; // sf@19 | |
445 //unsigned __int8 v16; // of@19 | |
446 int v17; // ebx@25 | |
447 //double v18; // st7@27 | |
448 //double v19; // st6@27 | |
449 //double v20; // st5@27 | |
450 //char v21; // dl@27 | |
451 //unsigned int v22; // eax@44 | |
452 unsigned int v23; // eax@35 | |
453 //DWORD v24; // eax@37 | |
454 //int v25; // eax@38 | |
455 //char *v26; // edi@38 | |
456 IDirect3DTexture2 *v27; // eax@42 | |
457 Texture *v28; // [sp+Ch] [bp-1Ch]@15 | |
458 //int i; // [sp+10h] [bp-18h]@38 | |
459 //LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16 | |
460 //IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16 | |
461 //IndoorCameraD3D_Vec4 *a7; // [sp+1Ch] [bp-Ch]@1 | |
462 //unsigned int uFaceID_; // [sp+20h] [bp-8h]@1 | |
463 unsigned int uNumVerticesa; // [sp+24h] [bp-4h]@17 | |
464 int a4a; // [sp+34h] [bp+Ch]@25 | |
465 //unsigned int a4b; // [sp+34h] [bp+Ch]@38 | |
466 | |
467 //v4 = uFaceID; | |
468 //a7 = pVertices; | |
469 //uFaceID_ = uFaceID; | |
470 if (uFaceID >= pIndoor->uNumFaces) | |
471 return; | |
472 | |
473 static RenderVertexSoft static_vertices_F7C228[64]; | |
474 static RenderVertexSoft static_vertices_F7B628[64]; | |
475 static stru154 stru_F7B60C; // idb | |
476 | |
477 //v9 = &pIndoor->pFaces[uFaceID]; | |
478 auto pFace = &pIndoor->pFaces[uFaceID]; | |
479 if (pFace->uNumVertices < 3) | |
480 return; | |
481 | |
482 | |
483 if (pFace->Invisible()) | |
484 return; | |
485 | |
486 ++pBLVRenderParams->uNumFacesRenderedThisFrame; | |
487 pFace->uAttributes |= 0x80u; | |
488 | |
489 if (!pFace->GetTexture()) | |
490 return; | |
491 | |
492 v28 = pFace->GetTexture(); | |
493 | |
494 if (!pGame->pIndoorCameraD3D->IsCulled(pFace)) | |
495 { | |
496 uNumVerticesa = pFace->uNumVertices; | |
497 for (uint i = 0; i < pFace->uNumVertices; ++i) | |
498 { | |
499 static_vertices_F7C228[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x; | |
500 static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y; | |
501 static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z; | |
502 static_vertices_F7C228[i].u = (signed short)pFace->pVertexUIDs[i]; | |
503 static_vertices_F7C228[i].v = (signed short)pFace->pVertexVIDs[i]; | |
504 } | |
505 | |
506 if (!pVertices || | |
794 | 507 (pGame->pStru9Instance->_498377(pPortalBounding, 4u, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) ) |
0 | 508 { |
795 | 509 if (pGame->pIndoorCameraD3D->CalcPortalShape(static_vertices_F7C228, &uNumVerticesa, |
581 | 510 static_vertices_F7B628, pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum, 4, false, 0) != 1 || uNumVerticesa ) |
0 | 511 { |
512 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); | |
514 sub_4B0E07(uFaceID); | |
515 pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID); | |
516 pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID); | |
517 pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28); | |
518 pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0); | |
519 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
520 if (stru_F8AD28.uNumLightsApplied > 0 || | |
521 pDecalBuilder->uNumDecals > 0) | |
522 { | |
523 stru_F7B60C.face_plane.vNormal.x = pFace->pFacePlane.vNormal.x; | |
524 stru_F7B60C.polygonType = pFace->uPolygonType; | |
525 stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y; | |
526 stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z; | |
527 stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; | |
528 } | |
529 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
530 if (stru_F8AD28.uNumLightsApplied > 0 && !(pFace->uAttributes & FACE_DO_NOT_LIGHT)) |
581 | 531 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0); |
0 | 532 |
533 if (pDecalBuilder->uNumDecals > 0) | |
581 | 534 pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID); |
0 | 535 |
791 | 536 if (pFace->Fluid() && |
265 | 537 pFace->uBitmapID == pRenderer->hd_water_tile_id ) |
0 | 538 { |
539 __debugbreak(); | |
265 | 540 v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
0 | 541 goto LABEL_42; |
542 } | |
543 | |
791 | 544 if (pFace->Fluid()) |
0 | 545 { |
546 //auto v24 = GetTickCount() / 4; | |
547 //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi; | |
548 uint eightSeconds = GetTickCount() % 8000; | |
549 float angle = (eightSeconds / 8000.0f) * 2 * 3.1415f; | |
550 | |
551 //animte lava back and forth | |
552 for (uint i = 0; i < uNumVerticesa; ++i) | |
553 //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)); | |
554 array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle); | |
555 | |
556 v23 = pFace->uBitmapID; | |
557 goto LABEL_42; | |
558 } | |
595 | 559 else if (pFace->uAttributes & 0x4000) |
0 | 560 { |
581 | 561 v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_); |
0 | 562 LABEL_42: |
581 | 563 v27 = pBitmaps_LOD->pHardwareTextures[v23]; |
595 | 564 if (pFace->uAttributes & FACE_DO_NOT_LIGHT) |
581 | 565 _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); |
566 else | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
567 pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); |
581 | 568 return; |
0 | 569 } |
783 | 570 v17 = 0xFFFFFFFF; |
595 | 571 v23 = pFace->uBitmapID; |
572 goto LABEL_42; | |
0 | 573 } |
574 } | |
575 } | |
576 } | |
577 | |
578 //----- (004AFF79) -------------------------------------------------------- | |
579 void IndoorLocation::ExecDraw_sw(unsigned int uFaceID) | |
580 { | |
581 unsigned int v1; // ebx@1 | |
582 BLVFace *v2; // esi@3 | |
583 unsigned int v3; // eax@3 | |
584 Texture *v4; // eax@8 | |
585 Texture *v5; // edi@8 | |
586 int v6; // eax@9 | |
587 int v7; // eax@9 | |
588 int v8; // ecx@17 | |
589 int v9; // ebx@17 | |
590 int v10; // eax@17 | |
591 int v11; // esi@17 | |
592 unsigned int v12; // eax@17 | |
593 int j; // ecx@19 | |
594 int v14; // edx@20 | |
595 int v15; // eax@20 | |
596 int v16; // edx@20 | |
597 int i; // ebx@22 | |
598 int v18; // ecx@23 | |
599 int v19; // eax@23 | |
600 int v20; // eax@23 | |
601 int v21; // eax@24 | |
602 unsigned __int8 *v22; // ecx@24 | |
603 int v23; // ebx@24 | |
604 int v24; // esi@25 | |
605 int v25; // eax@28 | |
606 unsigned __int16 *v26; // eax@28 | |
607 unsigned int v27; // eax@29 | |
608 int v28; // eax@30 | |
609 char *v29; // esi@31 | |
610 int v30; // eax@33 | |
611 int v31; // eax@33 | |
612 int v32; // eax@35 | |
613 int v33; // edx@35 | |
614 signed int v34; // ebx@35 | |
615 int v35; // eax@35 | |
616 int v36; // ebx@35 | |
617 signed int v37; // ebx@35 | |
618 signed int v38; // edi@35 | |
619 unsigned int v39; // edi@36 | |
620 int v40; // edx@40 | |
621 int v41; // ecx@40 | |
622 signed int v42; // edx@40 | |
623 int v43; // edx@42 | |
624 int v44; // eax@42 | |
625 unsigned __int16 *v45; // eax@43 | |
626 int *v46; // esi@44 | |
627 unsigned __int16 *v47; // edi@44 | |
628 unsigned int v48; // edx@44 | |
629 int v49; // ebx@44 | |
630 char v50; // cl@44 | |
631 char v51; // ch@44 | |
632 unsigned int v52; // ebx@46 | |
633 int v53; // edx@46 | |
634 unsigned int v54; // ebx@46 | |
635 int v55; // edx@46 | |
636 unsigned int v56; // ebx@47 | |
637 int v57; // edx@47 | |
638 int v58; // ebx@47 | |
639 int v59; // edx@47 | |
640 unsigned __int16 *v60; // eax@50 | |
641 int *v61; // esi@51 | |
642 unsigned __int16 *v62; // edi@51 | |
643 unsigned int v63; // edx@51 | |
644 int v64; // ebx@51 | |
645 char v65; // cl@51 | |
646 char v66; // ch@51 | |
647 unsigned int v67; // ebx@53 | |
648 int v68; // edx@53 | |
649 unsigned int v69; // ebx@53 | |
650 int v70; // edx@53 | |
651 unsigned int v71; // ebx@54 | |
652 int v72; // edx@54 | |
653 int v73; // ebx@54 | |
654 int v74; // edx@54 | |
655 unsigned __int16 *v75; // eax@58 | |
656 int *v76; // esi@59 | |
657 int v77; // edi@59 | |
658 unsigned int v78; // edx@59 | |
659 int v79; // ebx@59 | |
660 char v80; // cl@59 | |
661 char v81; // ch@59 | |
662 int v82; // ebx@61 | |
663 int v83; // edx@61 | |
664 unsigned int v84; // ebx@62 | |
665 int v85; // edx@62 | |
666 unsigned __int16 *v86; // eax@65 | |
667 int *v87; // esi@66 | |
668 int v88; // edi@66 | |
669 unsigned int v89; // edx@66 | |
670 int v90; // ebx@66 | |
671 char v91; // cl@66 | |
672 char v92; // ch@66 | |
673 int v93; // ebx@68 | |
674 int v94; // edx@68 | |
675 unsigned __int16 v95; // bx@69 | |
676 int v96; // edx@69 | |
677 unsigned __int8 *v97; // [sp+Ch] [bp-9Ch]@24 | |
678 unsigned __int8 *v98; // [sp+10h] [bp-98h]@24 | |
679 unsigned __int8 *v99; // [sp+14h] [bp-94h]@24 | |
680 unsigned __int8 *v100; // [sp+18h] [bp-90h]@24 | |
681 int v101; // [sp+1Ch] [bp-8Ch]@40 | |
682 int v102; // [sp+20h] [bp-88h]@31 | |
683 BLVFace *v103; // [sp+24h] [bp-84h]@3 | |
684 unsigned __int16 *v104; // [sp+28h] [bp-80h]@24 | |
685 int v105; // [sp+2Ch] [bp-7Ch]@30 | |
686 int v106; // [sp+30h] [bp-78h]@24 | |
687 int v107; // [sp+34h] [bp-74h]@9 | |
688 Texture *v108; // [sp+38h] [bp-70h]@8 | |
689 int v109; // [sp+3Ch] [bp-6Ch]@9 | |
690 unsigned int v110; // [sp+40h] [bp-68h]@24 | |
691 unsigned int v111; // [sp+44h] [bp-64h]@1 | |
692 int *k; // [sp+48h] [bp-60h]@31 | |
693 int v113; // [sp+4Ch] [bp-5Ch]@35 | |
694 int v114; // [sp+50h] [bp-58h]@35 | |
695 int v115; // [sp+54h] [bp-54h]@42 | |
696 unsigned __int8 *v116; // [sp+58h] [bp-50h]@35 | |
697 int v117; // [sp+5Ch] [bp-4Ch]@33 | |
698 int a1; // [sp+60h] [bp-48h]@27 | |
699 int v119; // [sp+64h] [bp-44h]@17 | |
700 int v120; // [sp+68h] [bp-40h]@23 | |
701 unsigned int v121; // [sp+6Ch] [bp-3Ch]@40 | |
702 unsigned int v122; // [sp+70h] [bp-38h]@35 | |
703 int v123; // [sp+74h] [bp-34h]@30 | |
704 int v124; // [sp+78h] [bp-30h]@17 | |
705 int v125; // [sp+7Ch] [bp-2Ch]@35 | |
706 unsigned int v126; // [sp+80h] [bp-28h]@9 | |
707 int v127; // [sp+84h] [bp-24h]@17 | |
708 int v128; // [sp+88h] [bp-20h]@9 | |
709 int *pZPixel; // [sp+8Ch] [bp-1Ch]@28 | |
710 int a2; // [sp+90h] [bp-18h]@16 | |
711 unsigned int v131; // [sp+94h] [bp-14h]@17 | |
712 unsigned __int16 *pColorPixel; // [sp+98h] [bp-10h]@28 | |
713 int v133; // [sp+9Ch] [bp-Ch]@17 | |
714 int v134; // [sp+A0h] [bp-8h]@17 | |
715 int v135; // [sp+A4h] [bp-4h]@24 | |
716 | |
717 v1 = uFaceID; | |
718 v111 = pRenderer->uTargetSurfacePitch; | |
719 if ( (uFaceID & 0x80000000u) == 0 ) | |
720 { | |
721 if ( (signed int)uFaceID < (signed int)pIndoor->uNumFaces ) | |
722 { | |
723 v2 = &pIndoor->pFaces[uFaceID]; | |
724 v103 = v2; | |
725 v3 = v2->uAttributes; | |
726 if ( !(BYTE1(v3) & 0x20) ) | |
727 { | |
728 if ( v3 & 0x400000 ) | |
729 { | |
730 sub_4ADD1D(uFaceID); | |
731 return; | |
732 } | |
733 if ( !(v3 & 0x10) || (sub_4AD504(uFaceID), pRenderer->pRenderD3D) ) | |
734 { | |
735 v4 = v2->GetTexture(); | |
736 ++pBLVRenderParams->uNumFacesRenderedThisFrame; | |
737 v5 = v4; | |
738 v108 = v4; | |
739 if ( v4 ) | |
740 { | |
741 v6 = v4->palette_id2; | |
742 LOBYTE(v2->uAttributes) |= 0x80u; | |
743 v109 = v6; | |
744 sub_4AE5F1(v1); | |
745 v126 = stru_F8AD28.pDeltaUV[0]; | |
746 v128 = stru_F8AD28.pDeltaUV[1]; | |
747 v107 = bUseLoResSprites; | |
748 v7 = sub_423B5D(v1); | |
749 if ( v7 ) | |
750 { | |
751 if ( sub_424829(v7, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) | |
752 { | |
753 if ( v2->uPolygonType == 1 ) | |
754 { | |
755 for ( i = 0; i < stru_F8AD28.uNumLightsApplied; stru_F8AD28._blv_lights_ys[v18] = v20 ) | |
756 { | |
757 v18 = i; | |
758 v120 = stru_F8AD28._blv_lights_xs[i]; | |
759 v134 = (unsigned __int64)(v120 * (signed __int64)-stru_F8AD28.plane_4.vNormal.y) >> 16; | |
760 v133 = stru_F8AD28.plane_4.vNormal.x; | |
761 v120 = stru_F8AD28._blv_lights_ys[i]; | |
762 v133 = (unsigned __int64)(v120 * (signed __int64)stru_F8AD28.plane_4.vNormal.x) >> 16; | |
763 v19 = v128; | |
764 stru_F8AD28._blv_lights_xs[i] = v126 | |
765 + v134 | |
766 + ((unsigned __int64)(v120 | |
767 * (signed __int64)stru_F8AD28.plane_4.vNormal.x) >> 16); | |
768 v20 = v19 - stru_F8AD28._blv_lights_zs[i++]; | |
769 } | |
770 } | |
771 else | |
772 { | |
773 if ( v2->uPolygonType != 3 ) | |
774 { | |
775 if ( v2->uPolygonType == 4 ) | |
776 { | |
777 LABEL_16: | |
778 a2 = 0; | |
779 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
780 { | |
781 do | |
782 { | |
783 v8 = a2; | |
784 v9 = stru_F8AD28._blv_lights_xs[a2]; | |
785 v131 = stru_F8AD28._blv_lights_ys[a2]; | |
786 v10 = stru_F8AD28._blv_lights_zs[a2]; | |
787 v11 = (signed int)(v10 * stru_F8AD28.plane_4.vNormal.z | |
788 + stru_F8AD28.plane_4.dist | |
789 + v9 * stru_F8AD28.plane_4.vNormal.x | |
790 + v131 * stru_F8AD28.plane_4.vNormal.y) >> 16; | |
791 v119 = v9 | |
792 - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x | |
793 * (signed __int64)((signed int)(v10 * stru_F8AD28.plane_4.vNormal.z | |
794 + stru_F8AD28.plane_4.dist | |
795 + v9 * stru_F8AD28.plane_4.vNormal.x | |
796 + v131 * stru_F8AD28.plane_4.vNormal.y) >> 16)) >> 16); | |
797 v131 -= (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)v11) >> 16; | |
798 v127 = v10 - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z * (signed __int64)v11) >> 16); | |
799 stru_F8AD28._blv_lights_xs[a2] = ((unsigned __int64)(v119 | |
800 * (signed __int64)stru_F8AD28.vec_14.x) >> 16) | |
801 + ((unsigned __int64)((signed int)v131 | |
802 * (signed __int64)stru_F8AD28.vec_14.y) >> 16); | |
803 v124 = (unsigned __int64)(v119 * (signed __int64)stru_F8AD28.vec_20.x) >> 16; | |
804 v134 = (unsigned __int64)((signed int)v131 * (signed __int64)stru_F8AD28.vec_20.y) >> 16; | |
805 v133 = (unsigned __int64)(v127 * (signed __int64)stru_F8AD28.vec_20.z) >> 16; | |
806 v12 = v126; | |
807 stru_F8AD28._blv_lights_ys[v8] = v124 | |
808 + ((unsigned __int64)((signed int)v131 | |
809 * (signed __int64)stru_F8AD28.vec_20.y) >> 16) | |
810 + ((unsigned __int64)(v127 | |
811 * (signed __int64)stru_F8AD28.vec_20.z) >> 16); | |
812 stru_F8AD28._blv_lights_xs[v8] += v12; | |
813 stru_F8AD28._blv_lights_ys[v8] += v128; | |
814 ++a2; | |
815 } | |
816 while ( a2 < stru_F8AD28.uNumLightsApplied ); | |
817 v2 = v103; | |
818 } | |
819 goto LABEL_24; | |
820 } | |
821 if ( v2->uPolygonType != 5 ) | |
822 { | |
823 if ( v2->uPolygonType != 6 ) | |
824 goto LABEL_24; | |
825 goto LABEL_16; | |
826 } | |
827 } | |
828 for ( j = 0; j < stru_F8AD28.uNumLightsApplied; *(int *)v15 = v16 ) | |
829 { | |
830 v14 = v128; | |
831 stru_F8AD28._blv_lights_xs[j] += v126; | |
832 v15 = 4 * j + 16297672; | |
833 v16 = v14 - stru_F8AD28._blv_lights_ys[j++]; | |
834 } | |
835 } | |
836 LABEL_24: | |
837 v135 = 1; | |
838 pGame->_44ED0A(v2, &v135, 31); | |
839 v104 = sr_sub_47C24C_get_palette(v2, v109, 0, 1); | |
840 v134 = stru_F8AD28.field_44; | |
841 v106 = stru_F8AD28.field_48; | |
842 v21 = stru_F8A590._viewport_space_y; | |
843 a2 = stru_F8A590._viewport_space_y; | |
844 v110 = v111 * stru_F8A590._viewport_space_y; | |
710 | 845 v97 = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 846 v98 = v5->pLevelOfDetail1; |
847 v99 = v5->pLevelOfDetail2; | |
848 v22 = v5->pLevelOfDetail3; | |
849 v23 = 640 * stru_F8A590._viewport_space_y; | |
850 v119 = 640 * stru_F8A590._viewport_space_y; | |
851 v100 = v22; | |
852 if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) | |
853 { | |
854 v24 = 2 * stru_F8A590._viewport_space_y; | |
855 v120 = 2 * stru_F8A590._viewport_space_y; | |
856 while ( 1 ) | |
857 { | |
858 a1 = *(__int16 *)((char *)stru_F8A590.array_18 + v24); | |
859 sub_4AE313(a1, v21, &stru_F81018.field_0); | |
860 if ( LOBYTE(viewparams->field_20) ) | |
861 { | |
862 v27 = v111 * (v24 - pBLVRenderParams->uViewportY); | |
863 pZPixel = &pBLVRenderParams->pTargetZBuffer[2 | |
864 * (*(__int16 *)((char *)stru_F8A590.array_18 + v24) | |
865 + 320 * (v24 - pBLVRenderParams->uViewportY)) | |
866 - pBLVRenderParams->uViewportX]; | |
867 pColorPixel = &pBLVRenderParams->pRenderTarget[v27 | |
868 + 2 * *(__int16 *)((char *)stru_F8A590.array_18 + v24) | |
869 - pBLVRenderParams->uViewportX]; | |
870 v26 = &pBLVRenderParams->pRenderTarget[v27 | |
871 + 2 * *(__int16 *)((char *)stru_F8A590.array_3D8 + v24) | |
872 - pBLVRenderParams->uViewportX]; | |
873 v23 = v119; | |
874 } | |
875 else | |
876 { | |
877 v25 = *(__int16 *)((char *)stru_F8A590.array_18 + v24); | |
878 pZPixel = &pBLVRenderParams->pTargetZBuffer[v25 + v23]; | |
879 pColorPixel = &pBLVRenderParams->pRenderTarget[v25 + v110]; | |
880 v26 = &pBLVRenderParams->pRenderTarget[v110 + *(__int16 *)((char *)stru_F8A590.array_3D8 + v24)]; | |
881 } | |
882 v131 = (unsigned int)v26; | |
883 HIWORD(v28) = HIWORD(stru_F81018.field_0.field_0); | |
884 LOWORD(v28) = 0; | |
885 v105 = stru_F8AD28.field_0 | v28; | |
886 v123 = sub_4AE491(SHIWORD(stru_F81018.field_0.field_4), SHIWORD(stru_F81018.field_0.field_8)); | |
887 if ( (unsigned int)pColorPixel < v131 ) | |
888 { | |
889 v102 = v107 + v106; | |
890 v29 = (char *)&stru_F81018.field_34.field_8; | |
891 a1 += v134; | |
892 for ( k = &stru_F81018.field_34.field_8; ; v29 = (char *)k ) | |
893 { | |
894 sub_4AE313(a1, a2, (stru337_stru0 *)(v29 - 8)); | |
895 v30 = *((int *)v29 - 2); | |
896 LOWORD(v30) = 0; | |
897 v117 = v105; | |
898 v31 = stru_F8AD28.field_0 | v30; | |
899 if ( v105 <= (unsigned int)v31 ) | |
900 v117 = v31; | |
901 v105 = v31; | |
902 v32 = *((int *)v29 - 14); | |
903 v122 = *((int *)v29 - 14) >> v107; | |
904 v33 = *((int *)v29 - 13); | |
905 v125 = *((int *)v29 - 13) >> v107; | |
906 v34 = *((int *)v29 - 1) - v32; | |
907 v113 = (*(int *)v29 - v33) >> v102; | |
908 v35 = *((int *)v29 - 11); | |
909 v114 = v34 >> v102; | |
910 v116 = (&v97)[4 * v35]; | |
911 v36 = v35 + 16 - v5->uWidthLn2; | |
912 v133 = v35 + 16; | |
913 v127 = v35 + v36; | |
914 v37 = v5->uWidthMinus1 >> v35; | |
915 v38 = v5->uHeightMinus1 >> v35 << (v35 + 16); | |
916 v128 = v37; | |
917 v126 = v38; | |
918 v39 = (unsigned int)(LOBYTE(viewparams->field_20) ? &pColorPixel[2 * v134] : &pColorPixel[v134]); | |
919 if ( v39 > v131 ) | |
920 v39 = v131; | |
921 v40 = *((short *)v29 + 1); | |
922 v41 = *((short *)v29 - 1); | |
923 v121 = v39; | |
924 v42 = sub_4AE491(v41, v40); | |
925 v101 = v42; | |
926 v124 = (signed int)(v39 - (int)pColorPixel) >> 1; | |
927 if ( v123 >> 16 == v42 >> 16 || v135 & 2 ) | |
928 { | |
929 v123 = (int)sr_sub_47C24C_get_palette(v103, v109, v123 >> 16, 1); | |
930 if ( LOBYTE(viewparams->field_20) ) | |
931 { | |
932 v86 = pColorPixel; | |
933 if ( (unsigned int)pColorPixel < v121 ) | |
934 { | |
935 v87 = pZPixel; | |
936 v88 = v123; | |
937 v89 = v122; | |
938 v90 = v125; | |
939 v91 = v133; | |
940 v92 = v127; | |
941 if ( v124 & 2 ) | |
942 { | |
943 *pZPixel = v117; | |
944 v87 -= 2; | |
945 v86 = pColorPixel + 2; | |
946 goto LABEL_69; | |
947 } | |
948 do | |
949 { | |
950 v86 += 4; | |
951 v93 = *(&v116[v128 & (v89 >> v91)] + ((v126 & v90) >> v92)); | |
952 v94 = v117; | |
953 LOWORD(v93) = *(short *)(v88 + 2 * v93); | |
954 *v87 = v117; | |
955 v87[1] = v94; | |
956 v87[640] = v94; | |
957 v87[641] = v94; | |
958 *(v86 - 4) = v93; | |
959 *(v86 - 3) = v93; | |
960 v86[636] = v93; | |
961 v86[637] = v93; | |
962 v87[2] = v94; | |
963 v87[3] = v94; | |
964 v87[642] = v94; | |
965 v87[643] = v94; | |
966 v122 += v114; | |
967 v125 += v113; | |
968 v89 = v122; | |
969 v90 = v125; | |
970 LABEL_69: | |
971 v87 += 4; | |
972 v95 = *(short *)(v88 + 2 * *(&v116[v128 & (v89 >> v91)] + ((v126 & v90) >> v92))); | |
973 v96 = v114; | |
974 *(v86 - 2) = v95; | |
975 *(v86 - 1) = v95; | |
976 v86[638] = v95; | |
977 v86[639] = v95; | |
978 v122 += v96; | |
979 v125 += v113; | |
980 v89 = v122; | |
981 v90 = v125; | |
982 } | |
983 while ( (unsigned int)v86 < v121 ); | |
984 pColorPixel = v86; | |
985 pZPixel = v87; | |
986 } | |
987 } | |
988 else | |
989 { | |
990 v75 = pColorPixel; | |
991 if ( (unsigned int)pColorPixel < v121 ) | |
992 { | |
993 v76 = pZPixel; | |
994 v77 = v123; | |
995 v78 = v122; | |
996 v79 = v125; | |
997 v80 = v133; | |
998 v81 = v127; | |
999 if ( v124 & 1 ) | |
1000 { | |
1001 *pZPixel = v117; | |
1002 --v76; | |
1003 v75 = pColorPixel + 1; | |
1004 goto LABEL_62; | |
1005 } | |
1006 do | |
1007 { | |
1008 v75 += 2; | |
1009 v82 = *(&v116[v128 & (v78 >> v80)] + ((v126 & v79) >> v81)); | |
1010 v83 = v117; | |
1011 LOWORD(v82) = *(short *)(v77 + 2 * v82); | |
1012 *v76 = v117; | |
1013 *(v75 - 2) = v82; | |
1014 v76[1] = v83; | |
1015 v122 += v114; | |
1016 v125 += v113; | |
1017 v78 = v122; | |
1018 v79 = v125; | |
1019 LABEL_62: | |
1020 v84 = (unsigned int)(&v116[v128 & (v78 >> v80)] + ((v126 & v79) >> v81)); | |
1021 v76 += 2; | |
1022 v85 = v114; | |
1023 *(v75 - 1) = *(short *)(v77 + 2 * *(char *)v84); | |
1024 v122 += v85; | |
1025 v125 += v113; | |
1026 v78 = v122; | |
1027 v79 = v125; | |
1028 } | |
1029 while ( (unsigned int)v75 < v121 ); | |
1030 pColorPixel = v75; | |
1031 pZPixel = v76; | |
1032 } | |
1033 } | |
1034 } | |
1035 else | |
1036 { | |
1037 v43 = (v42 - v123) >> v106; | |
1038 v44 = v123 - v43; | |
1039 v123 = v43; | |
1040 v115 = v44; | |
1041 if ( LOBYTE(viewparams->field_20) ) | |
1042 { | |
1043 v60 = pColorPixel; | |
1044 if ( (unsigned int)pColorPixel < v121 ) | |
1045 { | |
1046 v61 = pZPixel; | |
1047 v62 = v104; | |
1048 v63 = v122; | |
1049 v64 = v125; | |
1050 v65 = v133; | |
1051 v66 = v127; | |
1052 if ( v124 & 2 ) | |
1053 { | |
1054 *pZPixel = v117; | |
1055 v61 += 2; | |
1056 v60 = pColorPixel + 2; | |
1057 goto LABEL_54; | |
1058 } | |
1059 do | |
1060 { | |
1061 v67 = (v128 & (v63 >> v65)) + ((v126 & v64) >> v66); | |
1062 v68 = v123 + v115; | |
1063 v60 += 4; | |
1064 v115 = v68; | |
1065 v69 = ((v68 & 0xFFFF0000u) >> 8) + v116[v67]; | |
1066 v70 = v117; | |
1067 LOWORD(v69) = v62[v69]; | |
1068 *v61 = v117; | |
1069 v61[1] = v70; | |
1070 v61[640] = v70; | |
1071 v61[641] = v70; | |
1072 *(v60 - 4) = v69; | |
1073 *(v60 - 3) = v69; | |
1074 v60[636] = v69; | |
1075 v60[637] = v69; | |
1076 v61[2] = v70; | |
1077 v61[3] = v70; | |
1078 v61[642] = v70; | |
1079 v61[643] = v70; | |
1080 v122 += v114; | |
1081 v125 += v113; | |
1082 v63 = v122; | |
1083 v64 = v125; | |
1084 v61 += 4; | |
1085 LABEL_54: | |
1086 v71 = (v128 & (v63 >> v65)) + ((v126 & v64) >> v66); | |
1087 v72 = v123 + v115; | |
1088 v73 = v116[v71]; | |
1089 v115 = v72; | |
1090 LOWORD(v73) = v62[((v72 & 0xFFFF0000u) >> 8) + v73]; | |
1091 v74 = v114; | |
1092 *(v60 - 2) = v73; | |
1093 *(v60 - 1) = v73; | |
1094 v60[638] = v73; | |
1095 v60[639] = v73; | |
1096 v122 += v74; | |
1097 v125 += v113; | |
1098 v63 = v122; | |
1099 v64 = v125; | |
1100 } | |
1101 while ( (unsigned int)v60 < v121 ); | |
1102 pColorPixel = v60; | |
1103 pZPixel = v61; | |
1104 } | |
1105 } | |
1106 else | |
1107 { | |
1108 v45 = pColorPixel; | |
1109 if ( (unsigned int)pColorPixel < v121 ) | |
1110 { | |
1111 v46 = pZPixel; | |
1112 v47 = v104; | |
1113 v48 = v122; | |
1114 v49 = v125; | |
1115 v50 = v133; | |
1116 v51 = v127; | |
1117 if ( v124 & 1 ) | |
1118 { | |
1119 *pZPixel = v117; | |
1120 ++v46; | |
1121 v45 = pColorPixel + 1; | |
1122 goto LABEL_47; | |
1123 } | |
1124 do | |
1125 { | |
1126 v52 = (v128 & (v48 >> v50)) + ((v126 & v49) >> v51); | |
1127 v53 = v123 + v115; | |
1128 v45 += 2; | |
1129 v115 = v53; | |
1130 v54 = ((v53 & 0xFFFF0000u) >> 8) + v116[v52]; | |
1131 v55 = v117; | |
1132 LOWORD(v54) = v47[v54]; | |
1133 *v46 = v117; | |
1134 *(v45 - 2) = v54; | |
1135 v46[1] = v55; | |
1136 v122 += v114; | |
1137 v125 += v113; | |
1138 v48 = v122; | |
1139 v49 = v125; | |
1140 v46 += 2; | |
1141 LABEL_47: | |
1142 v56 = (v128 & (v48 >> v50)) + ((v126 & v49) >> v51); | |
1143 v57 = v123 + v115; | |
1144 v58 = v116[v56]; | |
1145 v115 = v57; | |
1146 LOWORD(v58) = v47[((v57 & 0xFFFF0000u) >> 8) + v58]; | |
1147 v59 = v114; | |
1148 *(v45 - 1) = v58; | |
1149 v122 += v59; | |
1150 v125 += v113; | |
1151 v48 = v122; | |
1152 v49 = v125; | |
1153 } | |
1154 while ( (unsigned int)v45 < v121 ); | |
1155 pColorPixel = v45; | |
1156 pZPixel = v46; | |
1157 } | |
1158 } | |
1159 } | |
1160 k += 13; | |
1161 v5 = v108; | |
1162 v123 = v101; | |
1163 a1 += v134; | |
1164 if ( (unsigned int)pColorPixel >= v131 ) | |
1165 break; | |
1166 } | |
1167 v23 = v119; | |
1168 v24 = v120; | |
1169 } | |
1170 ++a2; | |
1171 v110 += v111; | |
1172 v23 += 640; | |
1173 v24 += 2; | |
1174 v120 = v24; | |
1175 v119 = v23; | |
1176 if ( a2 > stru_F8A590._viewport_space_w ) | |
1177 break; | |
1178 v21 = a2; | |
1179 } | |
1180 } | |
1181 return; | |
1182 } | |
1183 } | |
1184 } | |
1185 } | |
1186 } | |
1187 } | |
1188 } | |
1189 } | |
1190 // 4AE491: using guessed type int __fastcall sub_4AE491(int, int); | |
1191 | |
1192 | |
1193 | |
1194 //----- (004B0E07) -------------------------------------------------------- | |
1195 unsigned int __fastcall sub_4B0E07(unsigned int uFaceID) | |
1196 { | |
1197 BLVFace *v1; // edi@1 | |
1198 BLVFaceExtra *v2; // ecx@1 | |
1199 Texture *v3; // esi@1 | |
1200 unsigned int v4; // eax@1 | |
1201 unsigned int v5; // ecx@1 | |
1202 unsigned int result; // eax@1 | |
1203 unsigned int v7; // ecx@5 | |
1204 | |
1205 v1 = &pIndoor->pFaces[uFaceID]; | |
1206 v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID]; | |
1207 v3 = (Texture *)(v1->uBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[v1->uBitmapID] : 0); | |
1208 stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU; | |
1209 stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV; | |
1210 v4 = GetTickCount(); | |
1211 v5 = v1->uAttributes; | |
1212 result = v4 >> 3; | |
1213 if ( v5 & 4 ) | |
1214 { | |
1215 stru_F8AD28.pDeltaUV[1] -= result & v3->uHeightMinus1; | |
1216 } | |
1217 else | |
1218 { | |
1219 if ( v5 & 0x20 ) | |
1220 stru_F8AD28.pDeltaUV[1] += result & v3->uHeightMinus1; | |
1221 } | |
1222 v7 = v1->uAttributes; | |
1223 if ( BYTE1(v7) & 8 ) | |
1224 { | |
1225 stru_F8AD28.pDeltaUV[0] -= result & v3->uWidthMinus1; | |
1226 } | |
1227 else | |
1228 { | |
1229 if ( v7 & 0x40 ) | |
1230 stru_F8AD28.pDeltaUV[0] += result & v3->uWidthMinus1; | |
1231 } | |
1232 return result; | |
1233 } | |
1234 | |
1235 //----- (004B0EA8) -------------------------------------------------------- | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1236 void BspRenderer::AddFaceToRenderList_d3d(unsigned int node_id, unsigned int uFaceID) |
0 | 1237 { |
1238 //unsigned int v3; // edx@1 | |
1239 //stru170 *v4; // ebx@1 | |
1240 //BLVFace *v5; // eax@1 | |
1241 //int v6; // ecx@2 | |
1242 unsigned __int16 v7; // ax@11 | |
1243 Vec3_short_ *v8; // esi@15 | |
1244 int v9; // edx@15 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1245 //signed int v10; // eax@18 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1246 //signed int v11; // edi@19 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1247 //signed int v12; // ecx@19 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1248 //signed int v13; // esi@19 |
0 | 1249 signed int v14; // edx@20 |
1250 int v15; // edx@24 | |
1251 //int v16; // esi@29 | |
1252 //BLVFace *v17; // edi@34 | |
1253 unsigned __int16 v18; // ax@34 | |
1254 char *v19; // eax@38 | |
1255 signed int v20; // ecx@38 | |
1256 char *v21; // eax@42 | |
1257 signed int v22; // ecx@42 | |
1258 //signed int v23; // edx@45 | |
1259 //char *v24; // ecx@46 | |
1260 //int v25; // eax@47 | |
1261 //Vec3_short_ *v26; // eax@47 | |
1262 //double v27; // st7@47 | |
1263 //signed int v28; // ST28_4@47 | |
1264 char v29; // al@48 | |
795 | 1265 //signed int v30; // eax@51 |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1266 //int v31; // eax@52 |
0 | 1267 //unsigned int v32; // eax@55 |
1268 //__int16 v33; // cx@56 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1269 //signed int v34; // [sp+Ch] [bp-14h]@18 |
0 | 1270 //int a0; // [sp+14h] [bp-Ch]@2 |
1271 //IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1272 //signed int v37; // [sp+18h] [bp-8h]@19 |
0 | 1273 //stru10 *v38; // [sp+18h] [bp-8h]@36 |
1274 //BLVFace *v39; // [sp+1Ch] [bp-4h]@1 | |
1275 | |
1276 //v3 = uFaceID; | |
1277 //v4 = this; | |
1278 //v5 = &pIndoor->pFaces[uFaceID]; | |
795 | 1279 nodes[num_nodes].viewing_portal_id = -1; |
0 | 1280 //v39 = &pIndoor->pFaces[uFaceID]; |
1281 | |
1282 auto pFace = &pIndoor->pFaces[uFaceID]; | |
1283 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1284 if (!pFace->Portal()) |
0 | 1285 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1286 if (num_faces < 1000) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1287 { |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1288 faces[num_faces].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1289 faces[num_faces++].uNodeID = node_id; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1290 } |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1291 return; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1292 } |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1293 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1294 auto p = &nodes[node_id]; |
0 | 1295 //v6 = (int)((char *)this + 2252 * a2); |
1296 //a0 = v6; | |
1297 if (p->uFaceID == uFaceID) | |
1298 return; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1299 if (!node_id && |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1300 pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane |
0 | 1301 pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && |
1302 pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && | |
1303 pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && | |
1304 pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && | |
1305 pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) | |
1306 { | |
1307 if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | |
1308 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1309 + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane |
0 | 1310 { |
1311 v7 = pFace->uSectorID; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1312 if ( nodes[0].uSectorID == v7 ) // draw back sector |
0 | 1313 v7 = pFace->uBackSectorID; |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1314 nodes[num_nodes].uSectorID = v7; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1315 nodes[num_nodes].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1316 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1317 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1318 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1319 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1320 nodes[num_nodes++].field_C._43F9E1(pBLVRenderParams->uViewportX, |
678
35a97ce58790
fixed stru10::49C9E3 (cause for attempting to get cross product on zero vectors)
Nomad
parents:
676
diff
changeset
|
1321 pBLVRenderParams->uViewportY, |
35a97ce58790
fixed stru10::49C9E3 (cause for attempting to get cross product on zero vectors)
Nomad
parents:
676
diff
changeset
|
1322 pBLVRenderParams->uViewportZ, |
35a97ce58790
fixed stru10::49C9E3 (cause for attempting to get cross product on zero vectors)
Nomad
parents:
676
diff
changeset
|
1323 pBLVRenderParams->uViewportW); |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1324 AddBspNodeToRenderList(num_nodes - 1); |
0 | 1325 return; |
1326 } | |
1327 //v5 = v39; | |
1328 //v6 = a0; | |
1329 } | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1330 |
0 | 1331 v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]]; |
1332 v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x) | |
1333 + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y) | |
1334 + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); | |
1335 if (p->uSectorID != pFace->uSectorID) | |
1336 v9 = -v9; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1337 if (v9 >= 0) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1338 return; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1339 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1340 auto num_vertices = sub_423B5D(uFaceID); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1341 if (num_vertices < 2) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1342 return; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1343 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1344 auto face_min_screenspace_x = _50BAC8_screen_space_x[0], |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1345 face_max_screenspace_x = _50BAC8_screen_space_x[0]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1346 auto face_min_screenspace_y = _50B9D8_screen_space_y[0], |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1347 face_max_screenspace_y = _50B9D8_screen_space_y[0]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1348 for (uint i = 1; i < num_vertices; ++i) |
0 | 1349 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1350 if (face_min_screenspace_x > _50BAC8_screen_space_x[i]) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1351 face_min_screenspace_x = _50BAC8_screen_space_x[i]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1352 if (face_max_screenspace_x < _50BAC8_screen_space_x[i]) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1353 face_max_screenspace_x = _50BAC8_screen_space_x[i]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1354 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1355 if (face_min_screenspace_y > _50B9D8_screen_space_y[i]) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1356 face_min_screenspace_y = _50B9D8_screen_space_y[i]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1357 if (face_max_screenspace_y < _50B9D8_screen_space_y[i]) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1358 face_max_screenspace_y = _50B9D8_screen_space_y[i]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1359 } |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1360 //v10 = sub_423B5D(uFaceID); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1361 //v34 = v10; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1362 //if ( v10 ) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1363 //{ |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1364 /* v11 = _50BAC8_screen_space_x[0]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1365 v12 = _50B9D8_screen_space_y[0]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1366 a2 = _50BAC8_screen_space_x[0]; |
0 | 1367 v13 = 1; |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1368 v37 = _50B9D8_screen_space_y[0]; |
0 | 1369 if ( v10 > 1 ) |
1370 { | |
1371 do | |
1372 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1373 v14 = _50BAC8_screen_space_x[v13]; |
0 | 1374 if ( v14 < a2 ) |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1375 a2 = _50BAC8_screen_space_x[v13]; |
0 | 1376 if ( v14 > v11 ) |
1377 v11 = v14; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1378 v15 = _50B9D8_screen_space_y[v13]; |
0 | 1379 if ( v15 < v37 ) |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1380 v37 = _50B9D8_screen_space_y[v13]; |
0 | 1381 if ( v15 > v12 ) |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1382 v12 = _50B9D8_screen_space_y[v13]; |
0 | 1383 v10 = v34; |
1384 ++v13; | |
1385 } | |
1386 while ( v13 < v34 ); | |
1387 } | |
1388 //v16 = a0; | |
1389 if (v11 >= p->uViewportX && | |
1390 a2 <= p->uViewportZ && | |
1391 v12 >= p->uViewportY && | |
1392 v37 <= p->uViewportW && | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1393 sub_424829(v10, &nodes[num_nodes].field_C, &p->field_C, uFaceID))*/ |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1394 if (face_max_screenspace_x >= p->uViewportX && |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1395 face_min_screenspace_x <= p->uViewportZ && |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1396 face_max_screenspace_y >= p->uViewportY && |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1397 face_min_screenspace_y <= p->uViewportW && |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1398 sub_424829(num_vertices, &nodes[num_nodes].field_C, &p->field_C, uFaceID)) |
0 | 1399 { |
1400 //v17 = v39; | |
1401 v18 = pFace->uSectorID; | |
1402 if (p->uSectorID == v18 ) | |
1403 v18 = pFace->uBackSectorID; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1404 nodes[num_nodes].uSectorID = v18; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1405 nodes[num_nodes].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1406 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1407 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1408 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1409 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; |
0 | 1410 //v38 = pGame->pStru10Instance; |
1411 //a0a = pGame->pIndoorCameraD3D; | |
795 | 1412 v29 = false; |
1413 if (p->viewing_portal_id == -1) | |
0 | 1414 { |
795 | 1415 v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); |
0 | 1416 } |
1417 else | |
1418 { | |
618
5cfb5dadf330
Margareth righ-click (addded constructor to NPCProfession) and cleaned BLV debug logs
Nomad
parents:
595
diff
changeset
|
1419 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; |
5cfb5dadf330
Margareth righ-click (addded constructor to NPCProfession) and cleaned BLV debug logs
Nomad
parents:
595
diff
changeset
|
1420 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; |
0 | 1421 |
1422 for (uint k = 0; k < pFace->uNumVertices; ++k) | |
1423 { | |
795 | 1424 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; |
1425 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; | |
1426 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; | |
0 | 1427 } |
795 | 1428 |
1429 | |
1430 unsigned int a2 = pFace->uNumVertices; | |
1431 pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, | |
1432 &a2, | |
1433 static_subAddFaceToRenderList_d3d_stru_F79E08, | |
1434 p->std__vector_0007AC, 4, 0, 0); | |
1435 | |
1436 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &a2, | |
1437 nodes[num_nodes].std__vector_0007AC, | |
1438 nodes[num_nodes].pPortalBounding); | |
0 | 1439 } |
1440 if ( v29 ) | |
1441 { | |
795 | 1442 assert(num_nodes < 150); |
1443 | |
1444 nodes[num_nodes].viewing_portal_id = uFaceID; | |
1445 AddBspNodeToRenderList(++num_nodes - 1); | |
0 | 1446 } |
486 | 1447 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) |
0 | 1448 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); |
791 | 1449 //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); |
0 | 1450 } |
1451 } | |
1452 | |
1453 | |
1454 //----- (004AFB86) -------------------------------------------------------- | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1455 void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID) |
0 | 1456 { |
1457 BspRenderer *v3; // ebx@1 | |
1458 BLVFace *v4; // eax@1 | |
1459 char *v5; // ecx@2 | |
1460 unsigned __int16 v6; // ax@11 | |
1461 int v7; // ecx@13 | |
1462 Vec3_short_ *v8; // esi@16 | |
1463 int v9; // edx@16 | |
1464 signed int v10; // eax@19 | |
1465 signed int v11; // edi@20 | |
1466 signed int v12; // ecx@20 | |
1467 signed int v13; // esi@20 | |
1468 int v14; // edx@21 | |
1469 int v15; // edx@25 | |
1470 unsigned __int16 v16; // ax@35 | |
1471 signed int v17; // eax@37 | |
1472 int v18; // eax@38 | |
1473 signed int v19; // [sp+Ch] [bp-14h]@19 | |
1474 char *v20; // [sp+14h] [bp-Ch]@2 | |
1475 BLVFace *v21; // [sp+18h] [bp-8h]@1 | |
1476 signed int v22; // [sp+1Ch] [bp-4h]@20 | |
1477 signed int v23; // [sp+28h] [bp+8h]@20 | |
1478 | |
1479 v3 = this; | |
1480 v4 = &pIndoor->pFaces[uFaceID]; | |
1481 v21 = v4; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1482 if (v4->Portal()) |
0 | 1483 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1484 v5 = (char *)this + 2252 * node_id; |
0 | 1485 v20 = v5; |
1486 if ( uFaceID == *((short *)v5 + 2982) ) | |
1487 return; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1488 if (!node_id |
0 | 1489 && pBLVRenderParams->vPartyPos.x >= v4->pBounding.x1 - 16 |
1490 && pBLVRenderParams->vPartyPos.x <= v4->pBounding.x2 + 16 | |
1491 && pBLVRenderParams->vPartyPos.y >= v4->pBounding.y1 - 16 | |
1492 && pBLVRenderParams->vPartyPos.y <= v4->pBounding.y2 + 16 | |
1493 && pBLVRenderParams->vPartyPos.z >= v4->pBounding.z1 - 16 | |
1494 && pBLVRenderParams->vPartyPos.z <= v4->pBounding.z2 + 16 ) | |
1495 { | |
1496 if ( abs(v4->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * v4->pFacePlane_old.vNormal.x | |
1497 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y | |
1498 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 ) | |
1499 { | |
1500 v6 = v21->uSectorID; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1501 if ( v3->nodes[0].uSectorID == v6 ) |
0 | 1502 v6 = v21->uBackSectorID; |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1503 v3->nodes[v3->num_nodes].uSectorID = v6; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1504 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1505 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1506 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1507 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1508 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1509 v3->nodes[v3->num_nodes++].field_C._43F9E1( |
0 | 1510 SLOWORD(pBLVRenderParams->uViewportX), |
1511 pBLVRenderParams->uViewportY, | |
1512 SLOWORD(pBLVRenderParams->uViewportZ), | |
1513 pBLVRenderParams->uViewportW); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1514 v7 = v3->num_nodes - 1; |
0 | 1515 goto LABEL_14; |
1516 } | |
1517 v4 = v21; | |
1518 v5 = v20; | |
1519 } | |
1520 v8 = &pIndoor->pVertices[*v4->pVertexIDs]; | |
1521 v9 = v4->pFacePlane_old.vNormal.x * ((signed __int16)*(int *)&v8->x - pBLVRenderParams->vPartyPos.x) | |
1522 + v4->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v8->x >> 16) - pBLVRenderParams->vPartyPos.y) | |
1523 + v4->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); | |
1524 if ( *((short *)v5 + 2004) != v4->uSectorID ) | |
1525 v9 = -v9; | |
1526 if ( v9 < 0 ) | |
1527 { | |
1528 v10 = sub_423B5D(uFaceID); | |
1529 v19 = v10; | |
1530 if ( v10 ) | |
1531 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1532 v11 = _50BAC8_screen_space_x[0]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1533 v12 = _50B9D8_screen_space_y[0]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1534 v23 = _50BAC8_screen_space_x[0]; |
0 | 1535 v13 = 1; |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1536 v22 = _50B9D8_screen_space_y[0]; |
0 | 1537 if ( v10 > 1 ) |
1538 { | |
1539 do | |
1540 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1541 v14 = _50BAC8_screen_space_x[v13]; |
0 | 1542 if ( v14 < v23 ) |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1543 v23 = _50BAC8_screen_space_x[v13]; |
0 | 1544 if ( v14 > v11 ) |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1545 v11 = _50BAC8_screen_space_x[v13]; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1546 v15 = _50B9D8_screen_space_y[v13]; |
0 | 1547 if ( v15 < v22 ) |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1548 v22 = _50B9D8_screen_space_y[v13]; |
0 | 1549 if ( v15 > v12 ) |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1550 v12 = _50B9D8_screen_space_y[v13]; |
0 | 1551 v10 = v19; |
1552 ++v13; | |
1553 } | |
1554 while ( v13 < v19 ); | |
1555 } | |
1556 if ( v11 >= *((short *)v20 + 2005) | |
1557 && v23 <= *((short *)v20 + 2007) | |
1558 && v12 >= *((short *)v20 + 2006) | |
1559 && v22 <= *((short *)v20 + 2008) | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1560 && sub_424829(v10, &v3->nodes[v3->num_nodes].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) ) |
0 | 1561 { |
1562 v16 = v21->uSectorID; | |
1563 if ( *((short *)v20 + 2004) == v16 ) | |
1564 v16 = v21->uBackSectorID; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1565 v3->nodes[v3->num_nodes].uSectorID = v16; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1566 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1567 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1568 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1569 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1570 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1571 v17 = v3->num_nodes; |
0 | 1572 if ( v17 < 150 ) |
1573 { | |
1574 v18 = v17 + 1; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1575 v3->num_nodes = v18; |
0 | 1576 v7 = v18 - 1; |
1577 LABEL_14: | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1578 AddBspNodeToRenderList(v7); |
0 | 1579 return; |
1580 } | |
1581 } | |
1582 } | |
1583 } | |
1584 } | |
1585 else | |
1586 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1587 if (num_faces < 1000) |
0 | 1588 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1589 faces[num_faces].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1590 faces[num_faces++].uNodeID = node_id; |
0 | 1591 } |
1592 } | |
1593 } | |
1594 | |
1595 //----- (004B0967) -------------------------------------------------------- | |
486 | 1596 void BspRenderer::DrawFaceOutlines() |
0 | 1597 { |
1598 signed int i; // edi@1 | |
1599 int v1; // esi@2 | |
1600 unsigned int v2; // ecx@4 | |
1601 int v3; // eax@4 | |
1602 int v4; // eax@6 | |
1603 unsigned __int16 *v5; // edx@6 | |
1604 int v6; // ecx@7 | |
1605 int v7; // esi@8 | |
1606 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1607 for ( i = 0; i < (signed int)pBspRenderer->num_faces; ++i ) |
0 | 1608 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1609 v1 = pBspRenderer->faces[i].uFaceID; |
0 | 1610 if ( v1 >= 0 ) |
1611 { | |
1612 if ( v1 < (signed int)pIndoor->uNumFaces ) | |
1613 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1614 v2 = pBspRenderer->faces[i].uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
1615 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C; |
0 | 1616 v3 = sub_423B5D(v2); |
1617 if ( v3 ) | |
1618 { | |
1619 if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) | |
1620 { | |
1621 v4 = stru_F8A590._viewport_space_y; | |
1622 v5 = pBLVRenderParams->pRenderTarget; | |
1623 if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) | |
1624 { | |
1625 v6 = 640 * stru_F8A590._viewport_space_y; | |
1626 do | |
1627 { | |
1628 v5[v6 + stru_F8A590.array_18[v4]] = -1; | |
1629 v7 = v6 + stru_F8A590.array_3D8[v4]; | |
1630 v6 += 640; | |
1631 v5[v7] = -1; | |
1632 ++v4; | |
1633 } | |
1634 while ( v4 <= stru_F8A590._viewport_space_w ); | |
1635 } | |
1636 } | |
1637 } | |
1638 } | |
1639 } | |
1640 } | |
1641 } | |
1642 | |
1643 | |
1644 //----- (004AE5BA) -------------------------------------------------------- | |
1645 Texture *BLVFace::GetTexture() | |
1646 { | |
1647 unsigned int v1; // ecx@2 | |
1648 | |
1649 if ( uAttributes & 0x4000 ) | |
1650 v1 = pTextureFrameTable->GetFrameTexture(this->uBitmapID, pBLVRenderParams->field_0_timer_); | |
1651 else | |
1652 v1 = uBitmapID; | |
1653 return (Texture *)(v1 != -1 ? (int)&pBitmaps_LOD->pTextures[v1] : 0); | |
1654 } | |
1655 | |
1656 | |
1657 //----- (00498B15) -------------------------------------------------------- | |
1658 void IndoorLocation::Release() | |
1659 { | |
1660 IndoorLocation *v1; // esi@1 | |
1661 char *v2; // ebp@1 | |
1662 void *v3; // ST00_4@1 | |
1663 | |
1664 v1 = this; | |
1665 v2 = (char *)&this->ptr_0002B4_doors_ddata; | |
1666 pAllocator->FreeChunk(this->ptr_0002B4_doors_ddata); | |
1667 *(int *)v2 = 0; | |
1668 pAllocator->FreeChunk(v1->ptr_0002B0_sector_rdata); | |
1669 v1->ptr_0002B0_sector_rdata = 0; | |
1670 pAllocator->FreeChunk(v1->ptr_0002B8_sector_lrdata); | |
1671 v1->ptr_0002B8_sector_lrdata = 0; | |
1672 pAllocator->FreeChunk(v1->ptr_2AC); | |
1673 v1->ptr_2AC = 0; | |
1674 pAllocator->FreeChunk(v1->pSpawnPoints); | |
1675 v3 = v1->pVertices; | |
1676 v1->pSpawnPoints = 0; | |
1677 v1->uNumSectors = 0; | |
1678 v1->uNumFaces = 0; | |
1679 v1->uNumVertices = 0; | |
1680 v1->uNumNodes = 0; | |
1681 v1->uNumDoors = 0; | |
1682 v1->uNumLights = 0; | |
1683 pAllocator->FreeChunk(v3); | |
1684 pAllocator->FreeChunk(v1->pFaces); | |
1685 pAllocator->FreeChunk(v1->pFaceExtras); | |
1686 pAllocator->FreeChunk(v1->pSectors); | |
1687 pAllocator->FreeChunk(v1->pLights); | |
1688 pAllocator->FreeChunk(v1->pDoors); | |
1689 pAllocator->FreeChunk(v1->pNodes); | |
1690 pAllocator->FreeChunk(v1->pMapOutlines); | |
1691 v1->pVertices = 0; | |
1692 v1->pFaces = 0; | |
1693 v1->pFaceExtras = 0; | |
1694 v1->pSectors = 0; | |
1695 v1->pLights = 0; | |
1696 v1->pDoors = 0; | |
1697 v1->pNodes = 0; | |
1698 v1->pMapOutlines = 0; | |
1699 v1->bLoaded = 0; | |
1700 } | |
1701 | |
1702 //----- (00498C45) -------------------------------------------------------- | |
711 | 1703 bool IndoorLocation::Alloc() |
1704 { | |
1705 pVertices = (Vec3_short_ *) pAllocator->AllocNamedChunk(pVertices, 15000*sizeof(Vec3_short_), "L.V");//0x15F90u | |
1706 pFaces = (BLVFace *) pAllocator->AllocNamedChunk(pFaces, 10000*sizeof(BLVFace), "L.F");//0xEA600u | |
1707 pFaceExtras = (BLVFaceExtra *) pAllocator->AllocNamedChunk(pFaceExtras,5000*sizeof(BLVFaceExtra), "L.FX"); //0x2BF20u | |
1708 pSectors = (BLVSector *) pAllocator->AllocNamedChunk(pSectors, 512*sizeof(BLVSector), "L.R");//0xE800u | |
1709 pLights = (BLVLightMM7 *) pAllocator->AllocNamedChunk(pLights, 400*sizeof(BLVLightMM7), "L.L");//0x1900u | |
1710 pDoors = (BLVDoor *) pAllocator->AllocNamedChunk(pDoors, 200*sizeof(BLVDoor), "L.D");//0x3E80u | |
1711 pNodes = (BSPNode *) pAllocator->AllocNamedChunk(pNodes, 5000*sizeof(BSPNode), "L.BSP");//0x9C40u | |
1712 pMapOutlines =(BLVMapOutlines *)pAllocator->AllocNamedChunk(pMapOutlines, sizeof(BLVMapOutlines), "L.Map");//0x14824u | |
1713 if (pVertices && pFaces && pFaceExtras && pSectors && pLights && pDoors && pNodes && pMapOutlines ) | |
0 | 1714 { |
711 | 1715 memset(pVertices, 0, 15000*sizeof(Vec3_short_)); |
1716 memset(pFaces, 0, 10000*sizeof(BLVFace)); | |
1717 memset(pFaceExtras,0, 5000*sizeof(BLVFaceExtra)); | |
1718 memset(pSectors, 0, 512*sizeof(BLVSector)); | |
1719 memset(pLights, 0, 400*sizeof(BLVLightMM7)); | |
1720 memset(pDoors, 0, 200*sizeof(BLVDoor)); | |
1721 memset(pNodes, 0, 5000*sizeof(BSPNode)); | |
1722 memset(pMapOutlines,0, sizeof(BLVMapOutlines)); | |
1723 return true; | |
0 | 1724 } |
1725 else | |
1726 { | |
711 | 1727 return false; |
0 | 1728 } |
1729 } | |
1730 | |
1731 | |
1732 | |
1733 //----- (00444810) -------------------------------------------------------- | |
1734 unsigned int IndoorLocation::GetLocationIndex(const char *Str1) | |
1735 { | |
1736 const char *v1; // edi@1 | |
1737 signed int v2; // esi@1 | |
1738 | |
434 | 1739 for (uint i = 0; i < 11; ++i) |
1740 if (!strcmpi(Str1, _4E6BDC_loc_names[i])) | |
1741 return i + 1; | |
1742 return 0; | |
0 | 1743 } |
1744 | |
1745 | |
1746 | |
1747 //----- (004488F7) -------------------------------------------------------- | |
711 | 1748 void IndoorLocation::ToggleLight(signed int sLightID, unsigned int bToggle) |
0 | 1749 { |
1750 char *v2; // eax@4 | |
1751 | |
711 | 1752 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && (sLightID <= pIndoor->uNumLights - 1) && (sLightID >= 0) ) |
0 | 1753 { |
711 | 1754 v2 = (char *)&pIndoor->pLights[sLightID].uAtributes; |
0 | 1755 if ( bToggle ) |
1756 *v2 &= 0xF7u; | |
1757 else | |
1758 *v2 |= 8u; | |
1759 pParty->uFlags |= 2u; | |
1760 } | |
1761 } | |
1762 | |
1763 | |
1764 //----- (00498E0A) -------------------------------------------------------- | |
1765 bool IndoorLocation::Load(char *pFilename, int a3, size_t _i, char *pDest) | |
1766 { | |
1767 /*unsigned int v5; // ebx@1 | |
1768 //IndoorLocation *v6; // esi@1 | |
1769 FILE *v7; // edi@3 | |
1770 bool result; // eax@3 | |
1771 char *v9; // ecx@4 | |
1772 void *v10; // eax@4 | |
1773 //unsigned __int8 v11; // zf@4 | |
1774 //unsigned __int8 v12; // sf@4 | |
1775 int v13; // eax@5 | |
1776 size_t v14; // ecx@6 | |
1777 char *v15; // ecx@6 | |
1778 int v16; // edx@6 | |
1779 size_t v17; // ecx@6 | |
1780 char *v18; // ecx@6 | |
1781 int v19; // edx@6 | |
1782 unsigned __int16 *v20; // edx@6 | |
1783 unsigned __int16 *v21; // edx@6 | |
1784 unsigned __int16 *v22; // edx@6 | |
1785 __int16 v23; // ax@10 | |
1786 char *v24; // ecx@10 | |
1787 __int16 v25; // cx@10 | |
1788 __int16 v26; // ax@11 | |
1789 char *v27; // ecx@11 | |
1790 unsigned __int16 v28; // ax@17 | |
1791 BLVFaceExtra *v29; // ecx@17 | |
1792 char *v30; // edx@17 | |
1793 int v31; // ecx@20 | |
1794 void *v32; // eax@25 | |
1795 int v33; // eax@26 | |
1796 unsigned __int16 *v34; // edx@27 | |
1797 size_t v35; // ecx@27 | |
1798 char *v36; // ecx@27 | |
1799 int v37; // edx@27 | |
1800 size_t v38; // ecx@27 | |
1801 char *v39; // ecx@27 | |
1802 int v40; // edx@27 | |
1803 unsigned __int16 *v41; // edx@27 | |
1804 unsigned __int16 *v42; // edx@27 | |
1805 unsigned __int16 *v43; // edx@27 | |
1806 unsigned __int16 *v44; // edx@27 | |
1807 size_t v45; // ecx@27 | |
1808 unsigned __int16 *v46; // edx@27 | |
1809 void *v47; // eax@28 | |
1810 BLVSector *v48; // eax@29 | |
1811 size_t v49; // ecx@29 | |
1812 unsigned __int16 *v50; // edx@31 | |
1813 void *v51; // eax@32 | |
1814 int v52; // eax@33 | |
1815 unsigned __int16 *v53; // edx@34 | |
1816 size_t v54; // ecx@34 | |
1817 char *v55; // ecx@34 | |
1818 int v56; // edx@34 | |
1819 size_t v57; // ecx@34 | |
1820 char *v58; // ecx@34 | |
1821 int v59; // edx@34 | |
1822 unsigned __int16 *v60; // edx@34 | |
1823 unsigned __int16 *v61; // edx@34 | |
1824 unsigned __int16 *v62; // edx@34 | |
1825 unsigned __int16 *v63; // edx@34 | |
1826 int v64; // ecx@34 | |
1827 BLVDoor *v65; // ecx@36 | |
1828 char *v66; // eax@37 | |
1829 int v67; // edx@38 | |
1830 int v68; // ecx@38 | |
1831 BLVFace *v69; // edx@38 | |
1832 int v70; // ecx@38 | |
1833 int v71; // edx@38 | |
1834 int v72; // eax@38 | |
1835 unsigned __int16 v73; // ax@42 | |
1836 char *v74; // ecx@42 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1837 SpriteObject *v75; // ecx@44 |
0 | 1838 size_t v76; // eax@45 |
1839 int j; // edx@46 | |
1840 unsigned __int16 v78; // ax@50 | |
1841 void *v79; // eax@52 | |
1842 void **v80; // esi@52 | |
1843 unsigned int v145; // eax@103 | |
1844 void *v146; // eax@103 | |
1845 unsigned int v147; // ecx@103 | |
1846 int v148; // ebx@103 | |
1847 unsigned int *v149; // ecx@103*/ | |
1848 //size_t v150; // eax@103 | |
1849 //unsigned int v151; // ebx@109 | |
1850 //unsigned int v152; // ecx@116 | |
1851 //unsigned int v153; // eax@117 | |
1852 //size_t v154; // ebx@126 | |
1853 //unsigned int v155; // ebx@134 | |
1854 //size_t v156; // eax@140 | |
1855 //signed int v157; // ebx@142 | |
1856 //int v158; // ebx@148 | |
1857 //BLVFace *v159; // eax@149 | |
1858 // BLVFaceExtra *v160; // ecx@149 | |
1859 //BLVFaceExtra *v161; // ecx@149 | |
1860 //signed int v162; // ebx@154 | |
1861 //unsigned int v163; // ebx@157 | |
1862 //unsigned int v164; // ebx@157 | |
1863 //unsigned int v165; // edx@158 | |
1864 //char *v166; // ecx@158 | |
1865 //unsigned __int16 v167; // ax@161 | |
1866 //__int16 v168; // ax@165 | |
1867 //unsigned int v169; // ebx@168 | |
1868 //void *v170; // eax@168 | |
1869 //size_t v171; // ebx@168 | |
1870 //int v172; // edx@168 | |
1871 //BLVDoor *v173; // ecx@169 | |
1872 //int k; // eax@169 | |
1873 //BLVDoor *v175; // ecx@172 | |
1874 //int v176; // edx@172 | |
1875 //BLVDoor *v177; // ecx@172 | |
1876 //int v178; // edx@172 | |
1877 //BLVDoor *v179; // ecx@172 | |
1878 //int v180; // edx@172 | |
1879 //BLVDoor *v181; // ecx@172 | |
1880 //int v182; // edx@172 | |
1881 //BLVDoor *v183; // ecx@172 | |
1882 //int v184; // edx@172 | |
1883 //BLVDoor *v185; // ecx@172 | |
1884 //int v186; // edx@172 | |
1885 //BLVDoor *v187; // ecx@172 | |
1886 //int v188; // edx@172 | |
1887 //unsigned __int16 *v189; // ebx@172 | |
1888 //char *v190; // edx@173 | |
1889 //BLVDoor *v191; // ecx@174 | |
1890 //BLVDoor *l; // eax@175 | |
1891 //signed int v193; // ebx@176 | |
1892 //int v194; // ecx@176 | |
1893 //BLVFaceExtra *v195; // ecx@176 | |
1894 //BLVFace *v196; // ebx@178 | |
1895 //std::string v197; // [sp-18h] [bp-680h]@66 | |
1896 //void *v198; // [sp-14h] [bp-67Ch]@72 | |
1897 //size_t v199; // [sp-10h] [bp-678h]@72 | |
1898 //size_t v200; // [sp-Ch] [bp-674h]@72 | |
1899 //const char *v201; // [sp-8h] [bp-670h]@4 | |
1900 //int v202; // [sp-4h] [bp-66Ch]@4 | |
1901 char v203[875]; // [sp+Ch] [bp-65Ch]@130 | |
1902 char FileName[260]; // [sp+378h] [bp-2F0h]@1 | |
1903 //char DstBuf; // [sp+47Ch] [bp-1ECh]@4 | |
1904 __int32 Offset; // [sp+480h] [bp-1E8h]@4 | |
1905 __int32 v207; // [sp+48Ch] [bp-1DCh]@4 | |
1906 __int32 v208; // [sp+498h] [bp-1D0h]@4 | |
1907 __int32 v209; // [sp+4A4h] [bp-1C4h]@4 | |
1908 __int32 v210; // [sp+4B0h] [bp-1B8h]@4 | |
1909 __int32 v211; // [sp+4BCh] [bp-1ACh]@15 | |
1910 __int32 v212; // [sp+4C8h] [bp-1A0h]@15 | |
1911 __int32 v213; // [sp+4D4h] [bp-194h]@25 | |
1912 __int32 v214; // [sp+4E0h] [bp-188h]@25 | |
1913 __int32 v215; // [sp+4ECh] [bp-17Ch]@32 | |
1914 __int32 v216; // [sp+4F8h] [bp-170h]@32 | |
1915 __int32 v217; // [sp+504h] [bp-164h]@40 | |
1916 __int32 v218; // [sp+510h] [bp-158h]@40 | |
1917 __int32 v219; // [sp+51Ch] [bp-14Ch]@43 | |
1918 __int32 v220; // [sp+528h] [bp-140h]@43 | |
1919 __int32 v221; // [sp+534h] [bp-134h]@52 | |
1920 __int32 v222; // [sp+540h] [bp-128h]@52 | |
1921 __int32 v223; // [sp+54Ch] [bp-11Ch]@52 | |
1922 __int32 v224; // [sp+558h] [bp-110h]@52 | |
1923 __int32 v225; // [sp+564h] [bp-104h]@52 | |
1924 __int32 v226; // [sp+570h] [bp-F8h]@52 | |
1925 __int32 v227; // [sp+57Ch] [bp-ECh]@52 | |
1926 __int32 v228; // [sp+588h] [bp-E0h]@52 | |
1927 __int32 v229; // [sp+594h] [bp-D4h]@52 | |
1928 __int32 v230; // [sp+5A0h] [bp-C8h]@52 | |
1929 __int32 v231; // [sp+5ACh] [bp-BCh]@52 | |
1930 __int32 v232; // [sp+5B8h] [bp-B0h]@52 | |
1931 __int32 v233; // [sp+5C4h] [bp-A4h]@52 | |
1932 __int32 v234; // [sp+5D0h] [bp-98h]@52 | |
1933 //char pName[40]; // [sp+5FCh] [bp-6Ch]@42 | |
1934 //size_t pSource; // [sp+624h] [bp-44h]@67 | |
1935 //char Dst[12]; // [sp+628h] [bp-40h]@9 | |
1936 //char *v238; // [sp+634h] [bp-34h]@38 | |
1937 ODMHeader header; // [sp+638h] [bp-30h]@61 | |
1938 //void *ptr; // [sp+648h] [bp-20h]@66 | |
1939 //size_t Count; // [sp+64Ch] [bp-1Ch]@109 | |
1940 //int uSourceLen; // [sp+653h] [bp-15h]@66 | |
1941 FILE *File; // [sp+658h] [bp-10h]@56 | |
1942 //BLVSector *v244; // [sp+65Ch] [bp-Ch]@72 | |
1943 //int v245; // [sp+660h] [bp-8h]@72 | |
1944 //BLVFace *Src; // [sp+664h] [bp-4h]@73 | |
1945 signed int Argsa; // [sp+670h] [bp+8h]@4 | |
1946 signed int Argsb; // [sp+670h] [bp+8h]@7 | |
1947 signed int Argsc; // [sp+670h] [bp+8h]@15 | |
1948 signed int Argsd; // [sp+670h] [bp+8h]@18 | |
1949 int Argse; // [sp+670h] [bp+8h]@25 | |
1950 int Argsf; // [sp+670h] [bp+8h]@28 | |
1951 int Argsg; // [sp+670h] [bp+8h]@32 | |
1952 int Argsh; // [sp+670h] [bp+8h]@35 | |
1953 signed int Argsi; // [sp+670h] [bp+8h]@40 | |
1954 signed int Argsj; // [sp+670h] [bp+8h]@45 | |
1955 //int Argsk; // [sp+670h] [bp+8h]@143 | |
1956 //void *Argsl; // [sp+670h] [bp+8h]@155 | |
1957 //signed int Argsm; // [sp+670h] [bp+8h]@161 | |
1958 //signed int Argsn; // [sp+670h] [bp+8h]@175 | |
1959 | |
1960 //v5 = 0; | |
1961 //v6 = this; | |
1962 _6807E0_num_decorations_with_sounds_6807B8 = 0; | |
1963 | |
1964 #pragma region "loading from txt" | |
1965 /*sprintf(FileName, "levels\\%s", pFilename); | |
1966 if ( GetFileAttributesA(FileName) != -1 ) | |
1967 { | |
1968 Release(); | |
1969 if ( Alloc() ) | |
1970 { | |
1971 v7 = fopen(FileName, "rb"); | |
1972 result = 1; | |
1973 if ( !v7 ) | |
1974 return result; | |
1975 v9 = pDest; | |
1976 bLoaded = 1; | |
1977 v202 = (int)v7; | |
1978 v201 = (const char *)1; | |
1979 *(int *)v9 = 1; | |
1980 fread(&DstBuf, 0x180u, (size_t)v201, (FILE *)v202); | |
1981 fseek(v7, Offset, 0); | |
1982 fread(&blv, 0x88u, 1u, v7); | |
1983 fseek(v7, v207, 0); | |
1984 fread(&uNumVertices, 1u, 4u, v7); | |
1985 fseek(v7, v208, 0); | |
1986 fread(pVertices, 6u, uNumVertices, v7); | |
1987 fseek(v7, v209, 0); | |
1988 fread(&uNumFaces, 4u, 1u, v7); | |
1989 fseek(v7, v210, 0); | |
1990 fread(pFaces, 0x60u, uNumFaces, v7); | |
1991 v10 = pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); | |
1992 v202 = (int)v7; | |
1993 ptr_2AC = (unsigned __int16 *)v10; | |
1994 fread(v10, 1u, blv.uFaces_fdata_Size, (FILE *)v202); | |
1995 v11 = uNumFaces == 0; | |
1996 v12 = (uNumFaces & 0x80000000u) != 0; | |
1997 pDest = 0; | |
1998 Argsa = 0; | |
1999 if ( !(v12 | v11) ) | |
2000 { | |
2001 v13 = 0; | |
2002 do | |
2003 { | |
2004 pFaces[v13].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)ptr_2AC]; | |
2005 v14 = (size_t)&pFaces[v13]; | |
2006 i = v14; | |
2007 v15 = &pDest[2 * *(char *)(v14 + 93) + 2]; | |
2008 v16 = (int)&v15[(unsigned int)ptr_2AC]; | |
2009 pDest = v15; | |
2010 *(int *)(i + 52) = v16; | |
2011 v17 = (size_t)&pFaces[v13]; | |
2012 i = v17; | |
2013 v18 = &pDest[2 * *(char *)(v17 + 93) + 2]; | |
2014 v19 = (int)&v18[(unsigned int)ptr_2AC]; | |
2015 pDest = v18; | |
2016 *(int *)(i + 56) = v19; | |
2017 i = (size_t)&pFaces[v13]; | |
2018 v20 = ptr_2AC; | |
2019 pDest += 2 * *(char *)(i + 93) + 2; | |
2020 *(int *)(i + 60) = (int)(char *)v20 + (int)pDest; | |
2021 i = (size_t)&pFaces[v13]; | |
2022 v21 = ptr_2AC; | |
2023 pDest += 2 * *(char *)(i + 93) + 2; | |
2024 *(int *)(i + 64) = (int)(char *)v21 + (int)pDest; | |
2025 i = (size_t)&pFaces[v13]; | |
2026 ++v13; | |
2027 v22 = ptr_2AC; | |
2028 pDest += 2 * *(char *)(i + 93) + 2; | |
2029 ++Argsa; | |
2030 *(int *)(i + 68) = (int)(char *)v22 + (int)pDest; | |
2031 pDest += 2 * *((char *)&pFaces[v13] - 3) + 2; | |
2032 } | |
2033 while ( Argsa < (signed int)uNumFaces ); | |
2034 } | |
2035 Argsb = 0; | |
2036 if ( (signed int)uNumFaces > 0 ) | |
2037 { | |
2038 pDest = 0; | |
2039 do | |
2040 { | |
2041 fread(Dst, 1u, 0xAu, v7); | |
2042 if ( pDest[(unsigned int)pFaces + 45] & 0x40 ) | |
2043 { | |
2044 v23 = pTextureFrameTable->FindTextureByName(Dst); | |
2045 v24 = pDest; | |
2046 *(short *)&pDest[(unsigned int)pFaces + 74] = v23; | |
2047 v25 = *(short *)&v24[(unsigned int)pFaces + 74]; | |
2048 if ( v25 ) | |
2049 { | |
2050 pTextureFrameTable->LoadAnimationSequenceAndPalettes(v25); | |
2051 } | |
2052 else | |
2053 { | |
2054 v26 = pBitmaps_LOD->LoadTexture(Dst); | |
2055 v27 = pDest; | |
2056 *(short *)&pDest[(unsigned int)pFaces + 74] = v26; | |
2057 v27[(unsigned int)pFaces + 45] &= 0xBFu; | |
2058 } | |
2059 } | |
2060 else | |
2061 { | |
2062 *(short *)&pDest[(unsigned int)pFaces + 74] = pBitmaps_LOD->LoadTexture(Dst); | |
2063 } | |
2064 ++Argsb; | |
2065 pDest += 96; | |
2066 } | |
2067 while ( Argsb < (signed int)uNumFaces ); | |
2068 } | |
2069 fseek(v7, v211, 0); | |
2070 fread(&uNumFaceExtras, 4u, 1u, v7); | |
2071 fseek(v7, v212, 0); | |
2072 fread(pFaceExtras, 0x24u, uNumFaceExtras, v7); | |
2073 Argsc = 0; | |
2074 if ( (signed int)uNumFaceExtras > 0 ) | |
2075 { | |
2076 pDest = 0; | |
2077 do | |
2078 { | |
2079 fread(Dst, 1u, 0xAu, v7); | |
2080 v28 = pBitmaps_LOD->LoadTexture(Dst); | |
2081 v29 = pFaceExtras; | |
2082 v30 = pDest; | |
2083 ++Argsc; | |
2084 pDest += 36; | |
2085 *(unsigned __int16 *)((char *)&v29->uAdditionalBitmapID + (int)v30) = v28; | |
2086 } | |
2087 while ( Argsc < (signed int)uNumFaceExtras ); | |
2088 } | |
2089 Argsd = 0; | |
2090 if ( (signed int)uNumFaces > 0 ) | |
2091 { | |
2092 pDest = 0; | |
2093 do | |
2094 { | |
2095 v31 = (int)&pFaceExtras[*(short *)&pDest[(unsigned int)pFaces + 72]]; | |
2096 if ( *(short *)(v31 + 26) ) | |
2097 { | |
2098 if ( ((BLVFaceExtra *)v31)->HasEventint() ) | |
2099 pDest[(unsigned int)pFaces + 46] |= 0x10u; | |
2100 else | |
2101 pDest[(unsigned int)pFaces + 46] &= 0xEFu; | |
2102 } | |
2103 ++Argsd; | |
2104 pDest += 96; | |
2105 } | |
2106 while ( Argsd < (signed int)uNumFaces ); | |
2107 } | |
2108 fseek(v7, v213, 0); | |
2109 fread(&uNumSectors, 4u, 1u, v7); | |
2110 fseek(v7, v214, 0); | |
2111 fread(pSectors, 0x74u, uNumSectors, v7); | |
2112 v32 = pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); | |
2113 v202 = (int)v7; | |
2114 ptr_0002B0_sector_rdata = (unsigned __int16 *)v32; | |
2115 fread(v32, 1u, blv.uSector_rdata_Size, (FILE *)v202); | |
2116 v11 = uNumSectors == 0; | |
2117 v12 = uNumSectors < 0; | |
2118 pDest = 0; | |
2119 Argse = 0; | |
2120 if ( !(v12 | v11) ) | |
2121 { | |
2122 v33 = 0; | |
2123 do | |
2124 { | |
2125 pSectors[v33].pFloors = (unsigned __int16 *)&pDest[(unsigned int)ptr_0002B0_sector_rdata]; | |
2126 i = (size_t)&pSectors[v33]; | |
2127 v34 = ptr_0002B0_sector_rdata; | |
2128 pDest += 2 * *(short *)(i + 4); | |
2129 *(int *)(i + 16) = (int)(char *)v34 + (int)pDest; | |
2130 v35 = (size_t)&pSectors[v33]; | |
2131 i = v35; | |
2132 v36 = &pDest[2 * *(short *)(v35 + 12)]; | |
2133 v37 = (int)&v36[(unsigned int)ptr_0002B0_sector_rdata]; | |
2134 pDest = v36; | |
2135 *(int *)(i + 24) = v37; | |
2136 v38 = (size_t)&pSectors[v33]; | |
2137 i = v38; | |
2138 v39 = &pDest[2 * *(short *)(v38 + 20)]; | |
2139 v40 = (int)&v39[(unsigned int)ptr_0002B0_sector_rdata]; | |
2140 pDest = v39; | |
2141 *(int *)(i + 32) = v40; | |
2142 i = (size_t)&pSectors[v33]; | |
2143 v41 = ptr_0002B0_sector_rdata; | |
2144 pDest += 2 * *(short *)(i + 28); | |
2145 *(int *)(i + 40) = (int)(char *)v41 + (int)pDest; | |
2146 i = (size_t)&pSectors[v33]; | |
2147 v42 = ptr_0002B0_sector_rdata; | |
2148 pDest += 2 * *(short *)(i + 36); | |
2149 *(int *)(i + 48) = (int)(char *)v42 + (int)pDest; | |
2150 i = (size_t)&pSectors[v33]; | |
2151 v43 = ptr_0002B0_sector_rdata; | |
2152 pDest += 2 * *(short *)(i + 44); | |
2153 *(int *)(i + 64) = (int)(char *)v43 + (int)pDest; | |
2154 i = (size_t)&pSectors[v33]; | |
2155 v44 = ptr_0002B0_sector_rdata; | |
2156 pDest += 2 * *(short *)(i + 60); | |
2157 *(int *)(i + 72) = (int)(char *)v44 + (int)pDest; | |
2158 v45 = (size_t)&pSectors[v33]; | |
2159 ++v33; | |
2160 i = v45; | |
2161 v46 = ptr_0002B0_sector_rdata; | |
2162 pDest += 2 * *(short *)(v45 + 68); | |
2163 ++Argse; | |
2164 *(int *)(v45 + 80) = (int)(char *)v46 + (int)pDest; | |
2165 pDest += 2 * *((short *)&pSectors[v33] - 20); | |
2166 } | |
2167 while ( Argse < uNumSectors ); | |
2168 } | |
2169 v47 = pAllocator->AllocNamedChunk( | |
2170 ptr_0002B8_sector_lrdata, | |
2171 blv.uSector_lrdata_Size, | |
2172 "L.RLData"); | |
2173 v202 = (int)v7; | |
2174 ptr_0002B8_sector_lrdata = (unsigned __int16 *)v47; | |
2175 fread(v47, 1u, blv.uSector_lrdata_Size, (FILE *)v202); | |
2176 v11 = uNumSectors == 0; | |
2177 v12 = uNumSectors < 0; | |
2178 pDest = 0; | |
2179 Argsf = 0; | |
2180 if ( !(v12 | v11) ) | |
2181 { | |
2182 v48 = pSectors; | |
2183 v49 = 0; | |
2184 for ( i = 0; ; v49 = i ) | |
2185 { | |
2186 v50 = ptr_0002B8_sector_lrdata; | |
2187 i += 116; | |
2188 ++Argsf; | |
2189 *(BLVLightMM7 **)((char *)&v48->pLights + v49) = (BLVLightMM7 *)((char *)v50 + (int)pDest); | |
2190 v48 = pSectors; | |
2191 pDest += 2 * *(__int16 *)((char *)&v48->uNumLights + v49); | |
2192 if ( Argsf >= uNumSectors ) | |
2193 break; | |
2194 } | |
2195 } | |
2196 fseek(v7, v215, 0); | |
2197 fread(&uNumDoors, 4u, 1u, v7); | |
2198 fseek(v7, v216, 0); | |
2199 fread(pDoors, 0x50u, 0xC8u, v7); | |
2200 v51 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
2201 v202 = (int)v7; | |
2202 ptr_0002B4_doors_ddata = (unsigned __int16 *)v51; | |
2203 fread(v51, 1u, blv.uDoors_ddata_Size, (FILE *)v202); | |
2204 v11 = uNumDoors == 0; | |
2205 v12 = uNumDoors < 0; | |
2206 pDest = 0; | |
2207 Argsg = 0; | |
2208 if ( !(v12 | v11) ) | |
2209 { | |
2210 v52 = 0; | |
2211 do | |
2212 { | |
2213 pDoors[v52].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)ptr_0002B4_doors_ddata]; | |
2214 i = (size_t)&pDoors[v52]; | |
2215 v53 = ptr_0002B4_doors_ddata; | |
2216 pDest += 2 * *(short *)(i + 68); | |
2217 *(int *)(i + 40) = (int)(char *)v53 + (int)pDest; | |
2218 v54 = (size_t)&pDoors[v52]; | |
2219 i = v54; | |
2220 v55 = &pDest[2 * *(short *)(v54 + 70)]; | |
2221 v56 = (int)&v55[(unsigned int)ptr_0002B4_doors_ddata]; | |
2222 pDest = v55; | |
2223 *(int *)(i + 44) = v56; | |
2224 v57 = (size_t)&pDoors[v52]; | |
2225 i = v57; | |
2226 v58 = &pDest[2 * *(short *)(v57 + 72)]; | |
2227 v59 = (int)&v58[(unsigned int)ptr_0002B4_doors_ddata]; | |
2228 pDest = v58; | |
2229 *(int *)(i + 48) = v59; | |
2230 i = (size_t)&pDoors[v52]; | |
2231 v60 = ptr_0002B4_doors_ddata; | |
2232 pDest += 2 * *(short *)(i + 70); | |
2233 *(int *)(i + 52) = (int)(char *)v60 + (int)pDest; | |
2234 i = (size_t)&pDoors[v52]; | |
2235 v61 = ptr_0002B4_doors_ddata; | |
2236 pDest += 2 * *(short *)(i + 70); | |
2237 *(int *)(i + 56) = (int)(char *)v61 + (int)pDest; | |
2238 i = (size_t)&pDoors[v52]; | |
2239 v62 = ptr_0002B4_doors_ddata; | |
2240 pDest += 2 * *(short *)(i + 74); | |
2241 *(int *)(i + 60) = (int)(char *)v62 + (int)pDest; | |
2242 i = (size_t)&pDoors[v52]; | |
2243 v63 = ptr_0002B4_doors_ddata; | |
2244 pDest += 2 * *(short *)(i + 74); | |
2245 *(int *)(i + 64) = (int)(char *)v63 + (int)pDest; | |
2246 ++Argsg; | |
2247 v64 = pDoors[v52].uNumOffsets; | |
2248 ++v52; | |
2249 pDest += 2 * v64; | |
2250 } | |
2251 while ( Argsg < uNumDoors ); | |
2252 } | |
2253 Argsh = 0; | |
2254 if ( uNumDoors > 0 ) | |
2255 { | |
2256 v65 = pDoors; | |
2257 pDest = 0; | |
2258 do | |
2259 { | |
2260 i = 0; | |
2261 v66 = &pDest[(int)v65]; | |
2262 if ( *(short *)&pDest[(int)v65 + 70] > 0 ) | |
2263 { | |
2264 do | |
2265 { | |
2266 v67 = *((int *)v66 + 10); | |
2267 a3 = 2 * i; | |
2268 v68 = *(short *)(v67 + 2 * i); | |
2269 v69 = pFaces; | |
2270 ++i; | |
2271 v70 = (int)&pFaceExtras[v69[v68].uFaceExtraID]; | |
2272 v71 = *((int *)v66 + 12); | |
2273 v72 = a3; | |
2274 v238 = (char *)v70; | |
2275 *(short *)(a3 + v71) = *(short *)(v70 + 20); | |
2276 *(__int16 *)(*(char **)((char *)&pDoors->pDeltaVs + (unsigned int)pDest) + v72) = *((short *)v238 + 11); | |
2277 v65 = pDoors; | |
2278 v66 = &pDest[(int)v65]; | |
2279 } | |
2280 while ( (signed int)i < *(short *)&pDest[(int)v65 + 70] ); | |
2281 } | |
2282 ++Argsh; | |
2283 pDest += 80; | |
2284 } | |
2285 while ( Argsh < uNumDoors ); | |
2286 } | |
2287 fseek(v7, v217, 0); | |
2288 fread(&uNumLevelDecorations, 4u, 1u, v7); | |
2289 fseek(v7, v218, 0); | |
2290 fread(pLevelDecorations, 0x20u, uNumLevelDecorations, v7); | |
2291 Argsi = 0; | |
2292 if ( (signed int)uNumLevelDecorations > 0 ) | |
2293 { | |
2294 pDest = (char *)pLevelDecorations; | |
2295 do | |
2296 { | |
2297 fread(pName, 1u, 0x20u, v7); | |
2298 v73 = pDecorationList->GetDecorIdByName(pName); | |
2299 v74 = pDest; | |
2300 ++Argsi; | |
2301 pDest += 32; | |
2302 *(short *)v74 = v73; | |
2303 } | |
2304 while ( Argsi < (signed int)uNumLevelDecorations ); | |
2305 } | |
2306 fseek(v7, v219, 0); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2307 fread(&uNumSpriteObjects, 4u, 1u, v7); |
0 | 2308 fseek(v7, v220, 0); |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2309 fread(pSpriteObjects, 0x70u, uNumSpriteObjects, v7); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2310 if ( (signed int)uNumSpriteObjects > 0 ) |
0 | 2311 { |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2312 v75 = pSpriteObjects; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2313 pDest = (char *)uNumSpriteObjects; |
0 | 2314 do |
2315 { | |
2316 Argsj = 0; | |
2317 v76 = 48 * v75->stru_24.uItemID; | |
2318 v11 = pObjectList->uNumObjects == 0; | |
2319 v12 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
2320 LOWORD(v76) = *(unsigned __int16 *)((char *)&pItemsTable->pItems[0].uSpriteID + v76); | |
2321 i = v76; | |
2322 v75->uItemType = v76; | |
2323 if ( v12 | v11 ) | |
2324 { | |
2325 LABEL_50: | |
2326 v78 = 0; | |
2327 } | |
2328 else | |
2329 { | |
2330 for ( j = (int)&pObjectList->pObjects->uObjectID; (short)v76 != *(short *)j; j = a3 ) | |
2331 { | |
2332 ++Argsj; | |
2333 a3 = j + 56; | |
2334 if ( Argsj >= (signed int)pObjectList->uNumObjects ) | |
2335 goto LABEL_50; | |
2336 LOWORD(v76) = i; | |
2337 } | |
2338 v78 = Argsj; | |
2339 } | |
2340 v75->uObjectDescID = v78; | |
2341 ++v75; | |
2342 --pDest; | |
2343 } | |
2344 while ( pDest ); | |
2345 } | |
2346 fseek(v7, v221, 0); | |
2347 fread(&uNumActors, 4u, 1u, v7); | |
2348 fseek(v7, v222, 0); | |
2349 fread(pActors, 0x344u, uNumActors, v7); | |
2350 fseek(v7, v228, 0); | |
2351 fread(&uNumChests, 4u, 1u, v7); | |
2352 fseek(v7, v229, 0); | |
2353 fread(pChests, 0x14CCu, uNumChests, v7); | |
2354 fseek(v7, v224, 0); | |
2355 fread(&uNumLights, 4u, 1u, v7); | |
2356 fseek(v7, v225, 0); | |
2357 fread(pLights, 0x10u, uNumLights, v7); | |
2358 fseek(v7, v226, 0); | |
2359 fread(&uNumNodes, 4u, 1u, v7); | |
2360 fseek(v7, v227, 0); | |
2361 fread(pNodes, 8u, uNumNodes, v7); | |
2362 fseek(v7, v230, 0); | |
2363 fread(&uNumSpawnPoints, 4u, 1u, v7); | |
2364 v79 = pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); | |
2365 v202 = 0; | |
2366 pSpawnPoints = (SpawnPointMM7 *)v79; | |
2367 fseek(v7, v231, v202); | |
2368 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, v7); | |
2369 fseek(v7, v232, 0); | |
2370 fread(&dlv, 0x28u, 1u, v7); | |
2371 fseek(v7, v233, 0); | |
2372 fread(&stru_5E4C90, 1u, 0xC8u, v7); | |
2373 fseek(v7, v234, 0); | |
2374 fread(&uLastVisitDay, 1u, 0x38u, v7); | |
2375 fseek(v7, v223, 0); | |
2376 v80 = (void **)&pMapOutlines; | |
2377 fread(*v80, 4u, 1u, v7); | |
2378 fread((char *)*v80 + 4, 0xCu, *(int *)*v80, v7); | |
2379 fclose(v7); | |
2380 goto LABEL_179; | |
2381 } | |
2382 return 4; | |
2383 }*/ | |
2384 #pragma endregion | |
2385 | |
2386 if (bLoaded) | |
2387 { | |
2388 Log::Warning(L"BLV is already loaded"); | |
2389 return 3; | |
2390 } | |
2391 | |
2392 if ( !pGames_LOD->DoesContainerExist(pFilename) ) | |
2393 Abortf("Unable to find %s in Games.LOD", pFilename); | |
2394 | |
2395 //v238 = pFilename - 4; | |
2396 //v81 = strlen(pFilename); | |
2397 strcpy(this->pFilename, pFilename); | |
2398 strcpy(&pFilename[strlen(pFilename) - 4], ".blv"); | |
2399 File = pGames_LOD->FindContainer(pFilename, 1); | |
2400 //File = v82; | |
2401 | |
2402 Release(); | |
2403 if ( !Alloc() ) | |
2404 return 4; | |
2405 | |
2406 header.uVersion = 91969; | |
2407 header.pMagic[0] = 'm'; | |
2408 header.pMagic[1] = 'v'; | |
2409 header.pMagic[2] = 'i'; | |
2410 header.pMagic[3] = 'i'; | |
2411 header.uCompressedSize = 0; | |
2412 header.uDecompressedSize = 0; | |
2413 fread(&header, sizeof(ODMHeader), 1u, File); | |
2414 if (header.uVersion != 91969 || | |
2415 header.pMagic[0] != 'm' || | |
2416 header.pMagic[1] != 'v' || | |
2417 header.pMagic[2] != 'i' || | |
2418 header.pMagic[3] != 'i' ) | |
2419 { | |
2420 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:792", 0); | |
2421 } | |
2422 //v83 = header.uCompressedSize; | |
2423 //pSource = header.uDecompressedSize; | |
2424 //v84 = malloc(header.uDecompressedSize); | |
2425 //v85 = v84; | |
2426 //ptr = v84; | |
2427 auto pRawBLV = malloc(header.uDecompressedSize); | |
2428 memset(pRawBLV, 0, header.uDecompressedSize); | |
2429 | |
2430 if (header.uCompressedSize == header.uDecompressedSize) | |
2431 fread(pRawBLV, header.uDecompressedSize, 1, File); | |
2432 else if (header.uCompressedSize < header.uDecompressedSize) | |
2433 { | |
2434 auto pTmpMem = malloc(header.uCompressedSize); | |
2435 { | |
2436 fread(pTmpMem, header.uCompressedSize, 1, File); | |
2437 | |
2438 uint uDecompressedSize = header.uDecompressedSize; | |
2439 zlib::MemUnzip(pRawBLV, &uDecompressedSize, pTmpMem, header.uCompressedSize); | |
2440 | |
2441 if (uDecompressedSize != header.uDecompressedSize) | |
2442 Log::Warning(L"uDecompressedSize != header.uDecompressedSize in BLV"); | |
2443 } | |
2444 free(pTmpMem); | |
2445 } | |
2446 else | |
2447 { | |
2448 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:803", 0); | |
2449 return 0; | |
2450 } | |
2451 | |
2452 bLoaded = true; | |
2453 | |
2454 auto pData = (char *)pRawBLV; | |
2455 | |
2456 pGameLoadingUI_ProgressBar->Progress(); | |
2457 | |
2458 memcpy(&blv, pData, 136); | |
2459 memcpy(&uNumVertices, pData += 136, 4); | |
2460 memcpy(pVertices, pData += 4, uNumVertices * sizeof(Vec3_short_)); | |
2461 | |
2462 pGameLoadingUI_ProgressBar->Progress(); | |
2463 | |
2464 memcpy(&uNumFaces, pData += uNumVertices * sizeof(Vec3_short_), 4); | |
2465 | |
2466 pGameLoadingUI_ProgressBar->Progress(); | |
2467 | |
2468 memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace)); | |
2469 ptr_2AC = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); | |
2470 | |
2471 memcpy(ptr_2AC, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size); | |
2472 | |
2473 for (uint i = 0, j = 0; i < uNumFaces; ++i) | |
2474 { | |
2475 auto pFace = pFaces + i; | |
2476 | |
2477 pFace->pVertexIDs = ptr_2AC + j; | |
2478 | |
2479 j += pFace->uNumVertices + 1; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
2480 pFace->pXInterceptDisplacements = (short *)(ptr_2AC + j); |
0 | 2481 |
2482 j += pFace->uNumVertices + 1; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
2483 pFace->pYInterceptDisplacements = (short *)(ptr_2AC + j); |
0 | 2484 |
2485 j += pFace->uNumVertices + 1; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
2486 pFace->pZInterceptDisplacements = (short *)(ptr_2AC + j); |
0 | 2487 |
2488 j += pFace->uNumVertices + 1; | |
2489 pFace->pVertexUIDs = (__int16 *)(ptr_2AC + j); | |
2490 | |
2491 j += pFace->uNumVertices + 1; | |
2492 pFace->pVertexVIDs = (__int16 *)(ptr_2AC + j); | |
2493 | |
2494 j += pFace->uNumVertices + 1; | |
2495 /*v93 = &pFaces[v92]; | |
2496 Src = v93; | |
2497 v94 = (BLVSector *)((char *)v244 + 2 * v93->uNumVertices + 2); | |
2498 v95 = (unsigned __int16 *)((char *)v94 + (unsigned int)ptr_2AC); | |
2499 v244 = v94; | |
2500 Src->pXInterceptDisplacements = v95; | |
2501 v96 = (int)&pFaces[v92]; | |
2502 Src = (BLVFace *)v96; | |
2503 v97 = (BLVSector *)((char *)v244 + 2 * *(char *)(v96 + 93) + 2); | |
2504 v98 = (unsigned __int16 *)((char *)v97 + (unsigned int)ptr_2AC); | |
2505 v244 = v97; | |
2506 Src->pYInterceptDisplacements = v98; | |
2507 Src = &pFaces[v92]; | |
2508 v99 = ptr_2AC; | |
2509 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
2510 Src->pZInterceptDisplacements = (unsigned __int16 *)((char *)v99 + (int)v244); | |
2511 Src = &pFaces[v92]; | |
2512 v100 = ptr_2AC; | |
2513 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
2514 Src->pVertexUIDs = (unsigned __int16 *)((char *)v100 + (int)v244); | |
2515 Src = &pFaces[v92]; | |
2516 ++v92; | |
2517 v101 = ptr_2AC; | |
2518 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
2519 ++v245; | |
2520 Src->pVertexVIDs = (unsigned __int16 *)((char *)v101 + (int)v244); | |
2521 v244 = (BLVSector *)((char *)v244 + 2 * *((char *)&pFaces[v92] - 3) + 2);*/ | |
2522 } | |
2523 | |
2524 pGameLoadingUI_ProgressBar->Progress(); | |
2525 | |
2526 pData += blv.uFaces_fdata_Size; | |
2527 | |
2528 for (uint i = 0; i < uNumFaces; ++i) | |
2529 { | |
2530 auto pFace = pFaces + i; | |
2531 | |
2532 char pTexName[16]; | |
2533 strncpy(pTexName, pData, 10); | |
2534 pData += 10; | |
2535 | |
2536 if (pFace->uAttributes & 0x4000) | |
2537 { | |
2538 pFace->uBitmapID = pTextureFrameTable->FindTextureByName(pTexName); | |
2539 if (pFace->uBitmapID) | |
2540 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pFace->uBitmapID); | |
2541 else | |
2542 { | |
2543 pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
2544 pFace->uAttributes &= ~0x4000; | |
2545 } | |
2546 } | |
2547 else | |
2548 pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
2549 } | |
2550 | |
2551 pGameLoadingUI_ProgressBar->Progress(); | |
2552 | |
2553 memcpy(&uNumFaceExtras, pData, 4u); | |
2554 memcpy(pFaceExtras, pData += 4, uNumFaceExtras * sizeof(BLVFaceExtra)); | |
2555 pData += uNumFaceExtras * sizeof(BLVFaceExtra); | |
2556 | |
2557 pGameLoadingUI_ProgressBar->Progress(); | |
2558 | |
2559 //v108 = (char *)v107 + 36 * uNumFaceExtras; | |
2560 //v245 = 0; | |
2561 //*(int *)((char *)&uSourceLen + 1) = 0; | |
2562 for (uint i = 0; i < uNumFaceExtras; ++i) | |
2563 { | |
2564 char pTexName[32]; | |
2565 strncpy(pTexName, pData, 10); | |
2566 pData += 10; | |
2567 | |
2568 if (!strcmp(pTexName, "")) | |
2569 pFaceExtras[i].uAdditionalBitmapID = -1; | |
2570 else | |
2571 pFaceExtras[i].uAdditionalBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
2572 } | |
2573 | |
2574 | |
2575 for (uint i = 0; i < uNumFaces; ++i) | |
2576 { | |
2577 auto pFace = pFaces + i; | |
2578 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
2579 | |
2580 if (pFaceExtra->uEventID) | |
2581 { | |
2582 if (pFaceExtra->HasEventint()) | |
2583 pFace->uAttributes |= 0x100000; | |
2584 else | |
2585 pFace->uAttributes &= ~0x100000; | |
2586 } | |
2587 } | |
2588 | |
2589 pGameLoadingUI_ProgressBar->Progress(); | |
2590 | |
2591 memcpy(&uNumSectors, pData, 4); | |
2592 memcpy(pSectors, pData + 4, uNumSectors * sizeof(BLVSector)); | |
2593 pData += 4 + uNumSectors * sizeof(BLVSector); | |
2594 | |
2595 pGameLoadingUI_ProgressBar->Progress(); | |
2596 | |
2597 ptr_0002B0_sector_rdata = (unsigned short *)pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); | |
2598 memcpy(ptr_0002B0_sector_rdata, pData, blv.uSector_rdata_Size); | |
2599 pData += blv.uSector_rdata_Size; | |
2600 | |
2601 for (uint i = 0, j = 0; i < uNumSectors; ++i) | |
2602 { | |
2603 auto pSector = pSectors + i; | |
2604 | |
2605 pSector->pFloors = ptr_0002B0_sector_rdata + j; | |
2606 j += pSector->uNumFloors; | |
2607 | |
2608 pSector->pWalls = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2609 j += pSector->uNumWalls; |
0 | 2610 |
2611 pSector->pCeilings = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2612 j += pSector->uNumCeilings; |
0 | 2613 |
2614 pSector->pFluids = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2615 j += pSector->uNumFluids; |
0 | 2616 |
2617 pSector->pPortals = ptr_0002B0_sector_rdata + j; | |
2618 j += pSector->uNumPortals; | |
2619 | |
2620 pSector->pFaceIDs = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2621 j += pSector->uNumFaces; |
0 | 2622 |
2623 pSector->pCogs = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2624 j += pSector->uNumCogs; |
0 | 2625 |
2626 pSector->pDecorationIDs = ptr_0002B0_sector_rdata + j; | |
2627 j += pSector->uNumDecorations; | |
2628 | |
2629 pSector->pMarkers = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2630 j += pSector->uNumMarkers; |
0 | 2631 |
2632 | |
2633 //do | |
2634 //{ | |
2635 /*pSectors[v118].pFloors = (unsigned __int16 *)((char *)Src + (unsigned int)ptr_0002B0_sector_rdata); | |
2636 v244 = &pSectors[v118]; | |
2637 v119 = ptr_0002B0_sector_rdata; | |
2638 Src = (BLVFace *)((char *)Src + 2 * v244->field_4); | |
2639 v244->pWalls = (unsigned __int16 *)((char *)v119 + (int)Src); | |
2640 v120 = (int)&pSectors[v118]; | |
2641 v244 = (BLVSector *)v120; | |
2642 v121 = (BLVFace *)((char *)Src + 2 * *(short *)(v120 + 12)); | |
2643 v122 = (unsigned __int16 *)((char *)v121 + (unsigned int)ptr_0002B0_sector_rdata); | |
2644 Src = v121; | |
2645 v244->pCeilings = v122; | |
2646 v123 = (int)&pSectors[v118]; | |
2647 v244 = (BLVSector *)v123; | |
2648 v124 = (BLVFace *)((char *)Src + 2 * *(short *)(v123 + 20)); | |
2649 v125 = (unsigned __int16 *)((char *)v124 + (unsigned int)ptr_0002B0_sector_rdata); | |
2650 Src = v124; | |
2651 v244->pFluids = v125; | |
2652 v244 = &pSectors[v118]; | |
2653 v126 = ptr_0002B0_sector_rdata; | |
2654 Src = (BLVFace *)((char *)Src + 2 * v244->field_1C); | |
2655 v244->pPortals = (unsigned __int16 *)((char *)v126 + (int)Src); | |
2656 v244 = &pSectors[v118]; | |
2657 v127 = ptr_0002B0_sector_rdata; | |
2658 Src = (BLVFace *)((char *)Src + 2 * v244->uNumPortals); | |
2659 v244->pFaceIDs = (unsigned __int16 *)((char *)v127 + (int)Src); | |
2660 v244 = &pSectors[v118]; | |
2661 v128 = ptr_0002B0_sector_rdata; | |
2662 Src = (BLVFace *)((char *)Src + 2 * v244->field_2C); | |
2663 v244->pCogs = (unsigned __int16 *)((char *)v128 + (int)Src); | |
2664 v244 = &pSectors[v118]; | |
2665 v129 = ptr_0002B0_sector_rdata; | |
2666 Src = (BLVFace *)((char *)Src + 2 * v244->field_3C); | |
2667 v244->pDecorationIDs = (unsigned __int16 *)((char *)v129 + (int)Src); | |
2668 v130 = (int)&pSectors[v118]; | |
2669 ++v118; | |
2670 v244 = (BLVSector *)v130; | |
2671 v131 = ptr_0002B0_sector_rdata; | |
2672 Src = (BLVFace *)((char *)Src + 2 * *(short *)(v130 + 68)); | |
2673 ++v245; | |
2674 *(int *)(v130 + 80) = (int)(char *)v131 + (int)Src; | |
2675 Src = (BLVFace *)((char *)Src + 2 * *((short *)&pSectors[v118] - 20));*/ | |
2676 //} | |
2677 //while ( v245 < uNumSectors ); | |
2678 } | |
2679 | |
2680 ptr_0002B8_sector_lrdata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B8_sector_lrdata, blv.uSector_lrdata_Size, "L.RLData"); | |
2681 memcpy(ptr_0002B8_sector_lrdata, pData, blv.uSector_lrdata_Size); | |
2682 pData += blv.uSector_lrdata_Size; | |
2683 | |
2684 pGameLoadingUI_ProgressBar->Progress(); | |
2685 | |
2686 for (uint i = 0, j = 0; i < uNumSectors; ++i) | |
2687 { | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2688 pSectors[i].pLights = ptr_0002B8_sector_lrdata + j; |
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2689 j += pSectors[i].uNumLights; |
0 | 2690 } |
2691 | |
2692 pGameLoadingUI_ProgressBar->Progress(); | |
2693 | |
2694 memcpy(&uNumDoors, pData, 4); | |
2695 pData += 4; | |
2696 | |
2697 pGameLoadingUI_ProgressBar->Progress(); | |
2698 pGameLoadingUI_ProgressBar->Progress(); | |
2699 | |
2700 memcpy(&uNumLevelDecorations, pData, 4); | |
2701 memcpy(pLevelDecorations, pData + 4, uNumLevelDecorations * sizeof(LevelDecoration)); | |
2702 pData += 4 + uNumLevelDecorations * sizeof(LevelDecoration); | |
2703 | |
2704 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2705 { | |
2706 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pData); | |
2707 | |
2708 pData += 32; | |
2709 } | |
2710 | |
2711 pGameLoadingUI_ProgressBar->Progress(); | |
2712 | |
2713 memcpy(&uNumLights, pData, 4); | |
2714 memcpy(pLights, pData + 4, uNumLights * sizeof(BLVLightMM7)); | |
2715 pData += 4 + uNumLights * sizeof(BLVLightMM7); | |
2716 | |
2717 pGameLoadingUI_ProgressBar->Progress(); | |
2718 pGameLoadingUI_ProgressBar->Progress(); | |
2719 | |
2720 memcpy(&uNumNodes, pData, 4); | |
2721 memcpy(pNodes, pData + 4, uNumNodes * sizeof(BSPNode)); | |
2722 pData += 4 + uNumNodes * sizeof(BSPNode); | |
2723 | |
2724 pGameLoadingUI_ProgressBar->Progress(); | |
2725 pGameLoadingUI_ProgressBar->Progress(); | |
2726 | |
2727 memcpy(&uNumSpawnPoints, pData, 4); | |
2728 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, uNumSpawnPoints * sizeof(SpawnPointMM7), "Spawn"); | |
2729 memcpy(pSpawnPoints, pData + 4, uNumSpawnPoints * sizeof(SpawnPointMM7)); | |
2730 pData += 4 + uNumSpawnPoints * sizeof(SpawnPointMM7); | |
2731 | |
2732 pGameLoadingUI_ProgressBar->Progress(); | |
2733 pGameLoadingUI_ProgressBar->Progress(); | |
2734 | |
2735 //v201 = (const char *)v148; | |
2736 //v200 = (size_t)pMapOutlines; | |
2737 memcpy(&pMapOutlines->uNumOutlines, pData, 4); | |
2738 memcpy(pMapOutlines->pOutlines, pData + 4, pMapOutlines->uNumOutlines * sizeof(BLVMapOutline)); | |
2739 //v149 = pMapOutlines; | |
2740 //v199 = 12 * *v149; | |
2741 //memcpy(v149 + 1, (const void *)(v148 + 4), v199); | |
2742 free(pRawBLV); | |
2743 pRawBLV = nullptr; | |
2744 | |
2745 void *pRawDLV = nullptr; | |
2746 strcpy(&pFilename[strlen(pFilename) - 4], ".dlv"); | |
2747 File = pNew_LOD->FindContainer(pFilename, 1); | |
2748 fread(&header, 0x10u, 1u, File);//(FILE *)v245); | |
2749 bool _v244 = false; | |
2750 if (header.uVersion != 91969 || | |
2751 header.pMagic[0] != 'm' || | |
2752 header.pMagic[1] != 'v' || | |
2753 header.pMagic[2] != 'i' || | |
2754 header.pMagic[3] != 'i' ) | |
2755 { | |
2756 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1090", 0); | |
2757 _v244 = true; | |
2758 } | |
2759 else | |
2760 { | |
2761 pRawDLV = malloc(header.uDecompressedSize); | |
2762 if (header.uCompressedSize == header.uDecompressedSize) | |
2763 fread(pRawDLV, 1, header.uCompressedSize, File); | |
2764 else if (header.uCompressedSize < header.uDecompressedSize) | |
2765 { | |
2766 auto pTmpMem = malloc(header.uCompressedSize); | |
2767 { | |
2768 fread(pTmpMem, header.uCompressedSize, 1, File); | |
2769 | |
2770 uint uDecompressedSize = header.uDecompressedSize; | |
2771 zlib::MemUnzip(pRawDLV, &uDecompressedSize, pTmpMem, header.uCompressedSize); | |
2772 | |
2773 if (uDecompressedSize != header.uDecompressedSize) | |
2774 Log::Warning(L"uDecompressedSize != header.uDecompressedSize in DLV"); | |
2775 } | |
2776 free(pTmpMem); | |
2777 } | |
2778 else | |
2779 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1108", 0); | |
2780 | |
2781 pData = (char *)pRawDLV; | |
2782 } | |
2783 | |
2784 memcpy(&dlv, pData, 40); | |
2785 pData += 40; | |
2786 | |
2787 //v152 = dlv.uNumFacesInBModels; | |
2788 if (dlv.uNumFacesInBModels) | |
2789 { | |
2790 //v153 = dlv.uNumDecorations; | |
2791 if (dlv.uNumDecorations) | |
2792 { | |
2793 if (dlv.uNumFacesInBModels != uNumFaces || | |
2794 dlv.uNumDecorations != uNumLevelDecorations) | |
2795 _v244 = true; | |
2796 } | |
2797 } | |
2798 | |
2799 if (dword_6BE364_game_settings_1 & 0x2000 ) | |
2800 _i = 29030400; | |
2801 bool _a = false; | |
2802 if ( a3 - dlv.uLastRepawnDay >= _i && strcmpi(pCurrentMapName, "d29.dlv") ) | |
2803 _a = true; | |
2804 | |
2805 //v154 = 875; | |
2806 if (_v244) | |
2807 { | |
2808 memset(v203, 0, 0x36B); | |
2809 goto LABEL_132; | |
2810 } | |
2811 if (_a || !dlv.uLastRepawnDay ) | |
2812 { | |
2813 memcpy(v203, pData, 0x36B); | |
2814 LABEL_132: | |
435 | 2815 free(pRawDLV); |
0 | 2816 dlv.uLastRepawnDay = a3; |
2817 if (_v244) | |
2818 ++dlv.uNumRespawns; | |
2819 //v201 = pFilename; | |
2820 *(int *)pDest = 1; | |
2821 File = pGames_LOD->FindContainer(pFilename, 0); | |
2822 fread(&header, 0x10u, 1u, File); | |
2823 auto v155 = header.uCompressedSize; | |
2824 auto Count = header.uDecompressedSize; | |
2825 auto Src = (BLVFace *)malloc(header.uDecompressedSize); | |
435 | 2826 pRawDLV = Src; |
0 | 2827 if ( v155 <= Count ) |
2828 { | |
2829 if ( v155 == Count ) | |
2830 { | |
2831 fread(Src, 1u, Count, File); | |
2832 } | |
2833 else | |
2834 { | |
2835 auto _uSourceLen = malloc(v155); | |
2836 fread(_uSourceLen, v155, 1u, File); | |
2837 zlib::MemUnzip(Src, &Count, _uSourceLen, v155); | |
2838 free(_uSourceLen); | |
2839 } | |
2840 } | |
2841 else | |
2842 { | |
2843 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0); | |
2844 } | |
2845 pData = ((char *)Src + 40); | |
2846 //v154 = 875; | |
2847 goto LABEL_140; | |
2848 } | |
2849 *(int *)pDest = 0; | |
2850 LABEL_140: | |
2851 //v202 = (int)".blv"; | |
2852 //v156 = strlen(pFilename); | |
2853 strcpy(&pFilename[strlen(pFilename) - 4], ".blv"); | |
2854 memcpy(_visible_outlines, pData, 875); | |
2855 pData += 875; | |
2856 | |
2857 if ( *(int *)pDest ) | |
2858 memcpy(_visible_outlines, v203, 875); | |
2859 | |
2860 for (uint i = 0; i < pMapOutlines->uNumOutlines; ++i) | |
2861 { | |
2862 auto pVertex = pMapOutlines->pOutlines + i; | |
2863 if ((unsigned __int8)(1 << (7 - i % 8)) & _visible_outlines[i / 8]) | |
2864 pVertex->uFlags |= 1; | |
2865 } | |
2866 | |
2867 | |
2868 for (uint i = 0; i < uNumFaces; ++i) | |
2869 { | |
2870 auto pFace = pFaces + i; | |
2871 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
2872 | |
2873 memcpy(&pFace->uAttributes, pData, 4); | |
2874 pData += 4; | |
2875 | |
2876 if (pFaceExtra->uEventID) | |
2877 { | |
2878 if (pFaceExtra->HasEventint()) | |
2879 pFace->uAttributes |= 0x100000; | |
2880 else | |
2881 pFace->uAttributes &= ~0x100000; | |
2882 } | |
2883 } | |
2884 | |
2885 pGameLoadingUI_ProgressBar->Progress(); | |
2886 | |
2887 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2888 { | |
2889 memcpy(&pLevelDecorations[i].field_2, pData, 2); | |
2890 pData += 2; | |
2891 } | |
2892 | |
2893 pGameLoadingUI_ProgressBar->Progress(); | |
2894 | |
2895 memcpy(&uNumActors, pData, 4); | |
2896 memcpy(pActors, pData + 4, uNumActors * sizeof(Actor)); | |
2897 pData += 4 + uNumActors * sizeof(Actor); | |
2898 | |
2899 pGameLoadingUI_ProgressBar->Progress(); | |
2900 pGameLoadingUI_ProgressBar->Progress(); | |
2901 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2902 memcpy(&uNumSpriteObjects, pData, 4); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2903 memcpy(pSpriteObjects, pData + 4, uNumSpriteObjects * sizeof(SpriteObject)); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2904 pData += 4 + uNumSpriteObjects * sizeof(SpriteObject); |
0 | 2905 |
2906 pGameLoadingUI_ProgressBar->Progress(); | |
2907 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2908 for (uint i = 0; i < uNumSpriteObjects; ++i) |
0 | 2909 { |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2910 auto pItem = pSpriteObjects + i; |
0 | 2911 |
2912 if (pItem->stru_24.uItemID && !(pItem->uAttributes & 0x0100)) | |
2913 { | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2914 pItem->uType = pItemsTable->pItems[pItem->stru_24.uItemID - 1].uSpriteID; |
0 | 2915 |
2916 uint uObjectID = 0; | |
2917 for (uint j = 0; j < pObjectList->uNumObjects; ++j) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2918 if (pItem->uType == pObjectList->pObjects[j].uObjectID) |
0 | 2919 { |
2920 pItem->uObjectDescID = j; | |
2921 break; | |
2922 } | |
2923 } | |
2924 } | |
2925 | |
2926 pGameLoadingUI_ProgressBar->Progress(); | |
2927 | |
2928 memcpy(&uNumChests, pData, 4); | |
2929 memcpy(pChests, pData + 4, uNumChests * sizeof(Chest)); | |
2930 pData += 4 + uNumChests * sizeof(Chest); | |
2931 | |
2932 pGameLoadingUI_ProgressBar->Progress(); | |
2933 pGameLoadingUI_ProgressBar->Progress(); | |
2934 | |
2935 memcpy(pDoors, pData, 0x3E80); | |
2936 pData += 0x3E80; | |
2937 | |
2938 //v201 = (const char *)blv.uDoors_ddata_Size; | |
2939 //v200 = (size_t)ptr_0002B4_doors_ddata; | |
2940 //v170 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
2941 //v171 = blv.uDoors_ddata_Size; | |
2942 ptr_0002B4_doors_ddata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
2943 memcpy(ptr_0002B4_doors_ddata, pData, blv.uDoors_ddata_Size); | |
2944 pData += blv.uDoors_ddata_Size; | |
2945 | |
2946 //Src = (BLVFace *)((char *)Src + v171); | |
2947 //v172 = 0; | |
2948 //v245 = 0; | |
2949 //if (uNumDoors > 0) | |
2950 for (uint i = 0, j = 0; i < uNumDoors; ++i) | |
2951 { | |
2952 auto pDoor = pDoors + i; | |
2953 | |
2954 pDoor->pVertexIDs = ptr_0002B4_doors_ddata + j; | |
2955 j += pDoor->uNumVertices; | |
2956 | |
2957 pDoor->pFaceIDs = ptr_0002B4_doors_ddata + j; | |
2958 j += pDoor->uNumFaces; | |
2959 | |
2960 pDoor->pSectorIDs = ptr_0002B4_doors_ddata + j; | |
2961 j += pDoor->field_48; | |
2962 | |
2963 pDoor->pDeltaUs = (short *)(ptr_0002B4_doors_ddata + j); | |
2964 j += pDoor->uNumFaces; | |
2965 | |
2966 pDoor->pDeltaVs = (short *)(ptr_0002B4_doors_ddata + j); | |
2967 j += pDoor->uNumFaces; | |
2968 | |
2969 pDoor->pXOffsets = ptr_0002B4_doors_ddata + j; | |
2970 j += pDoor->uNumOffsets; | |
2971 | |
2972 pDoor->pYOffsets = ptr_0002B4_doors_ddata + j; | |
2973 j += pDoor->uNumOffsets; | |
2974 | |
2975 pDoor->pZOffsets = ptr_0002B4_doors_ddata + j; | |
2976 j += pDoor->uNumOffsets; | |
2977 /*v173 = pDoors; | |
2978 for ( k = 0; ; v172 = v188 + 2 * *((short *)&v173[k] - 3) ) | |
2979 { | |
2980 v173[k].pVertexIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v172); | |
2981 v175 = &pDoors[k]; | |
2982 v176 = v172 + 2 * v175->uNumVertices; | |
2983 v175->pFaceIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v176); | |
2984 v177 = &pDoors[k]; | |
2985 v178 = v176 + 2 * v177->uNumFaces; | |
2986 v177->pSectorIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v178); | |
2987 v179 = &pDoors[k]; | |
2988 v180 = v178 + 2 * v179->field_48; | |
2989 v179->pDeltaUs = (__int16 *)((char *)ptr_0002B4_doors_ddata + v180); | |
2990 v181 = &pDoors[k]; | |
2991 v182 = v180 + 2 * v181->uNumFaces; | |
2992 v181->pDeltaVs = (__int16 *)((char *)ptr_0002B4_doors_ddata + v182); | |
2993 v183 = &pDoors[k]; | |
2994 v184 = v182 + 2 * v183->uNumFaces; | |
2995 v183->pXOffsets = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v184); | |
2996 v185 = &pDoors[k]; | |
2997 v186 = v184 + 2 * v185->uNumOffsets; | |
2998 v185->pYOffsets = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v186); | |
2999 v187 = &pDoors[k]; | |
3000 ++k; | |
3001 v188 = v186 + 2 * v187->uNumOffsets; | |
3002 v189 = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v188); | |
3003 ++v245; | |
3004 v187->pZOffsets = v189; | |
3005 v173 = pDoors; | |
3006 if ( v245 >= uNumDoors ) | |
3007 break; | |
3008 }*/ | |
3009 } | |
3010 //v190 = 0; | |
3011 //v245 = 0; | |
3012 for (uint i = 0; i < uNumDoors; ++i) | |
3013 { | |
3014 auto pDoor = pDoors + i; | |
3015 | |
3016 for (uint j = 0; j < pDoor->uNumFaces; ++j) | |
3017 { | |
3018 auto pFace = pFaces + pDoor->pFaceIDs[j]; | |
3019 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
3020 | |
3021 pDoor->pDeltaUs[j] = pFaceExtra->sTextureDeltaU; | |
3022 pDoor->pDeltaVs[j] = pFaceExtra->sTextureDeltaV; | |
3023 } | |
3024 //v191 = pDoors; | |
3025 //pDest = 0; | |
3026 //do | |
3027 // { | |
3028 /*Argsn = 0; | |
3029 for ( l = (BLVDoor *)&v190[(int)v191]; | |
3030 Argsn < *(short *)&v190[(int)v191 + 70]; | |
3031 l = (BLVDoor *)&v190[(int)v191] ) | |
3032 { | |
3033 v193 = Argsn; | |
3034 v194 = l->pFaceIDs[Argsn++]; | |
3035 v195 = &pFaceExtras[pFaces[v194].uFaceExtraID]; | |
3036 l->pDeltaUs[v193] = v195->sTextureDeltaU; | |
3037 v190 = pDest; | |
3038 *(short *)(v193 * 2 + *(int *)&pDest[(unsigned int)pDoors + 52]) = v195->sTextureDeltaV; | |
3039 v191 = pDoors; | |
3040 } | |
3041 ++v245; | |
3042 v190 += 80; | |
3043 pDest = v190;*/ | |
3044 //} | |
3045 //while ( v245 < uNumDoors ); | |
3046 } | |
3047 | |
3048 | |
3049 pGameLoadingUI_ProgressBar->Progress(); | |
3050 | |
3051 memcpy(&stru_5E4C90, pData, 0xC8); | |
3052 pData += 0xC8; | |
3053 | |
3054 pGameLoadingUI_ProgressBar->Progress(); | |
3055 | |
3056 memcpy(&stru1, pData, 0x38u); | |
3057 pData += 0x38; | |
3058 | |
3059 free(pRawDLV); | |
3060 //v5 = 0; | |
3061 | |
3062 pSoundList->LoadSound(64, 0); | |
3063 pSoundList->LoadSound(103, 0); | |
3064 pSoundList->LoadSound(63, 0); | |
3065 pSoundList->LoadSound(102, 0); | |
3066 pSoundList->LoadSound(50, 0); | |
3067 pSoundList->LoadSound(89, 0); | |
3068 | |
3069 return 0; | |
3070 } | |
3071 | |
3072 | |
3073 //----- (0049AC17) -------------------------------------------------------- | |
3074 int IndoorLocation::GetSector(int sX, int sY, int sZ) | |
3075 { | |
3076 int v4; // esi@1 | |
3077 //unsigned __int8 v5; // zf@1 | |
3078 //unsigned __int8 v6; // sf@1 | |
3079 //unsigned __int8 v7; // of@1 | |
3080 //BLVSector *v8; // eax@3 | |
3081 //int v9; // edi@9 | |
3082 //int v10; // eax@9 | |
3083 //int v11; // edx@9 | |
3084 //int v12; // eax@10 | |
3085 //unsigned __int16 v13; // ax@12 | |
3086 //int v14; // edi@14 | |
3087 //BLVFace *v15; // eax@14 | |
3088 //BLVFace *v16; // edi@14 | |
3089 //PolygonType v17; // al@14 | |
3090 //unsigned __int16 *pVertexIDs; // esi@16 | |
3091 //Vec3_short_ *v19; // eax@16 | |
3092 //int v20; // edx@16 | |
3093 //unsigned __int16 *v21; // esi@17 | |
3094 //int v22; // edi@19 | |
3095 //int v23; // edi@20 | |
3096 //Vec3_short_ *v24; // edx@20 | |
3097 signed int v25; // edx@21 | |
3098 int v26; // ebx@23 | |
3099 //int v27; // edx@26 | |
3100 //signed __int64 v28; // qtt@26 | |
3101 ///Vec3_short_ *v29; // eax@26 | |
3102 //Vec3_short_ *v30; // edx@26 | |
3103 //int v31; // edx@26 | |
791 | 3104 //signed int v32; // edi@27 |
0 | 3105 signed __int64 v33; // qtt@27 |
3106 //Vec3_short_ *v34; // edx@27 | |
791 | 3107 //int v35; // edx@32 |
0 | 3108 int v37; // edi@38 |
717 | 3109 int pSectorID; // ebx@40 |
0 | 3110 int v39; // eax@41 |
717 | 3111 BLVFace *pFace; // esi@42 |
3112 PolygonType pPolygonType; // dl@42 | |
0 | 3113 int v42; // edx@43 |
3114 int v43[50]; // [sp+Ch] [bp-108h]@1 | |
3115 //int v44; // [sp+D4h] [bp-40h]@9 | |
3116 //int v45; // [sp+D8h] [bp-3Ch]@14 | |
3117 //int v46; // [sp+DCh] [bp-38h]@14 | |
3118 //int v47; // [sp+E0h] [bp-34h]@19 | |
3119 //int v48; // [sp+E4h] [bp-30h]@9 | |
3120 //Vec3_short_ *v49; // [sp+E8h] [bp-2Ch]@19 | |
3121 bool v50; // [sp+ECh] [bp-28h]@19 | |
3122 int v51; // [sp+F0h] [bp-24h]@9 | |
3123 //unsigned int v52; // [sp+F4h] [bp-20h]@2 | |
3124 int v53; // [sp+F8h] [bp-1Ch]@10 | |
3125 int v54; // [sp+FCh] [bp-18h]@16 | |
3126 int v55; // [sp+100h] [bp-14h]@1 | |
3127 int v56; // [sp+104h] [bp-10h]@1 | |
3128 int v57; // [sp+108h] [bp-Ch]@16 | |
3129 //Vec3_short_ *v58; // [sp+10Ch] [bp-8h]@20 | |
3130 int v59; // [sp+110h] [bp-4h]@16 | |
3131 | |
3132 v4 = 0; | |
791 | 3133 v43[0] = 0; |
3134 | |
0 | 3135 v55 = 0; |
791 | 3136 |
0 | 3137 if (uNumSectors < 2) |
3138 return 0; | |
3139 | |
3140 for (uint i = 1; i < uNumSectors; ++i) | |
3141 { | |
3142 auto pSector = pSectors + i; | |
3143 | |
791 | 3144 if (pSector->pBounding.x1 > sX || pSector->pBounding.x2 < sX || |
3145 pSector->pBounding.y1 > sY || pSector->pBounding.y2 < sY || | |
3146 pSector->pBounding.z1 - 64 > sZ || pSector->pBounding.z2 + 64 < sZ) | |
3147 continue; | |
3148 | |
618
5cfb5dadf330
Margareth righ-click (addded constructor to NPCProfession) and cleaned BLV debug logs
Nomad
parents:
595
diff
changeset
|
3149 //Log::Warning(L"Sector[%u]", i); |
791 | 3150 v51 = pSector->uNumFloors + pSector->uNumPortals; |
3151 if (!v51) | |
3152 continue; | |
3153 | |
3154 | |
3155 for (uint j = 0; j < v51; ++j) | |
3156 { | |
3157 uint uFaceID; | |
3158 if (j < pSector->uNumFloors) | |
3159 uFaceID = pSector->pFloors[j]; | |
3160 else | |
3161 uFaceID = pSector->pPortals[j - pSector->uNumFloors]; | |
3162 | |
3163 auto pFace = pFaces + uFaceID; | |
3164 if (pFace->uPolygonType != POLYGON_Floor && | |
3165 pFace->uPolygonType != POLYGON_InBetweenFloorAndWall) | |
3166 continue; | |
3167 | |
3168 v54 = 0; | |
3169 v50 = pVertices[pFace->pVertexIDs[0]].y >= sY; | |
3170 | |
793 | 3171 for (uint k = 1; k <= pFace->uNumVertices; k++) |
791 | 3172 { |
3173 v59 = v50; | |
3174 | |
3175 if (v54 >= 2) | |
3176 break; | |
3177 | |
3178 auto v2 = &pVertices[pFace->pVertexIDs[k]]; | |
3179 v50 = v2->y >= sY; | |
3180 | |
793 | 3181 if (v59 == v50) |
791 | 3182 continue; |
3183 | |
3184 auto v1 = &pVertices[pFace->pVertexIDs[k - 1]]; | |
3185 v25 = v2->x >= sX ? 0 : 2; | |
3186 v26 = v25 | (v1->x < sX); | |
3187 | |
3188 if (v26 == 3) | |
3189 continue; | |
3190 | |
3191 if (!v26) | |
3192 ++v54; | |
3193 else | |
3194 { | |
3195 if (v1->x >= v2->x) | |
3196 { | |
3197 /*int _a58; | |
0 | 3198 int _a59; |
3199 | |
3200 v32 = v1->x - v2->x; | |
3201 LODWORD(v33) = v32 << 16; | |
791 | 3202 HIDWORD(v33) = v32 >> 16;*/ |
3203 //fixpoint_div(v1->x - v2->x, v1->y - v2->y); | |
3204 //_a58 = v33 / (v1->y - v2->y); | |
3205 //_a59 = fixpoint_mul(_a58, sY - v2->y); | |
3206 auto x_div_y = fixpoint_div(v1->x - v2->x, v1->y - v2->y); | |
793 | 3207 auto res = fixpoint_mul(x_div_y, sY - v2->y); // a / b * c - looks like projection |
3208 if (res + v2->x > sX) | |
791 | 3209 ++v54; |
3210 } | |
3211 else | |
3212 { | |
3213 auto x_div_y = fixpoint_div(v2->x - v1->x, v2->y - v1->y); | |
3214 auto res = fixpoint_mul(x_div_y, sY - v1->y); | |
3215 | |
3216 if (res + v1->x > sX) | |
3217 ++v54; | |
3218 | |
3219 /*int _a58; | |
0 | 3220 int _a59; |
791 | 3221 auto v32 = v2->x - v1->x; |
0 | 3222 LODWORD(v33) = v32 << 16; |
3223 HIDWORD(v33) = v32 >> 16; | |
3224 _a58 = v33 / (v2->y - v1->y); | |
791 | 3225 _a59 = fixpoint_mul(_a58, sY - v1->y); |
0 | 3226 |
787 | 3227 if (_a59 + pVertices[k].x > sX) |
791 | 3228 ++v54;*/ |
0 | 3229 } |
717 | 3230 } |
791 | 3231 } |
3232 | |
3233 if (pFace->uNumVertices && v54 == 1) | |
3234 v43[v55++] = uFaceID; | |
3235 } | |
0 | 3236 } |
3237 | |
791 | 3238 v4 = v43[0]; |
0 | 3239 if ( v55 == 1 ) |
3240 return this->pFaces[v4].uSectorID; | |
3241 v37 = 0; | |
3242 if ( !v55 ) | |
3243 return 0; | |
717 | 3244 pSectorID = 0; |
0 | 3245 v53 = 0xFFFFFFu; |
3246 if ( v55 > 0 ) | |
3247 { | |
3248 v39 = sY; | |
3249 while ( 1 ) | |
3250 { | |
717 | 3251 pFace = &this->pFaces[v43[v37]]; |
3252 //pPolygonType = pFace->uPolygonType; | |
3253 if ( pFace->uPolygonType == POLYGON_Floor ) | |
0 | 3254 { |
717 | 3255 v42 = this->pVertices[*pFace->pVertexIDs].z; |
3256 v39 = sZ - v42; | |
3257 //goto LABEL_47; | |
3258 } | |
3259 if ( pFace->uPolygonType == POLYGON_InBetweenFloorAndWall ) | |
3260 { | |
3261 //v51 = pFace->zCalc1; | |
3262 v57 = (unsigned __int64)(pFace->zCalc1 * (signed __int64)(sX << 16)) >> 16; | |
3263 //v56 = sY << 16; | |
3264 //v51 = pFace->zCalc2; | |
3265 v56 = (unsigned __int64)(pFace->zCalc2 * (signed __int64)(sY << 16)) >> 16; | |
3266 v42 = (v56 + pFace->zCalc3 + v57 + 32768) >> 16; | |
662 | 3267 v39 = sZ - v42; |
0 | 3268 } |
717 | 3269 //LABEL_47: |
0 | 3270 if ( v39 >= 0 ) |
3271 { | |
3272 if ( v39 < v53 ) | |
3273 { | |
717 | 3274 pSectorID = pFace->uSectorID; |
0 | 3275 v53 = v39; |
3276 } | |
3277 } | |
3278 ++v37; | |
3279 if ( v37 >= v55 ) | |
717 | 3280 return pSectorID; |
0 | 3281 } |
3282 } | |
717 | 3283 //return pSectorID; |
0 | 3284 } |
3285 // 49AC17: using guessed type int var_108[50]; | |
3286 | |
3287 | |
3288 //----- (00498A41) -------------------------------------------------------- | |
3289 char BLVFace::_get_normals(Vec3_int_ *a2, Vec3_int_ *a3) | |
3290 { | |
3291 BLVFace *v3; // ebx@1 | |
3292 int v4; // eax@1 | |
3293 signed __int64 v5; // qax@2 | |
3294 double v6; // st7@8 | |
3295 Vec3_float_ a1; // [sp+Ch] [bp-Ch]@8 | |
3296 | |
3297 v3 = this; | |
3298 LOBYTE(v4) = this->uPolygonType; | |
3299 if ( (char)v4 == POLYGON_VerticalWall ) | |
3300 { | |
3301 a2->x = -this->pFacePlane_old.vNormal.y; | |
3302 LODWORD(v5) = this->pFacePlane_old.vNormal.x; | |
3303 LABEL_9: | |
3304 a2->y = v5; | |
3305 v4 = 0; | |
3306 a2->z = 0; | |
3307 a3->y = 0; | |
3308 a3->z = 0xFFFF0000u; | |
3309 LABEL_11: | |
3310 a3->x = v4; | |
3311 goto LABEL_12; | |
3312 } | |
3313 if ( (char)v4 == POLYGON_Floor || (char)v4 == POLYGON_Ceiling ) | |
3314 { | |
3315 LABEL_10: | |
3316 v4 = 0; | |
3317 a2->x = 0x10000u; | |
3318 a2->z = 0; | |
3319 a2->y = 0; | |
3320 a3->y = 0xFFFF0000u; | |
3321 a3->z = 0; | |
3322 goto LABEL_11; | |
3323 } | |
3324 if ( (char)v4 == POLYGON_InBetweenFloorAndWall || (char)v4 == POLYGON_InBetweenCeilingAndWall ) | |
3325 { | |
3326 if ( abs(this->pFacePlane_old.vNormal.z) < 46441 ) | |
3327 { | |
3328 a1.x = (double)-v3->pFacePlane_old.vNormal.y; | |
3329 a1.y = (double)v3->pFacePlane_old.vNormal.x; | |
3330 a1.z = 0.0; | |
3331 a1.Normalize(); | |
3332 v6 = a1.y * 65536.0; | |
3333 a2->x = (signed __int64)(a1.x * 65536.0); | |
3334 v5 = (signed __int64)v6; | |
3335 goto LABEL_9; | |
3336 } | |
3337 goto LABEL_10; | |
3338 } | |
3339 LABEL_12: | |
3340 if ( BYTE2(v3->uAttributes) & 0x80 ) | |
3341 { | |
3342 a2->x = -a2->x; | |
3343 a2->y = -a2->y; | |
3344 a2->z = -a2->z; | |
3345 } | |
3346 if ( BYTE3(v3->uAttributes) & 1 ) | |
3347 { | |
3348 a3->x = -a3->x; | |
3349 a3->y = -a3->y; | |
3350 a3->z = -a3->z; | |
3351 } | |
3352 return v4; | |
3353 } | |
3354 | |
3355 //----- (0044C23B) -------------------------------------------------------- | |
428 | 3356 bool BLVFaceExtra::HasEventint() |
3357 { | |
3358 signed int event_index; // eax@1 | |
3359 _evt_raw* start_evt; | |
3360 _evt_raw* end_evt; | |
3361 | |
3362 event_index = 0; | |
3363 if ( (uLevelEVT_NumEvents - 1) <= 0 ) | |
3364 return false; | |
3365 while ( pLevelEVT_Index[event_index].uEventID != this->uEventID ) | |
0 | 3366 { |
428 | 3367 ++event_index; |
3368 if ( event_index >= (signed int)(uLevelEVT_NumEvents - 1) ) | |
3369 return false; | |
0 | 3370 } |
428 | 3371 end_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index+1].uEventOffsetInEVT]; |
3372 start_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; | |
3373 if ( (end_evt->_e_type != EVENT_Exit) || (start_evt->_e_type!= EVENT_MouseOver) ) | |
3374 return false; | |
0 | 3375 else |
428 | 3376 return true; |
0 | 3377 } |
3378 | |
3379 | |
3380 | |
3381 | |
3382 //----- (0046F228) -------------------------------------------------------- | |
3383 void __cdecl BLV_UpdateDoors() | |
3384 { | |
472 | 3385 //int v0; // ebx@1 |
3386 //int v1; // edi@1 | |
3387 //BLVDoor *v2; // esi@3 | |
3388 //unsigned __int16 v3; // ax@3 | |
3389 //unsigned int v4; // ecx@5 | |
3390 //int v5; // eax@8 | |
3391 //int v6; // ecx@8 | |
3392 //int v7; // eax@12 | |
3393 //int v8; // eax@16 | |
3394 //unsigned __int8 v9; // zf@18 | |
3395 //char v10; // sf@18 | |
3396 //unsigned __int8 v11; // of@18 | |
3397 //int v12; // edi@19 | |
3398 //int v13; // ecx@19 | |
3399 //__int16 v14; // ax@19 | |
0 | 3400 BLVFace *v15; // ebx@24 |
472 | 3401 //unsigned __int16 *v16; // ecx@24 |
0 | 3402 Vec3_short_ *v17; // esi@24 |
3403 int v18; // eax@24 | |
3404 int v19; // edx@24 | |
3405 signed int v20; // eax@24 | |
472 | 3406 //Vec3_short_ *v21; // ecx@24 |
3407 //double v22; // st7@24 | |
3408 //double v23; // st6@24 | |
0 | 3409 int v24; // esi@25 |
3410 int v25; // eax@25 | |
472 | 3411 //BLVDoor *v26; // edi@25 |
0 | 3412 signed __int64 v27; // qtt@27 |
3413 BLVFaceExtra *v28; // esi@32 | |
3414 int v29; // ecx@34 | |
3415 int v30; // edx@34 | |
3416 unsigned __int64 v31; // qax@34 | |
3417 int v32; // eax@34 | |
472 | 3418 //unsigned __int16 *v33; // eax@35 |
0 | 3419 Vec3_short_ *v34; // eax@35 |
3420 int v35; // ecx@35 | |
3421 int v36; // edx@35 | |
3422 signed int v37; // eax@35 | |
3423 signed int v38; // edx@35 | |
3424 int v39; // eax@35 | |
3425 int v40; // edx@35 | |
472 | 3426 //unsigned __int8 v41; // cf@35 |
3427 //unsigned __int16 *v42; // edi@36 | |
0 | 3428 Vec3_short_ *v43; // edi@36 |
472 | 3429 //int v44; // ecx@36 |
3430 //int v45; // edi@36 | |
3431 //int v46; // ecx@36 | |
3432 //__int16 *v47; // edx@44 | |
3433 //int v48; // ecx@44 | |
0 | 3434 unsigned int v49; // ecx@46 |
3435 unsigned __int16 v50; // ax@48 | |
3436 unsigned int v51; // eax@51 | |
3437 unsigned __int16 v52; // ax@54 | |
3438 int v53; // ecx@57 | |
472 | 3439 //int v54; // edx@57 |
0 | 3440 unsigned __int64 v55; // qax@57 |
3441 int v56; // ecx@58 | |
3442 int v57; // eax@58 | |
472 | 3443 //int v58; // eax@59 |
3444 //SoundID v59; // [sp-24h] [bp-88h]@12 | |
3445 //signed int v60; // [sp-20h] [bp-84h]@12 | |
3446 //unsigned int v61; // [sp-1Ch] [bp-80h]@12 | |
3447 //signed int v62; // [sp-18h] [bp-7Ch]@12 | |
3448 //signed int v63; // [sp-14h] [bp-78h]@12 | |
3449 //int v64; // [sp-10h] [bp-74h]@12 | |
3450 //unsigned int v65; // [sp-Ch] [bp-70h]@12 | |
3451 //int v66; // [sp-8h] [bp-6Ch]@12 | |
3452 Vec3_int_ v67; | |
3453 //int v67; // [sp+8h] [bp-5Ch]@31 | |
3454 //int v68; // [sp+Ch] [bp-58h]@34 | |
3455 //int v69; // [sp+10h] [bp-54h]@34 | |
3456 Vec3_int_ v70; | |
3457 //int v70; // [sp+14h] [bp-50h]@31 | |
3458 //int v71; // [sp+18h] [bp-4Ch]@34 | |
3459 //int v72; // [sp+1Ch] [bp-48h]@34 | |
0 | 3460 int v73; // [sp+20h] [bp-44h]@24 |
472 | 3461 //__int16 v74; // [sp+24h] [bp-40h]@24 |
0 | 3462 int v75; // [sp+28h] [bp-3Ch]@36 |
3463 int v76; // [sp+2Ch] [bp-38h]@36 | |
3464 int v77; // [sp+30h] [bp-34h]@36 | |
472 | 3465 //int v78; // [sp+34h] [bp-30h]@36 |
3466 //int v79; // [sp+38h] [bp-2Ch]@19 | |
3467 //unsigned int v80; // [sp+3Ch] [bp-28h]@2 | |
3468 //int v81; // [sp+40h] [bp-24h]@1 | |
0 | 3469 int v82; // [sp+44h] [bp-20h]@35 |
3470 int v83; // [sp+48h] [bp-1Ch]@34 | |
3471 int v84; // [sp+4Ch] [bp-18h]@34 | |
3472 int v85; // [sp+50h] [bp-14h]@19 | |
3473 SoundID eDoorSoundID; // [sp+54h] [bp-10h]@1 | |
472 | 3474 //BLVDoor *v87; // [sp+58h] [bp-Ch]@3 |
0 | 3475 int v88; // [sp+5Ch] [bp-8h]@18 |
3476 int v89; // [sp+60h] [bp-4h]@6 | |
3477 | |
472 | 3478 //v0 = 0; |
3479 //v1 = 0; | |
0 | 3480 eDoorSoundID = (SoundID)pDoorSoundIDsByLocationID[dword_6BE13C_uCurrentlyLoadedLocationID]; |
472 | 3481 //v81 = 0; |
3482 //if ( pIndoor->uNumDoors > 0 ) | |
3483 for (uint i = 0; i < pIndoor->uNumDoors; ++i) | |
0 | 3484 { |
472 | 3485 auto door = pIndoor->pDoors + i; |
3486 //v80 = 0; | |
3487 //do | |
3488 //{ | |
3489 //v2 = &pIndoor->pDoors[v80 / 0x50]; | |
3490 //v87 = &pIndoor->pDoors[v80 / 0x50]; | |
3491 //v3 = door->uState; | |
3492 if (door->uState == BLVDoor::Closed || door->uState == BLVDoor::Open) | |
0 | 3493 { |
472 | 3494 door->uAttributes &= 0xFFFFFFFDu; |
0 | 3495 goto LABEL_62; |
3496 } | |
472 | 3497 door->uTimeSinceTriggered += pEventTimer->uTimeElapsed; |
3498 //v4 = door->uTimeSinceTriggered; | |
3499 if (door->uState == BLVDoor::Opening) | |
0 | 3500 { |
472 | 3501 v89 = (signed int)(door->uTimeSinceTriggered * door->uCloseSpeed) / 128; |
3502 if ( v89 >= door->uMoveLength ) | |
0 | 3503 { |
472 | 3504 v89 = door->uMoveLength; |
3505 door->uState = BLVDoor::Open; | |
0 | 3506 LABEL_10: |
472 | 3507 if ( !(door->uAttributes & 6) && door->uNumVertices != 0) |
0 | 3508 { |
472 | 3509 //v66 = 0; |
3510 //v65 = 0; | |
3511 //v64 = 0; | |
3512 //v7 = 8 * i | OBJECT_BLVDoor; | |
3513 //v63 = 0; | |
3514 //v62 = -1; | |
3515 //LOBYTE(v7) = 8 * i | OBJECT_BLVDoor; | |
3516 //v61 = 0; | |
3517 //v60 = 8 * i | OBJECT_BLVDoor; | |
3518 //v59 = (SoundID)((int)eDoorSoundID + 1); | |
3519 //LABEL_17: | |
3520 pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), 8 * i | OBJECT_BLVDoor, 0, -1, 0, 0, 0, 0); | |
3521 //goto LABEL_18; | |
0 | 3522 } |
3523 goto LABEL_18; | |
3524 } | |
3525 } | |
3526 else | |
3527 { | |
472 | 3528 auto v5 = (signed int)(door->uTimeSinceTriggered * door->uOpenSpeed) / 128; |
3529 //v6 = door->uMoveLength; | |
3530 if ( v5 >= door->uMoveLength) | |
0 | 3531 { |
472 | 3532 v89 = 0; |
3533 door->uState = BLVDoor::Closed; | |
0 | 3534 goto LABEL_10; |
3535 } | |
472 | 3536 v89 = door->uMoveLength - v5; |
0 | 3537 } |
472 | 3538 if ( !(door->uAttributes & 6) && door->uNumVertices) |
0 | 3539 { |
472 | 3540 //v66 = 0; |
3541 //v65 = 0; | |
3542 //v64 = 0; | |
3543 //v8 = 8 * i | OBJECT_BLVDoor; | |
3544 //v63 = 0; | |
3545 //v62 = -1; | |
3546 //LOBYTE(v8) = 8 * v1 | 1; | |
3547 //v61 = 1; | |
3548 //v60 = 8 * i | OBJECT_BLVDoor; | |
3549 //v59 = eDoorSoundID; | |
3550 pAudioPlayer->PlaySound(eDoorSoundID, 8 * i | OBJECT_BLVDoor, 1, -1, 0, 0, 0, 0); | |
3551 //goto LABEL_18; | |
0 | 3552 } |
3553 LABEL_18: | |
472 | 3554 //v11 = __OFSUB__(v2->uNumVertices, 0); |
3555 //v9 = v2->uNumVertices == 0; | |
3556 //v10 = (signed __int16)(v2->uNumVertices - 0) < 0; | |
3557 //v88 = 0; | |
3558 //if (door->uNumVertices > 0) | |
3559 for (uint j = 0; j < door->uNumVertices; ++j) | |
0 | 3560 { |
472 | 3561 //do |
3562 //{ | |
3563 //v12 = v88; | |
3564 //v13 = door->pVertexIDs[v88]; | |
3565 //v85 = v89; | |
3566 //v79 = door->vDirection.x; | |
3567 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
3568 //v13 *= 6; | |
3569 pIndoor->pVertices[door->pVertexIDs[j]].x = ((unsigned int)(door->vDirection.x * v89) >> 16) + door->pXOffsets[j]; | |
3570 //v85 = v89; | |
3571 //v79 = door->vDirection.y; | |
3572 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
3573 pIndoor->pVertices[door->pVertexIDs[j]].y = ((unsigned int)(door->vDirection.y * v89) >> 16) + door->pYOffsets[j]; | |
3574 //v85 = v89; | |
3575 //v79 = door->vDirection.z; | |
3576 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
3577 //v14 = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j]; | |
3578 pIndoor->pVertices[door->pVertexIDs[j]].z = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j]; | |
3579 //++v88; | |
3580 //} | |
3581 //while ( v88 < door->uNumVertices ); | |
3582 //v1 = v81; | |
0 | 3583 } |
472 | 3584 //v11 = __OFSUB__(v2->uNumFaces, 0); |
3585 //v9 = v2->uNumFaces == 0; | |
3586 //v10 = (signed __int16)(v2->uNumFaces - 0) < 0; | |
3587 v88 = 0; | |
3588 if (door->uNumFaces > 0) | |
0 | 3589 { |
3590 while ( 1 ) | |
3591 { | |
472 | 3592 v15 = &pIndoor->pFaces[door->pFaceIDs[v88]]; |
3593 //v16 = v15->pVertexIDs; | |
3594 v17 = &pIndoor->pVertices[v15->pVertexIDs[0]]; | |
0 | 3595 v18 = v15->pFacePlane_old.vNormal.y; |
3596 v73 = *(int *)&v17->x; | |
472 | 3597 //v74 = v17->z; |
0 | 3598 v19 = v15->pFacePlane_old.vNormal.z; |
472 | 3599 v20 = -(v19 * (int)v17->z + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18); |
0 | 3600 v15->pFacePlane_old.dist = v20; |
472 | 3601 //v21 = &pIndoor->pVertices[v15->pVertexIDs[0]]; |
3602 //v79 = v21->x; | |
3603 //v22 = (double)v21->x; | |
3604 //v23 = (double)v21->y; | |
3605 //v79 = v21->z; | |
3606 v15->pFacePlane.dist = -((double)v17->z * v15->pFacePlane.vNormal.z | |
3607 + (double)v17->y * v15->pFacePlane.vNormal.y | |
3608 + (double)v17->x * v15->pFacePlane.vNormal.x); | |
0 | 3609 if ( v19 ) |
3610 { | |
3611 v24 = abs(v20 >> 15); | |
3612 v25 = abs(v15->pFacePlane_old.vNormal.z); | |
472 | 3613 //v26 = v87; |
0 | 3614 if ( v24 > v25 ) |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3615 Abortf("Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]", |
472 | 3616 door->uDoorID, |
3617 door->pFaceIDs[v88], | |
0 | 3618 v15->pFacePlane_old.dist, |
3619 v15->pFacePlane_old.vNormal.z); | |
472 | 3620 //v79 = v15->pFacePlane_old.vNormal.z; |
3621 //v85 = v15->pFacePlane_old.dist; | |
3622 LODWORD(v27) = v15->pFacePlane_old.dist << 16; | |
3623 HIDWORD(v27) = v15->pFacePlane_old.dist >> 16; | |
3624 //v85 = v27 / v15->pFacePlane_old.vNormal.z; | |
3625 v15->zCalc3 = -v27 / v15->pFacePlane_old.vNormal.z; | |
0 | 3626 } |
472 | 3627 /*else |
0 | 3628 { |
3629 v26 = v87; | |
472 | 3630 }*/ |
0 | 3631 if ( BYTE2(v15->uAttributes) & 4 || pRenderer->pRenderD3D ) |
472 | 3632 v15->_get_normals(&v70, &v67); |
0 | 3633 v28 = &pIndoor->pFaceExtras[v15->uFaceExtraID]; |
3634 if ( !pRenderer->pRenderD3D ) | |
3635 { | |
3636 if ( !(BYTE2(v15->uAttributes) & 4) ) | |
3637 goto LABEL_59; | |
472 | 3638 //v79 = door->vDirection.x; |
3639 v83 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16; | |
3640 //v85 = v71; | |
3641 //v79 = door->vDirection.y; | |
3642 v85 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16; | |
3643 //v84 = v72; | |
3644 //v79 = door->vDirection.z; | |
3645 v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16; | |
3646 //v79 = v83 + v85 + v84; | |
0 | 3647 v29 = v89; |
472 | 3648 //v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; |
3649 v28->sTextureDeltaU = -((v83 + v85 + v84) * (signed __int64)v89) >> 16; | |
3650 //v79 = door->vDirection.x; | |
3651 v85 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16; | |
3652 //v83 = v68; | |
3653 //v79 = door->vDirection.y; | |
3654 v83 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16; | |
3655 //v84 = v69; | |
3656 //v79 = door->vDirection.z; | |
3657 v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; | |
3658 //v30 = v83 + v84; | |
3659 //v79 = v85 + v30; | |
3660 v31 = (v85 + v83 + v84) * (signed __int64)v29; | |
3661 //v83 = v31 >> 16; | |
0 | 3662 v32 = v31 >> 16; |
3663 goto LABEL_58; | |
3664 } | |
3665 v28->sTextureDeltaU = 0; | |
3666 v28->sTextureDeltaV = 0; | |
472 | 3667 //v33 = v15->pVertexIDs; |
3668 //v85 = 1; | |
3669 v34 = &pIndoor->pVertices[v15->pVertexIDs[0]]; | |
0 | 3670 v35 = v34->z; |
3671 v36 = v34->y; | |
3672 v82 = v34->x; | |
472 | 3673 //v79 = v36; |
3674 v37 = v70.x * v82 + v70.y * v36 + v70.z * v35; | |
3675 v38 = v67.x * v82 + v67.y * v36 + v67.z * v35; | |
0 | 3676 v39 = v37 >> 16; |
3677 *v15->pVertexUIDs = v39; | |
3678 v40 = v38 >> 16; | |
3679 *v15->pVertexVIDs = v40; | |
472 | 3680 //v41 = v15->uNumVertices < 1u; |
3681 //v9 = v15->uNumVertices == 1; | |
3682 //v83 = v40; | |
0 | 3683 v84 = v39; |
3684 v82 = v40; | |
472 | 3685 //if (v15->uNumVertices > 1) |
3686 for (uint j = 1; j < v15->uNumVertices; ++j) | |
0 | 3687 { |
472 | 3688 //do |
3689 //{ | |
3690 //v42 = v15->pVertexIDs; | |
3691 //v75 = 2 * v85; | |
3692 v43 = &pIndoor->pVertices[v15->pVertexIDs[j]]; | |
3693 //v79 = v43->z; | |
3694 //v44 = v43->y; | |
3695 //v45 = v43->x; | |
3696 //v78 = v43->y; | |
3697 v76 = ((__int64)v70.z * v43->z + (__int64)v70.x * v43->x + (__int64)v70.y * v43->y) >> 16; | |
3698 //v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16; | |
3699 v77 = ((__int64)v67.x * v43->x + (__int64)v67.y * v43->y + (__int64)v43->z * v67.z) >> 16; | |
0 | 3700 if ( v76 < v39 ) |
3701 v39 = v76; | |
472 | 3702 if ( v77 < v40 ) |
3703 v40 = v77; | |
0 | 3704 if ( v76 > v84 ) |
3705 v84 = v76; | |
472 | 3706 if ( v77 > v82 ) |
3707 v82 = v77; | |
3708 //v40 = v83; | |
3709 //v47 = v15->pVertexUIDs; | |
3710 //v48 = v75; | |
3711 //++v85; | |
3712 v15->pVertexUIDs[j] = v76; | |
3713 v15->pVertexVIDs[j] = v77; | |
3714 //} | |
3715 //while ( v85 < v15->uNumVertices ); | |
3716 //v26 = v87; | |
0 | 3717 } |
3718 v49 = v15->uAttributes; | |
3719 if ( BYTE1(v49) & 0x10 ) | |
3720 goto LABEL_50; | |
3721 if ( SBYTE1(v49) < 0 ) | |
3722 { | |
3723 v50 = v15->uBitmapID; | |
3724 if ( v50 != -1 ) | |
3725 break; | |
3726 } | |
3727 LABEL_51: | |
3728 v51 = v15->uAttributes; | |
3729 if ( v51 & 8 ) | |
3730 { | |
3731 v28->sTextureDeltaV -= v40; | |
3732 } | |
3733 else | |
3734 { | |
3735 if ( v51 & 0x20000 ) | |
3736 { | |
3737 v52 = v15->uBitmapID; | |
3738 if ( v52 != -1 ) | |
564 | 3739 v28->sTextureDeltaV -= v82 + (v52 != -1 ? pBitmaps_LOD->pTextures[v52].uTextureHeight : 26); |
0 | 3740 } |
3741 } | |
3742 if ( BYTE2(v15->uAttributes) & 4 ) | |
3743 { | |
472 | 3744 //v75 = door->vDirection.x; |
3745 v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16; | |
3746 //v82 = v71; | |
3747 //v75 = door->vDirection.y; | |
3748 v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16; | |
3749 //v83 = v72; | |
3750 //v75 = door->vDirection.z; | |
3751 v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16; | |
3752 v75 = v84 + v82 + v83; | |
0 | 3753 v53 = v89; |
3754 v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16; | |
472 | 3755 v28->sTextureDeltaU = -v82; |
3756 //v75 = door->vDirection.x; | |
3757 v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16; | |
3758 //v82 = v68; | |
3759 //v75 = door->vDirection.y; | |
3760 v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16; | |
3761 //v83 = v69; | |
3762 //v75 = door->vDirection.z; | |
3763 v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; | |
3764 //v54 = v82 + v83; | |
3765 v75 = v84 + v82 + v83; | |
3766 v55 = v75 * (signed __int64)v53; | |
3767 //v82 = v55 >> 16; | |
0 | 3768 v32 = v55 >> 16; |
3769 LABEL_58: | |
3770 v56 = v88; | |
3771 v57 = -v32; | |
3772 v28->sTextureDeltaV = v57; | |
472 | 3773 v28->sTextureDeltaU += door->pDeltaUs[v56]; |
3774 v28->sTextureDeltaV = v57 + door->pDeltaVs[v56]; | |
0 | 3775 } |
3776 LABEL_59: | |
472 | 3777 //v58 = door->uNumFaces; |
0 | 3778 ++v88; |
472 | 3779 if ( v88 >= door->uNumFaces) |
0 | 3780 { |
472 | 3781 //v1 = v81; |
3782 //v0 = 0; | |
0 | 3783 goto LABEL_62; |
3784 } | |
472 | 3785 //v2 = v87; |
0 | 3786 } |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3787 LOWORD(v39) = v84; |
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3788 if (v15->uBitmapID != -1) |
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3789 LOWORD(v39) += pBitmaps_LOD->pTextures[v15->uBitmapID].uTextureWidth; |
0 | 3790 LABEL_50: |
3791 v28->sTextureDeltaU -= v39; | |
3792 goto LABEL_51; | |
3793 } | |
3794 LABEL_62: | |
472 | 3795 ; |
3796 //v80 += 80; | |
3797 //++v1; | |
3798 //v81 = v1; | |
3799 //} | |
3800 //while ( v1 < pIndoor->uNumDoors ); | |
0 | 3801 } |
3802 } | |
3803 // 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID; | |
3804 | |
3805 //----- (0046F90C) -------------------------------------------------------- | |
3806 void __cdecl UpdateActors_BLV() | |
3807 { | |
3808 Actor *v0; // esi@2 | |
3809 unsigned __int16 v1; // ax@2 | |
3810 int v2; // edi@6 | |
3811 int v3; // eax@6 | |
3812 int v4; // eax@8 | |
3813 __int16 v5; // ax@11 | |
3814 signed int v6; // ebx@14 | |
3815 unsigned __int8 v7; // zf@14 | |
3816 unsigned __int8 v8; // sf@14 | |
3817 signed __int16 v9; // ax@17 | |
3818 signed __int64 v10; // qax@18 | |
3819 unsigned __int16 v11; // ax@21 | |
3820 int v12; // eax@29 | |
3821 unsigned __int64 v13; // qax@29 | |
3822 int v14; // eax@30 | |
3823 unsigned __int64 v15; // qax@30 | |
3824 int v16; // ecx@33 | |
3825 BLVFace *v17; // edx@33 | |
3826 int v18; // ecx@33 | |
3827 BLVFace *v19; // eax@34 | |
3828 int v20; // ecx@46 | |
3829 int v21; // eax@46 | |
3830 int v22; // edi@46 | |
3831 int v23; // eax@48 | |
3832 unsigned int v24; // eax@51 | |
3833 int v25; // eax@52 | |
3834 int v26; // ebx@54 | |
3835 int v27; // ST08_4@54 | |
3836 int v28; // edi@54 | |
3837 int v29; // eax@54 | |
3838 int v30; // ecx@62 | |
3839 int v31; // ebx@62 | |
3840 int v32; // eax@62 | |
3841 int v33; // eax@64 | |
3842 unsigned int v34; // ecx@64 | |
3843 int v35; // ecx@64 | |
3844 signed int v36; // edx@85 | |
3845 signed int v37; // ebx@85 | |
3846 BLVFace *v38; // edi@89 | |
3847 int v39; // ecx@90 | |
3848 int v40; // ebx@90 | |
3849 PolygonType v41; // al@94 | |
3850 int v42; // eax@96 | |
3851 __int16 v43; // dx@96 | |
3852 int v44; // ecx@96 | |
3853 int v45; // edi@101 | |
3854 int v46; // edi@101 | |
3855 int v47; // eax@101 | |
3856 unsigned __int64 v48; // qax@101 | |
3857 unsigned __int8 v49; // zf@103 | |
3858 unsigned __int8 v50; // sf@103 | |
3859 unsigned __int8 v51; // of@103 | |
3860 AIDirection v52; // [sp+0h] [bp-60h]@75 | |
3861 AIDirection v53; // [sp+1Ch] [bp-44h]@116 | |
3862 int v54; // [sp+38h] [bp-28h]@53 | |
3863 unsigned int uSectorID; // [sp+3Ch] [bp-24h]@6 | |
3864 int v56; // [sp+40h] [bp-20h]@6 | |
3865 unsigned int _this; // [sp+44h] [bp-1Ch]@51 | |
3866 int v58; // [sp+48h] [bp-18h]@51 | |
3867 int v59; // [sp+4Ch] [bp-14h]@8 | |
3868 unsigned int uFaceID; // [sp+50h] [bp-10h]@6 | |
3869 int v61; // [sp+54h] [bp-Ch]@14 | |
3870 int v62; // [sp+58h] [bp-8h]@6 | |
3871 unsigned int v63; // [sp+5Ch] [bp-4h]@1 | |
3872 | |
3873 v63 = 0; | |
3874 if ( (signed int)uNumActors > 0 ) | |
3875 { | |
3876 while ( 1 ) | |
3877 { | |
3878 v0 = &pActors[v63]; | |
3879 v1 = v0->uAIState; | |
3880 if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed ) | |
3881 goto LABEL_123; | |
3882 uSectorID = v0->uSectorID; | |
783 | 3883 v2 = collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, &uSectorID, &uFaceID); |
0 | 3884 v0->uSectorID = uSectorID; |
3885 v3 = v0->pMonsterInfo.uFlying; | |
3886 v56 = v2; | |
3887 v62 = v3; | |
3888 if ( !v0->CanAct() ) | |
3889 v62 = 0; | |
3890 v4 = v0->vPosition.z; | |
3891 v59 = 0; | |
3892 if ( v4 > v2 + 1 ) | |
3893 v59 = 1; | |
3894 if ( v2 <= -30000 ) | |
3895 { | |
3896 v5 = pIndoor->GetSector(v0->vPosition.x, v0->vPosition.y, v4); | |
3897 v0->uSectorID = v5; | |
3898 if ( !v5 | |
723 | 3899 || (v56 = BLV_GetFloorLevel(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &uFaceID), v56 == -30000) ) |
0 | 3900 goto LABEL_123; |
3901 } | |
305 | 3902 if ( v0->uCurrentActionAnimation == ANIM_Walking) |
0 | 3903 { |
3904 v6 = v0->uMovementSpeed; | |
3905 v7 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0; | |
3906 v8 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0; | |
3907 v61 = v0->uMovementSpeed; | |
3908 if ( !v8 && (!(v8 | v7) || LODWORD(v0->pActorBuffs[7].uExpireTime)) ) | |
3909 { | |
3910 v9 = v0->pActorBuffs[7].uPower; | |
3911 if ( v9 ) | |
3912 LODWORD(v10) = v6 / (unsigned __int16)v9; | |
3913 else | |
3914 v10 = (signed __int64)((double)v61 * 0.5); | |
3915 v6 = v10; | |
3916 v61 = v10; | |
3917 } | |
3918 v11 = v0->uAIState; | |
3919 if ( v11 == 6 || v11 == 7 ) | |
3920 { | |
3921 v6 *= 2; | |
3922 v61 = v6; | |
3923 } | |
3924 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 1 ) | |
3925 v6 = (signed __int64)((double)v61 * flt_6BE3AC_debug_recmod1_x_1_6); | |
3926 if ( v6 > 1000 ) | |
3927 v6 = 1000; | |
323 | 3928 v12 = stru_5C6E00->Cos(v0->uYawAngle); |
0 | 3929 uSectorID = v12; |
3930 v13 = v12 * (signed __int64)v6; | |
3931 v61 = v13 >> 16; | |
3932 v0->vVelocity.x = WORD1(v13); | |
323 | 3933 uSectorID = stru_5C6E00->Sin(v0->uYawAngle); |
0 | 3934 v61 = (unsigned __int64)(uSectorID * (signed __int64)v6) >> 16; |
3935 v7 = v62 == 0; | |
3936 v0->vVelocity.y = (unsigned int)(uSectorID * v6) >> 16; | |
3937 if ( !v7 ) | |
3938 { | |
323 | 3939 v14 = stru_5C6E00->Sin(v0->uPitchAngle); |
0 | 3940 uSectorID = v14; |
3941 v15 = v14 * (signed __int64)v6; | |
3942 v61 = v15 >> 16; | |
3943 v0->vVelocity.z = WORD1(v15); | |
3944 } | |
3945 } | |
3946 else | |
3947 { | |
3948 v61 = v0->vVelocity.x; | |
3949 uSectorID = 55000; | |
3950 v61 = (unsigned __int64)(55000i64 * v61) >> 16; | |
3951 v0->vVelocity.x = v61; | |
3952 v61 = v0->vVelocity.y; | |
3953 v61 = (unsigned __int64)(uSectorID * (signed __int64)v61) >> 16; | |
3954 v7 = v62 == 0; | |
3955 v0->vVelocity.y = v61; | |
3956 if ( !v7 ) | |
3957 { | |
3958 uSectorID = 55000; | |
3959 v61 = v0->vVelocity.z; | |
3960 v61 = (unsigned __int64)(55000i64 * v61) >> 16; | |
3961 v0->vVelocity.z = v61; | |
3962 } | |
3963 } | |
3964 v16 = v0->vPosition.z; | |
3965 v17 = pIndoor->pFaces; | |
3966 v51 = __OFSUB__(v16, v56); | |
3967 v8 = v16 - v56 < 0; | |
3968 v18 = uFaceID; | |
3969 if ( v8 ^ v51 ) | |
3970 { | |
3971 v0->vPosition.z = v56 + 1; | |
3972 v19 = &v17[v18]; | |
3973 if ( v19->uPolygonType == 3 ) | |
3974 { | |
3975 if ( v0->vVelocity.z < 0 ) | |
3976 v0->vVelocity.z = 0; | |
3977 } | |
3978 else | |
3979 { | |
3980 if ( v19->pFacePlane_old.vNormal.z < 45000 ) | |
3981 v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
3982 } | |
3983 } | |
3984 else | |
3985 { | |
3986 if ( v59 && !v62 ) | |
3987 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
3988 } | |
3989 if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y + v0->vVelocity.z * v0->vVelocity.z >= 400 ) | |
3990 break; | |
3991 v0->vVelocity.z = 0; | |
3992 v0->vVelocity.y = 0; | |
3993 v0->vVelocity.x = 0; | |
3994 if ( BYTE2(v17[v18].uAttributes) & 0x40 ) | |
3995 { | |
3996 if (v0->uAIState == Dead) | |
3997 v0->uAIState = Removed; | |
3998 } | |
3999 LABEL_123: | |
4000 ++v63; | |
4001 if ( (signed int)v63 >= (signed int)uNumActors ) | |
4002 return; | |
4003 } | |
4004 v20 = v0->uActorRadius; | |
4005 v21 = v0->uActorHeight; | |
4006 stru_721530.field_84 = -1; | |
4007 stru_721530.field_70 = 0; | |
4008 uSectorID = 0; | |
4009 stru_721530.field_0 = 1; | |
4010 stru_721530.field_8 = v20; | |
4011 stru_721530.prolly_normal_d = v20; | |
4012 stru_721530.field_C = v21; | |
4013 v22 = 0; | |
4014 while ( 1 ) | |
4015 { | |
4016 stru_721530.field_34.x = v0->vPosition.x; | |
4017 stru_721530.normal.x = stru_721530.field_34.x; | |
4018 stru_721530.field_34.y = v0->vPosition.y; | |
4019 stru_721530.normal.y = stru_721530.field_34.y; | |
4020 v23 = v0->vPosition.z; | |
4021 stru_721530.normal.z = v23 + v20 + 1; | |
4022 stru_721530.field_34.z = v23 - v20 + stru_721530.field_C - 1; | |
4023 if ( stru_721530.field_34.z < stru_721530.normal.z ) | |
4024 stru_721530.field_34.z = v23 + v20 + 1; | |
4025 stru_721530.field_1C = v0->vVelocity.x; | |
4026 stru_721530.field_20 = v0->vVelocity.y; | |
4027 stru_721530.field_24 = v0->vVelocity.z; | |
4028 stru_721530.uSectorID = v0->uSectorID; | |
4029 if ( !stru_721530._47050A(v22) ) | |
4030 { | |
4031 v58 = v22; | |
4032 v24 = 8 * v63; | |
4033 LOBYTE(v24) = 8 * v63 | 3; | |
4034 v61 = v22; | |
4035 _this = v24; | |
4036 do | |
4037 { | |
4038 _46E44E_collide_against_faces_and_portals(1u); | |
4039 _46E0B2_collide_against_decorations(); | |
4040 _46EF01_collision_chech_player(0); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
4041 _46ED8A_collide_against_sprite_objects(_this); |
0 | 4042 v25 = 0; |
4043 v56 = 0; | |
4044 if ( ai_arrays_size > v22 ) | |
4045 { | |
4046 do | |
4047 { | |
390 | 4048 v54 = ai_near_actors_ids[v25]; |
0 | 4049 if ( v54 != v63 ) |
4050 { | |
4051 v26 = v54; | |
4052 v27 = abs(pActors[v54].vPosition.z - v0->vPosition.z); | |
4053 v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y); | |
4054 v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x); | |
322 | 4055 if ( int_get_vector_length(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius |
0 | 4056 && _46DF1A_collide_against_actor(v54, 40) ) |
4057 ++v58; | |
4058 v22 = 0; | |
4059 } | |
4060 v25 = v56++ + 1; | |
4061 } | |
4062 while ( v56 < ai_arrays_size ); | |
4063 } | |
4064 if ( _46F04E_collide_against_portals() ) | |
4065 break; | |
4066 ++v61; | |
4067 } | |
4068 while ( v61 < 100 ); | |
4069 v56 = v58 > 1; | |
4070 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
4071 { | |
4072 v30 = stru_721530.normal2.x; | |
4073 v31 = stru_721530.normal2.y; | |
4074 v32 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
4075 } | |
4076 else | |
4077 { | |
4078 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
4079 v30 = v58 + v0->vPosition.x; | |
4080 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
4081 v31 = v58 + v0->vPosition.y; | |
4082 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
4083 v32 = v58 + v0->vPosition.z; | |
4084 } | |
783 | 4085 v33 = collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID); |
0 | 4086 v34 = pIndoor->pFaces[uFaceID].uAttributes; |
4087 v35 = v34 & 0x400000; | |
4088 if (v35 && v0->uAIState == Dead) | |
4089 { | |
4090 v0->uAIState = Removed; | |
4091 goto LABEL_120; | |
4092 } | |
4093 if ( v59 != v22 || v62 != v22 || v35 == v22 ) | |
4094 { | |
4095 if ( v33 == -30000 ) | |
4096 goto LABEL_120; | |
4097 if ( v0->uCurrentActionAnimation != 1 || v33 >= v0->vPosition.z - 100 || v59 != v22 || v62 != v22 ) | |
4098 { | |
4099 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
4100 { | |
4101 v0->vPosition.x = LOWORD(stru_721530.normal2.x); | |
4102 v0->vPosition.y = LOWORD(stru_721530.normal2.y); | |
4103 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; | |
4104 v0->uSectorID = LOWORD(stru_721530.uSectorID); | |
4105 goto LABEL_123; | |
4106 } | |
4107 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
4108 v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16; | |
4109 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
4110 v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16; | |
4111 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
4112 v36 = stru_721530.uFaceID; | |
4113 v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; | |
4114 v0->uSectorID = LOWORD(stru_721530.uSectorID); | |
4115 stru_721530.field_70 += stru_721530.field_7C; | |
4116 v37 = v36 >> 3; | |
141 | 4117 if ( (v36 & 7) != OBJECT_Actor) |
0 | 4118 { |
141 | 4119 if ( (v36 & 7) != OBJECT_Player) |
0 | 4120 { |
141 | 4121 if ( (v36 & 7) == OBJECT_Decoration) |
0 | 4122 { |
295 | 4123 _this = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); |
0 | 4124 v45 = stru_5C6E00->Atan2( |
4125 v0->vPosition.x - pLevelDecorations[v37].vPosition.x, | |
4126 v0->vPosition.y - pLevelDecorations[v37].vPosition.y); | |
323 | 4127 v54 = stru_5C6E00->Cos(v45); |
0 | 4128 v56 = (unsigned __int64)(v54 * (signed __int64)(signed int)_this) >> 16; |
4129 v46 = v45 - stru_5C6E00->uIntegerHalfPi; | |
4130 v0->vVelocity.x = v54 * _this >> 16; | |
323 | 4131 v47 = stru_5C6E00->Sin(v45); |
0 | 4132 v54 = v47; |
4133 v48 = v47 * (signed __int64)(signed int)_this; | |
4134 v56 = v48 >> 16; | |
4135 v0->vVelocity.y = WORD1(v48); | |
4136 goto LABEL_119; | |
4137 } | |
141 | 4138 if ( (v36 & 7) == OBJECT_BModel) |
0 | 4139 { |
4140 stru_721530.field_84 = v36 >> 3; | |
4141 v38 = &pIndoor->pFaces[v37]; | |
4142 if ( v38->uPolygonType == 3 ) | |
4143 { | |
4144 v39 = v0->vVelocity.x; | |
4145 v40 = v0->vVelocity.y * v0->vVelocity.y; | |
4146 v0->vVelocity.z = 0; | |
4147 v0->vPosition.z = pIndoor->pVertices[*v38->pVertexIDs].z + 1; | |
4148 if ( v39 * v39 + v40 < 400 ) | |
4149 { | |
4150 v0->vVelocity.y = 0; | |
4151 v0->vVelocity.x = 0; | |
4152 goto LABEL_119; | |
4153 } | |
4154 } | |
4155 else | |
4156 { | |
4157 v61 = abs(v38->pFacePlane_old.vNormal.x * v0->vVelocity.x + v38->pFacePlane_old.vNormal.y | |
4158 * v0->vVelocity.y | |
4159 + v38->pFacePlane_old.vNormal.z | |
4160 * v0->vVelocity.z) >> 16; | |
4161 if ( stru_721530.field_64 >> 3 > v61 ) | |
4162 v61 = stru_721530.field_64 >> 3; | |
4163 v58 = v38->pFacePlane_old.vNormal.x; | |
4164 v58 = (unsigned __int64)(v61 * (signed __int64)v58) >> 16; | |
4165 _this = v38->pFacePlane_old.vNormal.y; | |
4166 _this = (unsigned __int64)(v61 * (signed __int64)(signed int)_this) >> 16; | |
4167 v56 = v38->pFacePlane_old.vNormal.z; | |
4168 v56 = (unsigned __int64)(v61 * (signed __int64)v56) >> 16; | |
4169 v0->vVelocity.x += v58; | |
4170 v0->vVelocity.y += _this; | |
4171 v0->vVelocity.z += v56; | |
4172 v41 = v38->uPolygonType; | |
4173 if ( v41 != 4 && v41 != 3 ) | |
4174 { | |
4175 v42 = v38->pFacePlane_old.vNormal.x; | |
4176 v43 = v0->vPosition.z; | |
4177 v44 = stru_721530.prolly_normal_d | |
4178 - ((v38->pFacePlane_old.dist | |
4179 + v38->pFacePlane_old.vNormal.z * v0->vPosition.z | |
4180 + v38->pFacePlane_old.vNormal.y * v0->vPosition.y | |
4181 + v42 * v0->vPosition.x) >> 16); | |
4182 if ( v44 > 0 ) | |
4183 { | |
4184 v0->vPosition.x += (unsigned int)(v44 * v42) >> 16; | |
4185 v0->vPosition.y += (unsigned int)(v44 * v38->pFacePlane_old.vNormal.y) >> 16; | |
4186 v0->vPosition.z = v43 + ((unsigned int)(v44 * v38->pFacePlane_old.vNormal.z) >> 16); | |
4187 } | |
4188 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y); | |
4189 } | |
4190 } | |
4191 if ( BYTE3(v38->uAttributes) & 8 ) | |
4192 EventProcessor(pIndoor->pFaceExtras[v38->uFaceExtraID].uEventID, 0, 1); | |
4193 } | |
4194 LABEL_119: | |
4195 v56 = v0->vVelocity.x; | |
4196 v54 = 58500; | |
4197 v56 = (unsigned __int64)(58500i64 * v56) >> 16; | |
4198 v0->vVelocity.x = v56; | |
4199 v56 = v0->vVelocity.y; | |
4200 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16; | |
4201 v54 = 58500; | |
4202 v0->vVelocity.y = v56; | |
4203 v56 = v0->vVelocity.z; | |
4204 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16; | |
4205 v22 = 0; | |
4206 v0->vVelocity.z = v56; | |
4207 goto LABEL_120; | |
4208 } | |
4209 if ( v0->GetActorsRelation(0) ) | |
4210 { | |
4211 v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[11].uExpireTime), v22); | |
4212 v49 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == v22; | |
4213 v50 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) - v22 < 0; | |
4214 v0->vVelocity.y = v22; | |
4215 v0->vVelocity.x = v22; | |
4216 if ( !(v50 ^ v51) | |
4217 && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v22) ) | |
4218 pParty->pPartyBuffs[11].Reset(); | |
4219 viewparams->bRedrawGameUI = 1; | |
4220 goto LABEL_119; | |
4221 } | |
4222 v36 = stru_721530.uFaceID; | |
4223 LABEL_118: | |
4224 Actor::FaceObject(v63, v36, v22, (AIDirection *)v22); | |
4225 goto LABEL_119; | |
4226 } | |
4227 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 2 || pTurnEngine->field_4 == 3) ) | |
4228 goto LABEL_119; | |
4229 if ( v0->pMonsterInfo.uHostilityType ) | |
4230 { | |
4231 if ( v56 == v22 ) | |
4232 goto LABEL_114; | |
4233 } | |
4234 else | |
4235 { | |
4236 if ( v56 == v22 ) | |
4237 { | |
4238 if ( !pActors[v37].pMonsterInfo.uHostilityType ) | |
4239 goto LABEL_118; | |
4240 LABEL_114: | |
4241 Actor::_402968(v63, v36, v22, (AIDirection *)v22); | |
4242 goto LABEL_119; | |
4243 } | |
4244 } | |
414 | 4245 Actor::AI_StandOrBored(v63, 4, v22, &v53); |
0 | 4246 goto LABEL_119; |
4247 } | |
4248 if ( v0->vPosition.x & 1 ) | |
4249 v0->uYawAngle += 100; | |
4250 else | |
4251 v0->uYawAngle -= 100; | |
4252 } | |
4253 else | |
4254 { | |
4255 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 2 || pTurnEngine->field_4 == 3) ) | |
4256 goto LABEL_123; | |
4257 if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 ) | |
4258 { | |
414 | 4259 Actor::AI_StandOrBored(v63, 4, v22, &v52); |
0 | 4260 goto LABEL_123; |
4261 } | |
4262 } | |
4263 } | |
4264 LABEL_120: | |
4265 ++uSectorID; | |
4266 if ( uSectorID >= 100 ) | |
4267 goto LABEL_123; | |
4268 v20 = stru_721530.prolly_normal_d; | |
4269 } | |
4270 } | |
4271 } | |
4272 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); | |
4273 // 4F75D8: using guessed type int ai_arrays_size; | |
4274 | |
4275 | |
4276 | |
4277 | |
4278 | |
4279 | |
4280 //----- (00460A78) -------------------------------------------------------- | |
4281 void __thiscall PrepareToLoadBLV(unsigned int bLoading) | |
4282 { | |
4283 unsigned int v1; // ebx@1 | |
4284 unsigned int v2; // eax@8 | |
4285 MapInfo *v3; // edi@9 | |
4286 int v4; // eax@11 | |
4287 int v5; // eax@12 | |
4288 int v6; // eax@13 | |
4289 int v7; // esi@27 | |
4290 SpawnPointMM7 *v8; // edx@28 | |
4291 //char v9; // bl@33 | |
4292 //int v10; // eax@34 | |
4293 //char *v11; // ecx@37 | |
4294 //int v12; // edi@44 | |
4295 //unsigned int v13; // edi@48 | |
4296 char *v14; // esi@49 | |
4297 __int16 v15; // ax@50 | |
4298 int v16; // ecx@52 | |
4299 DecorationDesc *v17; // eax@54 | |
4300 int v18; // ecx@55 | |
4301 //int *v19; // edi@58 | |
4302 //unsigned char v20; // dl@58 | |
4303 int v21; // eax@64 | |
4304 char v22; // cl@64 | |
4305 //signed int v23; // ebx@67 | |
4306 //char *v24; // esi@68 | |
4307 //int v25; // eax@70 | |
4308 //char *v26; // esi@78 | |
4309 //int v27; // eax@79 | |
4310 char v28; // zf@81 | |
4311 __int16 v29; // ax@85 | |
4312 signed int v30; // edi@94 | |
4313 int v31; // esi@94 | |
4314 char Args; // [sp+350h] [bp-C4h]@16 | |
4315 int v34[4]; // [sp+3E8h] [bp-2Ch]@96 | |
4316 int v35; // [sp+3F8h] [bp-1Ch]@1 | |
4317 //char b[4]; // [sp+3FCh] [bp-18h]@58 | |
4318 MapInfo *v37; // [sp+400h] [bp-14h]@1 | |
4319 int v38; // [sp+404h] [bp-10h]@1 | |
4320 unsigned int v39; // [sp+408h] [bp-Ch]@8 | |
4321 int pDest; // [sp+40Ch] [bp-8h]@1 | |
4322 //int i; // [sp+410h] [bp-4h]@27 | |
4323 | |
4324 v37 = (MapInfo *)bLoading; | |
4325 v1 = 0; | |
4326 v35 = 0; | |
4327 pGameLoadingUI_ProgressBar->Reset(0x20u); | |
4328 bUnderwater = 0; | |
4329 bNoNPCHiring = 0; | |
4330 v38 = 0; | |
4331 pDest = 1; | |
4332 uCurrentlyLoadedLevelType = LEVEL_Indoor; | |
4333 pGame->uFlags2 &= 0xFFFFFFF7u; | |
4334 if ( Is_out15odm_underwater() ) | |
4335 { | |
4336 bUnderwater = 1; | |
4337 pGame->uFlags2 |= 8u; | |
4338 } | |
4339 if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d23.blv") ) | |
4340 bNoNPCHiring = 1; | |
4341 pPaletteManager->pPalette_tintColor[0] = 0; | |
4342 pPaletteManager->pPalette_tintColor[1] = 0; | |
4343 pPaletteManager->pPalette_tintColor[2] = 0; | |
4344 pPaletteManager->RecalculateAll(); | |
4345 if ( qword_A750D8 ) | |
4346 qword_A750D8 = 0i64; | |
4347 v2 = pMapStats->GetMapInfo(pCurrentMapName); | |
4348 v39 = v2; | |
4349 if ( v2 ) | |
4350 { | |
4351 v3 = &pMapStats->pInfos[v2]; | |
4352 v1 = v3->uRespawnIntervalDays; | |
4353 v38 = GetAlertStatus(); | |
4354 } | |
4355 else | |
4356 { | |
4357 v3 = v37; | |
4358 } | |
4359 dword_6BE13C_uCurrentlyLoadedLocationID = v39; | |
4360 pAllocator->FreeChunk(ptr_6A0D08); | |
4361 ptr_6A0D08 = 0; | |
4362 _6A0D0C_txt_lod_loading = 0; | |
4363 TryLoadLevelFromLOD(); | |
4364 pStationaryLightsStack->uNumLightsActive = 0; | |
4365 v4 = pIndoor->Load( | |
4366 pCurrentMapName, | |
4367 (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1, | |
4368 v1, | |
4369 (char *)&pDest) | |
4370 - 1; | |
4371 if ( !v4 ) | |
4372 { | |
4373 sprintf(&Args, "Unable to open %s", pCurrentMapName); | |
4374 Abortf(&Args); | |
4375 } | |
4376 v5 = v4 - 1; | |
4377 if ( !v5 ) | |
4378 { | |
4379 sprintf(&Args, "File %s is not a BLV File", pCurrentMapName); | |
4380 Abortf(&Args); | |
4381 } | |
4382 v6 = v5 - 1; | |
4383 if ( !v6 ) | |
4384 Abortf("Attempt to open new level before clearing old"); | |
4385 if ( v6 == 1 ) | |
4386 Abortf("Out of memory loading indoor level"); | |
4387 if ( !(dword_6BE364_game_settings_1 & 0x2000) ) | |
4388 { | |
4389 InitializeActors(); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
4390 InitializeSpriteObjects(); |
0 | 4391 } |
4392 BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; | |
4393 if ( !v39 ) | |
4394 pDest = 0; | |
4395 if ( pDest == 1 ) | |
4396 { | |
4397 v7 = 0; | |
4398 for (uint i = 0; i < pIndoor->uNumSpawnPoints; ++v7 ) | |
4399 { | |
4400 v8 = &pIndoor->pSpawnPoints[v7]; | |
4401 if ( pIndoor->pSpawnPoints[v7].uKind == 3 ) | |
4402 SpawnEncounter(v3, v8, 0, 0, 0); | |
4403 else | |
4404 v3->SpawnRandomTreasure(v8); | |
4405 ++i; | |
4406 } | |
4407 RespawnGlobalDecorations(); | |
4408 } | |
4409 | |
4410 pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39], 0); | |
4411 pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39] + 1, 0); | |
4412 | |
4413 for (uint i = 0; i < pIndoor->uNumDoors; ++i) | |
4414 { | |
4415 auto pDoor = pIndoor->pDoors + i; | |
4416 | |
4417 if (pDoor->uAttributes & 0x01) | |
4418 { | |
4419 pDoor->uState = BLVDoor::Opening; | |
4420 pDoor->uTimeSinceTriggered = 15360; | |
4421 pDoor->uAttributes = 2; | |
4422 } | |
4423 | |
4424 if (pDoor->uState == BLVDoor::Closed) | |
4425 { | |
4426 pDoor->uState = BLVDoor::Closing; | |
4427 pDoor->uTimeSinceTriggered = 15360; | |
4428 pDoor->uAttributes = 2; | |
4429 } | |
4430 else if (pDoor->uState == BLVDoor::Open) | |
4431 { | |
4432 pDoor->uState = BLVDoor::Opening; | |
4433 pDoor->uTimeSinceTriggered = 15360; | |
4434 pDoor->uAttributes = 2; | |
4435 } | |
4436 } | |
4437 | |
4438 /* | |
4439 i = 0; | |
4440 v9 = 2; | |
4441 if ( pIndoor->uNumDoors > 0 ) | |
4442 { | |
4443 v10 = 0; | |
4444 while ( 1 ) | |
4445 { | |
4446 if ( pIndoor->pDoors[v10].uAttributes & 1 ) | |
4447 { | |
4448 pIndoor->pDoors[v10].uState = 1; | |
4449 pIndoor->pDoors[v10].uTimeSinceTriggered = 15360; | |
4450 pIndoor->pDoors[v10].uAttributes = 2; | |
4451 } | |
4452 v11 = (char *)&pIndoor->pDoors[v10].uState; | |
4453 if ( !*(short *)v11 ) | |
4454 break; | |
4455 if ( *(short *)v11 == 2 ) | |
4456 { | |
4457 *(short *)v11 = 1; | |
4458 goto LABEL_41; | |
4459 } | |
4460 LABEL_42: | |
4461 ++i; | |
4462 ++v10; | |
4463 if ( i >= pIndoor->uNumDoors ) | |
4464 goto LABEL_43; | |
4465 } | |
4466 *(short *)v11 = 3; | |
4467 LABEL_41: | |
4468 pIndoor->pDoors[v10].uTimeSinceTriggered = 15360; | |
4469 pIndoor->pDoors[v10].uAttributes = 2; | |
4470 goto LABEL_42; | |
4471 } | |
4472 LABEL_43: | |
4473 */ | |
4474 | |
4475 for (uint i = 0; i < pIndoor->uNumFaces; ++i) | |
4476 { | |
4477 auto pFace = pIndoor->pFaces + i; | |
4478 if (!pFace->uBitmapID != -1) | |
4479 pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id1); | |
4480 } | |
4481 | |
4482 /*i = 0; | |
4483 if ( (signed int)pIndoor->uNumFaces > 0 ) | |
4484 { | |
4485 v12 = 0; | |
4486 do | |
4487 { | |
4488 if ( pIndoor->pFaces[v12].uBitmapID != -1 ) | |
4489 pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id1); | |
4490 ++i; | |
4491 ++v12; | |
4492 } | |
4493 while ( i < (signed int)pIndoor->uNumFaces ); | |
4494 }*/ | |
4495 | |
4496 | |
4497 pGameLoadingUI_ProgressBar->Progress(); | |
4498 | |
4499 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
4500 { | |
4501 auto pDecortaion = pLevelDecorations + i; | |
4502 | |
4503 pDecorationList->InitializeDecorationSprite(pDecortaion->uDecorationDescID); | |
4504 | |
4505 v15 = pDecorationList->pDecorations[pDecortaion->uDecorationDescID].uSoundID; | |
4506 if (v15 && _6807E0_num_decorations_with_sounds_6807B8 < 9) | |
4507 { | |
4508 pSoundList->LoadSound(v15, 0); | |
4509 v16 = _6807E0_num_decorations_with_sounds_6807B8++; | |
4510 _6807B8_level_decorations_ids[v16] = i; | |
4511 } | |
4512 | |
4513 if ( !(pDecortaion->field_2 & 0x20) ) | |
4514 { | |
4515 v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID]; | |
380 | 4516 if (!v17->DontDraw()) |
0 | 4517 { |
4518 v18 = v17->uLightRadius; | |
4519 if ( v18 ) | |
4520 { | |
4521 unsigned char r = 255, | |
4522 g = 255, | |
4523 b = 255; | |
4524 if (pRenderer->pRenderD3D && pRenderer->bUseColoredLights) | |
4525 { | |
4526 r = v17->uColoredLightRed; | |
4527 g = v17->uColoredLightGreen; | |
4528 b = v17->uColoredLightBlue; | |
4529 } | |
4530 pStationaryLightsStack->AddLight(pDecortaion->vPosition.x, | |
4531 pDecortaion->vPosition.y, | |
4532 pDecortaion->vPosition.z + v17->uDecorationHeight, | |
4533 v18, | |
4534 r, | |
4535 g, | |
4536 b, | |
4537 byte_4E94D0); | |
4538 } | |
4539 } | |
4540 } | |
4541 | |
4542 if (!pDecortaion->field_16_event_id) | |
4543 { | |
4544 if (pDecortaion->IsInteractive()) | |
4545 { | |
4546 if ( v35 < 124 ) | |
4547 { | |
4548 v21 = v35 + 1; | |
4549 pDecortaion->_idx_in_stru123 = v35 + 75; | |
4550 v22 = stru_5E4C90._decor_events[v21 + 74 - 75]; | |
4551 v35 = v21; | |
4552 if ( !v22 ) | |
4553 pDecortaion->field_2 |= 0x20; | |
4554 } | |
4555 } | |
4556 } | |
4557 } | |
4558 | |
4559 pGameLoadingUI_ProgressBar->Progress(); | |
4560 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
4561 for (uint i = 0; i < uNumSpriteObjects; ++i) |
0 | 4562 { |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
4563 auto p = pSpriteObjects + i; |
0 | 4564 if (p->uObjectDescID) |
4565 { | |
4566 auto uItemID = p->stru_24.uItemID; | |
4567 if (uItemID) | |
4568 { | |
4569 if (uItemID != 220 && pItemsTable->pItems[uItemID].uEquipType == EQUIP_POTION && | |
570 | 4570 !p->stru_24.uEnchantmentType) |
4571 p->stru_24.uEnchantmentType = rand() % 15 + 5; | |
0 | 4572 pItemsTable->SetSpecialBonus(&p->stru_24); |
4573 } | |
4574 } | |
4575 } | |
4576 | |
4577 for (uint i = 0; i < uNumActors; ++i) | |
4578 //if ( (signed int)uNumActors > (signed int)v13 ) | |
4579 { | |
4580 Actor *pActor = pActors + i; | |
4581 //v26 = (char *)&pActors[0].uAttributes; | |
4582 //do | |
4583 //{ | |
4584 //v27 = *(int *)v26; | |
4585 if (pActor->uAttributes & 0x100000) | |
4586 { | |
4587 if ( !v39 ) | |
4588 { | |
4589 pActor->pMonsterInfo.field_3E = 19; | |
4590 pActor->uAttributes |= 0x10000; | |
4591 continue; | |
4592 } | |
4593 v28 = v38 == 0; | |
4594 } | |
4595 else | |
4596 { | |
4597 v28 = v38 == 1; | |
4598 } | |
4599 | |
4600 if ( !v28 ) | |
4601 { | |
4602 pActor->PrepareSprites(0); | |
4603 v29 = pActor->pMonsterInfo.field_3E; | |
4604 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
4605 if ( v29 != 11 && v29 != 19 && (!pActor->sCurrentHP || !pActor->pMonsterInfo.uHP) ) | |
4606 { | |
4607 pActor->pMonsterInfo.field_3E = 5; | |
4608 pActor->UpdateAnimation(); | |
4609 } | |
4610 } | |
4611 else | |
4612 { | |
4613 pActor->pMonsterInfo.field_3E = 19; | |
4614 pActor->uAttributes |= 0x10000; | |
4615 } | |
4616 //} | |
4617 //while ( i < (signed int)uNumActors ); | |
4618 } | |
4619 | |
4620 pGameLoadingUI_ProgressBar->Progress(); | |
4621 | |
4622 Actor this_; | |
4623 this_.pMonsterInfo.uID = 45; | |
4624 this_.PrepareSprites(0); | |
4625 if ( !v37 ) | |
4626 { | |
4627 pParty->sRotationX = 0; | |
4628 pParty->sRotationY = 0; | |
4629 pParty->vPosition.z = 0; | |
4630 pParty->vPosition.y = 0; | |
4631 pParty->vPosition.x = 0; | |
4632 pParty->uFallStartY = 0; | |
4633 pParty->uFallSpeed = 0; | |
4634 TeleportToStartingPoint(uLevel_StartingPointType); | |
4635 } | |
4636 viewparams->_443365(); | |
4637 PlayLevelMusic(); | |
4638 if ( !v37 ) | |
4639 { | |
4640 v30 = 0; | |
4641 v31 = 1; | |
4642 do | |
4643 { | |
4644 if ( pPlayers[v31]->CanAct() ) | |
4645 v34[v30++] = v31; | |
4646 ++v31; | |
4647 } | |
4648 while ( v31 <= 4 ); | |
4649 if ( v30 ) | |
4650 { | |
4651 if ( pDest ) | |
4652 { | |
4653 qword_A750D8 = 256i64; | |
4654 word_A750E0 = 46; | |
4655 word_A750E2 = LOWORD(v34[rand() % v30]); | |
4656 } | |
4657 } | |
4658 } | |
4659 } |