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