Mercurial > mm7
annotate Indoor.cpp @ 1439:468f434a8d8a
Слияние
author | Ritor1 |
---|---|
date | Mon, 22 Jul 2013 18:00:58 +0600 |
parents | bc99e1a48bea 8ea496564034 |
children | b67a3e0d6fc3 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
4 |
0 | 5 #include <assert.h> |
6 | |
1016 | 7 #include "LightmapBuilder.h" |
8 #include "DecalBuilder.h" | |
9 #include "stru9.h" | |
10 #include "stru10.h" | |
1078 | 11 #include "stru367.h" |
1016 | 12 |
13 #include "BSPModel.h" | |
0 | 14 #include "Outdoor.h" |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
15 #include "SpriteObject.h" |
0 | 16 #include "Events.h" |
17 #include "Game.h" | |
18 #include "Viewport.h" | |
19 #include "Time.h" | |
20 #include "Party.h" | |
21 #include "Math.h" | |
22 #include "Allocator.h" | |
23 #include "LOD.h" | |
24 #include "DecorationList.h" | |
25 #include "ObjectList.h" | |
26 #include "Actor.h" | |
27 #include "Chest.h" | |
28 #include "GUIProgressBar.h" | |
29 #include "stru123.h" | |
30 #include "AudioPlayer.h" | |
31 #include "Log.h" | |
32 #include "TurnEngine.h" | |
33 #include "PaletteManager.h" | |
34 #include "MapInfo.h" | |
186 | 35 #include "IndoorCamera.h" |
1262 | 36 #include "Lights.h" |
0 | 37 |
38 #include "mm7_data.h" | |
831 | 39 #include "MM7.h" |
1295 | 40 #include "Sprites.h" |
41 #include "Game.h" | |
42 #include "stru6.h" | |
43 #include "ParticleEngine.h" | |
44 #include "Outdoor_stuff.h" | |
1297 | 45 #include "texts.h" |
46 #include "GUIWindow.h" | |
0 | 47 |
48 | |
49 | |
50 | |
51 | |
52 IndoorLocation *pIndoor = new IndoorLocation; | |
53 BLVRenderParams *pBLVRenderParams = new BLVRenderParams; | |
54 | |
55 struct DecorationList *pDecorationList; | |
56 | |
1202 | 57 std::array<LevelDecoration, 3000> pLevelDecorations; |
0 | 58 size_t uNumLevelDecorations; |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
59 LevelDecoration* activeLevelDecoration; |
0 | 60 |
61 LEVEL_TYPE uCurrentlyLoadedLevelType = LEVEL_null; | |
62 | |
63 stru320 stru_F8AD28; // idb | |
64 stru337 stru_F81018; | |
65 stru167_wrap array_5118E8; | |
1376 | 66 BspRenderer_PortalViewportData stru_F8A590; |
0 | 67 BspRenderer *pBspRenderer = new BspRenderer; // idb |
68 stru141 stru_721530; | |
1202 | 69 std::array<stru352, 480> stru_F83B80; |
0 | 70 |
71 | |
72 | |
73 unsigned __int16 pDoorSoundIDsByLocationID[78] = | |
74 { | |
75 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, | |
76 300, 300, 300, 404, 302, 306, 308, 304, 308, 302, 400, 302, 300, | |
77 308, 308, 306, 308, 308, 304, 300, 404, 406, 300, 400, 406, 404, | |
78 306, 302, 408, 304, 300, 300, 300, 300, 300, 300, 300, 300, 300, | |
79 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 404, 304, | |
80 400, 300, 300, 404, 304, 400, 300, 300, 404, 304, 400, 300, 300 | |
81 }; | |
82 | |
83 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
84 std::array<const char *, 11> _4E6BDC_loc_names= |
1006 | 85 { |
86 "mdt12.blv", | |
87 "d18.blv", | |
88 "mdt14.blv", | |
89 "d37.blv", | |
90 "mdk01.blv", | |
91 "mdt01.blv", | |
92 "mdr01.blv", | |
93 "mdt10.blv", | |
94 "mdt09.blv", | |
95 "mdt15.blv", | |
96 "mdt11.blv" | |
97 }; | |
98 | |
0 | 99 |
100 //----- (0043F39E) -------------------------------------------------------- | |
101 void __fastcall PrepareDrawLists_BLV(IndoorLocation_drawstru *_this) | |
102 { | |
103 //int *v1; // ecx@1 | |
104 //double v2; // ST30_8@3 | |
105 //double v3; // ST30_8@6 | |
106 //double v4; // ST28_8@6 | |
107 int v5; // eax@4 | |
707 | 108 //int v6; // eax@7 |
0 | 109 unsigned int v7; // ebx@8 |
110 BLVSector *v8; // esi@8 | |
707 | 111 //unsigned __int16 *v9; // edi@8 |
112 //int i; // [sp+18h] [bp-8h]@7 | |
0 | 113 //unsigned __int8 v11; // [sp+1Ch] [bp-4h]@3 |
707 | 114 //signed int v12; // [sp+1Ch] [bp-4h]@8 |
0 | 115 |
116 pBLVRenderParams->Reset(_this); | |
117 pMobileLightsStack->uNumLightsActive = 0; | |
118 //uNumMobileLightsApplied = 0; | |
119 uNumDecorationsDrawnThisFrame = 0; | |
120 _unused000 = 0; | |
121 uNumSpritesDrawnThisFrame = 0; | |
122 uNumBillboardsToDraw = 0; | |
707 | 123 |
124 if ( !byte_4D864C || !(pGame->uFlags & 0x1000) ) // lightspot around party | |
0 | 125 { |
126 //v2 = pParty->flt_TorchlightColorB + 6.7553994e15; | |
127 //v11 = LOBYTE(v2); | |
128 v5 = 800; | |
129 if (pParty->TorchlightActive()) | |
707 | 130 v5 *= pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; |
0 | 131 //LOBYTE(v1) = byte_4E94D0; |
132 //v4 = pParty->flt_TorchlightColorR + 6.7553994e15; | |
133 //v3 = pParty->flt_TorchlightColorG + 6.7553994e15; | |
707 | 134 pMobileLightsStack->AddLight(pBLVRenderParams->vPartyPos.x, |
135 pBLVRenderParams->vPartyPos.y, | |
136 pBLVRenderParams->vPartyPos.z, | |
137 pBLVRenderParams->uPartySectorID, | |
138 v5, | |
139 floorf(pParty->flt_TorchlightColorR + 0.5f), | |
140 floorf(pParty->flt_TorchlightColorG + 0.5f), | |
141 floorf(pParty->flt_TorchlightColorB + 0.5f), | |
142 byte_4E94D0); | |
0 | 143 } |
144 PrepareBspRenderList_BLV(); | |
145 PrepareItemsRenderList_BLV(); | |
146 PrepareActorRenderList_BLV(); | |
707 | 147 |
148 //v6 = 0; | |
149 for (uint i = 0; i < pBspRenderer->uNumVisibleNotEmptySectors; ++i) | |
0 | 150 { |
707 | 151 v7 = pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[i]; |
152 //v12 = 0; | |
153 v8 = &pIndoor->pSectors[pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[i]]; | |
154 //v9 = v8->pDecorationIDs; | |
155 | |
156 for (uint j = 0; j < v8->uNumDecorations; ++j) | |
157 //if ( v8->uNumDecorations > 0 ) | |
0 | 158 { |
707 | 159 // do |
160 PrepareDecorationsRenderList_BLV(v8->pDecorationIDs[j], v7); | |
161 // while ( v12 < v8->uNumDecorations ); | |
0 | 162 } |
707 | 163 //v6 = i + 1; |
0 | 164 } |
657 | 165 FindBillboardsLightLevels_BLV(); |
0 | 166 pGame->PrepareBloodsplats(); |
167 } | |
168 | |
169 | |
170 | |
171 //----- (004407D9) -------------------------------------------------------- | |
172 int BLVRenderParams::Reset(IndoorLocation_drawstru *a2) | |
173 { | |
174 IndoorLocation_drawstru *v2; // ebx@1 | |
175 int v4; // ST08_4@1 | |
176 int v5; // ST04_4@1 | |
177 int v6; // ST00_4@1 | |
178 int v7; // eax@1 | |
179 int v8; // ST08_4@2 | |
180 int v9; // ST04_4@2 | |
181 int v10; // ST00_4@2 | |
182 unsigned int v11; // edi@4 | |
183 unsigned int v12; // ecx@4 | |
184 int v13; // edx@4 | |
185 signed int v14; // ecx@4 | |
186 unsigned int v15; // edx@4 | |
187 unsigned int v16; // eax@4 | |
188 double v17; // st7@5 | |
189 int v18; // eax@5 | |
190 double v19; // st7@5 | |
191 int v20; // eax@5 | |
192 double v21; // st7@5 | |
193 int v22; // eax@5 | |
194 unsigned int v23; // edx@5 | |
195 unsigned int v24; // ecx@5 | |
196 int v25; // eax@5 | |
197 int v26; // eax@5 | |
198 signed int v27; // eax@6 | |
199 int result; // eax@6 | |
200 int v29; // [sp+24h] [bp+8h]@5 | |
201 | |
202 v2 = a2; | |
203 this->field_0_timer_ = a2->field_0_timer; | |
204 this->uFlags = a2->uFlags; | |
205 this->vPartyPos.x = a2->vPosition.x; | |
206 this->vPartyPos.y = a2->vPosition.y; | |
207 this->vPartyPos.z = a2->vPosition.z; | |
208 v4 = this->vPartyPos.z; | |
209 v5 = this->vPartyPos.y; | |
210 this->sPartyRotY = a2->sRotationY; | |
211 v6 = this->vPartyPos.x; | |
212 this->sPartyRotX = a2->sRotationX; | |
213 v7 = pIndoor->GetSector(v6, v5, v4); | |
1006 | 214 this->uPartySectorID = v7; |
0 | 215 if ( !v7 ) |
216 { | |
1006 | 217 v8 = this->vPartyPos.z; |
218 this->vPartyPos.x = pParty->vPosition.x; | |
0 | 219 v9 = pParty->vPosition.y; |
1006 | 220 v10 = this->vPartyPos.x; |
221 this->vPartyPos.y = pParty->vPosition.y; | |
222 this->uPartySectorID = pIndoor->GetSector(v10, v9, v8); | |
0 | 223 } |
224 if ( pRenderer->pRenderD3D ) | |
225 { | |
1006 | 226 this->sCosineY = stru_5C6E00->Cos(this->sPartyRotY); |
227 this->sSineY = stru_5C6E00->Sin(this->sPartyRotY); | |
228 this->sCosineNegX = stru_5C6E00->Cos(-this->sPartyRotX); | |
229 this->sSineNegX = stru_5C6E00->Sin(-this->sPartyRotX); | |
230 this->fCosineY = cos((3.141592653589793 + 3.141592653589793) * (double)this->sPartyRotY * 0.00048828125); | |
231 this->fSineY = sin((3.141592653589793 + 3.141592653589793) * (double)this->sPartyRotY * 0.00048828125); | |
232 this->fCosineNegX = cos((3.141592653589793 + 3.141592653589793) * (double)-this->sPartyRotX * 0.00048828125); | |
233 this->fSineNegX = sin((3.141592653589793 + 3.141592653589793) * (double)-this->sPartyRotX * 0.00048828125); | |
234 this->field_64 = a2->field_3C; | |
235 v11 = this->uViewportW; | |
236 v12 = this->uViewportX; | |
237 v13 = this->uViewportZ - v12; | |
238 v14 = this->uViewportZ + v12; | |
239 this->field_70 = v13 + 1; | |
240 v15 = this->uViewportY; | |
241 this->uViewportHeight = v11 - v15 + 1; | |
242 v16 = this->uViewportW; | |
243 this->uViewportCenterX = v14 >> 1; | |
244 this->uViewportCenterY = (signed int)(v16 + v15) >> 1; | |
0 | 245 } |
246 else | |
247 { | |
1006 | 248 this->sCosineY = stru_5C6E00->Cos(-this->sPartyRotY); |
249 this->sSineY = stru_5C6E00->Sin(-this->sPartyRotY); | |
250 this->sCosineNegX = stru_5C6E00->Cos(-this->sPartyRotX); | |
251 this->sSineNegX = stru_5C6E00->Sin(-this->sPartyRotX); | |
252 v17 = cos((double)-this->sPartyRotY * 0.0030664064); | |
253 v18 = this->sPartyRotY; | |
254 this->fCosineY = v17; | |
0 | 255 v19 = sin((double)-v18 * 0.0030664064); |
1006 | 256 v20 = this->sPartyRotX; |
257 this->fSineY = v19; | |
0 | 258 v21 = cos((double)-v20 * 0.0030664064); |
1006 | 259 v22 = this->sPartyRotX; |
260 this->fCosineNegX = v21; | |
261 this->fSineNegX = sin((double)-v22 * 0.0030664064); | |
262 v23 = this->uViewportX; | |
263 this->field_64 = a2->field_3C; | |
264 v24 = this->uViewportZ; | |
265 this->field_70 = this->uViewportZ - v23 + 1; | |
266 v25 = this->uViewportW - this->uViewportY + 1; | |
267 this->uViewportHeight = v25; | |
0 | 268 v29 = v25; |
1006 | 269 v26 = this->field_64; |
270 this->uViewportCenterX = (signed int)(v24 + v23) >> 1; | |
271 this->uViewportCenterY = this->uViewportW - ((unsigned __int64)(v26 * (signed __int64)v29) >> 16); | |
0 | 272 } |
1006 | 273 v27 = (unsigned int)(signed __int64)((double)this->field_70 * 0.5 / tan((double)(v2->field_1C_mb_fov >> 1) * 0.01745329) |
0 | 274 + 0.5) << 16; |
1006 | 275 this->field_40 = v27; |
276 this->field_44 = 0x100000000i64 / v27; | |
277 this->pRenderTarget = v2->pRenderTarget; | |
278 this->uTargetWidth = v2->uTargetWidth; | |
279 this->uTargetHeight = v2->uTargetHeight; | |
280 this->uViewportX = v2->uViewportX; | |
281 this->uViewportY = v2->uViewportY; | |
282 this->uViewportZ = v2->uViewportZ; | |
283 this->uViewportW = v2->uViewportW; | |
284 this->pTargetZBuffer = v2->pTargetZ; | |
0 | 285 result = 0; |
1006 | 286 this->field_8C = 0; |
287 this->field_84 = 0; | |
288 this->uNumFacesRenderedThisFrame = 0; | |
289 this->field_88 = 0; | |
0 | 290 pBLVRenderParams->field_90 = 64; |
291 pBLVRenderParams->field_94 = 6; | |
292 return result; | |
293 } | |
294 | |
295 //----- (00440B44) -------------------------------------------------------- | |
296 void IndoorLocation::ExecDraw(bool bD3D) | |
297 { | |
298 int v2; // eax@3 | |
795 | 299 //IndoorCameraD3D_Vec4 *v3; // edx@4 |
300 //unsigned int v5; // ecx@9 | |
301 //RenderVertexSoft *v6; // [sp-4h] [bp-8h]@4 | |
0 | 302 |
303 if (bD3D) | |
304 { | |
305 pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
306 for (uint i = 0; i < pBspRenderer->num_faces; ++i) |
0 | 307 { |
1187 | 308 //v2 = pBspRenderer->faces[i].uNodeID; |
309 if (pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].viewing_portal_id == -1) | |
795 | 310 IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, nullptr, 4, nullptr); |
1187 | 311 else |
312 IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].std__vector_0007AC, 4, pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].pPortalBounding); | |
0 | 313 } |
314 } | |
795 | 315 else for (uint j = 0; j < pBspRenderer->num_faces; ++j ) |
0 | 316 { |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
317 __debugbreak(); // no SW |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
318 //pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].PortalScreenData; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
319 //IndoorLocation::ExecDraw_sw(pBspRenderer->faces[j].uFaceID); |
0 | 320 } |
321 } | |
322 | |
323 //----- (00440BED) -------------------------------------------------------- | |
324 void __fastcall sub_440BED(IndoorLocation_drawstru *_this) | |
325 { | |
326 unsigned __int16 *v1; // edi@7 | |
1074 | 327 BspRenderer_stru0 *v2; // esi@8 |
0 | 328 int v3; // ecx@9 |
329 unsigned int v4; // edx@9 | |
1074 | 330 short *v5; // eax@10 |
0 | 331 signed int v6; // [sp+8h] [bp-8h]@7 |
332 int v7; // [sp+Ch] [bp-4h]@8 | |
1074 | 333 short *v8; |
0 | 334 |
335 PrepareDrawLists_BLV(_this); | |
336 if (pBLVRenderParams->uPartySectorID) | |
337 IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0); | |
338 pRenderer->DrawBillboardList_BLV(); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
339 |
0 | 340 if ( !pRenderer->pRenderD3D ) |
341 { | |
486 | 342 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_D3D_OUTLINES) |
343 pBspRenderer->DrawFaceOutlines(); | |
344 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | |
0 | 345 { |
346 v1 = pBLVRenderParams->pRenderTarget; | |
1074 | 347 v7 = 0; |
348 for(int i=0; i < pBspRenderer->num_nodes; i++) | |
349 { | |
350 BspRenderer_stru0 *pNode = &pBspRenderer->nodes[i]; | |
1376 | 351 v4 = pRenderer->uTargetSurfacePitch * pNode->PortalScreenData._viewport_space_y; |
352 if ( pNode->PortalScreenData._viewport_space_y <= pNode->PortalScreenData._viewport_space_w ) | |
1074 | 353 { |
354 //v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[pNode->field_C._viewport_space_y + v7]; | |
1376 | 355 v5 = &pNode->PortalScreenData.viewport_right_side[pNode->PortalScreenData._viewport_space_y]; |
356 v8 = &pNode->PortalScreenData.viewport_left_side[pNode->PortalScreenData._viewport_space_y]; | |
1074 | 357 do |
358 { | |
359 v1[v4 + *v8] = 255; | |
1376 | 360 ++pNode->PortalScreenData._viewport_space_y; |
1074 | 361 v1[v4 + *v5] = 255; |
362 v4 += pRenderer->uTargetSurfacePitch; | |
363 ++v5; | |
364 ++v8; | |
365 } | |
1376 | 366 while ( pNode->PortalScreenData._viewport_space_y <= pNode->PortalScreenData._viewport_space_w ); |
1074 | 367 } |
368 } | |
0 | 369 } |
370 } | |
371 } | |
372 | |
373 | |
374 | |
375 | |
376 | |
377 //----- (00441BD4) -------------------------------------------------------- | |
378 void IndoorLocation::Draw() | |
379 { | |
186 | 380 //int v0; // eax@1 |
0 | 381 IndoorLocation_drawstru _this; // [sp+0h] [bp-4Ch]@5 |
382 int v2; // [sp+44h] [bp-8h]@5 | |
383 int v3; // [sp+48h] [bp-4h]@5 | |
384 | |
186 | 385 _this.uFlags = 0; |
386 if (viewparams->draw_sw_outlines) | |
387 _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES; | |
388 if (viewparams->draw_d3d_outlines) | |
389 _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; | |
390 | |
791 | 391 _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; |
392 _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES; | |
393 //INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES | |
394 | |
0 | 395 _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed; |
396 _this.field_1C_mb_fov = 65; | |
871 | 397 _this.vPosition.x = pParty->vPosition.x - fixpoint_sub0(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); |
398 _this.vPosition.y = pParty->vPosition.y - fixpoint_sub0(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); | |
581 | 399 _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel; |
400 _this.sRotationX = pParty->sRotationX; | |
0 | 401 _this.sRotationY = pParty->sRotationY; |
402 _this.pRenderTarget = pRenderer->pTargetSurface; | |
692 | 403 _this.uViewportX = pViewport->uScreen_TL_X; |
404 _this.uViewportY = pViewport->uScreen_TL_Y; | |
405 _this.uViewportZ = pViewport->uScreen_BR_X; | |
406 _this.uViewportW = pViewport->uScreen_BR_Y; | |
0 | 407 _this.field_3C = pViewport->field_30; |
581 | 408 |
0 | 409 _this.uTargetWidth = 640; |
410 _this.uTargetHeight = 480; | |
411 _this.pTargetZ = pRenderer->pActiveZBuffer; | |
412 sub_440BED(&_this); | |
569 | 413 pParty->uFlags &= ~2; |
0 | 414 pGame->DrawParticles(); |
415 array_5118E8._440F07(); | |
416 } | |
417 | |
418 //----- (004C0EF2) -------------------------------------------------------- | |
1025 | 419 void BLVFace::FromODM(ODMFace *face) |
0 | 420 { |
1025 | 421 this->pFacePlane_old.vNormal.x = face->pFacePlane.vNormal.x; |
422 this->pFacePlane_old.vNormal.y = face->pFacePlane.vNormal.y; | |
423 this->pFacePlane_old.vNormal.z = face->pFacePlane.vNormal.z; | |
424 this->pFacePlane_old.dist = face->pFacePlane.dist; | |
425 this->pFacePlane.vNormal.x = (double)(face->pFacePlane.vNormal.x & 0xFFFF) * 0.000015259022 | |
426 + (double)(face->pFacePlane.vNormal.x >> 16); | |
427 this->pFacePlane.vNormal.y = (double)(face->pFacePlane.vNormal.y & 0xFFFF) * 0.000015259022 | |
428 + (double)(face->pFacePlane.vNormal.y >> 16); | |
429 this->pFacePlane.vNormal.z = (double)(face->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022 | |
430 + (double)(face->pFacePlane.vNormal.z >> 16); | |
431 this->pFacePlane.dist = (double)(face->pFacePlane.dist & 0xFFFF) * 0.000015259022 + (double)(face->pFacePlane.dist >> 16); | |
432 this->uAttributes = face->uAttributes; | |
433 this->pBounding.x1 = face->pBoundingBox.x1; | |
434 this->pBounding.y1 = face->pBoundingBox.y1; | |
435 this->pBounding.z1 = face->pBoundingBox.z1; | |
436 this->pBounding.x2 = face->pBoundingBox.x2; | |
437 this->pBounding.y2 = face->pBoundingBox.y2; | |
438 this->pBounding.z2 = face->pBoundingBox.z2; | |
439 this->zCalc1 = face->zCalc1; | |
440 this->zCalc2 = face->zCalc2; | |
441 this->zCalc3 = face->zCalc3; | |
442 this->pXInterceptDisplacements = face->pXInterceptDisplacements; | |
443 this->pYInterceptDisplacements = face->pYInterceptDisplacements; | |
444 this->pZInterceptDisplacements = face->pZInterceptDisplacements; | |
445 this->uPolygonType = (PolygonType)face->uPolygonType; | |
446 this->uNumVertices = face->uNumVertices; | |
447 this->uBitmapID = face->uTextureID; | |
448 this->pVertexIDs = face->pVertexIDs; | |
0 | 449 } |
450 | |
451 //----- (004B0A25) -------------------------------------------------------- | |
794 | 452 void IndoorLocation::ExecDraw_d3d(unsigned int uFaceID, IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, RenderVertexSoft *pPortalBounding) |
0 | 453 { |
454 //unsigned int v4; // esi@1 | |
455 char *v5; // eax@4 | |
456 signed int v6; // ecx@4 | |
457 char *v7; // eax@8 | |
458 signed int v8; // ecx@8 | |
459 //BLVFace *v9; // esi@13 | |
460 //IndoorCameraD3D *v10; // edi@16 | |
461 //int v11; // ebx@17 | |
462 //Vec3_short_ *v12; // ecx@18 | |
463 //char *v13; // edx@18 | |
464 //int v14; // eax@19 | |
465 //unsigned __int8 v15; // sf@19 | |
466 //unsigned __int8 v16; // of@19 | |
467 int v17; // ebx@25 | |
468 //double v18; // st7@27 | |
469 //double v19; // st6@27 | |
470 //double v20; // st5@27 | |
471 //char v21; // dl@27 | |
472 //unsigned int v22; // eax@44 | |
473 unsigned int v23; // eax@35 | |
474 //DWORD v24; // eax@37 | |
475 //int v25; // eax@38 | |
476 //char *v26; // edi@38 | |
477 IDirect3DTexture2 *v27; // eax@42 | |
478 Texture *v28; // [sp+Ch] [bp-1Ch]@15 | |
479 //int i; // [sp+10h] [bp-18h]@38 | |
480 //LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16 | |
481 //IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16 | |
482 //IndoorCameraD3D_Vec4 *a7; // [sp+1Ch] [bp-Ch]@1 | |
483 //unsigned int uFaceID_; // [sp+20h] [bp-8h]@1 | |
484 unsigned int uNumVerticesa; // [sp+24h] [bp-4h]@17 | |
485 int a4a; // [sp+34h] [bp+Ch]@25 | |
486 //unsigned int a4b; // [sp+34h] [bp+Ch]@38 | |
487 | |
488 //v4 = uFaceID; | |
489 //a7 = pVertices; | |
490 //uFaceID_ = uFaceID; | |
491 if (uFaceID >= pIndoor->uNumFaces) | |
492 return; | |
493 | |
494 static RenderVertexSoft static_vertices_F7C228[64]; | |
495 static RenderVertexSoft static_vertices_F7B628[64]; | |
496 static stru154 stru_F7B60C; // idb | |
497 | |
498 //v9 = &pIndoor->pFaces[uFaceID]; | |
499 auto pFace = &pIndoor->pFaces[uFaceID]; | |
500 if (pFace->uNumVertices < 3) | |
501 return; | |
502 | |
503 | |
504 if (pFace->Invisible()) | |
505 return; | |
506 | |
507 ++pBLVRenderParams->uNumFacesRenderedThisFrame; | |
508 pFace->uAttributes |= 0x80u; | |
509 | |
510 if (!pFace->GetTexture()) | |
511 return; | |
512 | |
513 v28 = pFace->GetTexture(); | |
514 | |
515 if (!pGame->pIndoorCameraD3D->IsCulled(pFace)) | |
516 { | |
517 uNumVerticesa = pFace->uNumVertices; | |
518 for (uint i = 0; i < pFace->uNumVertices; ++i) | |
519 { | |
520 static_vertices_F7C228[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x; | |
521 static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y; | |
522 static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z; | |
523 static_vertices_F7C228[i].u = (signed short)pFace->pVertexUIDs[i]; | |
524 static_vertices_F7C228[i].v = (signed short)pFace->pVertexVIDs[i]; | |
525 } | |
526 | |
527 if (!pVertices || | |
1187 | 528 (pGame->pStru9Instance->_498377(pPortalBounding, 4, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) ) |
0 | 529 { |
795 | 530 if (pGame->pIndoorCameraD3D->CalcPortalShape(static_vertices_F7C228, &uNumVerticesa, |
581 | 531 static_vertices_F7B628, pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum, 4, false, 0) != 1 || uNumVerticesa ) |
0 | 532 { |
533 a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel); | |
1006 | 534 v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) |
535 | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8); | |
0 | 536 sub_4B0E07(uFaceID); |
537 pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID); | |
538 pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
539 pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28); |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
540 pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0); |
0 | 541 pGame->pLightmapBuilder->std__vector_000004_size = 0; |
542 if (stru_F8AD28.uNumLightsApplied > 0 || | |
543 pDecalBuilder->uNumDecals > 0) | |
544 { | |
545 stru_F7B60C.face_plane.vNormal.x = pFace->pFacePlane.vNormal.x; | |
546 stru_F7B60C.polygonType = pFace->uPolygonType; | |
547 stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y; | |
548 stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z; | |
549 stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; | |
550 } | |
551 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
552 if (stru_F8AD28.uNumLightsApplied > 0 && !(pFace->uAttributes & FACE_DO_NOT_LIGHT)) |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
553 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0); |
0 | 554 |
555 if (pDecalBuilder->uNumDecals > 0) | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
556 pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID); |
0 | 557 |
791 | 558 if (pFace->Fluid()) |
0 | 559 { |
831 | 560 if (pFace->uBitmapID == pRenderer->hd_water_tile_id) |
561 { | |
562 v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
563 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | |
564 } | |
805 | 565 else |
831 | 566 { |
567 //auto v24 = GetTickCount() / 4; | |
568 //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi; | |
569 uint eightSeconds = GetTickCount() % 8000; | |
570 float angle = (eightSeconds / 8000.0f) * 2 * 3.1415f; | |
571 | |
572 //animte lava back and forth | |
573 for (uint i = 0; i < uNumVerticesa; ++i) | |
574 //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)); | |
575 array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle); | |
576 v23 = pFace->uBitmapID; | |
577 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | |
578 } | |
0 | 579 } |
595 | 580 else if (pFace->uAttributes & 0x4000) |
0 | 581 { |
581 | 582 v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_); |
583 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | |
0 | 584 } |
831 | 585 else |
586 { | |
1394 | 587 v17 = 0xFF808080; |
831 | 588 v23 = pFace->uBitmapID; |
589 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | |
590 } | |
591 | |
805 | 592 if (pFace->uAttributes & FACE_DO_NOT_LIGHT) |
1390 | 593 pRenderer->DrawIndoorPolygonNoLight(uNumVerticesa, uFaceID); |
805 | 594 else |
831 | 595 pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, PID(OBJECT_BModel, uFaceID), v17, 0); |
596 return; | |
0 | 597 } |
598 } | |
599 } | |
600 } | |
601 | |
602 | |
603 | |
604 | |
605 //----- (004B0E07) -------------------------------------------------------- | |
606 unsigned int __fastcall sub_4B0E07(unsigned int uFaceID) | |
607 { | |
608 BLVFace *v1; // edi@1 | |
609 BLVFaceExtra *v2; // ecx@1 | |
610 Texture *v3; // esi@1 | |
611 unsigned int v4; // eax@1 | |
612 unsigned int v5; // ecx@1 | |
613 unsigned int result; // eax@1 | |
614 unsigned int v7; // ecx@5 | |
615 | |
616 v1 = &pIndoor->pFaces[uFaceID]; | |
617 v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID]; | |
945 | 618 v3 = pBitmaps_LOD->GetTexture(v1->uBitmapID); |
0 | 619 stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU; |
620 stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV; | |
621 v4 = GetTickCount(); | |
622 v5 = v1->uAttributes; | |
623 result = v4 >> 3; | |
624 if ( v5 & 4 ) | |
625 { | |
626 stru_F8AD28.pDeltaUV[1] -= result & v3->uHeightMinus1; | |
627 } | |
628 else | |
629 { | |
630 if ( v5 & 0x20 ) | |
631 stru_F8AD28.pDeltaUV[1] += result & v3->uHeightMinus1; | |
632 } | |
633 v7 = v1->uAttributes; | |
634 if ( BYTE1(v7) & 8 ) | |
635 { | |
636 stru_F8AD28.pDeltaUV[0] -= result & v3->uWidthMinus1; | |
637 } | |
638 else | |
639 { | |
640 if ( v7 & 0x40 ) | |
641 stru_F8AD28.pDeltaUV[0] += result & v3->uWidthMinus1; | |
642 } | |
643 return result; | |
644 } | |
645 | |
646 //----- (004B0EA8) -------------------------------------------------------- | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
647 void BspRenderer::AddFaceToRenderList_d3d(unsigned int node_id, unsigned int uFaceID) |
0 | 648 { |
649 //unsigned int v3; // edx@1 | |
650 //stru170 *v4; // ebx@1 | |
651 //BLVFace *v5; // eax@1 | |
652 //int v6; // ecx@2 | |
1319 | 653 unsigned __int16 pTransitionSector; // ax@11 |
0 | 654 Vec3_short_ *v8; // esi@15 |
655 int v9; // edx@15 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
656 //signed int v10; // eax@18 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
657 //signed int v11; // edi@19 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
658 //signed int v12; // ecx@19 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
659 //signed int v13; // esi@19 |
0 | 660 signed int v14; // edx@20 |
661 int v15; // edx@24 | |
662 //int v16; // esi@29 | |
663 //BLVFace *v17; // edi@34 | |
1319 | 664 //unsigned __int16 v18; // ax@34 |
0 | 665 char *v19; // eax@38 |
666 signed int v20; // ecx@38 | |
667 char *v21; // eax@42 | |
668 signed int v22; // ecx@42 | |
669 //signed int v23; // edx@45 | |
670 //char *v24; // ecx@46 | |
671 //int v25; // eax@47 | |
672 //Vec3_short_ *v26; // eax@47 | |
673 //double v27; // st7@47 | |
674 //signed int v28; // ST28_4@47 | |
675 char v29; // al@48 | |
795 | 676 //signed int v30; // eax@51 |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
677 //int v31; // eax@52 |
0 | 678 //unsigned int v32; // eax@55 |
679 //__int16 v33; // cx@56 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
680 //signed int v34; // [sp+Ch] [bp-14h]@18 |
0 | 681 //int a0; // [sp+14h] [bp-Ch]@2 |
682 //IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
683 //signed int v37; // [sp+18h] [bp-8h]@19 |
0 | 684 //stru10 *v38; // [sp+18h] [bp-8h]@36 |
685 //BLVFace *v39; // [sp+1Ch] [bp-4h]@1 | |
686 | |
687 //v3 = uFaceID; | |
688 //v4 = this; | |
689 //v5 = &pIndoor->pFaces[uFaceID]; | |
795 | 690 nodes[num_nodes].viewing_portal_id = -1; |
0 | 691 //v39 = &pIndoor->pFaces[uFaceID]; |
692 | |
693 auto pFace = &pIndoor->pFaces[uFaceID]; | |
1309 | 694 |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
695 if (!pFace->Portal()) |
0 | 696 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
697 if (num_faces < 1000) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
698 { |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
699 faces[num_faces].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
700 faces[num_faces++].uNodeID = node_id; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
701 } |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
702 return; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
703 } |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
704 |
1319 | 705 if (nodes[node_id].uFaceID == uFaceID) |
706 return; | |
707 if (!node_id && | |
708 pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane | |
709 pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && | |
710 pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && | |
711 pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && | |
712 pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && | |
713 pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) | |
714 { | |
715 if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | |
716 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y | |
717 + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane | |
0 | 718 { |
1319 | 719 pTransitionSector = pFace->uSectorID; |
720 if ( nodes[0].uSectorID == pTransitionSector ) // draw back sector | |
721 pTransitionSector = pFace->uBackSectorID; | |
722 nodes[num_nodes].uSectorID = pTransitionSector; | |
723 nodes[num_nodes].uFaceID = uFaceID; | |
724 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; | |
725 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; | |
726 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; | |
727 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; | |
1376 | 728 nodes[num_nodes].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, |
1319 | 729 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); |
730 AddBspNodeToRenderList(++num_nodes - 1); | |
731 return; | |
0 | 732 } |
1319 | 733 } |
734 | |
735 v9 = pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) | |
736 + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) | |
737 + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z); | |
738 if (nodes[node_id].uSectorID != pFace->uSectorID) | |
739 v9 = -v9; | |
740 if (v9 >= 0) | |
741 return; | |
742 | |
1344 | 743 auto num_vertices = GetPortalScreenCoord(uFaceID); |
1319 | 744 if (num_vertices < 2) |
745 return; | |
746 | |
1344 | 747 auto face_min_screenspace_x = PortalFace._screen_space_x[0], |
748 face_max_screenspace_x = PortalFace._screen_space_x[0]; | |
749 auto face_min_screenspace_y = PortalFace._screen_space_y[0], | |
750 face_max_screenspace_y = PortalFace._screen_space_y[0]; | |
1319 | 751 for (uint i = 1; i < num_vertices; ++i) |
752 { | |
1344 | 753 if (face_min_screenspace_x > PortalFace._screen_space_x[i]) |
754 face_min_screenspace_x = PortalFace._screen_space_x[i]; | |
755 if (face_max_screenspace_x < PortalFace._screen_space_x[i]) | |
756 face_max_screenspace_x = PortalFace._screen_space_x[i]; | |
757 | |
758 if (face_min_screenspace_y > PortalFace._screen_space_y[i]) | |
759 face_min_screenspace_y = PortalFace._screen_space_y[i]; | |
760 if (face_max_screenspace_y < PortalFace._screen_space_y[i]) | |
761 face_max_screenspace_y = PortalFace._screen_space_y[i]; | |
1319 | 762 } |
1132 | 763 //_screen_space_x = 719, 568, 493 |
764 //savegame: qw , 0Bh and 0x1D4h | |
765 //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ | |
1319 | 766 if (face_max_screenspace_x >= nodes[node_id].uViewportX && |
767 face_min_screenspace_x <= nodes[node_id].uViewportZ && | |
768 face_max_screenspace_y >= nodes[node_id].uViewportY && | |
769 face_min_screenspace_y <= nodes[node_id].uViewportW && | |
1376 | 770 PortalFrustrum(num_vertices, &nodes[num_nodes].PortalScreenData, &nodes[node_id].PortalScreenData, uFaceID)) |
1319 | 771 { |
772 pTransitionSector = pFace->uSectorID; | |
773 if (nodes[node_id].uSectorID == pTransitionSector ) | |
774 pTransitionSector = pFace->uBackSectorID; | |
775 nodes[num_nodes].uSectorID = pTransitionSector; | |
776 nodes[num_nodes].uFaceID = uFaceID; | |
777 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; | |
778 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; | |
779 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; | |
780 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; | |
781 v29 = false; | |
782 if (nodes[node_id].viewing_portal_id == -1)// | |
783 v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); | |
784 else// | |
785 { | |
786 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; | |
787 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; | |
788 | |
789 for (uint k = 0; k < pFace->uNumVertices; ++k) | |
790 { | |
791 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; | |
792 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; | |
793 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; | |
794 } | |
795 | |
796 unsigned int pNewNumVertices = pFace->uNumVertices; | |
797 pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, &pNewNumVertices, | |
798 static_subAddFaceToRenderList_d3d_stru_F79E08, nodes[node_id].std__vector_0007AC, 4, 0, 0); | |
799 | |
800 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &pNewNumVertices, | |
801 nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); | |
802 } | |
803 if ( 1 ) | |
804 { | |
805 assert(num_nodes < 150); | |
806 | |
807 nodes[num_nodes].viewing_portal_id = uFaceID; | |
808 AddBspNodeToRenderList(++num_nodes - 1); | |
809 } | |
810 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | |
811 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); | |
812 //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); | |
813 } | |
0 | 814 } |
815 | |
816 | |
817 //----- (004AFB86) -------------------------------------------------------- | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
818 void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID) |
0 | 819 { |
820 BspRenderer *v3; // ebx@1 | |
821 BLVFace *v4; // eax@1 | |
822 char *v5; // ecx@2 | |
823 unsigned __int16 v6; // ax@11 | |
824 int v7; // ecx@13 | |
825 Vec3_short_ *v8; // esi@16 | |
826 int v9; // edx@16 | |
827 signed int v10; // eax@19 | |
828 signed int v11; // edi@20 | |
829 signed int v12; // ecx@20 | |
830 signed int v13; // esi@20 | |
831 int v14; // edx@21 | |
832 int v15; // edx@25 | |
833 unsigned __int16 v16; // ax@35 | |
834 signed int v17; // eax@37 | |
835 int v18; // eax@38 | |
836 signed int v19; // [sp+Ch] [bp-14h]@19 | |
837 char *v20; // [sp+14h] [bp-Ch]@2 | |
838 BLVFace *v21; // [sp+18h] [bp-8h]@1 | |
839 signed int v22; // [sp+1Ch] [bp-4h]@20 | |
840 signed int v23; // [sp+28h] [bp+8h]@20 | |
841 | |
842 v3 = this; | |
843 v4 = &pIndoor->pFaces[uFaceID]; | |
844 v21 = v4; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
845 if (v4->Portal()) |
0 | 846 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
847 v5 = (char *)this + 2252 * node_id; |
0 | 848 v20 = v5; |
849 if ( uFaceID == *((short *)v5 + 2982) ) | |
850 return; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
851 if (!node_id |
0 | 852 && pBLVRenderParams->vPartyPos.x >= v4->pBounding.x1 - 16 |
853 && pBLVRenderParams->vPartyPos.x <= v4->pBounding.x2 + 16 | |
854 && pBLVRenderParams->vPartyPos.y >= v4->pBounding.y1 - 16 | |
855 && pBLVRenderParams->vPartyPos.y <= v4->pBounding.y2 + 16 | |
856 && pBLVRenderParams->vPartyPos.z >= v4->pBounding.z1 - 16 | |
857 && pBLVRenderParams->vPartyPos.z <= v4->pBounding.z2 + 16 ) | |
858 { | |
859 if ( abs(v4->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * v4->pFacePlane_old.vNormal.x | |
860 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y | |
861 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 ) | |
862 { | |
863 v6 = v21->uSectorID; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
864 if ( v3->nodes[0].uSectorID == v6 ) |
0 | 865 v6 = v21->uBackSectorID; |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
866 v3->nodes[v3->num_nodes].uSectorID = v6; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
867 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
868 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
869 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
870 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
871 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
1376 | 872 v3->nodes[v3->num_nodes++].PortalScreenData.GetViewportData( |
0 | 873 SLOWORD(pBLVRenderParams->uViewportX), |
874 pBLVRenderParams->uViewportY, | |
875 SLOWORD(pBLVRenderParams->uViewportZ), | |
876 pBLVRenderParams->uViewportW); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
877 v7 = v3->num_nodes - 1; |
0 | 878 goto LABEL_14; |
879 } | |
880 v4 = v21; | |
881 v5 = v20; | |
882 } | |
883 v8 = &pIndoor->pVertices[*v4->pVertexIDs]; | |
884 v9 = v4->pFacePlane_old.vNormal.x * ((signed __int16)*(int *)&v8->x - pBLVRenderParams->vPartyPos.x) | |
885 + v4->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v8->x >> 16) - pBLVRenderParams->vPartyPos.y) | |
886 + v4->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); | |
887 if ( *((short *)v5 + 2004) != v4->uSectorID ) | |
888 v9 = -v9; | |
889 if ( v9 < 0 ) | |
890 { | |
1344 | 891 v10 = GetPortalScreenCoord(uFaceID); |
0 | 892 v19 = v10; |
893 if ( v10 ) | |
894 { | |
1344 | 895 v11 = PortalFace._screen_space_x[0]; |
896 v12 = PortalFace._screen_space_y[0]; | |
897 v23 = PortalFace._screen_space_x[0]; | |
0 | 898 v13 = 1; |
1344 | 899 v22 = PortalFace._screen_space_y[0]; |
0 | 900 if ( v10 > 1 ) |
901 { | |
902 do | |
903 { | |
1344 | 904 v14 = PortalFace._screen_space_x[v13]; |
0 | 905 if ( v14 < v23 ) |
1344 | 906 v23 = PortalFace._screen_space_x[v13]; |
0 | 907 if ( v14 > v11 ) |
1344 | 908 v11 = PortalFace._screen_space_x[v13]; |
909 v15 = PortalFace._screen_space_y[v13]; | |
0 | 910 if ( v15 < v22 ) |
1344 | 911 v22 = PortalFace._screen_space_y[v13]; |
0 | 912 if ( v15 > v12 ) |
1344 | 913 v12 = PortalFace._screen_space_y[v13]; |
0 | 914 v10 = v19; |
915 ++v13; | |
916 } | |
917 while ( v13 < v19 ); | |
918 } | |
919 if ( v11 >= *((short *)v20 + 2005) | |
920 && v23 <= *((short *)v20 + 2007) | |
921 && v12 >= *((short *)v20 + 2006) | |
922 && v22 <= *((short *)v20 + 2008) | |
1376 | 923 && PortalFrustrum(v10, &v3->nodes[v3->num_nodes].PortalScreenData, (BspRenderer_PortalViewportData *)(v20 + 4020), uFaceID) ) |
0 | 924 { |
925 v16 = v21->uSectorID; | |
926 if ( *((short *)v20 + 2004) == v16 ) | |
927 v16 = v21->uBackSectorID; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
928 v3->nodes[v3->num_nodes].uSectorID = v16; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
929 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
930 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
931 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
932 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
933 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
934 v17 = v3->num_nodes; |
0 | 935 if ( v17 < 150 ) |
936 { | |
937 v18 = v17 + 1; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
938 v3->num_nodes = v18; |
0 | 939 v7 = v18 - 1; |
940 LABEL_14: | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
941 AddBspNodeToRenderList(v7); |
0 | 942 return; |
943 } | |
944 } | |
945 } | |
946 } | |
947 } | |
948 else | |
949 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
950 if (num_faces < 1000) |
0 | 951 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
952 faces[num_faces].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
953 faces[num_faces++].uNodeID = node_id; |
0 | 954 } |
955 } | |
956 } | |
957 | |
958 //----- (004B0967) -------------------------------------------------------- | |
486 | 959 void BspRenderer::DrawFaceOutlines() |
0 | 960 { |
961 signed int i; // edi@1 | |
962 int v1; // esi@2 | |
963 unsigned int v2; // ecx@4 | |
964 int v3; // eax@4 | |
965 int v4; // eax@6 | |
966 unsigned __int16 *v5; // edx@6 | |
967 int v6; // ecx@7 | |
968 int v7; // esi@8 | |
969 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
970 for ( i = 0; i < (signed int)pBspRenderer->num_faces; ++i ) |
0 | 971 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
972 v1 = pBspRenderer->faces[i].uFaceID; |
0 | 973 if ( v1 >= 0 ) |
974 { | |
975 if ( v1 < (signed int)pIndoor->uNumFaces ) | |
976 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
977 v2 = pBspRenderer->faces[i].uFaceID; |
1376 | 978 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].PortalScreenData; |
1344 | 979 v3 = GetPortalScreenCoord(v2); |
0 | 980 if ( v3 ) |
981 { | |
1372 | 982 if ( PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) |
0 | 983 { |
984 v4 = stru_F8A590._viewport_space_y; | |
985 v5 = pBLVRenderParams->pRenderTarget; | |
986 if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) | |
987 { | |
988 v6 = 640 * stru_F8A590._viewport_space_y; | |
989 do | |
990 { | |
1281 | 991 v5[v6 + stru_F8A590.viewport_left_side[v4]] = -1; |
992 v7 = v6 + stru_F8A590.viewport_right_side[v4]; | |
0 | 993 v6 += 640; |
994 v5[v7] = -1; | |
995 ++v4; | |
996 } | |
997 while ( v4 <= stru_F8A590._viewport_space_w ); | |
998 } | |
999 } | |
1000 } | |
1001 } | |
1002 } | |
1003 } | |
1004 } | |
1005 | |
1006 | |
1007 //----- (004AE5BA) -------------------------------------------------------- | |
1008 Texture *BLVFace::GetTexture() | |
1009 { | |
1010 unsigned int v1; // ecx@2 | |
1011 | |
1012 if ( uAttributes & 0x4000 ) | |
1013 v1 = pTextureFrameTable->GetFrameTexture(this->uBitmapID, pBLVRenderParams->field_0_timer_); | |
1014 else | |
1015 v1 = uBitmapID; | |
945 | 1016 return pBitmaps_LOD->GetTexture(v1); |
0 | 1017 } |
1018 | |
1019 | |
1020 //----- (00498B15) -------------------------------------------------------- | |
1021 void IndoorLocation::Release() | |
1022 { | |
1023 IndoorLocation *v1; // esi@1 | |
1024 char *v2; // ebp@1 | |
1025 void *v3; // ST00_4@1 | |
1026 | |
1027 v1 = this; | |
1028 v2 = (char *)&this->ptr_0002B4_doors_ddata; | |
1029 pAllocator->FreeChunk(this->ptr_0002B4_doors_ddata); | |
1030 *(int *)v2 = 0; | |
1031 pAllocator->FreeChunk(v1->ptr_0002B0_sector_rdata); | |
1032 v1->ptr_0002B0_sector_rdata = 0; | |
1033 pAllocator->FreeChunk(v1->ptr_0002B8_sector_lrdata); | |
1034 v1->ptr_0002B8_sector_lrdata = 0; | |
1006 | 1035 pAllocator->FreeChunk(v1->pLFaces); |
1036 v1->pLFaces = 0; | |
0 | 1037 pAllocator->FreeChunk(v1->pSpawnPoints); |
1038 v3 = v1->pVertices; | |
1039 v1->pSpawnPoints = 0; | |
1040 v1->uNumSectors = 0; | |
1041 v1->uNumFaces = 0; | |
1042 v1->uNumVertices = 0; | |
1043 v1->uNumNodes = 0; | |
1044 v1->uNumDoors = 0; | |
1045 v1->uNumLights = 0; | |
1046 pAllocator->FreeChunk(v3); | |
1047 pAllocator->FreeChunk(v1->pFaces); | |
1048 pAllocator->FreeChunk(v1->pFaceExtras); | |
1049 pAllocator->FreeChunk(v1->pSectors); | |
1050 pAllocator->FreeChunk(v1->pLights); | |
1051 pAllocator->FreeChunk(v1->pDoors); | |
1052 pAllocator->FreeChunk(v1->pNodes); | |
1053 pAllocator->FreeChunk(v1->pMapOutlines); | |
1054 v1->pVertices = 0; | |
1055 v1->pFaces = 0; | |
1056 v1->pFaceExtras = 0; | |
1057 v1->pSectors = 0; | |
1058 v1->pLights = 0; | |
1059 v1->pDoors = 0; | |
1060 v1->pNodes = 0; | |
1061 v1->pMapOutlines = 0; | |
1062 v1->bLoaded = 0; | |
1063 } | |
1064 | |
1065 //----- (00498C45) -------------------------------------------------------- | |
711 | 1066 bool IndoorLocation::Alloc() |
1067 { | |
1068 pVertices = (Vec3_short_ *) pAllocator->AllocNamedChunk(pVertices, 15000*sizeof(Vec3_short_), "L.V");//0x15F90u | |
1069 pFaces = (BLVFace *) pAllocator->AllocNamedChunk(pFaces, 10000*sizeof(BLVFace), "L.F");//0xEA600u | |
1070 pFaceExtras = (BLVFaceExtra *) pAllocator->AllocNamedChunk(pFaceExtras,5000*sizeof(BLVFaceExtra), "L.FX"); //0x2BF20u | |
1071 pSectors = (BLVSector *) pAllocator->AllocNamedChunk(pSectors, 512*sizeof(BLVSector), "L.R");//0xE800u | |
1072 pLights = (BLVLightMM7 *) pAllocator->AllocNamedChunk(pLights, 400*sizeof(BLVLightMM7), "L.L");//0x1900u | |
1073 pDoors = (BLVDoor *) pAllocator->AllocNamedChunk(pDoors, 200*sizeof(BLVDoor), "L.D");//0x3E80u | |
1074 pNodes = (BSPNode *) pAllocator->AllocNamedChunk(pNodes, 5000*sizeof(BSPNode), "L.BSP");//0x9C40u | |
1075 pMapOutlines =(BLVMapOutlines *)pAllocator->AllocNamedChunk(pMapOutlines, sizeof(BLVMapOutlines), "L.Map");//0x14824u | |
1076 if (pVertices && pFaces && pFaceExtras && pSectors && pLights && pDoors && pNodes && pMapOutlines ) | |
0 | 1077 { |
711 | 1078 memset(pVertices, 0, 15000*sizeof(Vec3_short_)); |
1079 memset(pFaces, 0, 10000*sizeof(BLVFace)); | |
1080 memset(pFaceExtras,0, 5000*sizeof(BLVFaceExtra)); | |
1081 memset(pSectors, 0, 512*sizeof(BLVSector)); | |
1082 memset(pLights, 0, 400*sizeof(BLVLightMM7)); | |
1083 memset(pDoors, 0, 200*sizeof(BLVDoor)); | |
1084 memset(pNodes, 0, 5000*sizeof(BSPNode)); | |
1085 memset(pMapOutlines,0, sizeof(BLVMapOutlines)); | |
1086 return true; | |
0 | 1087 } |
1088 else | |
1089 { | |
711 | 1090 return false; |
0 | 1091 } |
1092 } | |
1093 | |
1094 | |
1095 | |
1096 //----- (00444810) -------------------------------------------------------- | |
1097 unsigned int IndoorLocation::GetLocationIndex(const char *Str1) | |
1098 { | |
1099 const char *v1; // edi@1 | |
1100 signed int v2; // esi@1 | |
1101 | |
434 | 1102 for (uint i = 0; i < 11; ++i) |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
1103 if (!_stricmp(Str1, _4E6BDC_loc_names[i])) |
434 | 1104 return i + 1; |
1105 return 0; | |
0 | 1106 } |
1107 | |
1108 | |
1109 | |
1110 //----- (004488F7) -------------------------------------------------------- | |
711 | 1111 void IndoorLocation::ToggleLight(signed int sLightID, unsigned int bToggle) |
0 | 1112 { |
711 | 1113 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && (sLightID <= pIndoor->uNumLights - 1) && (sLightID >= 0) ) |
0 | 1114 { |
1115 if ( bToggle ) | |
1063 | 1116 pIndoor->pLights[sLightID].uAtributes &= 0xFFFFFFF7u; |
0 | 1117 else |
1063 | 1118 pIndoor->pLights[sLightID].uAtributes |= 8u; |
0 | 1119 pParty->uFlags |= 2u; |
1120 } | |
1121 } | |
1122 | |
1123 | |
1124 //----- (00498E0A) -------------------------------------------------------- | |
1125 bool IndoorLocation::Load(char *pFilename, int a3, size_t _i, char *pDest) | |
1126 { | |
1127 /*unsigned int v5; // ebx@1 | |
1128 //IndoorLocation *v6; // esi@1 | |
1129 FILE *v7; // edi@3 | |
1130 bool result; // eax@3 | |
1131 char *v9; // ecx@4 | |
1132 void *v10; // eax@4 | |
1133 //unsigned __int8 v11; // zf@4 | |
1134 //unsigned __int8 v12; // sf@4 | |
1135 int v13; // eax@5 | |
1136 size_t v14; // ecx@6 | |
1137 char *v15; // ecx@6 | |
1138 int v16; // edx@6 | |
1139 size_t v17; // ecx@6 | |
1140 char *v18; // ecx@6 | |
1141 int v19; // edx@6 | |
1142 unsigned __int16 *v20; // edx@6 | |
1143 unsigned __int16 *v21; // edx@6 | |
1144 unsigned __int16 *v22; // edx@6 | |
1145 __int16 v23; // ax@10 | |
1146 char *v24; // ecx@10 | |
1147 __int16 v25; // cx@10 | |
1148 __int16 v26; // ax@11 | |
1149 char *v27; // ecx@11 | |
1150 unsigned __int16 v28; // ax@17 | |
1151 BLVFaceExtra *v29; // ecx@17 | |
1152 char *v30; // edx@17 | |
1153 int v31; // ecx@20 | |
1154 void *v32; // eax@25 | |
1155 int v33; // eax@26 | |
1156 unsigned __int16 *v34; // edx@27 | |
1157 size_t v35; // ecx@27 | |
1158 char *v36; // ecx@27 | |
1159 int v37; // edx@27 | |
1160 size_t v38; // ecx@27 | |
1161 char *v39; // ecx@27 | |
1162 int v40; // edx@27 | |
1163 unsigned __int16 *v41; // edx@27 | |
1164 unsigned __int16 *v42; // edx@27 | |
1165 unsigned __int16 *v43; // edx@27 | |
1166 unsigned __int16 *v44; // edx@27 | |
1167 size_t v45; // ecx@27 | |
1168 unsigned __int16 *v46; // edx@27 | |
1169 void *v47; // eax@28 | |
1170 BLVSector *v48; // eax@29 | |
1171 size_t v49; // ecx@29 | |
1172 unsigned __int16 *v50; // edx@31 | |
1173 void *v51; // eax@32 | |
1174 int v52; // eax@33 | |
1175 unsigned __int16 *v53; // edx@34 | |
1176 size_t v54; // ecx@34 | |
1177 char *v55; // ecx@34 | |
1178 int v56; // edx@34 | |
1179 size_t v57; // ecx@34 | |
1180 char *v58; // ecx@34 | |
1181 int v59; // edx@34 | |
1182 unsigned __int16 *v60; // edx@34 | |
1183 unsigned __int16 *v61; // edx@34 | |
1184 unsigned __int16 *v62; // edx@34 | |
1185 unsigned __int16 *v63; // edx@34 | |
1186 int v64; // ecx@34 | |
1187 BLVDoor *v65; // ecx@36 | |
1188 char *v66; // eax@37 | |
1189 int v67; // edx@38 | |
1190 int v68; // ecx@38 | |
1191 BLVFace *v69; // edx@38 | |
1192 int v70; // ecx@38 | |
1193 int v71; // edx@38 | |
1194 int v72; // eax@38 | |
1195 unsigned __int16 v73; // ax@42 | |
1196 char *v74; // ecx@42 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1197 SpriteObject *v75; // ecx@44 |
0 | 1198 size_t v76; // eax@45 |
1199 int j; // edx@46 | |
1200 unsigned __int16 v78; // ax@50 | |
1201 void *v79; // eax@52 | |
1202 void **v80; // esi@52 | |
1203 unsigned int v145; // eax@103 | |
1204 void *v146; // eax@103 | |
1205 unsigned int v147; // ecx@103 | |
1206 int v148; // ebx@103 | |
1207 unsigned int *v149; // ecx@103*/ | |
1208 //size_t v150; // eax@103 | |
1209 //unsigned int v151; // ebx@109 | |
1210 //unsigned int v152; // ecx@116 | |
1211 //unsigned int v153; // eax@117 | |
1212 //size_t v154; // ebx@126 | |
1213 //unsigned int v155; // ebx@134 | |
1214 //size_t v156; // eax@140 | |
1215 //signed int v157; // ebx@142 | |
1216 //int v158; // ebx@148 | |
1217 //BLVFace *v159; // eax@149 | |
1218 // BLVFaceExtra *v160; // ecx@149 | |
1219 //BLVFaceExtra *v161; // ecx@149 | |
1220 //signed int v162; // ebx@154 | |
1221 //unsigned int v163; // ebx@157 | |
1222 //unsigned int v164; // ebx@157 | |
1223 //unsigned int v165; // edx@158 | |
1224 //char *v166; // ecx@158 | |
1225 //unsigned __int16 v167; // ax@161 | |
1226 //__int16 v168; // ax@165 | |
1227 //unsigned int v169; // ebx@168 | |
1228 //void *v170; // eax@168 | |
1229 //size_t v171; // ebx@168 | |
1230 //int v172; // edx@168 | |
1231 //BLVDoor *v173; // ecx@169 | |
1232 //int k; // eax@169 | |
1233 //BLVDoor *v175; // ecx@172 | |
1234 //int v176; // edx@172 | |
1235 //BLVDoor *v177; // ecx@172 | |
1236 //int v178; // edx@172 | |
1237 //BLVDoor *v179; // ecx@172 | |
1238 //int v180; // edx@172 | |
1239 //BLVDoor *v181; // ecx@172 | |
1240 //int v182; // edx@172 | |
1241 //BLVDoor *v183; // ecx@172 | |
1242 //int v184; // edx@172 | |
1243 //BLVDoor *v185; // ecx@172 | |
1244 //int v186; // edx@172 | |
1245 //BLVDoor *v187; // ecx@172 | |
1246 //int v188; // edx@172 | |
1247 //unsigned __int16 *v189; // ebx@172 | |
1248 //char *v190; // edx@173 | |
1249 //BLVDoor *v191; // ecx@174 | |
1250 //BLVDoor *l; // eax@175 | |
1251 //signed int v193; // ebx@176 | |
1252 //int v194; // ecx@176 | |
1253 //BLVFaceExtra *v195; // ecx@176 | |
1254 //BLVFace *v196; // ebx@178 | |
1255 //std::string v197; // [sp-18h] [bp-680h]@66 | |
1256 //void *v198; // [sp-14h] [bp-67Ch]@72 | |
1257 //size_t v199; // [sp-10h] [bp-678h]@72 | |
1258 //size_t v200; // [sp-Ch] [bp-674h]@72 | |
1259 //const char *v201; // [sp-8h] [bp-670h]@4 | |
1260 //int v202; // [sp-4h] [bp-66Ch]@4 | |
1261 char v203[875]; // [sp+Ch] [bp-65Ch]@130 | |
1262 char FileName[260]; // [sp+378h] [bp-2F0h]@1 | |
1263 //char DstBuf; // [sp+47Ch] [bp-1ECh]@4 | |
1264 __int32 Offset; // [sp+480h] [bp-1E8h]@4 | |
1265 __int32 v207; // [sp+48Ch] [bp-1DCh]@4 | |
1266 __int32 v208; // [sp+498h] [bp-1D0h]@4 | |
1267 __int32 v209; // [sp+4A4h] [bp-1C4h]@4 | |
1268 __int32 v210; // [sp+4B0h] [bp-1B8h]@4 | |
1269 __int32 v211; // [sp+4BCh] [bp-1ACh]@15 | |
1270 __int32 v212; // [sp+4C8h] [bp-1A0h]@15 | |
1271 __int32 v213; // [sp+4D4h] [bp-194h]@25 | |
1272 __int32 v214; // [sp+4E0h] [bp-188h]@25 | |
1273 __int32 v215; // [sp+4ECh] [bp-17Ch]@32 | |
1274 __int32 v216; // [sp+4F8h] [bp-170h]@32 | |
1275 __int32 v217; // [sp+504h] [bp-164h]@40 | |
1276 __int32 v218; // [sp+510h] [bp-158h]@40 | |
1277 __int32 v219; // [sp+51Ch] [bp-14Ch]@43 | |
1278 __int32 v220; // [sp+528h] [bp-140h]@43 | |
1279 __int32 v221; // [sp+534h] [bp-134h]@52 | |
1280 __int32 v222; // [sp+540h] [bp-128h]@52 | |
1281 __int32 v223; // [sp+54Ch] [bp-11Ch]@52 | |
1282 __int32 v224; // [sp+558h] [bp-110h]@52 | |
1283 __int32 v225; // [sp+564h] [bp-104h]@52 | |
1284 __int32 v226; // [sp+570h] [bp-F8h]@52 | |
1285 __int32 v227; // [sp+57Ch] [bp-ECh]@52 | |
1286 __int32 v228; // [sp+588h] [bp-E0h]@52 | |
1287 __int32 v229; // [sp+594h] [bp-D4h]@52 | |
1288 __int32 v230; // [sp+5A0h] [bp-C8h]@52 | |
1289 __int32 v231; // [sp+5ACh] [bp-BCh]@52 | |
1290 __int32 v232; // [sp+5B8h] [bp-B0h]@52 | |
1291 __int32 v233; // [sp+5C4h] [bp-A4h]@52 | |
1292 __int32 v234; // [sp+5D0h] [bp-98h]@52 | |
1293 //char pName[40]; // [sp+5FCh] [bp-6Ch]@42 | |
1294 //size_t pSource; // [sp+624h] [bp-44h]@67 | |
1295 //char Dst[12]; // [sp+628h] [bp-40h]@9 | |
1296 //char *v238; // [sp+634h] [bp-34h]@38 | |
1297 ODMHeader header; // [sp+638h] [bp-30h]@61 | |
1298 //void *ptr; // [sp+648h] [bp-20h]@66 | |
1299 //size_t Count; // [sp+64Ch] [bp-1Ch]@109 | |
1300 //int uSourceLen; // [sp+653h] [bp-15h]@66 | |
1301 FILE *File; // [sp+658h] [bp-10h]@56 | |
1302 //BLVSector *v244; // [sp+65Ch] [bp-Ch]@72 | |
1303 //int v245; // [sp+660h] [bp-8h]@72 | |
1304 //BLVFace *Src; // [sp+664h] [bp-4h]@73 | |
1305 signed int Argsa; // [sp+670h] [bp+8h]@4 | |
1306 signed int Argsb; // [sp+670h] [bp+8h]@7 | |
1307 signed int Argsc; // [sp+670h] [bp+8h]@15 | |
1308 signed int Argsd; // [sp+670h] [bp+8h]@18 | |
1309 int Argse; // [sp+670h] [bp+8h]@25 | |
1310 int Argsf; // [sp+670h] [bp+8h]@28 | |
1311 int Argsg; // [sp+670h] [bp+8h]@32 | |
1312 int Argsh; // [sp+670h] [bp+8h]@35 | |
1313 signed int Argsi; // [sp+670h] [bp+8h]@40 | |
1314 signed int Argsj; // [sp+670h] [bp+8h]@45 | |
1315 //int Argsk; // [sp+670h] [bp+8h]@143 | |
1316 //void *Argsl; // [sp+670h] [bp+8h]@155 | |
1317 //signed int Argsm; // [sp+670h] [bp+8h]@161 | |
1318 //signed int Argsn; // [sp+670h] [bp+8h]@175 | |
1319 | |
1320 //v5 = 0; | |
1321 //v6 = this; | |
1322 _6807E0_num_decorations_with_sounds_6807B8 = 0; | |
1323 | |
1324 #pragma region "loading from txt" | |
1325 /*sprintf(FileName, "levels\\%s", pFilename); | |
1326 if ( GetFileAttributesA(FileName) != -1 ) | |
1327 { | |
1328 Release(); | |
1329 if ( Alloc() ) | |
1330 { | |
1331 v7 = fopen(FileName, "rb"); | |
1332 result = 1; | |
1333 if ( !v7 ) | |
1334 return result; | |
1335 v9 = pDest; | |
1336 bLoaded = 1; | |
1337 v202 = (int)v7; | |
1338 v201 = (const char *)1; | |
1339 *(int *)v9 = 1; | |
1340 fread(&DstBuf, 0x180u, (size_t)v201, (FILE *)v202); | |
1341 fseek(v7, Offset, 0); | |
1342 fread(&blv, 0x88u, 1u, v7); | |
1343 fseek(v7, v207, 0); | |
1344 fread(&uNumVertices, 1u, 4u, v7); | |
1345 fseek(v7, v208, 0); | |
1346 fread(pVertices, 6u, uNumVertices, v7); | |
1347 fseek(v7, v209, 0); | |
1348 fread(&uNumFaces, 4u, 1u, v7); | |
1349 fseek(v7, v210, 0); | |
1350 fread(pFaces, 0x60u, uNumFaces, v7); | |
1351 v10 = pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); | |
1352 v202 = (int)v7; | |
1353 ptr_2AC = (unsigned __int16 *)v10; | |
1354 fread(v10, 1u, blv.uFaces_fdata_Size, (FILE *)v202); | |
1355 v11 = uNumFaces == 0; | |
1356 v12 = (uNumFaces & 0x80000000u) != 0; | |
1357 pDest = 0; | |
1358 Argsa = 0; | |
1359 if ( !(v12 | v11) ) | |
1360 { | |
1361 v13 = 0; | |
1362 do | |
1363 { | |
1364 pFaces[v13].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)ptr_2AC]; | |
1365 v14 = (size_t)&pFaces[v13]; | |
1366 i = v14; | |
1367 v15 = &pDest[2 * *(char *)(v14 + 93) + 2]; | |
1368 v16 = (int)&v15[(unsigned int)ptr_2AC]; | |
1369 pDest = v15; | |
1370 *(int *)(i + 52) = v16; | |
1371 v17 = (size_t)&pFaces[v13]; | |
1372 i = v17; | |
1373 v18 = &pDest[2 * *(char *)(v17 + 93) + 2]; | |
1374 v19 = (int)&v18[(unsigned int)ptr_2AC]; | |
1375 pDest = v18; | |
1376 *(int *)(i + 56) = v19; | |
1377 i = (size_t)&pFaces[v13]; | |
1378 v20 = ptr_2AC; | |
1379 pDest += 2 * *(char *)(i + 93) + 2; | |
1380 *(int *)(i + 60) = (int)(char *)v20 + (int)pDest; | |
1381 i = (size_t)&pFaces[v13]; | |
1382 v21 = ptr_2AC; | |
1383 pDest += 2 * *(char *)(i + 93) + 2; | |
1384 *(int *)(i + 64) = (int)(char *)v21 + (int)pDest; | |
1385 i = (size_t)&pFaces[v13]; | |
1386 ++v13; | |
1387 v22 = ptr_2AC; | |
1388 pDest += 2 * *(char *)(i + 93) + 2; | |
1389 ++Argsa; | |
1390 *(int *)(i + 68) = (int)(char *)v22 + (int)pDest; | |
1391 pDest += 2 * *((char *)&pFaces[v13] - 3) + 2; | |
1392 } | |
1393 while ( Argsa < (signed int)uNumFaces ); | |
1394 } | |
1395 Argsb = 0; | |
1396 if ( (signed int)uNumFaces > 0 ) | |
1397 { | |
1398 pDest = 0; | |
1399 do | |
1400 { | |
1401 fread(Dst, 1u, 0xAu, v7); | |
1402 if ( pDest[(unsigned int)pFaces + 45] & 0x40 ) | |
1403 { | |
1404 v23 = pTextureFrameTable->FindTextureByName(Dst); | |
1405 v24 = pDest; | |
1406 *(short *)&pDest[(unsigned int)pFaces + 74] = v23; | |
1407 v25 = *(short *)&v24[(unsigned int)pFaces + 74]; | |
1408 if ( v25 ) | |
1409 { | |
1410 pTextureFrameTable->LoadAnimationSequenceAndPalettes(v25); | |
1411 } | |
1412 else | |
1413 { | |
1414 v26 = pBitmaps_LOD->LoadTexture(Dst); | |
1415 v27 = pDest; | |
1416 *(short *)&pDest[(unsigned int)pFaces + 74] = v26; | |
1417 v27[(unsigned int)pFaces + 45] &= 0xBFu; | |
1418 } | |
1419 } | |
1420 else | |
1421 { | |
1422 *(short *)&pDest[(unsigned int)pFaces + 74] = pBitmaps_LOD->LoadTexture(Dst); | |
1423 } | |
1424 ++Argsb; | |
1425 pDest += 96; | |
1426 } | |
1427 while ( Argsb < (signed int)uNumFaces ); | |
1428 } | |
1429 fseek(v7, v211, 0); | |
1430 fread(&uNumFaceExtras, 4u, 1u, v7); | |
1431 fseek(v7, v212, 0); | |
1432 fread(pFaceExtras, 0x24u, uNumFaceExtras, v7); | |
1433 Argsc = 0; | |
1434 if ( (signed int)uNumFaceExtras > 0 ) | |
1435 { | |
1436 pDest = 0; | |
1437 do | |
1438 { | |
1439 fread(Dst, 1u, 0xAu, v7); | |
1440 v28 = pBitmaps_LOD->LoadTexture(Dst); | |
1441 v29 = pFaceExtras; | |
1442 v30 = pDest; | |
1443 ++Argsc; | |
1444 pDest += 36; | |
1445 *(unsigned __int16 *)((char *)&v29->uAdditionalBitmapID + (int)v30) = v28; | |
1446 } | |
1447 while ( Argsc < (signed int)uNumFaceExtras ); | |
1448 } | |
1449 Argsd = 0; | |
1450 if ( (signed int)uNumFaces > 0 ) | |
1451 { | |
1452 pDest = 0; | |
1453 do | |
1454 { | |
1455 v31 = (int)&pFaceExtras[*(short *)&pDest[(unsigned int)pFaces + 72]]; | |
1456 if ( *(short *)(v31 + 26) ) | |
1457 { | |
1458 if ( ((BLVFaceExtra *)v31)->HasEventint() ) | |
1459 pDest[(unsigned int)pFaces + 46] |= 0x10u; | |
1460 else | |
1461 pDest[(unsigned int)pFaces + 46] &= 0xEFu; | |
1462 } | |
1463 ++Argsd; | |
1464 pDest += 96; | |
1465 } | |
1466 while ( Argsd < (signed int)uNumFaces ); | |
1467 } | |
1468 fseek(v7, v213, 0); | |
1469 fread(&uNumSectors, 4u, 1u, v7); | |
1470 fseek(v7, v214, 0); | |
1471 fread(pSectors, 0x74u, uNumSectors, v7); | |
1472 v32 = pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); | |
1473 v202 = (int)v7; | |
1474 ptr_0002B0_sector_rdata = (unsigned __int16 *)v32; | |
1475 fread(v32, 1u, blv.uSector_rdata_Size, (FILE *)v202); | |
1476 v11 = uNumSectors == 0; | |
1477 v12 = uNumSectors < 0; | |
1478 pDest = 0; | |
1479 Argse = 0; | |
1480 if ( !(v12 | v11) ) | |
1481 { | |
1482 v33 = 0; | |
1483 do | |
1484 { | |
1485 pSectors[v33].pFloors = (unsigned __int16 *)&pDest[(unsigned int)ptr_0002B0_sector_rdata]; | |
1486 i = (size_t)&pSectors[v33]; | |
1487 v34 = ptr_0002B0_sector_rdata; | |
1488 pDest += 2 * *(short *)(i + 4); | |
1489 *(int *)(i + 16) = (int)(char *)v34 + (int)pDest; | |
1490 v35 = (size_t)&pSectors[v33]; | |
1491 i = v35; | |
1492 v36 = &pDest[2 * *(short *)(v35 + 12)]; | |
1493 v37 = (int)&v36[(unsigned int)ptr_0002B0_sector_rdata]; | |
1494 pDest = v36; | |
1495 *(int *)(i + 24) = v37; | |
1496 v38 = (size_t)&pSectors[v33]; | |
1497 i = v38; | |
1498 v39 = &pDest[2 * *(short *)(v38 + 20)]; | |
1499 v40 = (int)&v39[(unsigned int)ptr_0002B0_sector_rdata]; | |
1500 pDest = v39; | |
1501 *(int *)(i + 32) = v40; | |
1502 i = (size_t)&pSectors[v33]; | |
1503 v41 = ptr_0002B0_sector_rdata; | |
1504 pDest += 2 * *(short *)(i + 28); | |
1505 *(int *)(i + 40) = (int)(char *)v41 + (int)pDest; | |
1506 i = (size_t)&pSectors[v33]; | |
1507 v42 = ptr_0002B0_sector_rdata; | |
1508 pDest += 2 * *(short *)(i + 36); | |
1509 *(int *)(i + 48) = (int)(char *)v42 + (int)pDest; | |
1510 i = (size_t)&pSectors[v33]; | |
1511 v43 = ptr_0002B0_sector_rdata; | |
1512 pDest += 2 * *(short *)(i + 44); | |
1513 *(int *)(i + 64) = (int)(char *)v43 + (int)pDest; | |
1514 i = (size_t)&pSectors[v33]; | |
1515 v44 = ptr_0002B0_sector_rdata; | |
1516 pDest += 2 * *(short *)(i + 60); | |
1517 *(int *)(i + 72) = (int)(char *)v44 + (int)pDest; | |
1518 v45 = (size_t)&pSectors[v33]; | |
1519 ++v33; | |
1520 i = v45; | |
1521 v46 = ptr_0002B0_sector_rdata; | |
1522 pDest += 2 * *(short *)(v45 + 68); | |
1523 ++Argse; | |
1524 *(int *)(v45 + 80) = (int)(char *)v46 + (int)pDest; | |
1525 pDest += 2 * *((short *)&pSectors[v33] - 20); | |
1526 } | |
1527 while ( Argse < uNumSectors ); | |
1528 } | |
1529 v47 = pAllocator->AllocNamedChunk( | |
1530 ptr_0002B8_sector_lrdata, | |
1531 blv.uSector_lrdata_Size, | |
1532 "L.RLData"); | |
1533 v202 = (int)v7; | |
1534 ptr_0002B8_sector_lrdata = (unsigned __int16 *)v47; | |
1535 fread(v47, 1u, blv.uSector_lrdata_Size, (FILE *)v202); | |
1536 v11 = uNumSectors == 0; | |
1537 v12 = uNumSectors < 0; | |
1538 pDest = 0; | |
1539 Argsf = 0; | |
1540 if ( !(v12 | v11) ) | |
1541 { | |
1542 v48 = pSectors; | |
1543 v49 = 0; | |
1544 for ( i = 0; ; v49 = i ) | |
1545 { | |
1546 v50 = ptr_0002B8_sector_lrdata; | |
1547 i += 116; | |
1548 ++Argsf; | |
1549 *(BLVLightMM7 **)((char *)&v48->pLights + v49) = (BLVLightMM7 *)((char *)v50 + (int)pDest); | |
1550 v48 = pSectors; | |
1551 pDest += 2 * *(__int16 *)((char *)&v48->uNumLights + v49); | |
1552 if ( Argsf >= uNumSectors ) | |
1553 break; | |
1554 } | |
1555 } | |
1556 fseek(v7, v215, 0); | |
1557 fread(&uNumDoors, 4u, 1u, v7); | |
1558 fseek(v7, v216, 0); | |
1559 fread(pDoors, 0x50u, 0xC8u, v7); | |
1560 v51 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
1561 v202 = (int)v7; | |
1562 ptr_0002B4_doors_ddata = (unsigned __int16 *)v51; | |
1563 fread(v51, 1u, blv.uDoors_ddata_Size, (FILE *)v202); | |
1564 v11 = uNumDoors == 0; | |
1565 v12 = uNumDoors < 0; | |
1566 pDest = 0; | |
1567 Argsg = 0; | |
1568 if ( !(v12 | v11) ) | |
1569 { | |
1570 v52 = 0; | |
1571 do | |
1572 { | |
1573 pDoors[v52].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)ptr_0002B4_doors_ddata]; | |
1574 i = (size_t)&pDoors[v52]; | |
1575 v53 = ptr_0002B4_doors_ddata; | |
1576 pDest += 2 * *(short *)(i + 68); | |
1577 *(int *)(i + 40) = (int)(char *)v53 + (int)pDest; | |
1578 v54 = (size_t)&pDoors[v52]; | |
1579 i = v54; | |
1580 v55 = &pDest[2 * *(short *)(v54 + 70)]; | |
1581 v56 = (int)&v55[(unsigned int)ptr_0002B4_doors_ddata]; | |
1582 pDest = v55; | |
1583 *(int *)(i + 44) = v56; | |
1584 v57 = (size_t)&pDoors[v52]; | |
1585 i = v57; | |
1586 v58 = &pDest[2 * *(short *)(v57 + 72)]; | |
1587 v59 = (int)&v58[(unsigned int)ptr_0002B4_doors_ddata]; | |
1588 pDest = v58; | |
1589 *(int *)(i + 48) = v59; | |
1590 i = (size_t)&pDoors[v52]; | |
1591 v60 = ptr_0002B4_doors_ddata; | |
1592 pDest += 2 * *(short *)(i + 70); | |
1593 *(int *)(i + 52) = (int)(char *)v60 + (int)pDest; | |
1594 i = (size_t)&pDoors[v52]; | |
1595 v61 = ptr_0002B4_doors_ddata; | |
1596 pDest += 2 * *(short *)(i + 70); | |
1597 *(int *)(i + 56) = (int)(char *)v61 + (int)pDest; | |
1598 i = (size_t)&pDoors[v52]; | |
1599 v62 = ptr_0002B4_doors_ddata; | |
1600 pDest += 2 * *(short *)(i + 74); | |
1601 *(int *)(i + 60) = (int)(char *)v62 + (int)pDest; | |
1602 i = (size_t)&pDoors[v52]; | |
1603 v63 = ptr_0002B4_doors_ddata; | |
1604 pDest += 2 * *(short *)(i + 74); | |
1605 *(int *)(i + 64) = (int)(char *)v63 + (int)pDest; | |
1606 ++Argsg; | |
1607 v64 = pDoors[v52].uNumOffsets; | |
1608 ++v52; | |
1609 pDest += 2 * v64; | |
1610 } | |
1611 while ( Argsg < uNumDoors ); | |
1612 } | |
1613 Argsh = 0; | |
1614 if ( uNumDoors > 0 ) | |
1615 { | |
1616 v65 = pDoors; | |
1617 pDest = 0; | |
1618 do | |
1619 { | |
1620 i = 0; | |
1621 v66 = &pDest[(int)v65]; | |
1622 if ( *(short *)&pDest[(int)v65 + 70] > 0 ) | |
1623 { | |
1624 do | |
1625 { | |
1626 v67 = *((int *)v66 + 10); | |
1627 a3 = 2 * i; | |
1628 v68 = *(short *)(v67 + 2 * i); | |
1629 v69 = pFaces; | |
1630 ++i; | |
1631 v70 = (int)&pFaceExtras[v69[v68].uFaceExtraID]; | |
1632 v71 = *((int *)v66 + 12); | |
1633 v72 = a3; | |
1634 v238 = (char *)v70; | |
1635 *(short *)(a3 + v71) = *(short *)(v70 + 20); | |
1636 *(__int16 *)(*(char **)((char *)&pDoors->pDeltaVs + (unsigned int)pDest) + v72) = *((short *)v238 + 11); | |
1637 v65 = pDoors; | |
1638 v66 = &pDest[(int)v65]; | |
1639 } | |
1640 while ( (signed int)i < *(short *)&pDest[(int)v65 + 70] ); | |
1641 } | |
1642 ++Argsh; | |
1643 pDest += 80; | |
1644 } | |
1645 while ( Argsh < uNumDoors ); | |
1646 } | |
1647 fseek(v7, v217, 0); | |
1648 fread(&uNumLevelDecorations, 4u, 1u, v7); | |
1649 fseek(v7, v218, 0); | |
1650 fread(pLevelDecorations, 0x20u, uNumLevelDecorations, v7); | |
1651 Argsi = 0; | |
1652 if ( (signed int)uNumLevelDecorations > 0 ) | |
1653 { | |
1654 pDest = (char *)pLevelDecorations; | |
1655 do | |
1656 { | |
1657 fread(pName, 1u, 0x20u, v7); | |
1658 v73 = pDecorationList->GetDecorIdByName(pName); | |
1659 v74 = pDest; | |
1660 ++Argsi; | |
1661 pDest += 32; | |
1662 *(short *)v74 = v73; | |
1663 } | |
1664 while ( Argsi < (signed int)uNumLevelDecorations ); | |
1665 } | |
1666 fseek(v7, v219, 0); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1667 fread(&uNumSpriteObjects, 4u, 1u, v7); |
0 | 1668 fseek(v7, v220, 0); |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1669 fread(pSpriteObjects, 0x70u, uNumSpriteObjects, v7); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1670 if ( (signed int)uNumSpriteObjects > 0 ) |
0 | 1671 { |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1672 v75 = pSpriteObjects; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1673 pDest = (char *)uNumSpriteObjects; |
0 | 1674 do |
1675 { | |
1676 Argsj = 0; | |
1677 v76 = 48 * v75->stru_24.uItemID; | |
1678 v11 = pObjectList->uNumObjects == 0; | |
1679 v12 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
1680 LOWORD(v76) = *(unsigned __int16 *)((char *)&pItemsTable->pItems[0].uSpriteID + v76); | |
1681 i = v76; | |
1682 v75->uItemType = v76; | |
1683 if ( v12 | v11 ) | |
1684 { | |
1685 LABEL_50: | |
1686 v78 = 0; | |
1687 } | |
1688 else | |
1689 { | |
1690 for ( j = (int)&pObjectList->pObjects->uObjectID; (short)v76 != *(short *)j; j = a3 ) | |
1691 { | |
1692 ++Argsj; | |
1693 a3 = j + 56; | |
1694 if ( Argsj >= (signed int)pObjectList->uNumObjects ) | |
1695 goto LABEL_50; | |
1696 LOWORD(v76) = i; | |
1697 } | |
1698 v78 = Argsj; | |
1699 } | |
1700 v75->uObjectDescID = v78; | |
1701 ++v75; | |
1702 --pDest; | |
1703 } | |
1704 while ( pDest ); | |
1705 } | |
1706 fseek(v7, v221, 0); | |
1707 fread(&uNumActors, 4u, 1u, v7); | |
1708 fseek(v7, v222, 0); | |
1709 fread(pActors, 0x344u, uNumActors, v7); | |
1710 fseek(v7, v228, 0); | |
1711 fread(&uNumChests, 4u, 1u, v7); | |
1712 fseek(v7, v229, 0); | |
1713 fread(pChests, 0x14CCu, uNumChests, v7); | |
1714 fseek(v7, v224, 0); | |
1715 fread(&uNumLights, 4u, 1u, v7); | |
1716 fseek(v7, v225, 0); | |
1717 fread(pLights, 0x10u, uNumLights, v7); | |
1718 fseek(v7, v226, 0); | |
1719 fread(&uNumNodes, 4u, 1u, v7); | |
1720 fseek(v7, v227, 0); | |
1721 fread(pNodes, 8u, uNumNodes, v7); | |
1722 fseek(v7, v230, 0); | |
1723 fread(&uNumSpawnPoints, 4u, 1u, v7); | |
1724 v79 = pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); | |
1725 v202 = 0; | |
1726 pSpawnPoints = (SpawnPointMM7 *)v79; | |
1727 fseek(v7, v231, v202); | |
1728 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, v7); | |
1729 fseek(v7, v232, 0); | |
1730 fread(&dlv, 0x28u, 1u, v7); | |
1731 fseek(v7, v233, 0); | |
1732 fread(&stru_5E4C90, 1u, 0xC8u, v7); | |
1733 fseek(v7, v234, 0); | |
1734 fread(&uLastVisitDay, 1u, 0x38u, v7); | |
1735 fseek(v7, v223, 0); | |
1736 v80 = (void **)&pMapOutlines; | |
1737 fread(*v80, 4u, 1u, v7); | |
1738 fread((char *)*v80 + 4, 0xCu, *(int *)*v80, v7); | |
1739 fclose(v7); | |
1740 goto LABEL_179; | |
1741 } | |
1742 return 4; | |
1743 }*/ | |
1744 #pragma endregion | |
1745 | |
1746 if (bLoaded) | |
1747 { | |
1748 Log::Warning(L"BLV is already loaded"); | |
1749 return 3; | |
1750 } | |
1751 | |
1752 if ( !pGames_LOD->DoesContainerExist(pFilename) ) | |
1753 Abortf("Unable to find %s in Games.LOD", pFilename); | |
1754 | |
1755 //v238 = pFilename - 4; | |
1756 //v81 = strlen(pFilename); | |
1757 strcpy(this->pFilename, pFilename); | |
1758 strcpy(&pFilename[strlen(pFilename) - 4], ".blv"); | |
1759 File = pGames_LOD->FindContainer(pFilename, 1); | |
1760 //File = v82; | |
1761 | |
1762 Release(); | |
1763 if ( !Alloc() ) | |
1764 return 4; | |
1765 | |
1766 header.uVersion = 91969; | |
1767 header.pMagic[0] = 'm'; | |
1768 header.pMagic[1] = 'v'; | |
1769 header.pMagic[2] = 'i'; | |
1770 header.pMagic[3] = 'i'; | |
1771 header.uCompressedSize = 0; | |
1772 header.uDecompressedSize = 0; | |
1773 fread(&header, sizeof(ODMHeader), 1u, File); | |
1774 if (header.uVersion != 91969 || | |
1775 header.pMagic[0] != 'm' || | |
1776 header.pMagic[1] != 'v' || | |
1777 header.pMagic[2] != 'i' || | |
1778 header.pMagic[3] != 'i' ) | |
1779 { | |
1780 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:792", 0); | |
1781 } | |
1782 //v83 = header.uCompressedSize; | |
1783 //pSource = header.uDecompressedSize; | |
1784 //v84 = malloc(header.uDecompressedSize); | |
1785 //v85 = v84; | |
1786 //ptr = v84; | |
1787 auto pRawBLV = malloc(header.uDecompressedSize); | |
1788 memset(pRawBLV, 0, header.uDecompressedSize); | |
1789 | |
1790 if (header.uCompressedSize == header.uDecompressedSize) | |
1791 fread(pRawBLV, header.uDecompressedSize, 1, File); | |
1792 else if (header.uCompressedSize < header.uDecompressedSize) | |
1793 { | |
1794 auto pTmpMem = malloc(header.uCompressedSize); | |
1795 { | |
1796 fread(pTmpMem, header.uCompressedSize, 1, File); | |
1797 | |
1798 uint uDecompressedSize = header.uDecompressedSize; | |
1799 zlib::MemUnzip(pRawBLV, &uDecompressedSize, pTmpMem, header.uCompressedSize); | |
1800 | |
1801 if (uDecompressedSize != header.uDecompressedSize) | |
1802 Log::Warning(L"uDecompressedSize != header.uDecompressedSize in BLV"); | |
1803 } | |
1804 free(pTmpMem); | |
1805 } | |
1806 else | |
1807 { | |
1808 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:803", 0); | |
1809 return 0; | |
1810 } | |
1811 | |
1812 bLoaded = true; | |
1813 | |
1814 auto pData = (char *)pRawBLV; | |
1815 | |
1816 pGameLoadingUI_ProgressBar->Progress(); | |
1817 | |
1818 memcpy(&blv, pData, 136); | |
1819 memcpy(&uNumVertices, pData += 136, 4); | |
1820 memcpy(pVertices, pData += 4, uNumVertices * sizeof(Vec3_short_)); | |
1821 | |
1822 pGameLoadingUI_ProgressBar->Progress(); | |
1823 | |
1824 memcpy(&uNumFaces, pData += uNumVertices * sizeof(Vec3_short_), 4); | |
1825 | |
1826 pGameLoadingUI_ProgressBar->Progress(); | |
1827 | |
1828 memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace)); | |
1006 | 1829 pLFaces = (unsigned __int16 *)pAllocator->AllocNamedChunk(pLFaces, blv.uFaces_fdata_Size, "L.FData"); |
1830 | |
1831 memcpy(pLFaces, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size); | |
0 | 1832 |
1833 for (uint i = 0, j = 0; i < uNumFaces; ++i) | |
1834 { | |
1835 auto pFace = pFaces + i; | |
1836 | |
1006 | 1837 pFace->pVertexIDs = pLFaces + j; |
0 | 1838 |
1839 j += pFace->uNumVertices + 1; | |
1006 | 1840 pFace->pXInterceptDisplacements = (short *)(pLFaces + j); |
0 | 1841 |
1842 j += pFace->uNumVertices + 1; | |
1006 | 1843 pFace->pYInterceptDisplacements = (short *)(pLFaces + j); |
0 | 1844 |
1845 j += pFace->uNumVertices + 1; | |
1006 | 1846 pFace->pZInterceptDisplacements = (short *)(pLFaces + j); |
0 | 1847 |
1848 j += pFace->uNumVertices + 1; | |
1006 | 1849 pFace->pVertexUIDs = (__int16 *)(pLFaces + j); |
0 | 1850 |
1851 j += pFace->uNumVertices + 1; | |
1006 | 1852 pFace->pVertexVIDs = (__int16 *)(pLFaces + j); |
0 | 1853 |
1854 j += pFace->uNumVertices + 1; | |
1855 /*v93 = &pFaces[v92]; | |
1856 Src = v93; | |
1857 v94 = (BLVSector *)((char *)v244 + 2 * v93->uNumVertices + 2); | |
1858 v95 = (unsigned __int16 *)((char *)v94 + (unsigned int)ptr_2AC); | |
1859 v244 = v94; | |
1860 Src->pXInterceptDisplacements = v95; | |
1861 v96 = (int)&pFaces[v92]; | |
1862 Src = (BLVFace *)v96; | |
1863 v97 = (BLVSector *)((char *)v244 + 2 * *(char *)(v96 + 93) + 2); | |
1864 v98 = (unsigned __int16 *)((char *)v97 + (unsigned int)ptr_2AC); | |
1865 v244 = v97; | |
1866 Src->pYInterceptDisplacements = v98; | |
1867 Src = &pFaces[v92]; | |
1868 v99 = ptr_2AC; | |
1869 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
1870 Src->pZInterceptDisplacements = (unsigned __int16 *)((char *)v99 + (int)v244); | |
1871 Src = &pFaces[v92]; | |
1872 v100 = ptr_2AC; | |
1873 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
1874 Src->pVertexUIDs = (unsigned __int16 *)((char *)v100 + (int)v244); | |
1875 Src = &pFaces[v92]; | |
1876 ++v92; | |
1877 v101 = ptr_2AC; | |
1878 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
1879 ++v245; | |
1880 Src->pVertexVIDs = (unsigned __int16 *)((char *)v101 + (int)v244); | |
1881 v244 = (BLVSector *)((char *)v244 + 2 * *((char *)&pFaces[v92] - 3) + 2);*/ | |
1882 } | |
1883 | |
1884 pGameLoadingUI_ProgressBar->Progress(); | |
1885 | |
1886 pData += blv.uFaces_fdata_Size; | |
1887 | |
1888 for (uint i = 0; i < uNumFaces; ++i) | |
1889 { | |
1890 auto pFace = pFaces + i; | |
1891 | |
1892 char pTexName[16]; | |
1893 strncpy(pTexName, pData, 10); | |
1894 pData += 10; | |
1895 | |
1896 if (pFace->uAttributes & 0x4000) | |
1897 { | |
1898 pFace->uBitmapID = pTextureFrameTable->FindTextureByName(pTexName); | |
1899 if (pFace->uBitmapID) | |
1900 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pFace->uBitmapID); | |
1901 else | |
1902 { | |
1903 pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
1904 pFace->uAttributes &= ~0x4000; | |
1905 } | |
1906 } | |
1907 else | |
1908 pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
1909 } | |
1910 | |
1911 pGameLoadingUI_ProgressBar->Progress(); | |
1912 | |
1913 memcpy(&uNumFaceExtras, pData, 4u); | |
1914 memcpy(pFaceExtras, pData += 4, uNumFaceExtras * sizeof(BLVFaceExtra)); | |
1915 pData += uNumFaceExtras * sizeof(BLVFaceExtra); | |
1916 | |
1917 pGameLoadingUI_ProgressBar->Progress(); | |
1918 | |
1919 //v108 = (char *)v107 + 36 * uNumFaceExtras; | |
1920 //v245 = 0; | |
1921 //*(int *)((char *)&uSourceLen + 1) = 0; | |
1922 for (uint i = 0; i < uNumFaceExtras; ++i) | |
1923 { | |
1924 char pTexName[32]; | |
1925 strncpy(pTexName, pData, 10); | |
1926 pData += 10; | |
1927 | |
1928 if (!strcmp(pTexName, "")) | |
1929 pFaceExtras[i].uAdditionalBitmapID = -1; | |
1930 else | |
1931 pFaceExtras[i].uAdditionalBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
1932 } | |
1933 | |
1934 | |
1935 for (uint i = 0; i < uNumFaces; ++i) | |
1936 { | |
1937 auto pFace = pFaces + i; | |
1938 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
1939 | |
1940 if (pFaceExtra->uEventID) | |
1941 { | |
1942 if (pFaceExtra->HasEventint()) | |
1943 pFace->uAttributes |= 0x100000; | |
1944 else | |
1945 pFace->uAttributes &= ~0x100000; | |
1946 } | |
1947 } | |
1948 | |
1949 pGameLoadingUI_ProgressBar->Progress(); | |
1950 | |
1951 memcpy(&uNumSectors, pData, 4); | |
1952 memcpy(pSectors, pData + 4, uNumSectors * sizeof(BLVSector)); | |
1953 pData += 4 + uNumSectors * sizeof(BLVSector); | |
1954 | |
1955 pGameLoadingUI_ProgressBar->Progress(); | |
1956 | |
1957 ptr_0002B0_sector_rdata = (unsigned short *)pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); | |
1958 memcpy(ptr_0002B0_sector_rdata, pData, blv.uSector_rdata_Size); | |
1959 pData += blv.uSector_rdata_Size; | |
1960 | |
1961 for (uint i = 0, j = 0; i < uNumSectors; ++i) | |
1962 { | |
1963 auto pSector = pSectors + i; | |
1964 | |
1965 pSector->pFloors = ptr_0002B0_sector_rdata + j; | |
1966 j += pSector->uNumFloors; | |
1967 | |
1968 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
|
1969 j += pSector->uNumWalls; |
0 | 1970 |
1971 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
|
1972 j += pSector->uNumCeilings; |
0 | 1973 |
1974 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
|
1975 j += pSector->uNumFluids; |
0 | 1976 |
1977 pSector->pPortals = ptr_0002B0_sector_rdata + j; | |
1978 j += pSector->uNumPortals; | |
1979 | |
1980 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
|
1981 j += pSector->uNumFaces; |
0 | 1982 |
1983 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
|
1984 j += pSector->uNumCogs; |
0 | 1985 |
1986 pSector->pDecorationIDs = ptr_0002B0_sector_rdata + j; | |
1987 j += pSector->uNumDecorations; | |
1988 | |
1989 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
|
1990 j += pSector->uNumMarkers; |
0 | 1991 |
1992 | |
1993 //do | |
1994 //{ | |
1995 /*pSectors[v118].pFloors = (unsigned __int16 *)((char *)Src + (unsigned int)ptr_0002B0_sector_rdata); | |
1996 v244 = &pSectors[v118]; | |
1997 v119 = ptr_0002B0_sector_rdata; | |
1998 Src = (BLVFace *)((char *)Src + 2 * v244->field_4); | |
1999 v244->pWalls = (unsigned __int16 *)((char *)v119 + (int)Src); | |
2000 v120 = (int)&pSectors[v118]; | |
2001 v244 = (BLVSector *)v120; | |
2002 v121 = (BLVFace *)((char *)Src + 2 * *(short *)(v120 + 12)); | |
2003 v122 = (unsigned __int16 *)((char *)v121 + (unsigned int)ptr_0002B0_sector_rdata); | |
2004 Src = v121; | |
2005 v244->pCeilings = v122; | |
2006 v123 = (int)&pSectors[v118]; | |
2007 v244 = (BLVSector *)v123; | |
2008 v124 = (BLVFace *)((char *)Src + 2 * *(short *)(v123 + 20)); | |
2009 v125 = (unsigned __int16 *)((char *)v124 + (unsigned int)ptr_0002B0_sector_rdata); | |
2010 Src = v124; | |
2011 v244->pFluids = v125; | |
2012 v244 = &pSectors[v118]; | |
2013 v126 = ptr_0002B0_sector_rdata; | |
2014 Src = (BLVFace *)((char *)Src + 2 * v244->field_1C); | |
2015 v244->pPortals = (unsigned __int16 *)((char *)v126 + (int)Src); | |
2016 v244 = &pSectors[v118]; | |
2017 v127 = ptr_0002B0_sector_rdata; | |
2018 Src = (BLVFace *)((char *)Src + 2 * v244->uNumPortals); | |
2019 v244->pFaceIDs = (unsigned __int16 *)((char *)v127 + (int)Src); | |
2020 v244 = &pSectors[v118]; | |
2021 v128 = ptr_0002B0_sector_rdata; | |
2022 Src = (BLVFace *)((char *)Src + 2 * v244->field_2C); | |
2023 v244->pCogs = (unsigned __int16 *)((char *)v128 + (int)Src); | |
2024 v244 = &pSectors[v118]; | |
2025 v129 = ptr_0002B0_sector_rdata; | |
2026 Src = (BLVFace *)((char *)Src + 2 * v244->field_3C); | |
2027 v244->pDecorationIDs = (unsigned __int16 *)((char *)v129 + (int)Src); | |
2028 v130 = (int)&pSectors[v118]; | |
2029 ++v118; | |
2030 v244 = (BLVSector *)v130; | |
2031 v131 = ptr_0002B0_sector_rdata; | |
2032 Src = (BLVFace *)((char *)Src + 2 * *(short *)(v130 + 68)); | |
2033 ++v245; | |
2034 *(int *)(v130 + 80) = (int)(char *)v131 + (int)Src; | |
2035 Src = (BLVFace *)((char *)Src + 2 * *((short *)&pSectors[v118] - 20));*/ | |
2036 //} | |
2037 //while ( v245 < uNumSectors ); | |
2038 } | |
2039 | |
2040 ptr_0002B8_sector_lrdata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B8_sector_lrdata, blv.uSector_lrdata_Size, "L.RLData"); | |
2041 memcpy(ptr_0002B8_sector_lrdata, pData, blv.uSector_lrdata_Size); | |
2042 pData += blv.uSector_lrdata_Size; | |
2043 | |
2044 pGameLoadingUI_ProgressBar->Progress(); | |
2045 | |
2046 for (uint i = 0, j = 0; i < uNumSectors; ++i) | |
2047 { | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2048 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
|
2049 j += pSectors[i].uNumLights; |
0 | 2050 } |
2051 | |
2052 pGameLoadingUI_ProgressBar->Progress(); | |
2053 | |
2054 memcpy(&uNumDoors, pData, 4); | |
2055 pData += 4; | |
2056 | |
2057 pGameLoadingUI_ProgressBar->Progress(); | |
2058 pGameLoadingUI_ProgressBar->Progress(); | |
2059 | |
2060 memcpy(&uNumLevelDecorations, pData, 4); | |
1202 | 2061 memcpy(pLevelDecorations.data(), pData + 4, uNumLevelDecorations * sizeof(LevelDecoration)); |
0 | 2062 pData += 4 + uNumLevelDecorations * sizeof(LevelDecoration); |
2063 | |
2064 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2065 { | |
2066 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pData); | |
2067 | |
2068 pData += 32; | |
2069 } | |
2070 | |
2071 pGameLoadingUI_ProgressBar->Progress(); | |
2072 | |
2073 memcpy(&uNumLights, pData, 4); | |
2074 memcpy(pLights, pData + 4, uNumLights * sizeof(BLVLightMM7)); | |
2075 pData += 4 + uNumLights * sizeof(BLVLightMM7); | |
2076 | |
2077 pGameLoadingUI_ProgressBar->Progress(); | |
2078 pGameLoadingUI_ProgressBar->Progress(); | |
2079 | |
2080 memcpy(&uNumNodes, pData, 4); | |
2081 memcpy(pNodes, pData + 4, uNumNodes * sizeof(BSPNode)); | |
2082 pData += 4 + uNumNodes * sizeof(BSPNode); | |
2083 | |
2084 pGameLoadingUI_ProgressBar->Progress(); | |
2085 pGameLoadingUI_ProgressBar->Progress(); | |
2086 | |
2087 memcpy(&uNumSpawnPoints, pData, 4); | |
2088 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, uNumSpawnPoints * sizeof(SpawnPointMM7), "Spawn"); | |
2089 memcpy(pSpawnPoints, pData + 4, uNumSpawnPoints * sizeof(SpawnPointMM7)); | |
2090 pData += 4 + uNumSpawnPoints * sizeof(SpawnPointMM7); | |
2091 | |
2092 pGameLoadingUI_ProgressBar->Progress(); | |
2093 pGameLoadingUI_ProgressBar->Progress(); | |
2094 | |
2095 //v201 = (const char *)v148; | |
2096 //v200 = (size_t)pMapOutlines; | |
2097 memcpy(&pMapOutlines->uNumOutlines, pData, 4); | |
2098 memcpy(pMapOutlines->pOutlines, pData + 4, pMapOutlines->uNumOutlines * sizeof(BLVMapOutline)); | |
2099 //v149 = pMapOutlines; | |
2100 //v199 = 12 * *v149; | |
2101 //memcpy(v149 + 1, (const void *)(v148 + 4), v199); | |
2102 free(pRawBLV); | |
2103 pRawBLV = nullptr; | |
2104 | |
2105 void *pRawDLV = nullptr; | |
2106 strcpy(&pFilename[strlen(pFilename) - 4], ".dlv"); | |
2107 File = pNew_LOD->FindContainer(pFilename, 1); | |
2108 fread(&header, 0x10u, 1u, File);//(FILE *)v245); | |
2109 bool _v244 = false; | |
2110 if (header.uVersion != 91969 || | |
2111 header.pMagic[0] != 'm' || | |
2112 header.pMagic[1] != 'v' || | |
2113 header.pMagic[2] != 'i' || | |
2114 header.pMagic[3] != 'i' ) | |
2115 { | |
2116 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1090", 0); | |
2117 _v244 = true; | |
2118 } | |
2119 else | |
2120 { | |
2121 pRawDLV = malloc(header.uDecompressedSize); | |
2122 if (header.uCompressedSize == header.uDecompressedSize) | |
2123 fread(pRawDLV, 1, header.uCompressedSize, File); | |
2124 else if (header.uCompressedSize < header.uDecompressedSize) | |
2125 { | |
2126 auto pTmpMem = malloc(header.uCompressedSize); | |
2127 { | |
2128 fread(pTmpMem, header.uCompressedSize, 1, File); | |
2129 | |
2130 uint uDecompressedSize = header.uDecompressedSize; | |
2131 zlib::MemUnzip(pRawDLV, &uDecompressedSize, pTmpMem, header.uCompressedSize); | |
2132 | |
2133 if (uDecompressedSize != header.uDecompressedSize) | |
2134 Log::Warning(L"uDecompressedSize != header.uDecompressedSize in DLV"); | |
2135 } | |
2136 free(pTmpMem); | |
2137 } | |
2138 else | |
2139 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1108", 0); | |
2140 | |
2141 pData = (char *)pRawDLV; | |
2142 } | |
2143 | |
2144 memcpy(&dlv, pData, 40); | |
2145 pData += 40; | |
2146 | |
2147 //v152 = dlv.uNumFacesInBModels; | |
2148 if (dlv.uNumFacesInBModels) | |
2149 { | |
2150 //v153 = dlv.uNumDecorations; | |
2151 if (dlv.uNumDecorations) | |
2152 { | |
2153 if (dlv.uNumFacesInBModels != uNumFaces || | |
2154 dlv.uNumDecorations != uNumLevelDecorations) | |
2155 _v244 = true; | |
2156 } | |
2157 } | |
2158 | |
2159 if (dword_6BE364_game_settings_1 & 0x2000 ) | |
2160 _i = 29030400; | |
2161 bool _a = false; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
2162 if ( a3 - dlv.uLastRepawnDay >= _i && _stricmp(pCurrentMapName.data(), "d29.dlv") ) |
0 | 2163 _a = true; |
2164 | |
2165 //v154 = 875; | |
2166 if (_v244) | |
2167 { | |
2168 memset(v203, 0, 0x36B); | |
2169 goto LABEL_132; | |
2170 } | |
2171 if (_a || !dlv.uLastRepawnDay ) | |
2172 { | |
2173 memcpy(v203, pData, 0x36B); | |
2174 LABEL_132: | |
435 | 2175 free(pRawDLV); |
0 | 2176 dlv.uLastRepawnDay = a3; |
2177 if (_v244) | |
2178 ++dlv.uNumRespawns; | |
2179 //v201 = pFilename; | |
2180 *(int *)pDest = 1; | |
2181 File = pGames_LOD->FindContainer(pFilename, 0); | |
2182 fread(&header, 0x10u, 1u, File); | |
2183 auto v155 = header.uCompressedSize; | |
2184 auto Count = header.uDecompressedSize; | |
2185 auto Src = (BLVFace *)malloc(header.uDecompressedSize); | |
435 | 2186 pRawDLV = Src; |
0 | 2187 if ( v155 <= Count ) |
2188 { | |
2189 if ( v155 == Count ) | |
2190 { | |
2191 fread(Src, 1u, Count, File); | |
2192 } | |
2193 else | |
2194 { | |
2195 auto _uSourceLen = malloc(v155); | |
2196 fread(_uSourceLen, v155, 1u, File); | |
2197 zlib::MemUnzip(Src, &Count, _uSourceLen, v155); | |
2198 free(_uSourceLen); | |
2199 } | |
2200 } | |
2201 else | |
2202 { | |
2203 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0); | |
2204 } | |
2205 pData = ((char *)Src + 40); | |
2206 //v154 = 875; | |
2207 goto LABEL_140; | |
2208 } | |
2209 *(int *)pDest = 0; | |
2210 LABEL_140: | |
2211 //v202 = (int)".blv"; | |
2212 //v156 = strlen(pFilename); | |
2213 strcpy(&pFilename[strlen(pFilename) - 4], ".blv"); | |
2214 memcpy(_visible_outlines, pData, 875); | |
2215 pData += 875; | |
2216 | |
2217 if ( *(int *)pDest ) | |
2218 memcpy(_visible_outlines, v203, 875); | |
2219 | |
2220 for (uint i = 0; i < pMapOutlines->uNumOutlines; ++i) | |
2221 { | |
2222 auto pVertex = pMapOutlines->pOutlines + i; | |
2223 if ((unsigned __int8)(1 << (7 - i % 8)) & _visible_outlines[i / 8]) | |
2224 pVertex->uFlags |= 1; | |
2225 } | |
2226 | |
2227 | |
2228 for (uint i = 0; i < uNumFaces; ++i) | |
2229 { | |
2230 auto pFace = pFaces + i; | |
2231 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
2232 | |
2233 memcpy(&pFace->uAttributes, pData, 4); | |
2234 pData += 4; | |
2235 | |
2236 if (pFaceExtra->uEventID) | |
2237 { | |
2238 if (pFaceExtra->HasEventint()) | |
2239 pFace->uAttributes |= 0x100000; | |
2240 else | |
2241 pFace->uAttributes &= ~0x100000; | |
2242 } | |
2243 } | |
2244 | |
2245 pGameLoadingUI_ProgressBar->Progress(); | |
2246 | |
2247 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2248 { | |
2249 memcpy(&pLevelDecorations[i].field_2, pData, 2); | |
2250 pData += 2; | |
2251 } | |
2252 | |
2253 pGameLoadingUI_ProgressBar->Progress(); | |
2254 | |
2255 memcpy(&uNumActors, pData, 4); | |
1202 | 2256 memcpy(pActors.data(), pData + 4, uNumActors * sizeof(Actor)); |
0 | 2257 pData += 4 + uNumActors * sizeof(Actor); |
2258 | |
2259 pGameLoadingUI_ProgressBar->Progress(); | |
2260 pGameLoadingUI_ProgressBar->Progress(); | |
2261 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2262 memcpy(&uNumSpriteObjects, pData, 4); |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2263 memcpy(pSpriteObjects.data(), pData + 4, uNumSpriteObjects * sizeof(SpriteObject)); |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2264 pData += 4 + uNumSpriteObjects * sizeof(SpriteObject); |
0 | 2265 |
2266 pGameLoadingUI_ProgressBar->Progress(); | |
2267 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2268 for (uint i = 0; i < uNumSpriteObjects; ++i) |
0 | 2269 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2270 auto pItem = &pSpriteObjects[i]; |
0 | 2271 |
2272 if (pItem->stru_24.uItemID && !(pItem->uAttributes & 0x0100)) | |
2273 { | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2274 pItem->uType = pItemsTable->pItems[pItem->stru_24.uItemID - 1].uSpriteID; |
0 | 2275 |
2276 uint uObjectID = 0; | |
2277 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
|
2278 if (pItem->uType == pObjectList->pObjects[j].uObjectID) |
0 | 2279 { |
2280 pItem->uObjectDescID = j; | |
2281 break; | |
2282 } | |
2283 } | |
2284 } | |
2285 | |
2286 pGameLoadingUI_ProgressBar->Progress(); | |
2287 | |
2288 memcpy(&uNumChests, pData, 4); | |
1202 | 2289 memcpy(pChests.data(), pData + 4, uNumChests * sizeof(Chest)); |
0 | 2290 pData += 4 + uNumChests * sizeof(Chest); |
2291 | |
2292 pGameLoadingUI_ProgressBar->Progress(); | |
2293 pGameLoadingUI_ProgressBar->Progress(); | |
2294 | |
2295 memcpy(pDoors, pData, 0x3E80); | |
2296 pData += 0x3E80; | |
2297 | |
2298 //v201 = (const char *)blv.uDoors_ddata_Size; | |
2299 //v200 = (size_t)ptr_0002B4_doors_ddata; | |
2300 //v170 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
2301 //v171 = blv.uDoors_ddata_Size; | |
2302 ptr_0002B4_doors_ddata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
2303 memcpy(ptr_0002B4_doors_ddata, pData, blv.uDoors_ddata_Size); | |
2304 pData += blv.uDoors_ddata_Size; | |
2305 | |
2306 //Src = (BLVFace *)((char *)Src + v171); | |
2307 //v172 = 0; | |
2308 //v245 = 0; | |
2309 //if (uNumDoors > 0) | |
2310 for (uint i = 0, j = 0; i < uNumDoors; ++i) | |
2311 { | |
2312 auto pDoor = pDoors + i; | |
2313 | |
2314 pDoor->pVertexIDs = ptr_0002B4_doors_ddata + j; | |
2315 j += pDoor->uNumVertices; | |
2316 | |
2317 pDoor->pFaceIDs = ptr_0002B4_doors_ddata + j; | |
2318 j += pDoor->uNumFaces; | |
2319 | |
2320 pDoor->pSectorIDs = ptr_0002B4_doors_ddata + j; | |
2321 j += pDoor->field_48; | |
2322 | |
2323 pDoor->pDeltaUs = (short *)(ptr_0002B4_doors_ddata + j); | |
2324 j += pDoor->uNumFaces; | |
2325 | |
2326 pDoor->pDeltaVs = (short *)(ptr_0002B4_doors_ddata + j); | |
2327 j += pDoor->uNumFaces; | |
2328 | |
2329 pDoor->pXOffsets = ptr_0002B4_doors_ddata + j; | |
2330 j += pDoor->uNumOffsets; | |
2331 | |
2332 pDoor->pYOffsets = ptr_0002B4_doors_ddata + j; | |
2333 j += pDoor->uNumOffsets; | |
2334 | |
2335 pDoor->pZOffsets = ptr_0002B4_doors_ddata + j; | |
2336 j += pDoor->uNumOffsets; | |
2337 /*v173 = pDoors; | |
2338 for ( k = 0; ; v172 = v188 + 2 * *((short *)&v173[k] - 3) ) | |
2339 { | |
2340 v173[k].pVertexIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v172); | |
2341 v175 = &pDoors[k]; | |
2342 v176 = v172 + 2 * v175->uNumVertices; | |
2343 v175->pFaceIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v176); | |
2344 v177 = &pDoors[k]; | |
2345 v178 = v176 + 2 * v177->uNumFaces; | |
2346 v177->pSectorIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v178); | |
2347 v179 = &pDoors[k]; | |
2348 v180 = v178 + 2 * v179->field_48; | |
2349 v179->pDeltaUs = (__int16 *)((char *)ptr_0002B4_doors_ddata + v180); | |
2350 v181 = &pDoors[k]; | |
2351 v182 = v180 + 2 * v181->uNumFaces; | |
2352 v181->pDeltaVs = (__int16 *)((char *)ptr_0002B4_doors_ddata + v182); | |
2353 v183 = &pDoors[k]; | |
2354 v184 = v182 + 2 * v183->uNumFaces; | |
2355 v183->pXOffsets = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v184); | |
2356 v185 = &pDoors[k]; | |
2357 v186 = v184 + 2 * v185->uNumOffsets; | |
2358 v185->pYOffsets = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v186); | |
2359 v187 = &pDoors[k]; | |
2360 ++k; | |
2361 v188 = v186 + 2 * v187->uNumOffsets; | |
2362 v189 = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v188); | |
2363 ++v245; | |
2364 v187->pZOffsets = v189; | |
2365 v173 = pDoors; | |
2366 if ( v245 >= uNumDoors ) | |
2367 break; | |
2368 }*/ | |
2369 } | |
2370 //v190 = 0; | |
2371 //v245 = 0; | |
2372 for (uint i = 0; i < uNumDoors; ++i) | |
2373 { | |
2374 auto pDoor = pDoors + i; | |
2375 | |
2376 for (uint j = 0; j < pDoor->uNumFaces; ++j) | |
2377 { | |
2378 auto pFace = pFaces + pDoor->pFaceIDs[j]; | |
2379 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
2380 | |
2381 pDoor->pDeltaUs[j] = pFaceExtra->sTextureDeltaU; | |
2382 pDoor->pDeltaVs[j] = pFaceExtra->sTextureDeltaV; | |
2383 } | |
2384 //v191 = pDoors; | |
2385 //pDest = 0; | |
2386 //do | |
2387 // { | |
2388 /*Argsn = 0; | |
2389 for ( l = (BLVDoor *)&v190[(int)v191]; | |
2390 Argsn < *(short *)&v190[(int)v191 + 70]; | |
2391 l = (BLVDoor *)&v190[(int)v191] ) | |
2392 { | |
2393 v193 = Argsn; | |
2394 v194 = l->pFaceIDs[Argsn++]; | |
2395 v195 = &pFaceExtras[pFaces[v194].uFaceExtraID]; | |
2396 l->pDeltaUs[v193] = v195->sTextureDeltaU; | |
2397 v190 = pDest; | |
2398 *(short *)(v193 * 2 + *(int *)&pDest[(unsigned int)pDoors + 52]) = v195->sTextureDeltaV; | |
2399 v191 = pDoors; | |
2400 } | |
2401 ++v245; | |
2402 v190 += 80; | |
2403 pDest = v190;*/ | |
2404 //} | |
2405 //while ( v245 < uNumDoors ); | |
2406 } | |
2407 | |
2408 | |
2409 pGameLoadingUI_ProgressBar->Progress(); | |
2410 | |
2411 memcpy(&stru_5E4C90, pData, 0xC8); | |
2412 pData += 0xC8; | |
2413 | |
2414 pGameLoadingUI_ProgressBar->Progress(); | |
2415 | |
2416 memcpy(&stru1, pData, 0x38u); | |
2417 pData += 0x38; | |
2418 | |
2419 free(pRawDLV); | |
2420 //v5 = 0; | |
2421 | |
2422 pSoundList->LoadSound(64, 0); | |
2423 pSoundList->LoadSound(103, 0); | |
2424 pSoundList->LoadSound(63, 0); | |
2425 pSoundList->LoadSound(102, 0); | |
2426 pSoundList->LoadSound(50, 0); | |
2427 pSoundList->LoadSound(89, 0); | |
2428 | |
2429 return 0; | |
2430 } | |
2431 | |
2432 | |
2433 //----- (0049AC17) -------------------------------------------------------- | |
2434 int IndoorLocation::GetSector(int sX, int sY, int sZ) | |
2435 { | |
2436 int v4; // esi@1 | |
2437 //unsigned __int8 v5; // zf@1 | |
2438 //unsigned __int8 v6; // sf@1 | |
2439 //unsigned __int8 v7; // of@1 | |
2440 //BLVSector *v8; // eax@3 | |
2441 //int v9; // edi@9 | |
2442 //int v10; // eax@9 | |
2443 //int v11; // edx@9 | |
2444 //int v12; // eax@10 | |
2445 //unsigned __int16 v13; // ax@12 | |
2446 //int v14; // edi@14 | |
2447 //BLVFace *v15; // eax@14 | |
2448 //BLVFace *v16; // edi@14 | |
2449 //PolygonType v17; // al@14 | |
2450 //unsigned __int16 *pVertexIDs; // esi@16 | |
2451 //Vec3_short_ *v19; // eax@16 | |
2452 //int v20; // edx@16 | |
2453 //unsigned __int16 *v21; // esi@17 | |
2454 //int v22; // edi@19 | |
2455 //int v23; // edi@20 | |
2456 //Vec3_short_ *v24; // edx@20 | |
2457 signed int v25; // edx@21 | |
2458 int v26; // ebx@23 | |
2459 //int v27; // edx@26 | |
2460 //signed __int64 v28; // qtt@26 | |
2461 ///Vec3_short_ *v29; // eax@26 | |
2462 //Vec3_short_ *v30; // edx@26 | |
2463 //int v31; // edx@26 | |
791 | 2464 //signed int v32; // edi@27 |
0 | 2465 signed __int64 v33; // qtt@27 |
2466 //Vec3_short_ *v34; // edx@27 | |
791 | 2467 //int v35; // edx@32 |
0 | 2468 int v37; // edi@38 |
717 | 2469 int pSectorID; // ebx@40 |
0 | 2470 int v39; // eax@41 |
717 | 2471 BLVFace *pFace; // esi@42 |
2472 PolygonType pPolygonType; // dl@42 | |
0 | 2473 int v42; // edx@43 |
2474 int v43[50]; // [sp+Ch] [bp-108h]@1 | |
2475 //int v44; // [sp+D4h] [bp-40h]@9 | |
2476 //int v45; // [sp+D8h] [bp-3Ch]@14 | |
2477 //int v46; // [sp+DCh] [bp-38h]@14 | |
2478 //int v47; // [sp+E0h] [bp-34h]@19 | |
2479 //int v48; // [sp+E4h] [bp-30h]@9 | |
2480 //Vec3_short_ *v49; // [sp+E8h] [bp-2Ch]@19 | |
2481 bool v50; // [sp+ECh] [bp-28h]@19 | |
2482 int v51; // [sp+F0h] [bp-24h]@9 | |
2483 //unsigned int v52; // [sp+F4h] [bp-20h]@2 | |
2484 int v53; // [sp+F8h] [bp-1Ch]@10 | |
2485 int v54; // [sp+FCh] [bp-18h]@16 | |
2486 int v55; // [sp+100h] [bp-14h]@1 | |
2487 int v56; // [sp+104h] [bp-10h]@1 | |
2488 int v57; // [sp+108h] [bp-Ch]@16 | |
2489 //Vec3_short_ *v58; // [sp+10Ch] [bp-8h]@20 | |
2490 int v59; // [sp+110h] [bp-4h]@16 | |
2491 | |
2492 v4 = 0; | |
791 | 2493 v43[0] = 0; |
2494 | |
0 | 2495 v55 = 0; |
791 | 2496 |
0 | 2497 if (uNumSectors < 2) |
2498 return 0; | |
2499 | |
2500 for (uint i = 1; i < uNumSectors; ++i) | |
2501 { | |
2502 auto pSector = pSectors + i; | |
2503 | |
791 | 2504 if (pSector->pBounding.x1 > sX || pSector->pBounding.x2 < sX || |
2505 pSector->pBounding.y1 > sY || pSector->pBounding.y2 < sY || | |
2506 pSector->pBounding.z1 - 64 > sZ || pSector->pBounding.z2 + 64 < sZ) | |
2507 continue; | |
2508 | |
618
5cfb5dadf330
Margareth righ-click (addded constructor to NPCProfession) and cleaned BLV debug logs
Nomad
parents:
595
diff
changeset
|
2509 //Log::Warning(L"Sector[%u]", i); |
791 | 2510 v51 = pSector->uNumFloors + pSector->uNumPortals; |
2511 if (!v51) | |
2512 continue; | |
2513 | |
2514 | |
2515 for (uint j = 0; j < v51; ++j) | |
2516 { | |
2517 uint uFaceID; | |
2518 if (j < pSector->uNumFloors) | |
2519 uFaceID = pSector->pFloors[j]; | |
2520 else | |
2521 uFaceID = pSector->pPortals[j - pSector->uNumFloors]; | |
2522 | |
2523 auto pFace = pFaces + uFaceID; | |
2524 if (pFace->uPolygonType != POLYGON_Floor && | |
2525 pFace->uPolygonType != POLYGON_InBetweenFloorAndWall) | |
2526 continue; | |
2527 | |
2528 v54 = 0; | |
2529 v50 = pVertices[pFace->pVertexIDs[0]].y >= sY; | |
2530 | |
793 | 2531 for (uint k = 1; k <= pFace->uNumVertices; k++) |
791 | 2532 { |
2533 v59 = v50; | |
2534 | |
2535 if (v54 >= 2) | |
2536 break; | |
2537 | |
2538 auto v2 = &pVertices[pFace->pVertexIDs[k]]; | |
2539 v50 = v2->y >= sY; | |
2540 | |
793 | 2541 if (v59 == v50) |
791 | 2542 continue; |
2543 | |
2544 auto v1 = &pVertices[pFace->pVertexIDs[k - 1]]; | |
2545 v25 = v2->x >= sX ? 0 : 2; | |
2546 v26 = v25 | (v1->x < sX); | |
2547 | |
2548 if (v26 == 3) | |
2549 continue; | |
2550 | |
2551 if (!v26) | |
2552 ++v54; | |
2553 else | |
2554 { | |
2555 if (v1->x >= v2->x) | |
2556 { | |
2557 /*int _a58; | |
0 | 2558 int _a59; |
2559 | |
2560 v32 = v1->x - v2->x; | |
2561 LODWORD(v33) = v32 << 16; | |
791 | 2562 HIDWORD(v33) = v32 >> 16;*/ |
2563 //fixpoint_div(v1->x - v2->x, v1->y - v2->y); | |
2564 //_a58 = v33 / (v1->y - v2->y); | |
871 | 2565 //_a59 = fixpoint_sub0(_a58, sY - v2->y); |
791 | 2566 auto x_div_y = fixpoint_div(v1->x - v2->x, v1->y - v2->y); |
871 | 2567 auto res = fixpoint_sub0(x_div_y, sY - v2->y); // a / b * c - looks like projection |
793 | 2568 if (res + v2->x > sX) |
791 | 2569 ++v54; |
2570 } | |
2571 else | |
2572 { | |
2573 auto x_div_y = fixpoint_div(v2->x - v1->x, v2->y - v1->y); | |
871 | 2574 auto res = fixpoint_sub0(x_div_y, sY - v1->y); |
791 | 2575 |
2576 if (res + v1->x > sX) | |
2577 ++v54; | |
2578 | |
2579 /*int _a58; | |
0 | 2580 int _a59; |
791 | 2581 auto v32 = v2->x - v1->x; |
0 | 2582 LODWORD(v33) = v32 << 16; |
2583 HIDWORD(v33) = v32 >> 16; | |
2584 _a58 = v33 / (v2->y - v1->y); | |
871 | 2585 _a59 = fixpoint_sub0(_a58, sY - v1->y); |
0 | 2586 |
787 | 2587 if (_a59 + pVertices[k].x > sX) |
791 | 2588 ++v54;*/ |
0 | 2589 } |
717 | 2590 } |
791 | 2591 } |
2592 | |
2593 if (pFace->uNumVertices && v54 == 1) | |
2594 v43[v55++] = uFaceID; | |
2595 } | |
0 | 2596 } |
2597 | |
791 | 2598 v4 = v43[0]; |
0 | 2599 if ( v55 == 1 ) |
2600 return this->pFaces[v4].uSectorID; | |
2601 v37 = 0; | |
2602 if ( !v55 ) | |
2603 return 0; | |
717 | 2604 pSectorID = 0; |
0 | 2605 v53 = 0xFFFFFFu; |
2606 if ( v55 > 0 ) | |
2607 { | |
2608 v39 = sY; | |
2609 while ( 1 ) | |
2610 { | |
717 | 2611 pFace = &this->pFaces[v43[v37]]; |
2612 //pPolygonType = pFace->uPolygonType; | |
2613 if ( pFace->uPolygonType == POLYGON_Floor ) | |
0 | 2614 { |
717 | 2615 v42 = this->pVertices[*pFace->pVertexIDs].z; |
2616 v39 = sZ - v42; | |
2617 //goto LABEL_47; | |
2618 } | |
2619 if ( pFace->uPolygonType == POLYGON_InBetweenFloorAndWall ) | |
2620 { | |
2621 //v51 = pFace->zCalc1; | |
2622 v57 = (unsigned __int64)(pFace->zCalc1 * (signed __int64)(sX << 16)) >> 16; | |
2623 //v56 = sY << 16; | |
2624 //v51 = pFace->zCalc2; | |
2625 v56 = (unsigned __int64)(pFace->zCalc2 * (signed __int64)(sY << 16)) >> 16; | |
2626 v42 = (v56 + pFace->zCalc3 + v57 + 32768) >> 16; | |
662 | 2627 v39 = sZ - v42; |
0 | 2628 } |
717 | 2629 //LABEL_47: |
0 | 2630 if ( v39 >= 0 ) |
2631 { | |
2632 if ( v39 < v53 ) | |
2633 { | |
717 | 2634 pSectorID = pFace->uSectorID; |
0 | 2635 v53 = v39; |
2636 } | |
2637 } | |
2638 ++v37; | |
2639 if ( v37 >= v55 ) | |
717 | 2640 return pSectorID; |
0 | 2641 } |
2642 } | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1104
diff
changeset
|
2643 return pSectorID; |
0 | 2644 } |
2645 // 49AC17: using guessed type int var_108[50]; | |
2646 | |
2647 | |
2648 //----- (00498A41) -------------------------------------------------------- | |
2649 char BLVFace::_get_normals(Vec3_int_ *a2, Vec3_int_ *a3) | |
2650 { | |
2651 BLVFace *v3; // ebx@1 | |
2652 int v4; // eax@1 | |
2653 signed __int64 v5; // qax@2 | |
2654 double v6; // st7@8 | |
2655 Vec3_float_ a1; // [sp+Ch] [bp-Ch]@8 | |
2656 | |
2657 v3 = this; | |
2658 LOBYTE(v4) = this->uPolygonType; | |
2659 if ( (char)v4 == POLYGON_VerticalWall ) | |
2660 { | |
2661 a2->x = -this->pFacePlane_old.vNormal.y; | |
2662 LODWORD(v5) = this->pFacePlane_old.vNormal.x; | |
2663 LABEL_9: | |
2664 a2->y = v5; | |
2665 v4 = 0; | |
2666 a2->z = 0; | |
2667 a3->y = 0; | |
2668 a3->z = 0xFFFF0000u; | |
2669 LABEL_11: | |
2670 a3->x = v4; | |
2671 goto LABEL_12; | |
2672 } | |
2673 if ( (char)v4 == POLYGON_Floor || (char)v4 == POLYGON_Ceiling ) | |
2674 { | |
2675 LABEL_10: | |
2676 v4 = 0; | |
2677 a2->x = 0x10000u; | |
2678 a2->z = 0; | |
2679 a2->y = 0; | |
2680 a3->y = 0xFFFF0000u; | |
2681 a3->z = 0; | |
2682 goto LABEL_11; | |
2683 } | |
2684 if ( (char)v4 == POLYGON_InBetweenFloorAndWall || (char)v4 == POLYGON_InBetweenCeilingAndWall ) | |
2685 { | |
2686 if ( abs(this->pFacePlane_old.vNormal.z) < 46441 ) | |
2687 { | |
2688 a1.x = (double)-v3->pFacePlane_old.vNormal.y; | |
2689 a1.y = (double)v3->pFacePlane_old.vNormal.x; | |
2690 a1.z = 0.0; | |
2691 a1.Normalize(); | |
2692 v6 = a1.y * 65536.0; | |
2693 a2->x = (signed __int64)(a1.x * 65536.0); | |
2694 v5 = (signed __int64)v6; | |
2695 goto LABEL_9; | |
2696 } | |
2697 goto LABEL_10; | |
2698 } | |
2699 LABEL_12: | |
2700 if ( BYTE2(v3->uAttributes) & 0x80 ) | |
2701 { | |
2702 a2->x = -a2->x; | |
2703 a2->y = -a2->y; | |
2704 a2->z = -a2->z; | |
2705 } | |
2706 if ( BYTE3(v3->uAttributes) & 1 ) | |
2707 { | |
2708 a3->x = -a3->x; | |
2709 a3->y = -a3->y; | |
2710 a3->z = -a3->z; | |
2711 } | |
2712 return v4; | |
2713 } | |
2714 | |
2715 //----- (0044C23B) -------------------------------------------------------- | |
428 | 2716 bool BLVFaceExtra::HasEventint() |
2717 { | |
2718 signed int event_index; // eax@1 | |
2719 _evt_raw* start_evt; | |
2720 _evt_raw* end_evt; | |
2721 | |
2722 event_index = 0; | |
2723 if ( (uLevelEVT_NumEvents - 1) <= 0 ) | |
2724 return false; | |
2725 while ( pLevelEVT_Index[event_index].uEventID != this->uEventID ) | |
0 | 2726 { |
428 | 2727 ++event_index; |
2728 if ( event_index >= (signed int)(uLevelEVT_NumEvents - 1) ) | |
2729 return false; | |
0 | 2730 } |
428 | 2731 end_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index+1].uEventOffsetInEVT]; |
2732 start_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; | |
2733 if ( (end_evt->_e_type != EVENT_Exit) || (start_evt->_e_type!= EVENT_MouseOver) ) | |
2734 return false; | |
0 | 2735 else |
428 | 2736 return true; |
0 | 2737 } |
2738 | |
2739 | |
2740 | |
2741 | |
2742 //----- (0046F228) -------------------------------------------------------- | |
2743 void __cdecl BLV_UpdateDoors() | |
2744 { | |
472 | 2745 //int v0; // ebx@1 |
2746 //int v1; // edi@1 | |
2747 //BLVDoor *v2; // esi@3 | |
2748 //unsigned __int16 v3; // ax@3 | |
2749 //unsigned int v4; // ecx@5 | |
2750 //int v5; // eax@8 | |
2751 //int v6; // ecx@8 | |
2752 //int v7; // eax@12 | |
2753 //int v8; // eax@16 | |
2754 //unsigned __int8 v9; // zf@18 | |
2755 //char v10; // sf@18 | |
2756 //unsigned __int8 v11; // of@18 | |
2757 //int v12; // edi@19 | |
2758 //int v13; // ecx@19 | |
2759 //__int16 v14; // ax@19 | |
0 | 2760 BLVFace *v15; // ebx@24 |
472 | 2761 //unsigned __int16 *v16; // ecx@24 |
0 | 2762 Vec3_short_ *v17; // esi@24 |
2763 int v18; // eax@24 | |
2764 int v19; // edx@24 | |
2765 signed int v20; // eax@24 | |
472 | 2766 //Vec3_short_ *v21; // ecx@24 |
2767 //double v22; // st7@24 | |
2768 //double v23; // st6@24 | |
0 | 2769 int v24; // esi@25 |
2770 int v25; // eax@25 | |
472 | 2771 //BLVDoor *v26; // edi@25 |
0 | 2772 signed __int64 v27; // qtt@27 |
2773 BLVFaceExtra *v28; // esi@32 | |
2774 int v29; // ecx@34 | |
2775 int v30; // edx@34 | |
2776 unsigned __int64 v31; // qax@34 | |
2777 int v32; // eax@34 | |
472 | 2778 //unsigned __int16 *v33; // eax@35 |
0 | 2779 Vec3_short_ *v34; // eax@35 |
2780 int v35; // ecx@35 | |
2781 int v36; // edx@35 | |
2782 signed int v37; // eax@35 | |
2783 signed int v38; // edx@35 | |
2784 int v39; // eax@35 | |
2785 int v40; // edx@35 | |
472 | 2786 //unsigned __int8 v41; // cf@35 |
2787 //unsigned __int16 *v42; // edi@36 | |
0 | 2788 Vec3_short_ *v43; // edi@36 |
472 | 2789 //int v44; // ecx@36 |
2790 //int v45; // edi@36 | |
2791 //int v46; // ecx@36 | |
2792 //__int16 *v47; // edx@44 | |
2793 //int v48; // ecx@44 | |
0 | 2794 unsigned int v49; // ecx@46 |
2795 unsigned __int16 v50; // ax@48 | |
2796 unsigned int v51; // eax@51 | |
2797 unsigned __int16 v52; // ax@54 | |
2798 int v53; // ecx@57 | |
472 | 2799 //int v54; // edx@57 |
0 | 2800 unsigned __int64 v55; // qax@57 |
2801 int v56; // ecx@58 | |
2802 int v57; // eax@58 | |
472 | 2803 //int v58; // eax@59 |
2804 //SoundID v59; // [sp-24h] [bp-88h]@12 | |
2805 //signed int v60; // [sp-20h] [bp-84h]@12 | |
2806 //unsigned int v61; // [sp-1Ch] [bp-80h]@12 | |
2807 //signed int v62; // [sp-18h] [bp-7Ch]@12 | |
2808 //signed int v63; // [sp-14h] [bp-78h]@12 | |
2809 //int v64; // [sp-10h] [bp-74h]@12 | |
2810 //unsigned int v65; // [sp-Ch] [bp-70h]@12 | |
2811 //int v66; // [sp-8h] [bp-6Ch]@12 | |
2812 Vec3_int_ v67; | |
2813 //int v67; // [sp+8h] [bp-5Ch]@31 | |
2814 //int v68; // [sp+Ch] [bp-58h]@34 | |
2815 //int v69; // [sp+10h] [bp-54h]@34 | |
2816 Vec3_int_ v70; | |
2817 //int v70; // [sp+14h] [bp-50h]@31 | |
2818 //int v71; // [sp+18h] [bp-4Ch]@34 | |
2819 //int v72; // [sp+1Ch] [bp-48h]@34 | |
0 | 2820 int v73; // [sp+20h] [bp-44h]@24 |
472 | 2821 //__int16 v74; // [sp+24h] [bp-40h]@24 |
0 | 2822 int v75; // [sp+28h] [bp-3Ch]@36 |
2823 int v76; // [sp+2Ch] [bp-38h]@36 | |
2824 int v77; // [sp+30h] [bp-34h]@36 | |
472 | 2825 //int v78; // [sp+34h] [bp-30h]@36 |
2826 //int v79; // [sp+38h] [bp-2Ch]@19 | |
2827 //unsigned int v80; // [sp+3Ch] [bp-28h]@2 | |
2828 //int v81; // [sp+40h] [bp-24h]@1 | |
0 | 2829 int v82; // [sp+44h] [bp-20h]@35 |
2830 int v83; // [sp+48h] [bp-1Ch]@34 | |
2831 int v84; // [sp+4Ch] [bp-18h]@34 | |
2832 int v85; // [sp+50h] [bp-14h]@19 | |
2833 SoundID eDoorSoundID; // [sp+54h] [bp-10h]@1 | |
472 | 2834 //BLVDoor *v87; // [sp+58h] [bp-Ch]@3 |
0 | 2835 int v88; // [sp+5Ch] [bp-8h]@18 |
2836 int v89; // [sp+60h] [bp-4h]@6 | |
2837 | |
472 | 2838 //v0 = 0; |
2839 //v1 = 0; | |
0 | 2840 eDoorSoundID = (SoundID)pDoorSoundIDsByLocationID[dword_6BE13C_uCurrentlyLoadedLocationID]; |
472 | 2841 //v81 = 0; |
2842 //if ( pIndoor->uNumDoors > 0 ) | |
2843 for (uint i = 0; i < pIndoor->uNumDoors; ++i) | |
0 | 2844 { |
472 | 2845 auto door = pIndoor->pDoors + i; |
2846 //v80 = 0; | |
2847 //do | |
2848 //{ | |
2849 //v2 = &pIndoor->pDoors[v80 / 0x50]; | |
2850 //v87 = &pIndoor->pDoors[v80 / 0x50]; | |
2851 //v3 = door->uState; | |
2852 if (door->uState == BLVDoor::Closed || door->uState == BLVDoor::Open) | |
0 | 2853 { |
472 | 2854 door->uAttributes &= 0xFFFFFFFDu; |
0 | 2855 goto LABEL_62; |
2856 } | |
472 | 2857 door->uTimeSinceTriggered += pEventTimer->uTimeElapsed; |
2858 //v4 = door->uTimeSinceTriggered; | |
2859 if (door->uState == BLVDoor::Opening) | |
0 | 2860 { |
472 | 2861 v89 = (signed int)(door->uTimeSinceTriggered * door->uCloseSpeed) / 128; |
2862 if ( v89 >= door->uMoveLength ) | |
0 | 2863 { |
472 | 2864 v89 = door->uMoveLength; |
2865 door->uState = BLVDoor::Open; | |
0 | 2866 LABEL_10: |
472 | 2867 if ( !(door->uAttributes & 6) && door->uNumVertices != 0) |
0 | 2868 { |
472 | 2869 //v66 = 0; |
2870 //v65 = 0; | |
2871 //v64 = 0; | |
862 | 2872 //v7 = PID(OBJECT_BLVDoor,i); |
472 | 2873 //v63 = 0; |
2874 //v62 = -1; | |
862 | 2875 //LOBYTE(v7) = PID(OBJECT_BLVDoor,i); |
472 | 2876 //v61 = 0; |
862 | 2877 //v60 = PID(OBJECT_BLVDoor,i); |
472 | 2878 //v59 = (SoundID)((int)eDoorSoundID + 1); |
2879 //LABEL_17: | |
862 | 2880 pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), PID(OBJECT_BLVDoor,i), 0, -1, 0, 0, 0, 0); |
472 | 2881 //goto LABEL_18; |
0 | 2882 } |
2883 goto LABEL_18; | |
2884 } | |
2885 } | |
2886 else | |
2887 { | |
472 | 2888 auto v5 = (signed int)(door->uTimeSinceTriggered * door->uOpenSpeed) / 128; |
2889 //v6 = door->uMoveLength; | |
2890 if ( v5 >= door->uMoveLength) | |
0 | 2891 { |
472 | 2892 v89 = 0; |
2893 door->uState = BLVDoor::Closed; | |
0 | 2894 goto LABEL_10; |
2895 } | |
472 | 2896 v89 = door->uMoveLength - v5; |
0 | 2897 } |
472 | 2898 if ( !(door->uAttributes & 6) && door->uNumVertices) |
0 | 2899 { |
472 | 2900 //v66 = 0; |
2901 //v65 = 0; | |
2902 //v64 = 0; | |
862 | 2903 //v8 = PID(OBJECT_BLVDoor,i); |
472 | 2904 //v63 = 0; |
2905 //v62 = -1; | |
2906 //LOBYTE(v8) = 8 * v1 | 1; | |
2907 //v61 = 1; | |
862 | 2908 //v60 = PID(OBJECT_BLVDoor,i); |
472 | 2909 //v59 = eDoorSoundID; |
862 | 2910 pAudioPlayer->PlaySound(eDoorSoundID, PID(OBJECT_BLVDoor,i), 1, -1, 0, 0, 0, 0); |
472 | 2911 //goto LABEL_18; |
0 | 2912 } |
2913 LABEL_18: | |
472 | 2914 //v11 = __OFSUB__(v2->uNumVertices, 0); |
2915 //v9 = v2->uNumVertices == 0; | |
2916 //v10 = (signed __int16)(v2->uNumVertices - 0) < 0; | |
2917 //v88 = 0; | |
2918 //if (door->uNumVertices > 0) | |
2919 for (uint j = 0; j < door->uNumVertices; ++j) | |
0 | 2920 { |
472 | 2921 //do |
2922 //{ | |
2923 //v12 = v88; | |
2924 //v13 = door->pVertexIDs[v88]; | |
2925 //v85 = v89; | |
2926 //v79 = door->vDirection.x; | |
2927 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
2928 //v13 *= 6; | |
2929 pIndoor->pVertices[door->pVertexIDs[j]].x = ((unsigned int)(door->vDirection.x * v89) >> 16) + door->pXOffsets[j]; | |
2930 //v85 = v89; | |
2931 //v79 = door->vDirection.y; | |
2932 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
2933 pIndoor->pVertices[door->pVertexIDs[j]].y = ((unsigned int)(door->vDirection.y * v89) >> 16) + door->pYOffsets[j]; | |
2934 //v85 = v89; | |
2935 //v79 = door->vDirection.z; | |
2936 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
2937 //v14 = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j]; | |
2938 pIndoor->pVertices[door->pVertexIDs[j]].z = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j]; | |
2939 //++v88; | |
2940 //} | |
2941 //while ( v88 < door->uNumVertices ); | |
2942 //v1 = v81; | |
0 | 2943 } |
472 | 2944 //v11 = __OFSUB__(v2->uNumFaces, 0); |
2945 //v9 = v2->uNumFaces == 0; | |
2946 //v10 = (signed __int16)(v2->uNumFaces - 0) < 0; | |
2947 v88 = 0; | |
2948 if (door->uNumFaces > 0) | |
0 | 2949 { |
2950 while ( 1 ) | |
2951 { | |
472 | 2952 v15 = &pIndoor->pFaces[door->pFaceIDs[v88]]; |
2953 //v16 = v15->pVertexIDs; | |
2954 v17 = &pIndoor->pVertices[v15->pVertexIDs[0]]; | |
0 | 2955 v18 = v15->pFacePlane_old.vNormal.y; |
2956 v73 = *(int *)&v17->x; | |
472 | 2957 //v74 = v17->z; |
0 | 2958 v19 = v15->pFacePlane_old.vNormal.z; |
472 | 2959 v20 = -(v19 * (int)v17->z + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18); |
0 | 2960 v15->pFacePlane_old.dist = v20; |
472 | 2961 //v21 = &pIndoor->pVertices[v15->pVertexIDs[0]]; |
2962 //v79 = v21->x; | |
2963 //v22 = (double)v21->x; | |
2964 //v23 = (double)v21->y; | |
2965 //v79 = v21->z; | |
2966 v15->pFacePlane.dist = -((double)v17->z * v15->pFacePlane.vNormal.z | |
2967 + (double)v17->y * v15->pFacePlane.vNormal.y | |
2968 + (double)v17->x * v15->pFacePlane.vNormal.x); | |
0 | 2969 if ( v19 ) |
2970 { | |
2971 v24 = abs(v20 >> 15); | |
2972 v25 = abs(v15->pFacePlane_old.vNormal.z); | |
472 | 2973 //v26 = v87; |
0 | 2974 if ( v24 > v25 ) |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2975 Abortf("Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]", |
472 | 2976 door->uDoorID, |
2977 door->pFaceIDs[v88], | |
0 | 2978 v15->pFacePlane_old.dist, |
2979 v15->pFacePlane_old.vNormal.z); | |
472 | 2980 //v79 = v15->pFacePlane_old.vNormal.z; |
2981 //v85 = v15->pFacePlane_old.dist; | |
2982 LODWORD(v27) = v15->pFacePlane_old.dist << 16; | |
2983 HIDWORD(v27) = v15->pFacePlane_old.dist >> 16; | |
2984 //v85 = v27 / v15->pFacePlane_old.vNormal.z; | |
2985 v15->zCalc3 = -v27 / v15->pFacePlane_old.vNormal.z; | |
0 | 2986 } |
472 | 2987 /*else |
0 | 2988 { |
2989 v26 = v87; | |
472 | 2990 }*/ |
0 | 2991 if ( BYTE2(v15->uAttributes) & 4 || pRenderer->pRenderD3D ) |
472 | 2992 v15->_get_normals(&v70, &v67); |
0 | 2993 v28 = &pIndoor->pFaceExtras[v15->uFaceExtraID]; |
2994 if ( !pRenderer->pRenderD3D ) | |
2995 { | |
2996 if ( !(BYTE2(v15->uAttributes) & 4) ) | |
2997 goto LABEL_59; | |
472 | 2998 //v79 = door->vDirection.x; |
2999 v83 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16; | |
3000 //v85 = v71; | |
3001 //v79 = door->vDirection.y; | |
3002 v85 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16; | |
3003 //v84 = v72; | |
3004 //v79 = door->vDirection.z; | |
3005 v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16; | |
3006 //v79 = v83 + v85 + v84; | |
0 | 3007 v29 = v89; |
472 | 3008 //v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; |
3009 v28->sTextureDeltaU = -((v83 + v85 + v84) * (signed __int64)v89) >> 16; | |
3010 //v79 = door->vDirection.x; | |
3011 v85 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16; | |
3012 //v83 = v68; | |
3013 //v79 = door->vDirection.y; | |
3014 v83 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16; | |
3015 //v84 = v69; | |
3016 //v79 = door->vDirection.z; | |
3017 v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; | |
3018 //v30 = v83 + v84; | |
3019 //v79 = v85 + v30; | |
3020 v31 = (v85 + v83 + v84) * (signed __int64)v29; | |
3021 //v83 = v31 >> 16; | |
0 | 3022 v32 = v31 >> 16; |
3023 goto LABEL_58; | |
3024 } | |
3025 v28->sTextureDeltaU = 0; | |
3026 v28->sTextureDeltaV = 0; | |
472 | 3027 //v33 = v15->pVertexIDs; |
3028 //v85 = 1; | |
3029 v34 = &pIndoor->pVertices[v15->pVertexIDs[0]]; | |
0 | 3030 v35 = v34->z; |
3031 v36 = v34->y; | |
3032 v82 = v34->x; | |
472 | 3033 //v79 = v36; |
3034 v37 = v70.x * v82 + v70.y * v36 + v70.z * v35; | |
3035 v38 = v67.x * v82 + v67.y * v36 + v67.z * v35; | |
0 | 3036 v39 = v37 >> 16; |
3037 *v15->pVertexUIDs = v39; | |
3038 v40 = v38 >> 16; | |
3039 *v15->pVertexVIDs = v40; | |
472 | 3040 //v41 = v15->uNumVertices < 1u; |
3041 //v9 = v15->uNumVertices == 1; | |
3042 //v83 = v40; | |
0 | 3043 v84 = v39; |
3044 v82 = v40; | |
472 | 3045 //if (v15->uNumVertices > 1) |
3046 for (uint j = 1; j < v15->uNumVertices; ++j) | |
0 | 3047 { |
472 | 3048 //do |
3049 //{ | |
3050 //v42 = v15->pVertexIDs; | |
3051 //v75 = 2 * v85; | |
3052 v43 = &pIndoor->pVertices[v15->pVertexIDs[j]]; | |
3053 //v79 = v43->z; | |
3054 //v44 = v43->y; | |
3055 //v45 = v43->x; | |
3056 //v78 = v43->y; | |
3057 v76 = ((__int64)v70.z * v43->z + (__int64)v70.x * v43->x + (__int64)v70.y * v43->y) >> 16; | |
3058 //v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16; | |
3059 v77 = ((__int64)v67.x * v43->x + (__int64)v67.y * v43->y + (__int64)v43->z * v67.z) >> 16; | |
0 | 3060 if ( v76 < v39 ) |
3061 v39 = v76; | |
472 | 3062 if ( v77 < v40 ) |
3063 v40 = v77; | |
0 | 3064 if ( v76 > v84 ) |
3065 v84 = v76; | |
472 | 3066 if ( v77 > v82 ) |
3067 v82 = v77; | |
3068 //v40 = v83; | |
3069 //v47 = v15->pVertexUIDs; | |
3070 //v48 = v75; | |
3071 //++v85; | |
3072 v15->pVertexUIDs[j] = v76; | |
3073 v15->pVertexVIDs[j] = v77; | |
3074 //} | |
3075 //while ( v85 < v15->uNumVertices ); | |
3076 //v26 = v87; | |
0 | 3077 } |
3078 v49 = v15->uAttributes; | |
3079 if ( BYTE1(v49) & 0x10 ) | |
3080 goto LABEL_50; | |
3081 if ( SBYTE1(v49) < 0 ) | |
3082 { | |
3083 v50 = v15->uBitmapID; | |
3084 if ( v50 != -1 ) | |
3085 break; | |
3086 } | |
3087 LABEL_51: | |
3088 v51 = v15->uAttributes; | |
3089 if ( v51 & 8 ) | |
3090 { | |
3091 v28->sTextureDeltaV -= v40; | |
3092 } | |
3093 else | |
3094 { | |
3095 if ( v51 & 0x20000 ) | |
3096 { | |
3097 v52 = v15->uBitmapID; | |
3098 if ( v52 != -1 ) | |
945 | 3099 v28->sTextureDeltaV -= v82 + pBitmaps_LOD->GetTexture(v52)->uTextureHeight; |
0 | 3100 } |
3101 } | |
3102 if ( BYTE2(v15->uAttributes) & 4 ) | |
3103 { | |
472 | 3104 //v75 = door->vDirection.x; |
3105 v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16; | |
3106 //v82 = v71; | |
3107 //v75 = door->vDirection.y; | |
3108 v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16; | |
3109 //v83 = v72; | |
3110 //v75 = door->vDirection.z; | |
3111 v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16; | |
3112 v75 = v84 + v82 + v83; | |
0 | 3113 v53 = v89; |
3114 v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16; | |
472 | 3115 v28->sTextureDeltaU = -v82; |
3116 //v75 = door->vDirection.x; | |
3117 v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16; | |
3118 //v82 = v68; | |
3119 //v75 = door->vDirection.y; | |
3120 v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16; | |
3121 //v83 = v69; | |
3122 //v75 = door->vDirection.z; | |
3123 v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; | |
3124 //v54 = v82 + v83; | |
3125 v75 = v84 + v82 + v83; | |
3126 v55 = v75 * (signed __int64)v53; | |
3127 //v82 = v55 >> 16; | |
0 | 3128 v32 = v55 >> 16; |
3129 LABEL_58: | |
3130 v56 = v88; | |
3131 v57 = -v32; | |
3132 v28->sTextureDeltaV = v57; | |
472 | 3133 v28->sTextureDeltaU += door->pDeltaUs[v56]; |
3134 v28->sTextureDeltaV = v57 + door->pDeltaVs[v56]; | |
0 | 3135 } |
3136 LABEL_59: | |
472 | 3137 //v58 = door->uNumFaces; |
0 | 3138 ++v88; |
472 | 3139 if ( v88 >= door->uNumFaces) |
0 | 3140 { |
472 | 3141 //v1 = v81; |
3142 //v0 = 0; | |
0 | 3143 goto LABEL_62; |
3144 } | |
472 | 3145 //v2 = v87; |
0 | 3146 } |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3147 LOWORD(v39) = v84; |
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3148 if (v15->uBitmapID != -1) |
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3149 LOWORD(v39) += pBitmaps_LOD->pTextures[v15->uBitmapID].uTextureWidth; |
0 | 3150 LABEL_50: |
3151 v28->sTextureDeltaU -= v39; | |
3152 goto LABEL_51; | |
3153 } | |
3154 LABEL_62: | |
472 | 3155 ; |
3156 //v80 += 80; | |
3157 //++v1; | |
3158 //v81 = v1; | |
3159 //} | |
3160 //while ( v1 < pIndoor->uNumDoors ); | |
0 | 3161 } |
3162 } | |
3163 // 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID; | |
3164 | |
3165 //----- (0046F90C) -------------------------------------------------------- | |
3166 void __cdecl UpdateActors_BLV() | |
3167 { | |
3168 Actor *v0; // esi@2 | |
3169 unsigned __int16 v1; // ax@2 | |
3170 int v2; // edi@6 | |
3171 int v3; // eax@6 | |
3172 int v4; // eax@8 | |
3173 __int16 v5; // ax@11 | |
3174 signed int v6; // ebx@14 | |
3175 unsigned __int8 v7; // zf@14 | |
3176 unsigned __int8 v8; // sf@14 | |
3177 signed __int16 v9; // ax@17 | |
3178 signed __int64 v10; // qax@18 | |
3179 unsigned __int16 v11; // ax@21 | |
3180 int v12; // eax@29 | |
3181 unsigned __int64 v13; // qax@29 | |
3182 int v14; // eax@30 | |
3183 unsigned __int64 v15; // qax@30 | |
3184 int v16; // ecx@33 | |
3185 BLVFace *v17; // edx@33 | |
3186 int v18; // ecx@33 | |
3187 BLVFace *v19; // eax@34 | |
3188 int v20; // ecx@46 | |
3189 int v21; // eax@46 | |
3190 int v22; // edi@46 | |
3191 int v23; // eax@48 | |
3192 unsigned int v24; // eax@51 | |
3193 int v25; // eax@52 | |
3194 int v26; // ebx@54 | |
3195 int v27; // ST08_4@54 | |
3196 int v28; // edi@54 | |
3197 int v29; // eax@54 | |
3198 int v30; // ecx@62 | |
3199 int v31; // ebx@62 | |
3200 int v32; // eax@62 | |
3201 int v33; // eax@64 | |
3202 unsigned int v34; // ecx@64 | |
3203 int v35; // ecx@64 | |
3204 signed int v36; // edx@85 | |
3205 signed int v37; // ebx@85 | |
3206 BLVFace *v38; // edi@89 | |
3207 int v39; // ecx@90 | |
3208 int v40; // ebx@90 | |
3209 PolygonType v41; // al@94 | |
3210 int v42; // eax@96 | |
3211 __int16 v43; // dx@96 | |
3212 int v44; // ecx@96 | |
3213 int v45; // edi@101 | |
3214 int v46; // edi@101 | |
3215 int v47; // eax@101 | |
3216 unsigned __int64 v48; // qax@101 | |
3217 unsigned __int8 v49; // zf@103 | |
3218 unsigned __int8 v50; // sf@103 | |
3219 unsigned __int8 v51; // of@103 | |
3220 AIDirection v52; // [sp+0h] [bp-60h]@75 | |
3221 AIDirection v53; // [sp+1Ch] [bp-44h]@116 | |
3222 int v54; // [sp+38h] [bp-28h]@53 | |
3223 unsigned int uSectorID; // [sp+3Ch] [bp-24h]@6 | |
3224 int v56; // [sp+40h] [bp-20h]@6 | |
3225 unsigned int _this; // [sp+44h] [bp-1Ch]@51 | |
3226 int v58; // [sp+48h] [bp-18h]@51 | |
3227 int v59; // [sp+4Ch] [bp-14h]@8 | |
3228 unsigned int uFaceID; // [sp+50h] [bp-10h]@6 | |
3229 int v61; // [sp+54h] [bp-Ch]@14 | |
3230 int v62; // [sp+58h] [bp-8h]@6 | |
3231 unsigned int v63; // [sp+5Ch] [bp-4h]@1 | |
3232 | |
3233 v63 = 0; | |
3234 if ( (signed int)uNumActors > 0 ) | |
3235 { | |
3236 while ( 1 ) | |
3237 { | |
3238 v0 = &pActors[v63]; | |
3239 v1 = v0->uAIState; | |
3240 if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed ) | |
3241 goto LABEL_123; | |
3242 uSectorID = v0->uSectorID; | |
783 | 3243 v2 = collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, &uSectorID, &uFaceID); |
0 | 3244 v0->uSectorID = uSectorID; |
3245 v3 = v0->pMonsterInfo.uFlying; | |
3246 v56 = v2; | |
3247 v62 = v3; | |
3248 if ( !v0->CanAct() ) | |
3249 v62 = 0; | |
3250 v4 = v0->vPosition.z; | |
3251 v59 = 0; | |
3252 if ( v4 > v2 + 1 ) | |
3253 v59 = 1; | |
3254 if ( v2 <= -30000 ) | |
3255 { | |
3256 v5 = pIndoor->GetSector(v0->vPosition.x, v0->vPosition.y, v4); | |
3257 v0->uSectorID = v5; | |
3258 if ( !v5 | |
723 | 3259 || (v56 = BLV_GetFloorLevel(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &uFaceID), v56 == -30000) ) |
0 | 3260 goto LABEL_123; |
3261 } | |
305 | 3262 if ( v0->uCurrentActionAnimation == ANIM_Walking) |
0 | 3263 { |
3264 v6 = v0->uMovementSpeed; | |
3265 v7 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0; | |
3266 v8 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0; | |
3267 v61 = v0->uMovementSpeed; | |
3268 if ( !v8 && (!(v8 | v7) || LODWORD(v0->pActorBuffs[7].uExpireTime)) ) | |
3269 { | |
3270 v9 = v0->pActorBuffs[7].uPower; | |
3271 if ( v9 ) | |
3272 LODWORD(v10) = v6 / (unsigned __int16)v9; | |
3273 else | |
3274 v10 = (signed __int64)((double)v61 * 0.5); | |
3275 v6 = v10; | |
3276 v61 = v10; | |
3277 } | |
3278 v11 = v0->uAIState; | |
3279 if ( v11 == 6 || v11 == 7 ) | |
3280 { | |
3281 v6 *= 2; | |
3282 v61 = v6; | |
3283 } | |
1340 | 3284 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 ) |
0 | 3285 v6 = (signed __int64)((double)v61 * flt_6BE3AC_debug_recmod1_x_1_6); |
3286 if ( v6 > 1000 ) | |
3287 v6 = 1000; | |
323 | 3288 v12 = stru_5C6E00->Cos(v0->uYawAngle); |
0 | 3289 uSectorID = v12; |
3290 v13 = v12 * (signed __int64)v6; | |
3291 v61 = v13 >> 16; | |
3292 v0->vVelocity.x = WORD1(v13); | |
323 | 3293 uSectorID = stru_5C6E00->Sin(v0->uYawAngle); |
0 | 3294 v61 = (unsigned __int64)(uSectorID * (signed __int64)v6) >> 16; |
3295 v7 = v62 == 0; | |
3296 v0->vVelocity.y = (unsigned int)(uSectorID * v6) >> 16; | |
3297 if ( !v7 ) | |
3298 { | |
323 | 3299 v14 = stru_5C6E00->Sin(v0->uPitchAngle); |
0 | 3300 uSectorID = v14; |
3301 v15 = v14 * (signed __int64)v6; | |
3302 v61 = v15 >> 16; | |
3303 v0->vVelocity.z = WORD1(v15); | |
3304 } | |
3305 } | |
3306 else | |
3307 { | |
3308 v61 = v0->vVelocity.x; | |
3309 uSectorID = 55000; | |
3310 v61 = (unsigned __int64)(55000i64 * v61) >> 16; | |
3311 v0->vVelocity.x = v61; | |
3312 v61 = v0->vVelocity.y; | |
3313 v61 = (unsigned __int64)(uSectorID * (signed __int64)v61) >> 16; | |
3314 v7 = v62 == 0; | |
3315 v0->vVelocity.y = v61; | |
3316 if ( !v7 ) | |
3317 { | |
3318 uSectorID = 55000; | |
3319 v61 = v0->vVelocity.z; | |
3320 v61 = (unsigned __int64)(55000i64 * v61) >> 16; | |
3321 v0->vVelocity.z = v61; | |
3322 } | |
3323 } | |
3324 v16 = v0->vPosition.z; | |
3325 v17 = pIndoor->pFaces; | |
3326 v51 = __OFSUB__(v16, v56); | |
3327 v8 = v16 - v56 < 0; | |
3328 v18 = uFaceID; | |
3329 if ( v8 ^ v51 ) | |
3330 { | |
3331 v0->vPosition.z = v56 + 1; | |
3332 v19 = &v17[v18]; | |
3333 if ( v19->uPolygonType == 3 ) | |
3334 { | |
3335 if ( v0->vVelocity.z < 0 ) | |
3336 v0->vVelocity.z = 0; | |
3337 } | |
3338 else | |
3339 { | |
3340 if ( v19->pFacePlane_old.vNormal.z < 45000 ) | |
3341 v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
3342 } | |
3343 } | |
3344 else | |
3345 { | |
3346 if ( v59 && !v62 ) | |
3347 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
3348 } | |
3349 if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y + v0->vVelocity.z * v0->vVelocity.z >= 400 ) | |
3350 break; | |
3351 v0->vVelocity.z = 0; | |
3352 v0->vVelocity.y = 0; | |
3353 v0->vVelocity.x = 0; | |
3354 if ( BYTE2(v17[v18].uAttributes) & 0x40 ) | |
3355 { | |
3356 if (v0->uAIState == Dead) | |
3357 v0->uAIState = Removed; | |
3358 } | |
3359 LABEL_123: | |
3360 ++v63; | |
3361 if ( (signed int)v63 >= (signed int)uNumActors ) | |
3362 return; | |
3363 } | |
3364 v20 = v0->uActorRadius; | |
3365 v21 = v0->uActorHeight; | |
3366 stru_721530.field_84 = -1; | |
3367 stru_721530.field_70 = 0; | |
3368 uSectorID = 0; | |
3369 stru_721530.field_0 = 1; | |
3370 stru_721530.field_8 = v20; | |
3371 stru_721530.prolly_normal_d = v20; | |
3372 stru_721530.field_C = v21; | |
3373 v22 = 0; | |
3374 while ( 1 ) | |
3375 { | |
3376 stru_721530.field_34.x = v0->vPosition.x; | |
3377 stru_721530.normal.x = stru_721530.field_34.x; | |
3378 stru_721530.field_34.y = v0->vPosition.y; | |
3379 stru_721530.normal.y = stru_721530.field_34.y; | |
3380 v23 = v0->vPosition.z; | |
3381 stru_721530.normal.z = v23 + v20 + 1; | |
3382 stru_721530.field_34.z = v23 - v20 + stru_721530.field_C - 1; | |
3383 if ( stru_721530.field_34.z < stru_721530.normal.z ) | |
3384 stru_721530.field_34.z = v23 + v20 + 1; | |
3385 stru_721530.field_1C = v0->vVelocity.x; | |
3386 stru_721530.field_20 = v0->vVelocity.y; | |
3387 stru_721530.field_24 = v0->vVelocity.z; | |
3388 stru_721530.uSectorID = v0->uSectorID; | |
3389 if ( !stru_721530._47050A(v22) ) | |
3390 { | |
3391 v58 = v22; | |
3392 v24 = 8 * v63; | |
862 | 3393 LOBYTE(v24) = PID(OBJECT_Actor,v63); |
0 | 3394 v61 = v22; |
3395 _this = v24; | |
3396 do | |
3397 { | |
3398 _46E44E_collide_against_faces_and_portals(1u); | |
3399 _46E0B2_collide_against_decorations(); | |
3400 _46EF01_collision_chech_player(0); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3401 _46ED8A_collide_against_sprite_objects(_this); |
0 | 3402 v25 = 0; |
3403 v56 = 0; | |
3404 if ( ai_arrays_size > v22 ) | |
3405 { | |
3406 do | |
3407 { | |
390 | 3408 v54 = ai_near_actors_ids[v25]; |
0 | 3409 if ( v54 != v63 ) |
3410 { | |
3411 v26 = v54; | |
3412 v27 = abs(pActors[v54].vPosition.z - v0->vPosition.z); | |
3413 v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y); | |
3414 v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x); | |
322 | 3415 if ( int_get_vector_length(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius |
0 | 3416 && _46DF1A_collide_against_actor(v54, 40) ) |
3417 ++v58; | |
3418 v22 = 0; | |
3419 } | |
3420 v25 = v56++ + 1; | |
3421 } | |
3422 while ( v56 < ai_arrays_size ); | |
3423 } | |
3424 if ( _46F04E_collide_against_portals() ) | |
3425 break; | |
3426 ++v61; | |
3427 } | |
3428 while ( v61 < 100 ); | |
3429 v56 = v58 > 1; | |
3430 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
3431 { | |
3432 v30 = stru_721530.normal2.x; | |
3433 v31 = stru_721530.normal2.y; | |
3434 v32 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
3435 } | |
3436 else | |
3437 { | |
3438 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
3439 v30 = v58 + v0->vPosition.x; | |
3440 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
3441 v31 = v58 + v0->vPosition.y; | |
3442 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
3443 v32 = v58 + v0->vPosition.z; | |
3444 } | |
783 | 3445 v33 = collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID); |
0 | 3446 v34 = pIndoor->pFaces[uFaceID].uAttributes; |
3447 v35 = v34 & 0x400000; | |
3448 if (v35 && v0->uAIState == Dead) | |
3449 { | |
3450 v0->uAIState = Removed; | |
3451 goto LABEL_120; | |
3452 } | |
3453 if ( v59 != v22 || v62 != v22 || v35 == v22 ) | |
3454 { | |
3455 if ( v33 == -30000 ) | |
3456 goto LABEL_120; | |
3457 if ( v0->uCurrentActionAnimation != 1 || v33 >= v0->vPosition.z - 100 || v59 != v22 || v62 != v22 ) | |
3458 { | |
3459 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
3460 { | |
3461 v0->vPosition.x = LOWORD(stru_721530.normal2.x); | |
3462 v0->vPosition.y = LOWORD(stru_721530.normal2.y); | |
3463 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; | |
3464 v0->uSectorID = LOWORD(stru_721530.uSectorID); | |
3465 goto LABEL_123; | |
3466 } | |
3467 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
3468 v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16; | |
3469 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
3470 v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16; | |
3471 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
3472 v36 = stru_721530.uFaceID; | |
3473 v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; | |
3474 v0->uSectorID = LOWORD(stru_721530.uSectorID); | |
3475 stru_721530.field_70 += stru_721530.field_7C; | |
848 | 3476 v37 = PID_ID(v36); |
3477 if ( PID_TYPE(v36) != OBJECT_Actor) | |
0 | 3478 { |
848 | 3479 if ( PID_TYPE(v36) != OBJECT_Player) |
0 | 3480 { |
848 | 3481 if ( PID_TYPE(v36) == OBJECT_Decoration) |
0 | 3482 { |
295 | 3483 _this = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); |
0 | 3484 v45 = stru_5C6E00->Atan2( |
3485 v0->vPosition.x - pLevelDecorations[v37].vPosition.x, | |
3486 v0->vPosition.y - pLevelDecorations[v37].vPosition.y); | |
323 | 3487 v54 = stru_5C6E00->Cos(v45); |
0 | 3488 v56 = (unsigned __int64)(v54 * (signed __int64)(signed int)_this) >> 16; |
3489 v46 = v45 - stru_5C6E00->uIntegerHalfPi; | |
3490 v0->vVelocity.x = v54 * _this >> 16; | |
323 | 3491 v47 = stru_5C6E00->Sin(v45); |
0 | 3492 v54 = v47; |
3493 v48 = v47 * (signed __int64)(signed int)_this; | |
3494 v56 = v48 >> 16; | |
3495 v0->vVelocity.y = WORD1(v48); | |
3496 goto LABEL_119; | |
3497 } | |
848 | 3498 if ( PID_TYPE(v36) == OBJECT_BModel) |
0 | 3499 { |
3500 stru_721530.field_84 = v36 >> 3; | |
3501 v38 = &pIndoor->pFaces[v37]; | |
3502 if ( v38->uPolygonType == 3 ) | |
3503 { | |
3504 v39 = v0->vVelocity.x; | |
3505 v40 = v0->vVelocity.y * v0->vVelocity.y; | |
3506 v0->vVelocity.z = 0; | |
3507 v0->vPosition.z = pIndoor->pVertices[*v38->pVertexIDs].z + 1; | |
3508 if ( v39 * v39 + v40 < 400 ) | |
3509 { | |
3510 v0->vVelocity.y = 0; | |
3511 v0->vVelocity.x = 0; | |
3512 goto LABEL_119; | |
3513 } | |
3514 } | |
3515 else | |
3516 { | |
3517 v61 = abs(v38->pFacePlane_old.vNormal.x * v0->vVelocity.x + v38->pFacePlane_old.vNormal.y | |
3518 * v0->vVelocity.y | |
3519 + v38->pFacePlane_old.vNormal.z | |
3520 * v0->vVelocity.z) >> 16; | |
3521 if ( stru_721530.field_64 >> 3 > v61 ) | |
3522 v61 = stru_721530.field_64 >> 3; | |
3523 v58 = v38->pFacePlane_old.vNormal.x; | |
3524 v58 = (unsigned __int64)(v61 * (signed __int64)v58) >> 16; | |
3525 _this = v38->pFacePlane_old.vNormal.y; | |
3526 _this = (unsigned __int64)(v61 * (signed __int64)(signed int)_this) >> 16; | |
3527 v56 = v38->pFacePlane_old.vNormal.z; | |
3528 v56 = (unsigned __int64)(v61 * (signed __int64)v56) >> 16; | |
3529 v0->vVelocity.x += v58; | |
3530 v0->vVelocity.y += _this; | |
3531 v0->vVelocity.z += v56; | |
3532 v41 = v38->uPolygonType; | |
3533 if ( v41 != 4 && v41 != 3 ) | |
3534 { | |
3535 v42 = v38->pFacePlane_old.vNormal.x; | |
3536 v43 = v0->vPosition.z; | |
3537 v44 = stru_721530.prolly_normal_d | |
3538 - ((v38->pFacePlane_old.dist | |
3539 + v38->pFacePlane_old.vNormal.z * v0->vPosition.z | |
3540 + v38->pFacePlane_old.vNormal.y * v0->vPosition.y | |
3541 + v42 * v0->vPosition.x) >> 16); | |
3542 if ( v44 > 0 ) | |
3543 { | |
3544 v0->vPosition.x += (unsigned int)(v44 * v42) >> 16; | |
3545 v0->vPosition.y += (unsigned int)(v44 * v38->pFacePlane_old.vNormal.y) >> 16; | |
3546 v0->vPosition.z = v43 + ((unsigned int)(v44 * v38->pFacePlane_old.vNormal.z) >> 16); | |
3547 } | |
3548 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y); | |
3549 } | |
3550 } | |
3551 if ( BYTE3(v38->uAttributes) & 8 ) | |
3552 EventProcessor(pIndoor->pFaceExtras[v38->uFaceExtraID].uEventID, 0, 1); | |
3553 } | |
3554 LABEL_119: | |
3555 v56 = v0->vVelocity.x; | |
3556 v54 = 58500; | |
3557 v56 = (unsigned __int64)(58500i64 * v56) >> 16; | |
3558 v0->vVelocity.x = v56; | |
3559 v56 = v0->vVelocity.y; | |
3560 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16; | |
3561 v54 = 58500; | |
3562 v0->vVelocity.y = v56; | |
3563 v56 = v0->vVelocity.z; | |
3564 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16; | |
3565 v22 = 0; | |
3566 v0->vVelocity.z = v56; | |
3567 goto LABEL_120; | |
3568 } | |
3569 if ( v0->GetActorsRelation(0) ) | |
3570 { | |
1167 | 3571 v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime), v22); |
3572 v49 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == v22; | |
3573 v50 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) - v22 < 0; | |
0 | 3574 v0->vVelocity.y = v22; |
3575 v0->vVelocity.x = v22; | |
3576 if ( !(v50 ^ v51) | |
1167 | 3577 && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > v22) ) |
3578 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
0 | 3579 viewparams->bRedrawGameUI = 1; |
3580 goto LABEL_119; | |
3581 } | |
3582 v36 = stru_721530.uFaceID; | |
3583 LABEL_118: | |
1060 | 3584 Actor::AI_FaceObject(v63, v36, v22, (AIDirection *)v22); |
0 | 3585 goto LABEL_119; |
3586 } | |
1340 | 3587 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) ) |
0 | 3588 goto LABEL_119; |
3589 if ( v0->pMonsterInfo.uHostilityType ) | |
3590 { | |
3591 if ( v56 == v22 ) | |
3592 goto LABEL_114; | |
3593 } | |
3594 else | |
3595 { | |
3596 if ( v56 == v22 ) | |
3597 { | |
3598 if ( !pActors[v37].pMonsterInfo.uHostilityType ) | |
3599 goto LABEL_118; | |
3600 LABEL_114: | |
1060 | 3601 Actor::AI_Flee(v63, v36, v22, (AIDirection *)v22); |
0 | 3602 goto LABEL_119; |
3603 } | |
3604 } | |
414 | 3605 Actor::AI_StandOrBored(v63, 4, v22, &v53); |
0 | 3606 goto LABEL_119; |
3607 } | |
3608 if ( v0->vPosition.x & 1 ) | |
3609 v0->uYawAngle += 100; | |
3610 else | |
3611 v0->uYawAngle -= 100; | |
3612 } | |
3613 else | |
3614 { | |
1340 | 3615 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) ) |
0 | 3616 goto LABEL_123; |
3617 if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 ) | |
3618 { | |
414 | 3619 Actor::AI_StandOrBored(v63, 4, v22, &v52); |
0 | 3620 goto LABEL_123; |
3621 } | |
3622 } | |
3623 } | |
3624 LABEL_120: | |
3625 ++uSectorID; | |
3626 if ( uSectorID >= 100 ) | |
3627 goto LABEL_123; | |
3628 v20 = stru_721530.prolly_normal_d; | |
3629 } | |
3630 } | |
3631 } | |
3632 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); | |
3633 // 4F75D8: using guessed type int ai_arrays_size; | |
3634 | |
3635 | |
3636 | |
3637 | |
3638 | |
3639 | |
3640 //----- (00460A78) -------------------------------------------------------- | |
3641 void __thiscall PrepareToLoadBLV(unsigned int bLoading) | |
3642 { | |
3643 unsigned int v1; // ebx@1 | |
3644 unsigned int v2; // eax@8 | |
3645 MapInfo *v3; // edi@9 | |
3646 int v4; // eax@11 | |
3647 int v5; // eax@12 | |
3648 int v6; // eax@13 | |
3649 int v7; // esi@27 | |
3650 SpawnPointMM7 *v8; // edx@28 | |
3651 //char v9; // bl@33 | |
3652 //int v10; // eax@34 | |
3653 //char *v11; // ecx@37 | |
3654 //int v12; // edi@44 | |
3655 //unsigned int v13; // edi@48 | |
3656 char *v14; // esi@49 | |
3657 __int16 v15; // ax@50 | |
3658 int v16; // ecx@52 | |
3659 DecorationDesc *v17; // eax@54 | |
3660 int v18; // ecx@55 | |
3661 //int *v19; // edi@58 | |
3662 //unsigned char v20; // dl@58 | |
3663 int v21; // eax@64 | |
3664 char v22; // cl@64 | |
3665 //signed int v23; // ebx@67 | |
3666 //char *v24; // esi@68 | |
3667 //int v25; // eax@70 | |
3668 //char *v26; // esi@78 | |
3669 //int v27; // eax@79 | |
3670 char v28; // zf@81 | |
3671 __int16 v29; // ax@85 | |
3672 signed int v30; // edi@94 | |
3673 int v31; // esi@94 | |
3674 char Args; // [sp+350h] [bp-C4h]@16 | |
3675 int v34[4]; // [sp+3E8h] [bp-2Ch]@96 | |
3676 int v35; // [sp+3F8h] [bp-1Ch]@1 | |
3677 //char b[4]; // [sp+3FCh] [bp-18h]@58 | |
3678 MapInfo *v37; // [sp+400h] [bp-14h]@1 | |
3679 int v38; // [sp+404h] [bp-10h]@1 | |
3680 unsigned int v39; // [sp+408h] [bp-Ch]@8 | |
3681 int pDest; // [sp+40Ch] [bp-8h]@1 | |
3682 //int i; // [sp+410h] [bp-4h]@27 | |
3683 | |
3684 v37 = (MapInfo *)bLoading; | |
3685 v1 = 0; | |
3686 v35 = 0; | |
3687 pGameLoadingUI_ProgressBar->Reset(0x20u); | |
3688 bUnderwater = 0; | |
3689 bNoNPCHiring = 0; | |
3690 v38 = 0; | |
3691 pDest = 1; | |
3692 uCurrentlyLoadedLevelType = LEVEL_Indoor; | |
3693 pGame->uFlags2 &= 0xFFFFFFF7u; | |
3694 if ( Is_out15odm_underwater() ) | |
3695 { | |
3696 bUnderwater = 1; | |
3697 pGame->uFlags2 |= 8u; | |
3698 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
3699 if ( !_stricmp(pCurrentMapName.data(), "out15.odm") || !_stricmp(pCurrentMapName.data(), "d23.blv") ) |
0 | 3700 bNoNPCHiring = 1; |
3701 pPaletteManager->pPalette_tintColor[0] = 0; | |
3702 pPaletteManager->pPalette_tintColor[1] = 0; | |
3703 pPaletteManager->pPalette_tintColor[2] = 0; | |
3704 pPaletteManager->RecalculateAll(); | |
3705 if ( qword_A750D8 ) | |
3706 qword_A750D8 = 0i64; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
3707 v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 3708 v39 = v2; |
3709 if ( v2 ) | |
3710 { | |
3711 v3 = &pMapStats->pInfos[v2]; | |
3712 v1 = v3->uRespawnIntervalDays; | |
3713 v38 = GetAlertStatus(); | |
3714 } | |
3715 else | |
3716 { | |
3717 v3 = v37; | |
3718 } | |
3719 dword_6BE13C_uCurrentlyLoadedLocationID = v39; | |
3720 pAllocator->FreeChunk(ptr_6A0D08); | |
3721 ptr_6A0D08 = 0; | |
3722 _6A0D0C_txt_lod_loading = 0; | |
3723 TryLoadLevelFromLOD(); | |
3724 pStationaryLightsStack->uNumLightsActive = 0; | |
3725 v4 = pIndoor->Load( | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
3726 pCurrentMapName.data(), |
0 | 3727 (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1, |
3728 v1, | |
3729 (char *)&pDest) | |
3730 - 1; | |
3731 if ( !v4 ) | |
3732 { | |
3733 sprintf(&Args, "Unable to open %s", pCurrentMapName); | |
3734 Abortf(&Args); | |
3735 } | |
3736 v5 = v4 - 1; | |
3737 if ( !v5 ) | |
3738 { | |
3739 sprintf(&Args, "File %s is not a BLV File", pCurrentMapName); | |
3740 Abortf(&Args); | |
3741 } | |
3742 v6 = v5 - 1; | |
3743 if ( !v6 ) | |
3744 Abortf("Attempt to open new level before clearing old"); | |
3745 if ( v6 == 1 ) | |
3746 Abortf("Out of memory loading indoor level"); | |
3747 if ( !(dword_6BE364_game_settings_1 & 0x2000) ) | |
3748 { | |
3749 InitializeActors(); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3750 InitializeSpriteObjects(); |
0 | 3751 } |
3752 BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; | |
3753 if ( !v39 ) | |
3754 pDest = 0; | |
3755 if ( pDest == 1 ) | |
3756 { | |
3757 v7 = 0; | |
3758 for (uint i = 0; i < pIndoor->uNumSpawnPoints; ++v7 ) | |
3759 { | |
3760 v8 = &pIndoor->pSpawnPoints[v7]; | |
3761 if ( pIndoor->pSpawnPoints[v7].uKind == 3 ) | |
3762 SpawnEncounter(v3, v8, 0, 0, 0); | |
3763 else | |
3764 v3->SpawnRandomTreasure(v8); | |
3765 ++i; | |
3766 } | |
3767 RespawnGlobalDecorations(); | |
3768 } | |
3769 | |
3770 pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39], 0); | |
3771 pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39] + 1, 0); | |
3772 | |
3773 for (uint i = 0; i < pIndoor->uNumDoors; ++i) | |
3774 { | |
3775 auto pDoor = pIndoor->pDoors + i; | |
3776 | |
3777 if (pDoor->uAttributes & 0x01) | |
3778 { | |
3779 pDoor->uState = BLVDoor::Opening; | |
3780 pDoor->uTimeSinceTriggered = 15360; | |
3781 pDoor->uAttributes = 2; | |
3782 } | |
3783 | |
3784 if (pDoor->uState == BLVDoor::Closed) | |
3785 { | |
3786 pDoor->uState = BLVDoor::Closing; | |
3787 pDoor->uTimeSinceTriggered = 15360; | |
3788 pDoor->uAttributes = 2; | |
3789 } | |
3790 else if (pDoor->uState == BLVDoor::Open) | |
3791 { | |
3792 pDoor->uState = BLVDoor::Opening; | |
3793 pDoor->uTimeSinceTriggered = 15360; | |
3794 pDoor->uAttributes = 2; | |
3795 } | |
3796 } | |
3797 | |
3798 /* | |
3799 i = 0; | |
3800 v9 = 2; | |
3801 if ( pIndoor->uNumDoors > 0 ) | |
3802 { | |
3803 v10 = 0; | |
3804 while ( 1 ) | |
3805 { | |
3806 if ( pIndoor->pDoors[v10].uAttributes & 1 ) | |
3807 { | |
3808 pIndoor->pDoors[v10].uState = 1; | |
3809 pIndoor->pDoors[v10].uTimeSinceTriggered = 15360; | |
3810 pIndoor->pDoors[v10].uAttributes = 2; | |
3811 } | |
3812 v11 = (char *)&pIndoor->pDoors[v10].uState; | |
3813 if ( !*(short *)v11 ) | |
3814 break; | |
3815 if ( *(short *)v11 == 2 ) | |
3816 { | |
3817 *(short *)v11 = 1; | |
3818 goto LABEL_41; | |
3819 } | |
3820 LABEL_42: | |
3821 ++i; | |
3822 ++v10; | |
3823 if ( i >= pIndoor->uNumDoors ) | |
3824 goto LABEL_43; | |
3825 } | |
3826 *(short *)v11 = 3; | |
3827 LABEL_41: | |
3828 pIndoor->pDoors[v10].uTimeSinceTriggered = 15360; | |
3829 pIndoor->pDoors[v10].uAttributes = 2; | |
3830 goto LABEL_42; | |
3831 } | |
3832 LABEL_43: | |
3833 */ | |
3834 | |
3835 for (uint i = 0; i < pIndoor->uNumFaces; ++i) | |
3836 { | |
3837 auto pFace = pIndoor->pFaces + i; | |
3838 if (!pFace->uBitmapID != -1) | |
3839 pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id1); | |
3840 } | |
3841 | |
3842 /*i = 0; | |
3843 if ( (signed int)pIndoor->uNumFaces > 0 ) | |
3844 { | |
3845 v12 = 0; | |
3846 do | |
3847 { | |
3848 if ( pIndoor->pFaces[v12].uBitmapID != -1 ) | |
3849 pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id1); | |
3850 ++i; | |
3851 ++v12; | |
3852 } | |
3853 while ( i < (signed int)pIndoor->uNumFaces ); | |
3854 }*/ | |
3855 | |
3856 | |
3857 pGameLoadingUI_ProgressBar->Progress(); | |
3858 | |
3859 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
3860 { | |
1202 | 3861 auto pDecortaion = &pLevelDecorations[i]; |
0 | 3862 |
3863 pDecorationList->InitializeDecorationSprite(pDecortaion->uDecorationDescID); | |
3864 | |
3865 v15 = pDecorationList->pDecorations[pDecortaion->uDecorationDescID].uSoundID; | |
3866 if (v15 && _6807E0_num_decorations_with_sounds_6807B8 < 9) | |
3867 { | |
3868 pSoundList->LoadSound(v15, 0); | |
3869 v16 = _6807E0_num_decorations_with_sounds_6807B8++; | |
3870 _6807B8_level_decorations_ids[v16] = i; | |
3871 } | |
3872 | |
3873 if ( !(pDecortaion->field_2 & 0x20) ) | |
3874 { | |
3875 v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID]; | |
380 | 3876 if (!v17->DontDraw()) |
0 | 3877 { |
3878 v18 = v17->uLightRadius; | |
3879 if ( v18 ) | |
3880 { | |
3881 unsigned char r = 255, | |
3882 g = 255, | |
3883 b = 255; | |
3884 if (pRenderer->pRenderD3D && pRenderer->bUseColoredLights) | |
3885 { | |
3886 r = v17->uColoredLightRed; | |
3887 g = v17->uColoredLightGreen; | |
3888 b = v17->uColoredLightBlue; | |
3889 } | |
3890 pStationaryLightsStack->AddLight(pDecortaion->vPosition.x, | |
3891 pDecortaion->vPosition.y, | |
3892 pDecortaion->vPosition.z + v17->uDecorationHeight, | |
3893 v18, | |
3894 r, | |
3895 g, | |
3896 b, | |
3897 byte_4E94D0); | |
3898 } | |
3899 } | |
3900 } | |
3901 | |
3902 if (!pDecortaion->field_16_event_id) | |
3903 { | |
3904 if (pDecortaion->IsInteractive()) | |
3905 { | |
3906 if ( v35 < 124 ) | |
3907 { | |
3908 v21 = v35 + 1; | |
3909 pDecortaion->_idx_in_stru123 = v35 + 75; | |
3910 v22 = stru_5E4C90._decor_events[v21 + 74 - 75]; | |
3911 v35 = v21; | |
3912 if ( !v22 ) | |
3913 pDecortaion->field_2 |= 0x20; | |
3914 } | |
3915 } | |
3916 } | |
3917 } | |
3918 | |
3919 pGameLoadingUI_ProgressBar->Progress(); | |
3920 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3921 for (uint i = 0; i < uNumSpriteObjects; ++i) |
0 | 3922 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
3923 auto p = &pSpriteObjects[i]; |
0 | 3924 if (p->uObjectDescID) |
3925 { | |
3926 auto uItemID = p->stru_24.uItemID; | |
3927 if (uItemID) | |
3928 { | |
3929 if (uItemID != 220 && pItemsTable->pItems[uItemID].uEquipType == EQUIP_POTION && | |
570 | 3930 !p->stru_24.uEnchantmentType) |
3931 p->stru_24.uEnchantmentType = rand() % 15 + 5; | |
0 | 3932 pItemsTable->SetSpecialBonus(&p->stru_24); |
3933 } | |
3934 } | |
3935 } | |
3936 | |
3937 for (uint i = 0; i < uNumActors; ++i) | |
3938 //if ( (signed int)uNumActors > (signed int)v13 ) | |
3939 { | |
1202 | 3940 Actor *pActor = &pActors[i]; |
0 | 3941 //v26 = (char *)&pActors[0].uAttributes; |
3942 //do | |
3943 //{ | |
3944 //v27 = *(int *)v26; | |
3945 if (pActor->uAttributes & 0x100000) | |
3946 { | |
3947 if ( !v39 ) | |
3948 { | |
3949 pActor->pMonsterInfo.field_3E = 19; | |
3950 pActor->uAttributes |= 0x10000; | |
3951 continue; | |
3952 } | |
3953 v28 = v38 == 0; | |
3954 } | |
3955 else | |
3956 { | |
3957 v28 = v38 == 1; | |
3958 } | |
3959 | |
3960 if ( !v28 ) | |
3961 { | |
3962 pActor->PrepareSprites(0); | |
3963 v29 = pActor->pMonsterInfo.field_3E; | |
3964 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
3965 if ( v29 != 11 && v29 != 19 && (!pActor->sCurrentHP || !pActor->pMonsterInfo.uHP) ) | |
3966 { | |
3967 pActor->pMonsterInfo.field_3E = 5; | |
3968 pActor->UpdateAnimation(); | |
3969 } | |
3970 } | |
3971 else | |
3972 { | |
3973 pActor->pMonsterInfo.field_3E = 19; | |
3974 pActor->uAttributes |= 0x10000; | |
3975 } | |
3976 //} | |
3977 //while ( i < (signed int)uNumActors ); | |
3978 } | |
3979 | |
3980 pGameLoadingUI_ProgressBar->Progress(); | |
3981 | |
3982 Actor this_; | |
3983 this_.pMonsterInfo.uID = 45; | |
3984 this_.PrepareSprites(0); | |
3985 if ( !v37 ) | |
3986 { | |
3987 pParty->sRotationX = 0; | |
3988 pParty->sRotationY = 0; | |
3989 pParty->vPosition.z = 0; | |
3990 pParty->vPosition.y = 0; | |
3991 pParty->vPosition.x = 0; | |
3992 pParty->uFallStartY = 0; | |
3993 pParty->uFallSpeed = 0; | |
3994 TeleportToStartingPoint(uLevel_StartingPointType); | |
3995 } | |
3996 viewparams->_443365(); | |
3997 PlayLevelMusic(); | |
3998 if ( !v37 ) | |
3999 { | |
4000 v30 = 0; | |
4001 v31 = 1; | |
4002 do | |
4003 { | |
4004 if ( pPlayers[v31]->CanAct() ) | |
4005 v34[v30++] = v31; | |
4006 ++v31; | |
4007 } | |
4008 while ( v31 <= 4 ); | |
4009 if ( v30 ) | |
4010 { | |
4011 if ( pDest ) | |
4012 { | |
4013 qword_A750D8 = 256i64; | |
4014 word_A750E0 = 46; | |
4015 word_A750E2 = LOWORD(v34[rand() % v30]); | |
4016 } | |
4017 } | |
4018 } | |
1295 | 4019 } |
4020 //----- (0046CEC3) -------------------------------------------------------- | |
4021 int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID) | |
4022 { | |
4023 int v13; // ecx@13 | |
4024 signed int v14; // ebx@14 | |
4025 int v15; // eax@16 | |
4026 //int v16; // edx@19 | |
4027 //int v17; // ST18_4@19 | |
4028 //signed int v18; // edx@19 | |
4029 //signed __int64 v19; // qtt@19 | |
4030 int v21; // eax@27 | |
4031 //int v22; // ecx@29 | |
4032 signed int v28; // eax@45 | |
4033 int v29; // ebx@47 | |
4034 int v30; // edx@49 | |
4035 //int v31; // ST10_4@49 | |
4036 //signed int v32; // edx@49 | |
4037 signed __int64 v33; // qtt@49 | |
4038 //signed int v34; // eax@54 | |
4039 //signed int v35; // esi@56 | |
4040 //int result; // eax@57 | |
4041 int v38; // edx@62 | |
4042 //int v44; // [sp+20h] [bp-20h]@10 | |
4043 bool v47; // [sp+24h] [bp-1Ch]@43 | |
4044 bool v48; // [sp+28h] [bp-18h]@10 | |
4045 bool v49; // [sp+28h] [bp-18h]@41 | |
4046 bool v50; // [sp+2Ch] [bp-14h]@12 | |
4047 signed int v53; // [sp+30h] [bp-10h]@10 | |
4048 signed int v54; // [sp+30h] [bp-10h]@41 | |
4049 signed int v55; // [sp+34h] [bp-Ch]@1 | |
4050 | |
4051 //LOG_DECOMPILATION_WARNING(); | |
4052 | |
4053 static int blv_floor_id[50]; // 00721200 | |
4054 static int blv_floor_level[50]; // 007212C8 | |
4055 | |
4056 static __int16 word_721390_ys[104]; // idb | |
4057 static __int16 word_721460_xs[104]; // idb | |
4058 | |
4059 auto pSector = &pIndoor->pSectors[uSectorID]; | |
4060 v55 = 0; | |
4061 for (uint i = 0; i < pSector->uNumFloors; ++i) | |
4062 { | |
4063 auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]]; | |
4064 if (pFloor->Clickable()) | |
4065 continue; | |
4066 | |
4067 assert(pFloor->uNumVertices); | |
4068 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && | |
4069 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) | |
4070 { | |
4071 for (uint j = 0; j < pFloor->uNumVertices; ++j) | |
4072 { | |
4073 word_721460_xs[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; | |
4074 word_721460_xs[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; | |
4075 word_721390_ys[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; | |
4076 word_721390_ys[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; | |
4077 } | |
4078 word_721460_xs[2 * pFloor->uNumVertices] = word_721460_xs[0]; | |
4079 word_721390_ys[2 * pFloor->uNumVertices] = word_721390_ys[0]; | |
4080 | |
4081 v50 = word_721390_ys[0] >= y; | |
4082 v53 = 0; | |
4083 | |
4084 for (uint j = 0; j < 2 * pFloor->uNumVertices; ++j) | |
4085 { | |
4086 if (v53 >= 2) | |
4087 break; | |
4088 | |
4089 v48 = v50; | |
4090 v50 = word_721390_ys[j + 1] >= y; | |
4091 | |
4092 v13 = i; | |
4093 if (v48 == v50) | |
4094 continue; | |
4095 | |
4096 v14 = word_721460_xs[j + 1] >= x ? 0 : 2; | |
4097 v15 = v14 | (word_721460_xs[j] < x); | |
4098 | |
4099 if (v15 == 3) | |
4100 continue; | |
4101 else if (!v15) | |
4102 ++v53; | |
4103 else | |
4104 { | |
4105 auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); | |
4106 auto res = fixpoint_sub0((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); | |
4107 | |
4108 if (res + word_721460_xs[j] >= x) | |
4109 ++v53; | |
4110 } | |
4111 } | |
4112 | |
4113 | |
4114 if ( v53 == 1 ) | |
4115 { | |
4116 if ( v55 >= 50 ) | |
4117 break; | |
4118 if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling ) | |
4119 { | |
4120 v21 = pIndoor->pVertices[pFloor->pVertexIDs[0]].z; | |
4121 } | |
4122 else | |
4123 { | |
4124 v21 = fixpoint_sub0(pFloor->zCalc1, x) + fixpoint_sub0(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16); | |
4125 } | |
4126 blv_floor_level[v55] = v21; | |
4127 blv_floor_id[v55] = pSector->pFloors[i]; | |
4128 v55++; | |
4129 } | |
4130 } | |
4131 } | |
4132 | |
4133 | |
4134 if ( pSector->field_0 & 8 ) | |
4135 { | |
4136 for (uint i = 0; i < pSector->uNumPortals; ++i) | |
4137 { | |
4138 auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; | |
4139 if (portal->uPolygonType != POLYGON_Floor) | |
4140 continue; | |
4141 | |
4142 if (!portal->uNumVertices) | |
4143 continue; | |
4144 | |
4145 if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 && | |
4146 y <= portal->pBounding.y2 && y >= portal->pBounding.y1 ) | |
4147 { | |
4148 for (uint j = 0; j < portal->uNumVertices; ++j) | |
4149 { | |
4150 word_721460_xs[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; | |
4151 word_721460_xs[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; | |
4152 word_721390_ys[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; | |
4153 word_721390_ys[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; | |
4154 } | |
4155 word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0]; | |
4156 word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0]; | |
4157 v54 = 0; | |
4158 v47 = word_721390_ys[0] >= y; | |
4159 | |
4160 for (uint j = 0; j < 2 * portal->uNumVertices; ++j) | |
4161 { | |
4162 v49 = v47; | |
4163 if ( v54 >= 2 ) | |
4164 break; | |
4165 v47 = word_721390_ys[j + 1] >= y; | |
4166 if ( v49 != v47 ) | |
4167 { | |
4168 v28 = word_721460_xs[j + 1] >= x ? 0 : 2; | |
4169 v29 = v28 | (word_721460_xs[j] < x); | |
4170 if ( v29 != 3 ) | |
4171 { | |
4172 if ( !v29 ) | |
4173 ++v54; | |
4174 else | |
4175 { | |
4176 auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); | |
4177 auto res = fixpoint_sub0(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); | |
4178 if (res + word_721460_xs[j] >= x) | |
4179 ++v54; | |
4180 } | |
4181 } | |
4182 } | |
4183 } | |
4184 if ( v54 == 1 ) | |
4185 { | |
4186 if ( v55 >= 50 ) | |
4187 break; | |
4188 blv_floor_level[v55] = -29000; | |
4189 blv_floor_id[v55] = pSector->pPortals[i]; | |
4190 v55++; | |
4191 } | |
4192 } | |
4193 } | |
4194 } | |
4195 if ( v55 == 1 ) | |
4196 { | |
4197 *pFaceID = blv_floor_id[0]; | |
4198 return blv_floor_level[0]; | |
4199 } | |
4200 if ( !v55 ) | |
4201 return -30000; | |
4202 *pFaceID = blv_floor_id[0]; | |
4203 //result = blv_floor_level[0]; | |
4204 | |
4205 /*for ( v35 = 1; v35 < v55; ++v35 ) | |
4206 { | |
4207 if ( blv_floor_level[0] <= z + 5 ) | |
4208 { | |
4209 if ( blv_floor_level[v35] >= blv_floor_level[0] || blv_floor_level[v35] > z + 5 ) | |
4210 continue; | |
4211 blv_floor_level[0] = blv_floor_level[v35]; | |
4212 *pFaceID = blv_floor_id[v35]; | |
4213 continue; | |
4214 } | |
4215 if ( blv_floor_level[v35] < blv_floor_level[0] ) | |
4216 { | |
4217 blv_floor_level[0] = blv_floor_level[v35]; | |
4218 *pFaceID = blv_floor_id[v35]; | |
4219 } | |
4220 }*/ | |
4221 | |
4222 | |
4223 int result = blv_floor_level[0]; | |
4224 for (uint i = 1; i < v55; ++i) | |
4225 { | |
4226 v38 = blv_floor_level[i]; | |
4227 if ( result <= z + 5 ) | |
4228 { | |
4229 if ( v38 > result && v38 <= z + 5 ) | |
4230 { | |
4231 result = blv_floor_level[i]; | |
4232 *pFaceID = blv_floor_id[i]; | |
4233 } | |
4234 } | |
4235 else if ( v38 < result ) | |
4236 { | |
4237 result = blv_floor_level[i]; | |
4238 *pFaceID = blv_floor_id[i]; | |
4239 } | |
4240 } | |
4241 | |
4242 return result; | |
4243 } | |
4244 //----- (004016FA) -------------------------------------------------------- | |
4245 int __cdecl MakeActorAIList_BLV() | |
4246 { | |
4247 Actor *v0; // esi@2 | |
4248 int v1; // eax@4 | |
4249 int v2; // ebx@4 | |
4250 unsigned int v3; // ecx@4 | |
4251 int v4; // edx@5 | |
4252 int v5; // edx@7 | |
4253 unsigned int v6; // edx@9 | |
4254 unsigned int v7; // ST24_4@10 | |
4255 int v8; // eax@10 | |
4256 int v9; // edi@10 | |
4257 int v10; // ebx@14 | |
4258 char v11; // zf@16 | |
4259 int v12; // eax@22 | |
4260 int v13; // edx@24 | |
4261 int v14; // ecx@25 | |
4262 int v15; // ebx@26 | |
4263 unsigned int *v16; // ecx@27 | |
4264 unsigned int v17; // esi@27 | |
4265 int v18; // ecx@31 | |
4266 signed int v19; // edi@31 | |
4267 Actor *v20; // esi@32 | |
4268 bool v21; // eax@33 | |
4269 int v22; // eax@34 | |
4270 signed int v23; // ebx@36 | |
4271 Actor *v24; // esi@37 | |
4272 signed int v25; // eax@40 | |
4273 int v26; // eax@43 | |
4274 int v27; // ebx@45 | |
4275 int j; // edi@45 | |
4276 unsigned int v29; // eax@46 | |
4277 int v30; // eax@48 | |
4278 int v31; // ecx@51 | |
4279 int v32; // eax@51 | |
4280 signed int v33; // eax@53 | |
4281 __int64 v34; // qax@55 | |
4282 char *v35; // ecx@56 | |
4283 int v37; // [sp+Ch] [bp-18h]@1 | |
4284 int v38; // [sp+10h] [bp-14h]@4 | |
4285 int v39; // [sp+14h] [bp-10h]@4 | |
4286 int v40; // [sp+18h] [bp-Ch]@10 | |
4287 int v41; // [sp+18h] [bp-Ch]@29 | |
4288 int i; // [sp+18h] [bp-Ch]@31 | |
4289 signed int v43; // [sp+1Ch] [bp-8h]@1 | |
4290 signed int v44; // [sp+1Ch] [bp-8h]@25 | |
4291 int v45; // [sp+20h] [bp-4h]@1 | |
4292 | |
4293 // __debugbreak(); // refactor for blv ai | |
4294 pParty->uFlags &= 0xFFFFFFCFu; | |
4295 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
4296 v45 = 0; | |
4297 v43 = 0; | |
4298 if ( (signed int)uNumActors > 0 ) | |
4299 { | |
4300 v0 = pActors.data();//[0].uAttributes; | |
4301 do | |
4302 { | |
4303 BYTE1(v0->uAttributes) &= 0xFBu; | |
4304 if ( ! v0->CanAct() ) | |
4305 goto LABEL_60; | |
4306 v39 = abs(pParty->vPosition.z - v0->vPosition.z); | |
4307 v38 = abs(pParty->vPosition.y - v0->vPosition.y); | |
4308 v1 = abs(pParty->vPosition.x - v0->vPosition.x); | |
4309 v2 = v38; | |
4310 v3 = v39; | |
4311 if ( v1 < v38 ) | |
4312 { | |
4313 v4 = v1; | |
4314 v1 = v38; | |
4315 v2 = v4; | |
4316 } | |
4317 if ( v1 < v39 ) | |
4318 { | |
4319 v5 = v1; | |
4320 v1 = v39; | |
4321 v3 = v5; | |
4322 } | |
4323 if ( v2 < (signed int)v3 ) | |
4324 { | |
4325 v6 = v3; | |
4326 v3 = v2; | |
4327 v2 = v6; | |
4328 } | |
4329 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; | |
4330 v8 = v0->uActorRadius; | |
4331 v9 = v7 - v8; | |
4332 v40 = v7 - v8; | |
4333 if ( v40 < 0 ) | |
4334 { | |
4335 v9 = 0; | |
4336 v40 = 0; | |
4337 } | |
4338 if ( v9 < 10240 ) | |
4339 { | |
4340 v10 = v0->uAttributes & 0xFEFFFFFF; | |
4341 v0->uAttributes = v10; | |
4342 if ( v10 & 0x80000 || v0->GetActorsRelation(0) ) | |
4343 { | |
4344 v11 = (pParty->uFlags & 0x10) == 0; | |
4345 v0->uAttributes = v10 | 0x1000000; | |
4346 if ( v11 && (double)v40 < 307.2 ) | |
4347 pParty->uFlags |= 0x10u; | |
4348 if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) | |
4349 pParty->uFlags |= 0x20u; | |
4350 } | |
4351 v12 = v45++; | |
4352 ai_near_actors_distances[v12] = v9; | |
4353 ai_near_actors_ids[v12] = v43; | |
4354 } | |
4355 else | |
4356 { | |
4357 LABEL_60: | |
4358 BYTE1(v0->uAttributes) &= 0xBFu; | |
4359 } | |
4360 ++v43; | |
4361 ++v0; | |
4362 } | |
4363 while ( v43 < (signed int)uNumActors ); | |
4364 } | |
4365 v13 = 0; | |
4366 if ( v45 > 0 ) | |
4367 { | |
4368 v14 = 1; | |
4369 v44 = 1; | |
4370 do | |
4371 { | |
4372 while ( 1 ) | |
4373 { | |
4374 v41 = v14; | |
4375 if ( v14 >= v45 ) | |
4376 break; | |
4377 v15 = ai_near_actors_distances[v13]; | |
4378 if ( v15 > ai_near_actors_distances[v14] ) | |
4379 { | |
4380 v16 = &ai_near_actors_ids[v14]; | |
4381 v17 = ai_near_actors_ids[v13]; | |
4382 ai_near_actors_ids[v13] = *v16; | |
4383 *v16 = v17; | |
4384 v14 = v41; | |
4385 ai_near_actors_distances[v13] = ai_near_actors_distances[v41]; | |
4386 ai_near_actors_distances[v41] = v15; | |
4387 } | |
4388 ++v14; | |
4389 } | |
4390 ++v13; | |
4391 v14 = v44 + 1; | |
4392 v44 = v14; | |
4393 } | |
4394 while ( v14 - 1 < v45 ); | |
4395 } | |
4396 v18 = 0; | |
4397 v19 = 0; | |
4398 for ( i = 0; v18 < v45; i = v18 ) | |
4399 { | |
4400 v20 = &pActors[ai_near_actors_ids[v18]]; | |
4401 if ( v20->uAttributes & 0x8000 | |
4402 || (v21 = sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor,ai_near_actors_ids[v18]), 4u), v18 = i, v21) ) | |
4403 { | |
4404 v22 = ai_near_actors_ids[v18]; | |
4405 v20->uAttributes |= 0x8000u; | |
4406 ai_array_4F6638_actor_ids[v19] = v22; | |
4407 ai_array_4F5E68[v19++] = ai_near_actors_distances[v18]; | |
4408 if ( v19 >= 30 ) | |
4409 break; | |
4410 } | |
4411 ++v18; | |
4412 } | |
4413 v23 = 0; | |
4414 ai_arrays_size = v19; | |
4415 if ( (signed int)uNumActors > 0 ) | |
4416 { | |
4417 v24 = pActors.data();//[0].uAttributes; | |
4418 do | |
4419 { | |
4420 if ( v24->CanAct() && v24->uSectorID == v37 ) | |
4421 { | |
4422 v25 = 0; | |
4423 if ( v19 <= 0 ) | |
4424 { | |
4425 LABEL_43: | |
4426 v26 = ai_arrays_size; | |
4427 BYTE1(v24->uAttributes) |= 0x40u; | |
4428 ++ai_arrays_size; | |
4429 ai_array_4F6638_actor_ids[v26] = v23; | |
4430 } | |
4431 else | |
4432 { | |
4433 while ( ai_array_4F6638_actor_ids[v25] != v23 ) | |
4434 { | |
4435 ++v25; | |
4436 if ( v25 >= v19 ) | |
4437 goto LABEL_43; | |
4438 } | |
4439 } | |
4440 } | |
4441 ++v23; | |
4442 ++v24; | |
4443 } | |
4444 while ( v23 < (signed int)uNumActors ); | |
4445 } | |
4446 v27 = ai_arrays_size; | |
4447 for ( j = 0; j < v45; ++j ) | |
4448 { | |
4449 v29 = ai_near_actors_ids[j]; | |
4450 if ( pActors[v29].uAttributes & 0xC000 && pActors[v29].CanAct() ) | |
4451 { | |
4452 v30 = 0; | |
4453 if ( v27 <= 0 ) | |
4454 { | |
4455 LABEL_51: | |
4456 v31 = ai_arrays_size; | |
4457 v32 = ai_near_actors_ids[j]; | |
4458 ++ai_arrays_size; | |
4459 ai_array_4F6638_actor_ids[v31] = v32; | |
4460 } | |
4461 else | |
4462 { | |
4463 while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] ) | |
4464 { | |
4465 ++v30; | |
4466 if ( v30 >= v27 ) | |
4467 goto LABEL_51; | |
4468 } | |
4469 } | |
4470 } | |
4471 } | |
4472 v33 = ai_arrays_size; | |
4473 if ( ai_arrays_size > 30 ) | |
4474 { | |
4475 v33 = 30; | |
4476 ai_arrays_size = 30; | |
4477 } | |
4478 memcpy(ai_near_actors_ids.data(), ai_array_4F6638_actor_ids.data(), 4 * v33); | |
4479 memcpy(ai_near_actors_distances.data(), ai_array_4F5E68.data(), 4 * ai_arrays_size); | |
4480 v34 = (unsigned int)ai_arrays_size; | |
4481 if ( ai_arrays_size > 0 ) | |
4482 { | |
4483 do | |
4484 { | |
4485 v35 = (char *)&pActors[ai_near_actors_ids[HIDWORD(v34)]].uAttributes; | |
4486 v35[1] |= 4u; | |
4487 ++HIDWORD(v34); | |
4488 } | |
4489 while ( SHIDWORD(v34) < (signed int)v34 ); | |
4490 } | |
4491 return v34; | |
4492 } | |
4493 //----- (0043FDED) -------------------------------------------------------- | |
4494 void PrepareActorRenderList_BLV() | |
4495 { | |
4496 RenderBillboard *v0; // esi@0 | |
4497 unsigned __int16 v3; // ax@3 | |
4498 unsigned int v4; // eax@5 | |
4499 unsigned __int16 v5; // cx@5 | |
4500 int v6; // esi@5 | |
4501 unsigned int v7; // eax@7 | |
4502 int v8; // eax@10 | |
4503 SpriteFrame *v9; // eax@16 | |
4504 SpriteFrame *v10; // ebx@18 | |
4505 //int *v11; // eax@18 | |
4506 int v12; // ecx@28 | |
4507 //IndoorCameraD3D **v14; // eax@36 | |
4508 double v15; // st7@36 | |
4509 float v16; // eax@36 | |
4510 //double v17; // ST30_8@36 | |
4511 signed __int64 v18; // qtt@36 | |
4512 int v19; // ST5C_4@36 | |
4513 signed __int64 v20; // qtt@37 | |
4514 int v21; // ST5C_4@37 | |
4515 signed __int16 v22; // cx@39 | |
4516 int v23; // ST50_4@40 | |
4517 signed int v24; // ecx@40 | |
4518 int v25; // edx@44 | |
4519 __int16 v26; // ax@44 | |
4520 //MonsterDesc *v27; // edx@44 | |
4521 //int v28; // ecx@44 | |
4522 unsigned __int8 v29; // zf@44 | |
4523 unsigned __int8 v30; // sf@44 | |
4524 unsigned int v31; // [sp-8h] [bp-5Ch]@15 | |
4525 int v32; // [sp+1Ch] [bp-38h]@5 | |
4526 int a3; // [sp+20h] [bp-34h]@5 | |
4527 int a2; // [sp+24h] [bp-30h]@5 | |
4528 int a1a; // [sp+28h] [bp-2Ch]@5 | |
4529 __int16 a5; // [sp+2Ch] [bp-28h]@5 | |
4530 int a5a; // [sp+2Ch] [bp-28h]@36 | |
4531 int a5b; // [sp+2Ch] [bp-28h]@40 | |
4532 __int16 v41; // [sp+3Ch] [bp-18h]@18 | |
4533 int a6; // [sp+40h] [bp-14h]@34 | |
4534 int v43; // [sp+44h] [bp-10h]@34 | |
4535 int z; // [sp+48h] [bp-Ch]@32 | |
4536 signed int y; // [sp+4Ch] [bp-8h]@32 | |
4537 int x; // [sp+50h] [bp-4h]@32 | |
4538 | |
4539 for (uint i = 0; i < uNumActors; ++i) | |
4540 { | |
4541 auto p = &pActors[i]; | |
4542 | |
4543 if (p->uAIState == Removed || | |
4544 p->uAIState == Disabled) | |
4545 continue; | |
4546 | |
4547 a5 = p->uSectorID; | |
4548 a2 = p->vPosition.y; | |
4549 a1a = p->vPosition.x; | |
4550 a3 = p->vPosition.z; | |
4551 v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); | |
4552 LOWORD(v0) = p->uYawAngle; | |
4553 v5 = p->uCurrentActionAnimation; | |
4554 v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7; | |
4555 v32 = v6; | |
4556 if ( pParty->bTurnBasedModeOn ) | |
4557 { | |
4558 if ( v5 == 1 ) | |
4559 { | |
4560 v7 = pMiscTimer->uTotalGameTimeElapsed; | |
4561 goto LABEL_10; | |
4562 } | |
4563 } | |
4564 else | |
4565 { | |
4566 if ( v5 == 1 ) | |
4567 { | |
4568 v7 = pBLVRenderParams->field_0_timer_; | |
4569 LABEL_10: | |
4570 v8 = i * 32 + v7; | |
4571 goto LABEL_12; | |
4572 } | |
4573 } | |
4574 v8 = p->uCurrentActionTime; | |
4575 LABEL_12: | |
4576 if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 ) | |
4577 v8 = 0; | |
4578 v31 = p->pSpriteIDs[v5]; | |
4579 if (p->uAIState == Resurrected) | |
4580 v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8); | |
4581 else | |
4582 v9 = pSpriteFrameTable->GetFrame(v31, v8); | |
4583 v41 = 0; | |
4584 v10 = v9; | |
4585 //v11 = (int *)v9->uFlags; | |
4586 if (v9->uFlags & 2) | |
4587 v41 = 2; | |
4588 if (v9->uFlags & 0x40000) | |
4589 v41 |= 0x40u; | |
4590 if (v9->uFlags & 0x20000) | |
4591 LOBYTE(v41) = v41 | 0x80; | |
4592 v0 = (RenderBillboard *)(256 << v6); | |
4593 if ( (unsigned int)v0 & v9->uFlags) | |
4594 v41 |= 4u; | |
4595 if ( v10->uGlowRadius ) | |
4596 { | |
4597 //LOBYTE(v11) = byte_4E94D3; | |
4598 pMobileLightsStack->AddLight( | |
4599 a1a, | |
4600 a2, | |
4601 a3, | |
4602 a5, | |
4603 v10->uGlowRadius, | |
4604 0xFFu, | |
4605 0xFFu, | |
4606 0xFFu, | |
4607 byte_4E94D3); | |
4608 } | |
4609 v12 = 0; | |
4610 if ( pBspRenderer->uNumVisibleNotEmptySectors <= 0 ) | |
4611 continue; | |
4612 while (pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID) | |
4613 { | |
4614 ++v12; | |
4615 if ( v12 >= pBspRenderer->uNumVisibleNotEmptySectors ) | |
4616 goto _continue; | |
4617 } | |
4618 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1) | |
4619 || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) ) | |
4620 continue; | |
4621 pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6); | |
4622 v0 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
4623 if (uNumBillboardsToDraw >= 500) | |
4624 break; | |
4625 ++uNumBillboardsToDraw; | |
4626 ++uNumSpritesDrawnThisFrame; | |
4627 p->uAttributes |= 8u; | |
4628 v29 = pRenderer->pRenderD3D == 0; | |
4629 v0->uHwSpriteID = v10->pHwSpriteIDs[v32]; | |
4630 v0->uPalette = v10->uPaletteIndex; | |
4631 v0->uIndoorSectorID = a5; | |
4632 if ( v29 ) | |
4633 { | |
4634 LODWORD(v20) = pBLVRenderParams->field_40 << 16; | |
4635 HIDWORD(v20) = pBLVRenderParams->field_40 >> 16; | |
4636 v21 = v20 / x; | |
4637 v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v20 / x) >> 16; | |
4638 a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16; | |
4639 } | |
4640 else | |
4641 { | |
4642 //v14 = &pGame->pIndoorCameraD3D; | |
4643 v0->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
4644 v15 = pGame->pIndoorCameraD3D->fov_y; | |
4645 v16 = v0->fov_x; | |
4646 v0->fov_y = v15; | |
4647 //v17 = v16 + 6.7553994e15; | |
4648 LODWORD(v18) = 0; | |
4649 HIDWORD(v18) = floorf(v16 + 0.5f); | |
4650 v19 = v18 / x; | |
4651 v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v18 / x) >> 16; | |
4652 a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16; | |
4653 } | |
4654 v0->_screenspace_y_scaler_packedfloat = a5a; | |
4655 if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 ) | |
4656 { | |
4657 if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 ) | |
4658 { | |
4659 a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; | |
4660 goto LABEL_43; | |
4661 } | |
4662 } | |
4663 else | |
4664 { | |
4665 v22 = p->pActorBuffs[3].uPower; | |
4666 if ( v22 ) | |
4667 { | |
4668 v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->_screenspace_x_scaler_packedfloat) >> 16; | |
4669 v24 = p->pActorBuffs[3].uPower; | |
4670 v0->_screenspace_x_scaler_packedfloat = v23; | |
4671 a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; | |
4672 LABEL_43: | |
4673 v0->_screenspace_y_scaler_packedfloat = a5b; | |
4674 goto LABEL_44; | |
4675 } | |
4676 } | |
4677 LABEL_44: | |
4678 HIWORD(v25) = HIWORD(x); | |
4679 v0->world_x = a1a; | |
4680 v0->world_y = a2; | |
4681 v0->world_z = a3; | |
4682 v0->uScreenSpaceX = v43; | |
4683 v0->uScreenSpaceY = a6; | |
4684 LOWORD(v25) = 0; | |
4685 LOBYTE(v26) = v41; | |
4686 | |
4687 //v0->sZValue = v25 + (PID(OBJECT_Actor,i)); | |
4688 v0->actual_z = HIWORD(x); | |
4689 v0->object_pid = PID(OBJECT_Actor,i); | |
4690 | |
4691 v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0; | |
4692 v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0; | |
4693 v0->field_1E = v41; | |
4694 v0->pSpriteFrame = v10; | |
4695 v0->uTintColor = pMonsterList->pMonsters[p->pMonsterInfo.uID - 1].uTintColor; | |
4696 if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) ) | |
4697 { | |
4698 HIBYTE(v26) = HIBYTE(v41) | 1; | |
4699 v0->field_1E = v26; | |
4700 } | |
4701 | |
4702 _continue: | |
4703 ; | |
4704 } | |
4705 } | |
4706 //----- (0044028F) -------------------------------------------------------- | |
4707 void PrepareItemsRenderList_BLV() | |
4708 { | |
4709 ObjectDesc *v1; // ebx@4 | |
4710 __int16 v2; // ax@5 | |
4711 RenderBillboard *v3; // esi@12 | |
4712 SpriteFrame *v4; // eax@12 | |
4713 SpriteFrame *v5; // ebx@12 | |
4714 unsigned int v6; // eax@12 | |
4715 int v7; // ecx@12 | |
4716 int v8; // edx@12 | |
4717 int v9; // ecx@12 | |
4718 unsigned __int16 v10; // ax@12 | |
4719 int *v11; // eax@20 | |
4720 //char v12; // zf@26 | |
4721 __int64 v18; // ST5C_4@27 | |
4722 signed __int64 v19; // qtt@28 | |
4723 int v20; // ST5C_4@28 | |
4724 //int v21; // edx@29 | |
4725 __int16 v22; // ax@29 | |
4726 //int v23; // eax@29 | |
4727 SpriteFrame *v24; // [sp+1Ch] [bp-40h]@12 | |
4728 //__int16 a5; // [sp+28h] [bp-34h]@12 | |
4729 int a6; // [sp+2Ch] [bp-30h]@12 | |
4730 int a2; // [sp+30h] [bp-2Ch]@12 | |
4731 int a1; // [sp+34h] [bp-28h]@12 | |
4732 int v30; // [sp+38h] [bp-24h]@12 | |
4733 int v31; // [sp+38h] [bp-24h]@27 | |
4734 int a3; // [sp+40h] [bp-1Ch]@12 | |
4735 signed __int16 v34; // [sp+44h] [bp-18h]@14 | |
4736 int v35; // [sp+48h] [bp-14h]@25 | |
4737 int v36; // [sp+4Ch] [bp-10h]@25 | |
4738 signed int z; // [sp+50h] [bp-Ch]@24 | |
4739 signed int y; // [sp+54h] [bp-8h]@24 | |
4740 signed int x; // [sp+58h] [bp-4h]@24 | |
4741 | |
4742 for (uint i = 0; i < uNumSpriteObjects; ++i) | |
4743 { | |
4744 auto p = &pSpriteObjects[i]; | |
4745 if (p->uObjectDescID) | |
4746 { | |
4747 v1 = &pObjectList->pObjects[p->uObjectDescID]; | |
4748 if ( !(v1->uFlags & 1) ) | |
4749 { | |
4750 if ( ((v2 = p->uType, v2 < 1000) || v2 >= 10000) | |
4751 && (v2 < 500 || v2 >= 600) | |
4752 && (v2 < 811 || v2 >= 815) | |
4753 || pGame->pStru6Instance->_4A81CA(p)) | |
4754 { | |
4755 //a5 = p->uSectorID; | |
4756 a1 = p->vPosition.x; | |
4757 a2 = p->vPosition.y; | |
4758 a3 = p->vPosition.z; | |
4759 v3 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
4760 v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, p->uSpriteFrameID); | |
4761 v5 = v4; | |
4762 v24 = v4; | |
4763 v30 = v4->uFlags; | |
4764 a6 = v4->uGlowRadius * p->field_22_glow_radius_multiplier; | |
4765 v6 = stru_5C6E00->Atan2(p->vPosition.x - pBLVRenderParams->vPartyPos.x, | |
4766 p->vPosition.y - pBLVRenderParams->vPartyPos.y); | |
4767 LOWORD(v7) = p->uFacing; | |
4768 v8 = v30; | |
4769 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7; | |
4770 v10 = v5->pHwSpriteIDs[v9]; | |
4771 v3->uHwSpriteID = v10; | |
4772 if ( v30 & 0x20 ) | |
4773 { | |
4774 v8 = v30; | |
4775 a3 -= (signed int)((unsigned __int64)(v5->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
4776 } | |
4777 v34 = 0; | |
4778 if ( v8 & 2 ) | |
4779 v34 = 2; | |
4780 if ( v8 & 0x40000 ) | |
4781 v34 |= 0x40u; | |
4782 if ( v8 & 0x20000 ) | |
4783 LOBYTE(v34) = v34 | 0x80; | |
4784 v11 = (int *)(256 << v9); | |
4785 if ( (256 << v9) & v8 ) | |
4786 v34 |= 4u; | |
4787 if ( a6 ) | |
4788 { | |
4789 LOBYTE(v11) = byte_4E94D3; | |
4790 pMobileLightsStack->AddLight( | |
4791 a1, | |
4792 a2, | |
4793 a3, | |
4794 p->uSectorID, | |
4795 a6, | |
4796 v1->uParticleTrailColorR, | |
4797 v1->uParticleTrailColorG, | |
4798 v1->uParticleTrailColorB, | |
4799 byte_4E94D3); | |
4800 } | |
4801 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( | |
4802 a1, | |
4803 a2, | |
4804 a3, | |
4805 &x, | |
4806 &y, | |
4807 &z, | |
4808 1) ) | |
4809 { | |
4810 pGame->pIndoorCameraD3D->Project(x, y, z, &v36, &v35); | |
4811 | |
4812 assert(uNumBillboardsToDraw < 500); | |
4813 //if ( (signed int)uNumBillboardsToDraw >= 500 ) | |
4814 // return; | |
4815 ++uNumBillboardsToDraw; | |
4816 ++uNumSpritesDrawnThisFrame; | |
4817 p->uAttributes |= 1u; | |
4818 //v12 = pRenderer->pRenderD3D == 0; | |
4819 v3->uPalette = v24->uPaletteIndex; | |
4820 v3->uIndoorSectorID = p->uSectorID; | |
4821 if ( pRenderer->pRenderD3D ) | |
4822 { | |
4823 v3->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
4824 v3->fov_y = pGame->pIndoorCameraD3D->fov_y; | |
4825 LODWORD(v18) = 0; | |
4826 HIDWORD(v18) = (int)floorf(v3->fov_x + 0.5f); | |
4827 v18 = v18 / x; | |
4828 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v18) >> 16; | |
4829 v31 = (unsigned __int64)(v24->scale * v18) >> 16; | |
4830 } | |
4831 else | |
4832 { | |
4833 LODWORD(v19) = pBLVRenderParams->field_40 << 16; | |
4834 HIDWORD(v19) = pBLVRenderParams->field_40 >> 16; | |
4835 v20 = v19 / x; | |
4836 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v19 / x) >> 16; | |
4837 v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16; | |
4838 } | |
4839 //HIWORD(v21) = HIWORD(x); | |
4840 //LOWORD(v21) = 0; | |
4841 v3->_screenspace_y_scaler_packedfloat = v31; | |
4842 v3->field_1E = v34; | |
4843 v3->world_x = a1; | |
4844 v3->world_y = a2; | |
4845 v3->world_z = a3; | |
4846 v3->uScreenSpaceX = v36; | |
4847 v22 = v35; | |
4848 v3->uTintColor = 0; | |
4849 v3->uScreenSpaceY = v22; | |
4850 //v23 = 8 * i; | |
4851 //LOBYTE(v23) = PID(OBJECT_Item,i); | |
4852 v3->pSpriteFrame = v24; | |
4853 //v12 = (p->uAttributes & 0x20) == 0; | |
4854 //v3->sZValue = v21 + v23; | |
4855 v3->actual_z = HIWORD(x); | |
4856 v3->object_pid = PID(OBJECT_Item,i); | |
4857 if (p->uAttributes & 0x20) | |
4858 { | |
4859 if ( !pRenderer->pRenderD3D ) | |
4860 v3->sZValue = 0; | |
4861 } | |
4862 } | |
4863 } | |
4864 } | |
4865 } | |
4866 } | |
4867 } | |
4868 | |
4869 //----- (00440639) -------------------------------------------------------- | |
4870 void AddBspNodeToRenderList(unsigned int node_id) | |
4871 { | |
4872 BLVSector *pSector; // esi@1 | |
4873 | |
4874 pSector = &pIndoor->pSectors[pBspRenderer->nodes[node_id].uSectorID]; | |
4875 if ( pRenderer->pRenderD3D ) | |
4876 { | |
4877 for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i) | |
4878 //Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]); | |
4879 pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[i]); | |
4880 } | |
4881 else | |
4882 { | |
4883 for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i) | |
4884 pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[i]); | |
4885 } | |
4886 if ( pSector->field_0 & 0x10 ) | |
4887 sub_4406BC(node_id, pSector->uFirstBSPNode); | |
4888 } | |
4889 | |
4890 //----- (004406BC) -------------------------------------------------------- | |
4891 void __fastcall sub_4406BC(unsigned int node_id, unsigned int uFirstNode) | |
4892 { | |
4893 BLVSector *pSector; // esi@2 | |
4894 BSPNode *pNode; // edi@2 | |
4895 BLVFace *pFace; // eax@2 | |
4896 int v5; // ecx@2 | |
4897 __int16 v6; // ax@6 | |
4898 int v7; // ebp@10 | |
4899 int v8; // ebx@10 | |
4900 __int16 v9; // di@18 | |
4901 //int v10; // [sp+10h] [bp-Ch]@1 | |
4902 //bool v11; // [sp+14h] [bp-8h]@5 | |
4903 BspRenderer_stru0 *node; // [sp+18h] [bp-4h]@1 | |
4904 | |
4905 //Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode); | |
4906 | |
4907 //v10 = a1; | |
4908 node = &pBspRenderer->nodes[node_id]; | |
4909 while ( 1 ) | |
4910 { | |
4911 pSector = &pIndoor->pSectors[node->uSectorID]; | |
4912 pNode = &pIndoor->pNodes[uFirstNode]; | |
4913 pFace = &pIndoor->pFaces[pSector->pFaceIDs[pNode->uCoplanarOffset]]; | |
4914 v5 = pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | |
4915 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z;//plane equation | |
4916 if (pFace->Portal() && pFace->uSectorID != node->uSectorID ) | |
4917 v5 = -v5; | |
4918 //v11 = v5 > 0; | |
4919 if ( v5 <= 0 ) | |
4920 v6 = pNode->uFront; | |
4921 else | |
4922 v6 = pNode->uBack; | |
4923 if ( v6 != -1 ) | |
4924 sub_4406BC(node_id, v6); | |
4925 v7 = pNode->uCoplanarOffset; | |
4926 v8 = v7 + pNode->uCoplanarSize; | |
4927 | |
4928 //Log::Warning(L"Node %u: %X to %X (%hX)", uFirstNode, v7, v8, v2->pFaceIDs[v7]); | |
4929 | |
4930 if ( pRenderer->pRenderD3D ) | |
4931 { | |
4932 while ( v7 < v8 ) | |
4933 pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[v7++]); | |
4934 } | |
4935 else | |
4936 { | |
4937 while ( v7 < v8 ) | |
4938 pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[v7++]); | |
4939 } | |
4940 v9 = v5 > 0 ? pNode->uFront : pNode->uBack; | |
4941 if ( v9 == -1 ) | |
4942 break; | |
4943 uFirstNode = v9; | |
4944 } | |
4945 } | |
4946 //----- (0043FA33) -------------------------------------------------------- | |
4947 void __fastcall PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID) | |
4948 { | |
4949 LevelDecoration *v2; // esi@1 | |
4950 DecorationDesc *v3; // ebx@2 | |
4951 __int16 v4; // ax@2 | |
4952 double v5; // st7@3 | |
4953 int v6; // eax@5 | |
4954 int v7; // edx@5 | |
4955 unsigned int v8; // edi@5 | |
4956 int v9; // edi@5 | |
4957 int v10; // eax@7 | |
4958 SpriteFrame *v11; // eax@7 | |
4959 SpriteFrame *v12; // esi@7 | |
4960 int v13; // eax@7 | |
4961 int v14; // ebx@16 | |
4962 RenderBillboard *v15; // ecx@17 | |
4963 char v16; // zf@18 | |
4964 IndoorCameraD3D **v17; // eax@19 | |
4965 double v18; // st7@19 | |
4966 //float v19; // eax@19 | |
4967 signed __int64 v20; // qtt@19 | |
4968 signed __int64 v21; // qtt@20 | |
4969 //int v22; // edx@21 | |
4970 //int v23; // eax@21 | |
4971 Particle_sw local_0; // [sp+Ch] [bp-A0h]@3 | |
4972 //double v25; // [sp+74h] [bp-38h]@19 | |
4973 //unsigned int v26; // [sp+7Ch] [bp-30h]@1 | |
4974 int a2; // [sp+80h] [bp-2Ch]@5 | |
4975 int a3; // [sp+84h] [bp-28h]@5 | |
4976 int a1; // [sp+88h] [bp-24h]@5 | |
4977 int v30; // [sp+8Ch] [bp-20h]@7 | |
4978 //float v31; // [sp+90h] [bp-1Ch]@1 | |
4979 int a5; // [sp+94h] [bp-18h]@17 | |
4980 int z; // [sp+98h] [bp-14h]@15 | |
4981 int a6; // [sp+9Ch] [bp-10h]@17 | |
4982 int y; // [sp+A0h] [bp-Ch]@15 | |
4983 int x; // [sp+A4h] [bp-8h]@15 | |
4984 int v37; // [sp+A8h] [bp-4h]@5 | |
4985 | |
4986 //v26 = uDecorationID; | |
4987 //LODWORD(v31) = uSectorID; | |
4988 v2 = &pLevelDecorations[uDecorationID]; | |
4989 if (v2->field_2 & 0x20) | |
4990 return; | |
4991 | |
4992 v3 = &pDecorationList->pDecorations[v2->uDecorationDescID]; | |
4993 v4 = v3->uFlags; | |
4994 if (v3->uFlags & DECORATION_EMITS_FIRE) | |
4995 { | |
4996 memset(&local_0, 0, 0x68u); // fire, like at the Pit's tavern | |
4997 v5 = (double)v2->vPosition.x; | |
4998 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; | |
4999 local_0.uDiffuse = 0xFF3C1E; | |
5000 local_0.x = v5; | |
5001 local_0.y = (double)v2->vPosition.y; | |
5002 local_0.z = (double)v2->vPosition.z; | |
1390 | 5003 local_0.r = 0.0; |
5004 local_0.g = 0.0; | |
5005 local_0.b = 0.0; | |
1295 | 5006 local_0.flt_28 = 1.0; |
5007 local_0.timeToLive = (rand() & 0x80) + 128; | |
5008 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
5009 pGame->pParticleEngine->AddParticle(&local_0); | |
5010 return; | |
5011 } | |
5012 | |
5013 | |
5014 if (v4 & DECORATION_DONT_DRAW) | |
5015 return; | |
5016 | |
5017 v6 = v2->vPosition.x; | |
5018 v7 = v2->vPosition.z; | |
5019 a2 = v2->vPosition.y; | |
5020 a1 = v6; | |
5021 a3 = v7; | |
5022 v8 = v2->field_10_y_rot | |
5023 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
5024 - stru_5C6E00->Atan2(v6 - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); | |
5025 v37 = pBLVRenderParams->field_0_timer_; | |
5026 v9 = ((signed int)(stru_5C6E00->uIntegerPi + v8) >> 8) & 7; | |
5027 if (pParty->bTurnBasedModeOn) | |
5028 v37 = pMiscTimer->uTotalGameTimeElapsed; | |
5029 v10 = abs(v2->vPosition.x + v2->vPosition.y); | |
5030 v11 = pSpriteFrameTable->GetFrame(v3->uSpriteID, v37 + v10); | |
5031 v30 = 0; | |
5032 v12 = v11; | |
5033 v13 = v11->uFlags; | |
5034 if ( v13 & 2 ) | |
5035 v30 = 2; | |
5036 if ( v13 & 0x40000 ) | |
5037 v30 |= 0x40u; | |
5038 if ( v13 & 0x20000 ) | |
5039 LOBYTE(v30) = v30 | 0x80; | |
5040 if ( (256 << v9) & v13 ) | |
5041 v30 |= 4u; | |
5042 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1, a2, a3, &x, &y, &z, 1) ) | |
5043 { | |
5044 v14 = abs(x); | |
5045 if ( v14 >= abs(y) ) | |
5046 { | |
5047 pGame->pIndoorCameraD3D->Project(x, y, z, &a5, &a6); | |
5048 | |
5049 v15 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
5050 assert(uNumBillboardsToDraw < 500); | |
5051 | |
5052 ++uNumBillboardsToDraw; | |
5053 ++uNumDecorationsDrawnThisFrame; | |
5054 v16 = pRenderer->pRenderD3D == 0; | |
5055 v15->uHwSpriteID = v12->pHwSpriteIDs[v9]; | |
5056 v15->uPalette = v12->uPaletteIndex; | |
5057 v15->uIndoorSectorID = uSectorID; | |
5058 if ( v16 ) | |
5059 { | |
5060 LODWORD(v21) = pBLVRenderParams->field_40 << 16; | |
5061 HIDWORD(v21) = pBLVRenderParams->field_40 >> 16; | |
5062 v37 = v21 / x; | |
5063 //LODWORD(v31) = v12->scale; | |
5064 v37 = v21 / x; | |
5065 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v21 / x) >> 16; | |
5066 v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16; | |
5067 } | |
5068 else | |
5069 { | |
5070 v17 = &pGame->pIndoorCameraD3D; | |
5071 v15->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
5072 v18 = (*v17)->fov_y; | |
5073 //v19 = v15->fov_x; | |
5074 v15->fov_y = v18; | |
5075 //v31 = v19; | |
5076 //v25 = v19 + 6.7553994e15; | |
5077 //v25 = floorf(v15->fov_x + 0.5f); | |
5078 LODWORD(v20) = 0; | |
5079 HIDWORD(v20) = floorf(v15->fov_x + 0.5f); | |
5080 v37 = v20 / x; | |
5081 //LODWORD(v31) = v12->scale; | |
5082 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5083 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5084 //v31 = v15->fov_y; | |
5085 //v25 = v31 + 6.7553994e15; | |
5086 //v25 = floorf(v15->fov_y + 0.5f); | |
5087 LODWORD(v20) = 0; | |
5088 HIDWORD(v20) = floorf(v15->fov_y + 0.5f); | |
5089 v37 = v20 / x; | |
5090 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5091 } | |
5092 //HIWORD(v22) = HIWORD(x); | |
5093 //LOWORD(v22) = 0; | |
5094 v15->_screenspace_y_scaler_packedfloat = v37; | |
5095 v15->field_1E = v30; | |
5096 v15->world_x = a1; | |
5097 v15->world_y = a2; | |
5098 v15->world_z = a3; | |
5099 v15->uScreenSpaceX = a5; | |
5100 v15->uScreenSpaceY = a6; | |
5101 //v23 = 8 * uDecorationID; | |
5102 //LOBYTE(v23) = PID(OBJECT_Decoration,uDecorationID); | |
5103 | |
5104 //v15->sZValue = v22 + v23; | |
5105 v15->actual_z = HIWORD(x); | |
5106 v15->object_pid = PID(OBJECT_Decoration,uDecorationID); | |
5107 | |
5108 v15->uTintColor = 0; | |
5109 v15->pSpriteFrame = v12; | |
5110 } | |
5111 } | |
5112 } | |
5113 //----- (0043F953) -------------------------------------------------------- | |
5114 void PrepareBspRenderList_BLV() | |
5115 { | |
5116 pBspRenderer->num_faces = 0; | |
5117 | |
5118 if (pBLVRenderParams->uPartySectorID) | |
5119 { | |
5120 pBspRenderer->nodes[0].uSectorID = pBLVRenderParams->uPartySectorID; | |
5121 pBspRenderer->nodes[0].uViewportW = pBLVRenderParams->uViewportW; | |
5122 pBspRenderer->nodes[0].uViewportZ = pBLVRenderParams->uViewportZ; | |
5123 pBspRenderer->nodes[0].uViewportY = pBLVRenderParams->uViewportY; | |
5124 pBspRenderer->nodes[0].uViewportX = pBLVRenderParams->uViewportX; | |
1376 | 5125 pBspRenderer->nodes[0].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, |
1295 | 5126 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); |
5127 pBspRenderer->nodes[0].uFaceID = -1; | |
5128 pBspRenderer->nodes[0].viewing_portal_id = -1; | |
5129 pBspRenderer->num_nodes = 1; | |
5130 AddBspNodeToRenderList(0); | |
5131 } | |
5132 | |
5133 pBspRenderer->MakeVisibleSectorList(); | |
5134 } | |
5135 | |
5136 //----- (0043F9E1) -------------------------------------------------------- | |
1376 | 5137 void BspRenderer_PortalViewportData::GetViewportData(__int16 x, int y, __int16 z, int w) |
1295 | 5138 { |
5139 _viewport_space_y = y; | |
5140 _viewport_space_w = w; | |
5141 | |
5142 for (uint i = 0; i < 480; ++i) | |
5143 { | |
5144 if ( i < y || i > w ) | |
5145 { | |
5146 viewport_left_side[i] = 640; | |
5147 viewport_right_side[i] = -1; | |
5148 } | |
5149 else | |
5150 { | |
5151 viewport_left_side[i] = x; | |
5152 viewport_right_side[i] = z; | |
5153 } | |
5154 } | |
5155 } | |
5156 //----- (0048653D) -------------------------------------------------------- | |
5157 int stru149::_48653D(int a2, int a3, int a4, int a5, int a6, int a7)//portal frustum culling | |
5158 { | |
5159 stru149 *v7; // esi@1 | |
5160 int v8; // edi@1 | |
5161 int v9; // eax@1 | |
5162 //int v10; // edx@1 | |
5163 //int v11; // ecx@1 | |
5164 int v12; // eax@1 | |
5165 int v13; // ebx@2 | |
5166 int v14; // ecx@2 | |
5167 int v15; // eax@2 | |
5168 int v16; // ST14_4@3 | |
5169 int v17; // ST10_4@3 | |
5170 int v18; // eax@5 | |
5171 int v19; // ST10_4@6 | |
5172 int v20; // eax@8 | |
5173 int v21; // ST10_4@9 | |
5174 int v22; // eax@10 | |
5175 int v23; // ecx@10 | |
5176 int v24; // eax@10 | |
5177 int result; // eax@10 | |
5178 //int v26; // [sp+14h] [bp-14h]@1 | |
5179 int v27; // [sp+18h] [bp-10h]@1 | |
5180 int v28; // [sp+1Ch] [bp-Ch]@1 | |
5181 int v29; // [sp+24h] [bp-4h]@1 | |
5182 int v30; // [sp+30h] [bp+8h]@10 | |
5183 int v31; // [sp+3Ch] [bp+14h]@10 | |
5184 | |
5185 v7 = this; | |
5186 v8 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotY); | |
5187 v29 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotY); | |
5188 v28 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotX); | |
5189 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX); | |
5190 //v11 = -pBLVRenderParams->vPartyPos.y; | |
5191 //v26 = -pBLVRenderParams->vPartyPos.x; | |
5192 v27 = v9; | |
5193 v12 = -pBLVRenderParams->vPartyPos.z; | |
5194 if ( pBLVRenderParams->sPartyRotX ) | |
5195 { | |
5196 v16 = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y; | |
5197 v13 = v28; | |
5198 v17 = -65536 * pBLVRenderParams->vPartyPos.z; | |
5199 v7->field_0_party_dir_x = ((unsigned __int64)(v16 * (signed __int64)v28) >> 16) | |
5200 + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)v27) >> 16); | |
5201 v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x; | |
5202 v14 = v27; | |
5203 v15 = ((unsigned __int64)(v17 * (signed __int64)v28) >> 16) - ((unsigned __int64)(v16 * (signed __int64)v27) >> 16); | |
5204 } | |
5205 else | |
5206 { | |
5207 v7->field_0_party_dir_x = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y; | |
5208 v13 = v28; | |
5209 v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x; | |
5210 v14 = v27; | |
5211 v15 = v12 << 16; | |
5212 } | |
5213 v7->field_8 = v15; | |
5214 if ( pBLVRenderParams->sPartyRotX ) | |
5215 { | |
5216 v19 = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16); | |
5217 v7->field_C = ((unsigned __int64)(v19 * (signed __int64)v13) >> 16) | |
5218 + ((unsigned __int64)(a4 * (signed __int64)v14) >> 16); | |
5219 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16) | |
5220 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16); | |
5221 v18 = ((unsigned __int64)(a4 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v14) >> 16); | |
5222 } | |
5223 else | |
5224 { | |
5225 v7->field_C = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16) | |
5226 + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16); | |
5227 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16) | |
5228 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16); | |
5229 v18 = a4; | |
5230 } | |
5231 v7->field_14 = v18; | |
5232 if ( pBLVRenderParams->sPartyRotX ) | |
5233 { | |
5234 v21 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16); | |
5235 v7->field_18 = ((unsigned __int64)(v21 * (signed __int64)v13) >> 16) | |
5236 + ((unsigned __int64)(a7 * (signed __int64)v14) >> 16); | |
5237 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16) | |
5238 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16); | |
5239 v20 = ((unsigned __int64)(a7 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v21 * (signed __int64)v14) >> 16); | |
5240 } | |
5241 else | |
5242 { | |
5243 v7->field_18 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16) | |
5244 + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16); | |
5245 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16) | |
5246 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16); | |
5247 v20 = a7; | |
5248 } | |
5249 v7->field_18 = -v7->field_18; | |
5250 v7->field_1C = -v7->field_1C; | |
5251 v7->field_20 = v20; | |
5252 v22 = v7->field_C; | |
5253 v7->field_20 = -v7->field_20; | |
5254 v23 = ((unsigned __int64)(v22 * (signed __int64)v7->field_0_party_dir_x) >> 16) | |
5255 + ((unsigned __int64)(v7->field_10 * (signed __int64)v7->field_4_party_dir_y) >> 16) | |
5256 + ((unsigned __int64)(v7->field_14 * (signed __int64)v7->field_8) >> 16); | |
5257 v30 = v7->field_18; | |
5258 v24 = v7->field_0_party_dir_x; | |
5259 v7->field_24 = v23; | |
5260 v31 = (unsigned __int64)(v30 * (signed __int64)v24) >> 16; | |
5261 result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4_party_dir_y) >> 16; | |
5262 v7->field_28 = v31 + result + ((unsigned __int64)(v7->field_20 * (signed __int64)v7->field_8) >> 16); | |
5263 return result; | |
1297 | 5264 } |
5265 //----- (00407A1C) -------------------------------------------------------- | |
5266 bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v) | |
5267 { | |
5268 unsigned int v4; // esi@1 | |
5269 Vec3_int_ v5; // ST08_12@2 | |
5270 int v6; // edi@2 | |
5271 int v7; // ebx@2 | |
5272 int v8; // esi@2 | |
5273 signed int v9; // ecx@2 | |
5274 int v10; // eax@2 | |
5275 int v11; // ecx@4 | |
5276 int v12; // eax@4 | |
5277 int v13; // ebx@4 | |
5278 int v14; // edx@6 | |
5279 char *v15; // edi@16 | |
5280 ODMFace *v16; // esi@19 | |
5281 int v17; // ST34_4@25 | |
5282 int v18; // ST38_4@25 | |
5283 int v19; // eax@25 | |
5284 char v20; // zf@25 | |
5285 int v21; // ebx@25 | |
5286 int v22; // eax@26 | |
5287 signed int v23; // edi@26 | |
5288 int v24; // ST34_4@30 | |
5289 signed __int64 v25; // qtt@31 | |
5290 int v26; // eax@31 | |
5291 Vec3_int_ v27; // ST08_12@37 | |
5292 Vec3_int_ v28; // ST08_12@37 | |
5293 int v29; // edi@37 | |
5294 int v30; // ebx@37 | |
5295 int v31; // esi@37 | |
5296 signed int v32; // ecx@37 | |
5297 int v33; // eax@37 | |
5298 int v34; // ecx@39 | |
5299 int v35; // eax@39 | |
5300 int v36; // ebx@39 | |
5301 int v37; // edx@41 | |
5302 char *v38; // edi@51 | |
5303 ODMFace *v39; // esi@54 | |
5304 int v40; // ebx@60 | |
5305 int v41; // eax@61 | |
5306 signed int v42; // edi@61 | |
5307 signed __int64 v43; // qtt@66 | |
5308 int v44; // eax@66 | |
5309 Vec3_int_ v45; // ST08_12@73 | |
5310 int v46; // edi@73 | |
5311 int v47; // ebx@73 | |
5312 int v48; // esi@73 | |
5313 signed int v49; // ecx@73 | |
5314 int v50; // eax@73 | |
5315 int v51; // edx@75 | |
5316 int v52; // ecx@75 | |
5317 int v53; // eax@75 | |
5318 int v54; // ebx@75 | |
5319 int v55; // edi@77 | |
5320 int v56; // ecx@77 | |
5321 int v57; // eax@81 | |
5322 int v58; // esi@81 | |
5323 int v59; // eax@90 | |
5324 BLVSector *v60; // edx@90 | |
5325 int v61; // ecx@90 | |
5326 BLVFace *v62; // esi@91 | |
5327 int v63; // ST34_4@98 | |
5328 int v64; // ST30_4@98 | |
5329 int v65; // eax@98 | |
5330 int v66; // ebx@98 | |
5331 int v67; // eax@99 | |
5332 signed int v68; // edi@99 | |
5333 int v69; // ST2C_4@103 | |
5334 signed __int64 v70; // qtt@104 | |
5335 int v71; // eax@104 | |
5336 Vec3_int_ v72; // ST08_12@111 | |
5337 Vec3_int_ v73; // ST08_12@111 | |
5338 int v74; // edi@111 | |
5339 int v75; // ebx@111 | |
5340 int v76; // esi@111 | |
5341 signed int v77; // ecx@111 | |
5342 int v78; // eax@111 | |
5343 int v79; // edx@113 | |
5344 int v80; // ecx@113 | |
5345 int v81; // eax@113 | |
5346 int v82; // ebx@113 | |
5347 int v83; // edi@115 | |
5348 int v84; // ecx@115 | |
5349 int v85; // eax@119 | |
5350 int v86; // esi@119 | |
5351 int v87; // ecx@128 | |
5352 BLVSector *v88; // eax@128 | |
5353 int v89; // ecx@128 | |
5354 BLVFace *v90; // esi@129 | |
5355 int v91; // ebx@136 | |
5356 int v92; // eax@137 | |
5357 signed int v93; // edi@137 | |
5358 signed __int64 v94; // qtt@142 | |
5359 int v95; // eax@142 | |
5360 Vec3_int_ v97; // [sp-18h] [bp-94h]@1 | |
5361 int v98; // [sp-Ch] [bp-88h]@88 | |
5362 int v99; // [sp-Ch] [bp-88h]@126 | |
5363 int v100; // [sp-8h] [bp-84h]@88 | |
5364 int v101; // [sp-8h] [bp-84h]@126 | |
5365 int v102; // [sp-4h] [bp-80h]@88 | |
5366 int v103; // [sp-4h] [bp-80h]@126 | |
5367 int v104; // [sp+Ch] [bp-70h]@13 | |
5368 int v105; // [sp+Ch] [bp-70h]@48 | |
5369 int v106; // [sp+10h] [bp-6Ch]@18 | |
5370 int v107; // [sp+10h] [bp-6Ch]@98 | |
5371 int v108; // [sp+10h] [bp-6Ch]@104 | |
5372 int v109; // [sp+18h] [bp-64h]@25 | |
5373 int v110; // [sp+18h] [bp-64h]@31 | |
5374 int i; // [sp+18h] [bp-64h]@90 | |
5375 int v112; // [sp+18h] [bp-64h]@128 | |
5376 signed int v113; // [sp+20h] [bp-5Ch]@1 | |
5377 signed int v114; // [sp+24h] [bp-58h]@1 | |
5378 unsigned __int64 a4; // [sp+28h] [bp-54h]@1 | |
5379 unsigned int a4_8; // [sp+30h] [bp-4Ch]@1 | |
5380 int v117; // [sp+34h] [bp-48h]@4 | |
5381 int v118; // [sp+34h] [bp-48h]@39 | |
5382 int v119; // [sp+34h] [bp-48h]@75 | |
5383 int v120; // [sp+34h] [bp-48h]@113 | |
5384 int v121; // [sp+38h] [bp-44h]@4 | |
5385 int v122; // [sp+38h] [bp-44h]@39 | |
5386 int v123; // [sp+38h] [bp-44h]@76 | |
5387 int v124; // [sp+38h] [bp-44h]@114 | |
5388 int v125; // [sp+3Ch] [bp-40h]@4 | |
5389 int v126; // [sp+3Ch] [bp-40h]@39 | |
5390 int v127; // [sp+3Ch] [bp-40h]@77 | |
5391 int v128; // [sp+3Ch] [bp-40h]@115 | |
5392 int v129; // [sp+40h] [bp-3Ch]@11 | |
5393 int v130; // [sp+40h] [bp-3Ch]@46 | |
5394 int v131; // [sp+40h] [bp-3Ch]@78 | |
5395 int v132; // [sp+40h] [bp-3Ch]@116 | |
5396 int v133; // [sp+44h] [bp-38h]@10 | |
5397 int v134; // [sp+44h] [bp-38h]@45 | |
5398 int v135; // [sp+44h] [bp-38h]@81 | |
5399 int v136; // [sp+44h] [bp-38h]@119 | |
5400 int v137; // [sp+48h] [bp-34h]@7 | |
5401 int v138; // [sp+48h] [bp-34h]@42 | |
5402 int v139; // [sp+48h] [bp-34h]@82 | |
5403 int v140; // [sp+48h] [bp-34h]@120 | |
5404 int v141; // [sp+4Ch] [bp-30h]@6 | |
5405 int v142; // [sp+4Ch] [bp-30h]@41 | |
5406 int v143; // [sp+4Ch] [bp-30h]@75 | |
5407 int v144; // [sp+4Ch] [bp-30h]@113 | |
5408 int v145; // [sp+50h] [bp-2Ch]@5 | |
5409 int v146; // [sp+50h] [bp-2Ch]@40 | |
5410 int v147; // [sp+50h] [bp-2Ch]@75 | |
5411 int v148; // [sp+50h] [bp-2Ch]@113 | |
5412 int v149; // [sp+54h] [bp-28h]@4 | |
5413 int v150; // [sp+54h] [bp-28h]@39 | |
5414 int v151; // [sp+54h] [bp-28h]@75 | |
5415 int v152; // [sp+54h] [bp-28h]@113 | |
5416 int sDepth; // [sp+58h] [bp-24h]@17 | |
5417 int sDeptha; // [sp+58h] [bp-24h]@52 | |
5418 int sDepthb; // [sp+58h] [bp-24h]@90 | |
5419 char *a5; // [sp+5Ch] [bp-20h]@16 | |
5420 char *a5a; // [sp+5Ch] [bp-20h]@51 | |
5421 signed int a5b; // [sp+5Ch] [bp-20h]@83 | |
5422 signed int a5c; // [sp+5Ch] [bp-20h]@121 | |
5423 signed int v160; // [sp+60h] [bp-1Ch]@12 | |
5424 signed int v161; // [sp+60h] [bp-1Ch]@47 | |
5425 int v162; // [sp+60h] [bp-1Ch]@128 | |
5426 int v163; // [sp+64h] [bp-18h]@2 | |
5427 int outx; // [sp+68h] [bp-14h]@2 | |
5428 int outy; // [sp+6Ch] [bp-10h]@2 | |
5429 int outz; // [sp+70h] [bp-Ch]@2 | |
5430 Vec3_int_ pOut; // [sp+74h] [bp-8h]@2 | |
5431 int ya; // [sp+84h] [bp+8h]@60 | |
5432 int yb; // [sp+84h] [bp+8h]@136 | |
5433 int ve; // [sp+88h] [bp+Ch]@60 | |
5434 int va; // [sp+88h] [bp+Ch]@60 | |
5435 int vb; // [sp+88h] [bp+Ch]@66 | |
5436 int vf; // [sp+88h] [bp+Ch]@136 | |
5437 int vc; // [sp+88h] [bp+Ch]@136 | |
5438 int vd; // [sp+88h] [bp+Ch]@142 | |
5439 int v_4; // [sp+8Ch] [bp+10h]@60 | |
5440 int v_4a; // [sp+8Ch] [bp+10h]@65 | |
5441 int v_4b; // [sp+8Ch] [bp+10h]@136 | |
5442 int v_4c; // [sp+8Ch] [bp+10h]@141 | |
5443 int v_8; // [sp+90h] [bp+14h]@53 | |
5444 | |
5445 a4 = __PAIR__(z, x); | |
5446 v4 = stru_5C6E00->Atan2(v.x - x, v.y - z); | |
5447 v114 = 0; | |
5448 v97.z = y; | |
5449 v113 = 0; | |
5450 a4_8 = v4; | |
5451 *(_QWORD *)&v97.x = a4; | |
5452 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) | |
5453 { | |
5454 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); | |
5455 v45.z = v.z; | |
5456 *(_QWORD *)&v45.x = *(_QWORD *)&v; | |
5457 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163); | |
5458 v46 = outy - pOut.y; | |
5459 v47 = v163 - outz; | |
5460 v48 = outx - pOut.x; | |
5461 v49 = integer_sqrt(v48 * v48 + v46 * v46 + v47 * v47); | |
5462 v50 = 65536; | |
5463 if ( v49 ) | |
5464 v50 = 65536 / v49; | |
5465 v51 = outx; | |
5466 v143 = v48 * v50; | |
5467 v52 = v46 * v50; | |
5468 v53 = v47 * v50; | |
5469 v54 = pOut.x; | |
5470 v147 = v52; | |
5471 v151 = v53; | |
5472 v119 = pOut.x; | |
5473 if ( pOut.x < outx ) | |
5474 { | |
5475 v123 = outx; | |
5476 } | |
5477 else | |
5478 { | |
5479 v119 = outx; | |
5480 v123 = pOut.x; | |
5481 } | |
5482 v55 = pOut.y; | |
5483 v56 = outy; | |
5484 v127 = pOut.y; | |
5485 if ( pOut.y < outy ) | |
5486 { | |
5487 v131 = outy; | |
5488 } | |
5489 else | |
5490 { | |
5491 v127 = outy; | |
5492 v131 = pOut.y; | |
5493 } | |
5494 v57 = v163; | |
5495 v58 = outz; | |
5496 v135 = outz; | |
5497 if ( outz < v163 ) | |
5498 { | |
5499 v139 = v163; | |
5500 } | |
5501 else | |
5502 { | |
5503 v135 = v163; | |
5504 v139 = outz; | |
5505 } | |
5506 a5b = 0; | |
5507 while ( !v114 ) | |
5508 { | |
5509 if ( a5b ) | |
5510 { | |
5511 v102 = v58; | |
5512 v100 = v55; | |
5513 v98 = v54; | |
5514 } | |
5515 else | |
5516 { | |
5517 v102 = v57; | |
5518 v100 = v56; | |
5519 v98 = v51; | |
5520 } | |
5521 v59 = pIndoor->GetSector(v98, v100, v102); | |
5522 v60 = pIndoor->pSectors; | |
5523 v61 = 116 * v59; | |
5524 sDepthb = 0; | |
5525 for ( i = 116 * v59; | |
5526 sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61) | |
5527 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61); | |
5528 ++sDepthb ) | |
5529 { | |
5530 v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]]; | |
5531 if ( v62->Portal() | |
5532 || v119 > v62->pBounding.x2 | |
5533 || v123 < v62->pBounding.x1 | |
5534 || v127 > v62->pBounding.y2 | |
5535 || v131 < v62->pBounding.y1 | |
5536 || v135 > v62->pBounding.z2 | |
5537 || v139 < v62->pBounding.z1 | |
5538 || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16, | |
5539 v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16, | |
5540 v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16, | |
5541 v20 = v63 + v64 + v65 == 0, | |
5542 v66 = v63 + v64 + v65, | |
5543 v107 = v63 + v64 + v65, | |
5544 v20) ) | |
5545 goto LABEL_107; | |
5546 v67 = outz * v62->pFacePlane_old.vNormal.z; | |
5547 v68 = -(v62->pFacePlane_old.dist | |
5548 + v67 | |
5549 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5550 + pOut.x * v62->pFacePlane_old.vNormal.x); | |
5551 if ( v66 <= 0 ) | |
5552 { | |
5553 if ( v62->pFacePlane_old.dist | |
5554 + v67 | |
5555 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5556 + pOut.x * v62->pFacePlane_old.vNormal.x < 0 ) | |
5557 goto LABEL_107; | |
5558 } | |
5559 else | |
5560 { | |
5561 if ( v62->pFacePlane_old.dist | |
5562 + v67 | |
5563 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5564 + pOut.x * v62->pFacePlane_old.vNormal.x > 0 ) | |
5565 goto LABEL_107; | |
5566 } | |
5567 v69 = abs(-(v62->pFacePlane_old.dist | |
5568 + v67 | |
5569 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5570 + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14; | |
5571 if ( v69 <= abs(v66) ) | |
5572 { | |
5573 LODWORD(v70) = v68 << 16; | |
5574 HIDWORD(v70) = v68 >> 16; | |
5575 v71 = v70 / v107; | |
5576 v108 = v70 / v107; | |
5577 if ( v71 >= 0 ) | |
5578 { | |
5579 if ( sub_4075DB( | |
5580 pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16), | |
5581 pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16), | |
5582 outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16), | |
5583 v62) ) | |
5584 { | |
5585 v114 = 1; | |
5586 break; | |
5587 } | |
5588 } | |
5589 } | |
5590 v61 = i; | |
5591 LABEL_107: | |
5592 v60 = pIndoor->pSectors; | |
5593 } | |
5594 ++a5b; | |
5595 if ( a5b >= 2 ) | |
5596 break; | |
5597 v57 = v163; | |
5598 v56 = outy; | |
5599 v51 = outx; | |
5600 v58 = outz; | |
5601 v55 = pOut.y; | |
5602 v54 = pOut.x; | |
5603 } | |
5604 v72.z = y; | |
5605 *(_QWORD *)&v72.x = a4; | |
5606 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz); | |
5607 v73.z = v.z; | |
5608 *(_QWORD *)&v73.x = *(_QWORD *)&v; | |
5609 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163); | |
5610 v74 = outy - pOut.y; | |
5611 v75 = v163 - outz; | |
5612 v76 = outx - pOut.x; | |
5613 v77 = integer_sqrt(v76 * v76 + v74 * v74 + v75 * v75); | |
5614 v78 = 65536; | |
5615 if ( v77 ) | |
5616 v78 = 65536 / v77; | |
5617 v79 = outx; | |
5618 v144 = v76 * v78; | |
5619 v80 = v74 * v78; | |
5620 v81 = v75 * v78; | |
5621 v82 = pOut.x; | |
5622 v148 = v80; | |
5623 v152 = v81; | |
5624 v120 = pOut.x; | |
5625 if ( pOut.x < outx ) | |
5626 { | |
5627 v124 = outx; | |
5628 } | |
5629 else | |
5630 { | |
5631 v120 = outx; | |
5632 v124 = pOut.x; | |
5633 } | |
5634 v83 = pOut.y; | |
5635 v84 = outy; | |
5636 v128 = pOut.y; | |
5637 if ( pOut.y < outy ) | |
5638 { | |
5639 v132 = outy; | |
5640 } | |
5641 else | |
5642 { | |
5643 v128 = outy; | |
5644 v132 = pOut.y; | |
5645 } | |
5646 v85 = v163; | |
5647 v86 = outz; | |
5648 v136 = outz; | |
5649 if ( outz < v163 ) | |
5650 { | |
5651 v140 = v163; | |
5652 } | |
5653 else | |
5654 { | |
5655 v136 = v163; | |
5656 v140 = outz; | |
5657 } | |
5658 a5c = 0; | |
5659 while ( 1 ) | |
5660 { | |
5661 if ( v113 ) | |
5662 return !v114 || !v113; | |
5663 if ( a5c ) | |
5664 { | |
5665 v103 = v86; | |
5666 v101 = v83; | |
5667 v99 = v82; | |
5668 } | |
5669 else | |
5670 { | |
5671 v103 = v85; | |
5672 v101 = v84; | |
5673 v99 = v79; | |
5674 } | |
5675 v87 = pIndoor->GetSector(v99, v101, v103); | |
5676 v88 = pIndoor->pSectors; | |
5677 v89 = 116 * v87; | |
5678 v162 = 0; | |
5679 v112 = v89; | |
5680 if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) | |
5681 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 ) | |
5682 break; | |
5683 LABEL_148: | |
5684 ++a5c; | |
5685 if ( a5c >= 2 ) | |
5686 return !v114 || !v113; | |
5687 v85 = v163; | |
5688 v84 = outy; | |
5689 v79 = outx; | |
5690 v86 = outz; | |
5691 v83 = pOut.y; | |
5692 v82 = pOut.x; | |
5693 } | |
5694 while ( 1 ) | |
5695 { | |
5696 v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]]; | |
5697 if ( v90->Portal() | |
5698 || v120 > v90->pBounding.x2 | |
5699 || v124 < v90->pBounding.x1 | |
5700 || v128 > v90->pBounding.y2 | |
5701 || v132 < v90->pBounding.y1 | |
5702 || v136 > v90->pBounding.z2 | |
5703 || v140 < v90->pBounding.z1 | |
5704 || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16, | |
5705 v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16, | |
5706 vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16, | |
5707 v20 = yb + vf + v_4b == 0, | |
5708 v91 = yb + vf + v_4b, | |
5709 vc = yb + vf + v_4b, | |
5710 v20) ) | |
5711 goto LABEL_145; | |
5712 v92 = outz * v90->pFacePlane_old.vNormal.z; | |
5713 v93 = -(v90->pFacePlane_old.dist | |
5714 + v92 | |
5715 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5716 + pOut.x * v90->pFacePlane_old.vNormal.x); | |
5717 if ( v91 <= 0 ) | |
5718 { | |
5719 if ( v90->pFacePlane_old.dist | |
5720 + v92 | |
5721 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5722 + pOut.x * v90->pFacePlane_old.vNormal.x < 0 ) | |
5723 goto LABEL_145; | |
5724 } | |
5725 else | |
5726 { | |
5727 if ( v90->pFacePlane_old.dist | |
5728 + v92 | |
5729 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5730 + pOut.x * v90->pFacePlane_old.vNormal.x > 0 ) | |
5731 goto LABEL_145; | |
5732 } | |
5733 v_4c = abs(-(v90->pFacePlane_old.dist | |
5734 + v92 | |
5735 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5736 + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14; | |
5737 if ( v_4c <= abs(v91) ) | |
5738 { | |
5739 LODWORD(v94) = v93 << 16; | |
5740 HIDWORD(v94) = v93 >> 16; | |
5741 v95 = v94 / vc; | |
5742 vd = v94 / vc; | |
5743 if ( v95 >= 0 ) | |
5744 { | |
5745 if ( sub_4075DB( | |
5746 pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16), | |
5747 pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16), | |
5748 outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16), | |
5749 v90) ) | |
5750 { | |
5751 v113 = 1; | |
5752 goto LABEL_148; | |
5753 } | |
5754 } | |
5755 } | |
5756 v89 = v112; | |
5757 LABEL_145: | |
5758 v88 = pIndoor->pSectors; | |
5759 ++v162; | |
5760 if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) | |
5761 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) ) | |
5762 goto LABEL_148; | |
5763 } | |
5764 } | |
5765 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); | |
5766 v5.z = v.z; | |
5767 *(_QWORD *)&v5.x = *(_QWORD *)&v; | |
5768 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163); | |
5769 v6 = outy - pOut.y; | |
5770 v7 = v163 - outz; | |
5771 v8 = outx - pOut.x; | |
5772 v9 = integer_sqrt(v8 * v8 + v6 * v6 + v7 * v7); | |
5773 v10 = 65536; | |
5774 if ( v9 ) | |
5775 v10 = 65536 / v9; | |
5776 v125 = v8 * v10; | |
5777 v11 = v10; | |
5778 v12 = v7 * v10; | |
5779 v13 = pOut.x; | |
5780 v117 = v12; | |
5781 v121 = v6 * v11; | |
5782 v149 = pOut.x; | |
5783 if ( pOut.x < outx ) | |
5784 { | |
5785 v145 = outx; | |
5786 } | |
5787 else | |
5788 { | |
5789 v149 = outx; | |
5790 v145 = pOut.x; | |
5791 } | |
5792 v14 = outy; | |
5793 v141 = pOut.y; | |
5794 if ( pOut.y < outy ) | |
5795 { | |
5796 v137 = outy; | |
5797 } | |
5798 else | |
5799 { | |
5800 v141 = outy; | |
5801 v137 = pOut.y; | |
5802 } | |
5803 v133 = outz; | |
5804 if ( outz < v163 ) | |
5805 { | |
5806 v129 = v163; | |
5807 } | |
5808 else | |
5809 { | |
5810 v133 = v163; | |
5811 v129 = outz; | |
5812 } | |
5813 v160 = 0; | |
5814 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
5815 { | |
5816 v104 = 0; | |
5817 while ( 1 ) | |
5818 { | |
5819 v15 = (char *)&pOutdoor->pBModels[v104].pVertices; | |
5820 a5 = (char *)&pOutdoor->pBModels[v104].pVertices; | |
5821 if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 ) | |
5822 { | |
5823 sDepth = 0; | |
5824 if ( *((int *)v15 + 2) > 0 ) | |
5825 break; | |
5826 } | |
5827 LABEL_36: | |
5828 ++v160; | |
5829 ++v104; | |
5830 if ( v160 >= (signed int)pOutdoor->uNumBModels ) | |
5831 goto LABEL_37; | |
5832 v14 = outy; | |
5833 v13 = pOut.x; | |
5834 } | |
5835 v106 = 0; | |
5836 while ( 1 ) | |
5837 { | |
5838 v16 = (ODMFace *)(v106 + *((int *)a5 + 4)); | |
5839 if ( v149 > v16->pBoundingBox.x2 | |
5840 || v145 < v16->pBoundingBox.x1 | |
5841 || v141 > v16->pBoundingBox.y2 | |
5842 || v137 < v16->pBoundingBox.y1 | |
5843 || v133 > v16->pBoundingBox.z2 | |
5844 || v129 < v16->pBoundingBox.z1 | |
5845 || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16, | |
5846 v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16, | |
5847 v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16, | |
5848 v20 = v17 + v18 + v19 == 0, | |
5849 v21 = v17 + v18 + v19, | |
5850 v109 = v17 + v18 + v19, | |
5851 v20) ) | |
5852 goto LABEL_33; | |
5853 v22 = pOut.y * v16->pFacePlane.vNormal.y; | |
5854 v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x); | |
5855 if ( v21 <= 0 ) | |
5856 { | |
5857 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 ) | |
5858 goto LABEL_33; | |
5859 } | |
5860 else | |
5861 { | |
5862 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 ) | |
5863 goto LABEL_33; | |
5864 } | |
5865 v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14; | |
5866 if ( v24 <= abs(v21) ) | |
5867 { | |
5868 LODWORD(v25) = v23 << 16; | |
5869 HIDWORD(v25) = v23 >> 16; | |
5870 v26 = v25 / v109; | |
5871 v110 = v25 / v109; | |
5872 if ( v26 >= 0 ) | |
5873 { | |
5874 if ( sub_4077F1( | |
5875 pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16), | |
5876 pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16), | |
5877 outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16), | |
5878 v16, | |
5879 (BSPVertexBuffer *)a5) ) | |
5880 { | |
5881 v114 = 1; | |
5882 goto LABEL_36; | |
5883 } | |
5884 } | |
5885 } | |
5886 LABEL_33: | |
5887 ++sDepth; | |
5888 v106 += 308; | |
5889 if ( sDepth >= *((int *)a5 + 2) ) | |
5890 goto LABEL_36; | |
5891 } | |
5892 } | |
5893 LABEL_37: | |
5894 v27.z = y; | |
5895 *(_QWORD *)&v27.x = a4; | |
5896 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz); | |
5897 v28.z = v.z; | |
5898 *(_QWORD *)&v28.x = *(_QWORD *)&v; | |
5899 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163); | |
5900 v29 = outy - pOut.y; | |
5901 v30 = v163 - outz; | |
5902 v31 = outx - pOut.x; | |
5903 v32 = integer_sqrt(v31 * v31 + v29 * v29 + v30 * v30); | |
5904 v33 = 65536; | |
5905 if ( v32 ) | |
5906 v33 = 65536 / v32; | |
5907 v126 = v31 * v33; | |
5908 v34 = v33; | |
5909 v35 = v30 * v33; | |
5910 v36 = pOut.x; | |
5911 v118 = v35; | |
5912 v122 = v29 * v34; | |
5913 v150 = pOut.x; | |
5914 if ( pOut.x < outx ) | |
5915 { | |
5916 v146 = outx; | |
5917 } | |
5918 else | |
5919 { | |
5920 v150 = outx; | |
5921 v146 = pOut.x; | |
5922 } | |
5923 v37 = outy; | |
5924 v142 = pOut.y; | |
5925 if ( pOut.y < outy ) | |
5926 { | |
5927 v138 = outy; | |
5928 } | |
5929 else | |
5930 { | |
5931 v142 = outy; | |
5932 v138 = pOut.y; | |
5933 } | |
5934 v134 = outz; | |
5935 if ( outz < v163 ) | |
5936 { | |
5937 v130 = v163; | |
5938 } | |
5939 else | |
5940 { | |
5941 v134 = v163; | |
5942 v130 = outz; | |
5943 } | |
5944 v161 = 0; | |
5945 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
5946 { | |
5947 v105 = 0; | |
5948 while ( 1 ) | |
5949 { | |
5950 v38 = (char *)&pOutdoor->pBModels[v105].pVertices; | |
5951 a5a = (char *)&pOutdoor->pBModels[v105].pVertices; | |
5952 if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 ) | |
5953 { | |
5954 sDeptha = 0; | |
5955 if ( *((int *)v38 + 2) > 0 ) | |
5956 break; | |
5957 } | |
5958 LABEL_71: | |
5959 ++v161; | |
5960 ++v105; | |
5961 if ( v161 >= (signed int)pOutdoor->uNumBModels ) | |
5962 return !v114 || !v113; | |
5963 v37 = outy; | |
5964 v36 = pOut.x; | |
5965 } | |
5966 v_8 = 0; | |
5967 while ( 1 ) | |
5968 { | |
5969 v39 = (ODMFace *)(v_8 + *((int *)a5a + 4)); | |
5970 if ( v150 > v39->pBoundingBox.x2 | |
5971 || v146 < v39->pBoundingBox.x1 | |
5972 || v142 > v39->pBoundingBox.y2 | |
5973 || v138 < v39->pBoundingBox.y1 | |
5974 || v134 > v39->pBoundingBox.z2 | |
5975 || v130 < v39->pBoundingBox.z1 | |
5976 || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16, | |
5977 ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16, | |
5978 v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16, | |
5979 v20 = ya + ve + v_4 == 0, | |
5980 v40 = ya + ve + v_4, | |
5981 va = ya + ve + v_4, | |
5982 v20) ) | |
5983 goto LABEL_68; | |
5984 v41 = pOut.y * v39->pFacePlane.vNormal.y; | |
5985 v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x); | |
5986 if ( v40 <= 0 ) | |
5987 { | |
5988 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 ) | |
5989 goto LABEL_68; | |
5990 } | |
5991 else | |
5992 { | |
5993 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 ) | |
5994 goto LABEL_68; | |
5995 } | |
5996 v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14; | |
5997 if ( v_4a <= abs(v40) ) | |
5998 { | |
5999 LODWORD(v43) = v42 << 16; | |
6000 HIDWORD(v43) = v42 >> 16; | |
6001 v44 = v43 / va; | |
6002 vb = v43 / va; | |
6003 if ( v44 >= 0 ) | |
6004 { | |
6005 if ( sub_4077F1( | |
6006 pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16), | |
6007 pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16), | |
6008 outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16), | |
6009 v39, | |
6010 (BSPVertexBuffer *)a5a) ) | |
6011 { | |
6012 v113 = 1; | |
6013 goto LABEL_71; | |
6014 } | |
6015 } | |
6016 } | |
6017 LABEL_68: | |
6018 ++sDeptha; | |
6019 v_8 += 308; | |
6020 if ( sDeptha >= *((int *)a5a + 2) ) | |
6021 goto LABEL_71; | |
6022 } | |
6023 } | |
6024 return !v114 || !v113; | |
6025 } | |
6026 //----- (0043F333) -------------------------------------------------------- | |
6027 void BspRenderer::MakeVisibleSectorList() | |
6028 { | |
6029 int v6; // ebx@3 | |
6030 | |
6031 uNumVisibleNotEmptySectors = 0; | |
6032 for (uint i = 0; i < num_nodes; ++i) | |
6033 { | |
6034 if (!uNumVisibleNotEmptySectors) | |
6035 { | |
6036 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; | |
6037 continue; | |
6038 } | |
6039 | |
6040 v6 = 0; | |
6041 while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != nodes[i].uSectorID ) | |
6042 { | |
6043 ++v6; | |
6044 if ( v6 >= uNumVisibleNotEmptySectors) | |
6045 { | |
6046 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; | |
6047 } | |
6048 } | |
6049 | |
6050 } | |
6051 } | |
6052 //----- (0046A334) -------------------------------------------------------- | |
6053 char __fastcall DoInteractionWithTopmostZObject(int a1, int a2) | |
6054 { | |
6055 int v2; // edx@1 | |
6056 BLVFace *v4; // eax@9 | |
6057 unsigned int v5; // ecx@9 | |
6058 unsigned __int16 v6; // ax@11 | |
6059 //ODMFace *v7; // eax@16 | |
6060 LevelDecoration *v8; // esi@19 | |
6061 __int16 v9; // ax@19 | |
6062 int v10; // eax@22 | |
6063 int v11; // ecx@22 | |
6064 int v12; // edi@23 | |
6065 Actor *v13; // esi@23 | |
6066 unsigned __int16 v14; // ax@23 | |
6067 unsigned __int16 v15; // ax@33 | |
6068 const char *v16; // eax@34 | |
6069 int v17; // edi@36 | |
6070 int v18; // eax@36 | |
6071 ItemGen *v19; // esi@39 | |
6072 unsigned int v20; // eax@39 | |
6073 int v21; // ecx@40 | |
6074 std::string v22; // [sp-18h] [bp-2Ch]@5 | |
6075 const char *v23; // [sp-8h] [bp-1Ch]@5 | |
6076 int v24; // [sp-4h] [bp-18h]@5 | |
6077 char v25; // [sp+8h] [bp-Ch]@5 | |
6078 int v26; // [sp+Ch] [bp-8h]@1 | |
6079 int a3; // [sp+13h] [bp-1h]@5 | |
6080 | |
6081 v26 = a2; | |
6082 v2 = a1; | |
6083 switch ( PID_TYPE(a1) ) | |
6084 { | |
6085 case OBJECT_Item: // take the item | |
6086 v17 = PID_ID(a1); | |
6087 v26 = PID_ID(a1); | |
6088 v18 = PID_ID(a1); | |
6089 if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 | |
6090 || v17 >= 1000 | |
6091 || !pSpriteObjects[v18].uObjectDescID ) | |
6092 return 1; | |
6093 v19 = &pSpriteObjects[v18].stru_24; | |
6094 v20 = pSpriteObjects[v18].stru_24.uItemID; | |
6095 if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) | |
6096 { | |
6097 party_finds_gold(v19->uSpecEnchantmentType, 0); | |
6098 viewparams->bRedrawGameUI = 1; | |
6099 v21 = v17; | |
6100 } | |
6101 else | |
6102 { | |
6103 if ( pParty->pPickedItem.uItemID ) | |
6104 return 1; | |
6105 v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName; | |
6106 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v24); | |
6107 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
6108 if ( v19->uItemID == 506 ) | |
6109 _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); | |
6110 if ( v19->uItemID == 455 ) | |
6111 _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); | |
6112 if ( !pParty->AddItem(v19) ) | |
6113 pParty->SetHoldingItem(v19); | |
6114 v21 = v26; | |
6115 } | |
6116 SpriteObject::OnInteraction(v21); | |
6117 break; | |
6118 | |
6119 case OBJECT_Actor: | |
6120 v12 = PID_ID(a1); | |
6121 v13 = &pActors[PID_ID(a1)]; | |
6122 v14 = v13->uAIState; | |
6123 if ( v14 == 4 || v14 == 17 ) | |
6124 return 1; | |
6125 if ( v14 == 5 ) | |
6126 { | |
6127 stru_50C198.LootActor(&pActors[PID_ID(a1)]); | |
6128 } | |
6129 else | |
6130 { | |
6131 if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() ) | |
6132 { | |
6133 Actor::AI_FaceObject(v12, 4u, 0, 0); | |
6134 if ( v13->sNPC_ID ) | |
6135 { | |
6136 pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); | |
6137 } | |
6138 else | |
6139 { | |
6140 v15 = pNPCStats->pGroups_copy[v13->uGroup]; | |
6141 if ( v15 ) | |
6142 { | |
6143 v16 = pNPCStats->pCatchPhrases[v15]; | |
6144 if ( v16 ) | |
6145 { | |
6146 pParty->uFlags |= 2u; | |
6147 strcpy(byte_5B0938.data(), v16); | |
6148 sub_4451A8_press_any_key(0, 0, 0); | |
6149 } | |
6150 } | |
6151 } | |
6152 } | |
6153 } | |
6154 break; | |
6155 | |
6156 case OBJECT_Decoration: | |
6157 v8 = &pLevelDecorations[PID_ID(a1)]; | |
6158 v9 = v8->field_16_event_id; | |
6159 if ( v9 ) | |
6160 { | |
6161 EventProcessor(v9, a1, 1); | |
6162 LOBYTE(v8->field_2) |= 8u; | |
6163 } | |
6164 else | |
6165 { | |
6166 if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() ) | |
6167 return 1; | |
6168 v10 = v8->_idx_in_stru123; | |
6169 v24 = 1; | |
6170 v11 = stru_5E4C90._decor_events[v10 - 75] + 380; | |
6171 activeLevelDecoration = v8; | |
6172 EventProcessor(v11, 0, 1); | |
6173 activeLevelDecoration = NULL; | |
6174 } | |
6175 break; | |
6176 | |
6177 default: | |
6178 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); | |
6179 return 1; | |
6180 | |
6181 case OBJECT_BModel: | |
6182 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6183 { | |
6184 int bmodel_id = a1 >> 9, | |
6185 face_id = PID_ID(a1) & 0x3F; | |
6186 if (bmodel_id >= pOutdoor->uNumBModels) | |
6187 return 1; | |
6188 auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id]; | |
6189 if (face->uAttributes & 0x100000 || face->sCogTriggeredID == 0 ) | |
6190 return 1; | |
6191 EventProcessor((signed __int16)face->sCogTriggeredID, v2, 1); | |
6192 } | |
6193 else | |
6194 { | |
6195 v4 = &pIndoor->pFaces[PID_ID(a1)]; | |
6196 v5 = v4->uAttributes; | |
6197 if ( !(v5 & 0x2000000) ) | |
6198 { | |
6199 ShowNothingHereStatus(); | |
6200 return 1; | |
6201 } | |
6202 if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 ) | |
6203 return 1; | |
6204 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) | |
6205 EventProcessor((signed __int16)v6, v2, 1); | |
6206 } | |
6207 return 0; | |
6208 break; | |
6209 } | |
6210 return 0; | |
6211 } | |
6212 //----- (0046BDF1) -------------------------------------------------------- | |
6213 void __cdecl BLV_UpdateUserInputAndOther() | |
6214 { | |
6215 UpdateObjects(); | |
6216 BLV_ProcessPartyActions(); | |
6217 UpdateActors_BLV(); | |
6218 BLV_UpdateDoors(); | |
6219 check_event_triggers(); | |
6220 } | |
6221 //----- (00424829) -------------------------------------------------------- | |
1378 | 6222 // Finds out if current portal can be seen through the previous portal |
1376 | 6223 bool PortalFrustrum(int pNumVertices, BspRenderer_PortalViewportData *far_portal, BspRenderer_PortalViewportData *near_portal, int uFaceID) |
1297 | 6224 { |
6225 int min_y; // esi@5 | |
6226 int max_y; // edx@5 | |
1372 | 6227 int current_ID; // eax@12 |
1297 | 6228 int v13; // eax@22 |
6229 int v15; // ecx@29 | |
6230 int v18; // eax@39 | |
6231 int v19; // eax@44 | |
6232 int v20; // ecx@44 | |
6233 int v22; // edi@46 | |
6234 int v24; // edx@48 | |
6235 int v26; // eax@55 | |
6236 signed int v27; // edi@55 | |
6237 int v29; // edx@57 | |
6238 int v31; // eax@64 | |
6239 signed int v32; // edi@64 | |
6240 int v34; // eax@66 | |
6241 int v35; // dx@66 | |
6242 __int16 v36; // dx@67 | |
1379 | 6243 //__int16 v37; // di@67 |
1297 | 6244 __int16 v38; // dx@67 |
6245 int v46; // edx@87 | |
6246 int v49; // esi@93 | |
6247 int v53; // [sp+Ch] [bp-34h]@44 | |
6248 int v54; // [sp+10h] [bp-30h]@0 | |
1372 | 6249 int min_y_ID2; // [sp+14h] [bp-2Ch]@12 |
1297 | 6250 int v59; // [sp+14h] [bp-2Ch]@87 |
6251 int v61; // [sp+1Ch] [bp-24h]@29 | |
6252 int v62; // [sp+20h] [bp-20h]@0 | |
1372 | 6253 signed int direction1; // [sp+24h] [bp-1Ch]@3 |
6254 signed int direction2; // [sp+28h] [bp-18h]@3 | |
6255 int min_y_ID; // [sp+2Ch] [bp-14h]@5 | |
1297 | 6256 int v69; // [sp+34h] [bp-Ch]@29 |
6257 int v70; // [sp+34h] [bp-Ch]@46 | |
1370 | 6258 |
1297 | 6259 if ( pNumVertices <= 1 ) |
6260 return false; | |
1344 | 6261 min_y = PortalFace._screen_space_y[0]; |
1372 | 6262 min_y_ID = 0; |
1344 | 6263 max_y = PortalFace._screen_space_y[0]; |
1372 | 6264 //face direction( ) |
1344 | 6265 if ( !PortalFace.direction ) |
1297 | 6266 { |
1372 | 6267 direction1 = 1; |
6268 direction2 = -1; | |
1297 | 6269 } |
6270 else | |
6271 { | |
1372 | 6272 direction1 = -1; |
6273 direction2 = 1; | |
6274 } | |
6275 | |
6276 //get min and max y for portal( y ) | |
6277 for ( uint i = 1; i < pNumVertices; ++i ) | |
6278 { | |
1378 | 6279 if (PortalFace._screen_space_y[i] < min_y) |
1297 | 6280 { |
1372 | 6281 min_y_ID = i; |
6282 min_y = PortalFace._screen_space_y[i]; | |
1297 | 6283 } |
1378 | 6284 else if (PortalFace._screen_space_y[i] > max_y) |
6285 { | |
6286 max_y = PortalFace._screen_space_y[i]; | |
6287 } | |
1297 | 6288 } |
6289 if ( max_y == min_y ) | |
6290 return false; | |
6291 | |
1372 | 6292 //***************************************************************************************************************************** |
1376 | 6293 far_portal->_viewport_space_y = min_y; |
6294 far_portal->_viewport_space_w = max_y; | |
1372 | 6295 current_ID = min_y_ID; |
6296 min_y_ID2 = min_y_ID; | |
6297 | |
6298 for ( uint i = 0; i < pNumVertices; ++i ) | |
6299 { | |
6300 current_ID += direction2; | |
6301 if ( current_ID < pNumVertices ) | |
1297 | 6302 { |
1372 | 6303 if ( current_ID < 0 ) |
6304 current_ID += pNumVertices; | |
1297 | 6305 } |
6306 else | |
1372 | 6307 current_ID -= pNumVertices; |
6308 if ( PortalFace._screen_space_y[current_ID] <= PortalFace._screen_space_y[min_y_ID] )// | |
1297 | 6309 { |
1372 | 6310 min_y_ID2 = current_ID; |
6311 min_y_ID = current_ID; | |
1297 | 6312 } |
1372 | 6313 if ( PortalFace._screen_space_y[current_ID] == max_y ) |
1297 | 6314 break; |
6315 } | |
1372 | 6316 |
6317 v13 = min_y_ID2 + direction2; | |
1297 | 6318 if ( v13 < pNumVertices ) |
6319 { | |
6320 if ( v13 < 0 ) | |
6321 v13 += pNumVertices; | |
6322 } | |
6323 else | |
6324 v13 -= pNumVertices; | |
1372 | 6325 if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[min_y_ID2] ) |
6326 { | |
6327 v62 = PortalFace._screen_space_x[min_y_ID2] << 16; | |
1378 | 6328 v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[min_y_ID2]) << 16) / |
6329 (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[min_y_ID2]); | |
6330 far_portal->viewport_left_side[min_y] = (short)PortalFace._screen_space_x[min_y_ID2]; | |
1372 | 6331 } |
6332 //**************************************************************************************************************************************** | |
6333 // | |
6334 v15 = min_y_ID; | |
6335 v61 = min_y_ID; | |
1297 | 6336 for ( v69 = 0; v69 < pNumVertices; ++v69 ) |
6337 { | |
1372 | 6338 v15 += direction1; |
1297 | 6339 if ( v15 < pNumVertices ) |
6340 { | |
6341 if ( v15 < 0 ) | |
6342 v15 += pNumVertices; | |
6343 } | |
6344 else | |
6345 v15 -= pNumVertices; | |
1372 | 6346 if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[min_y_ID] ) |
1297 | 6347 { |
6348 v61 = v15; | |
1372 | 6349 min_y_ID = v15; |
1297 | 6350 } |
1344 | 6351 if ( PortalFace._screen_space_y[v15] == max_y ) |
1297 | 6352 break; |
6353 } | |
1372 | 6354 v18 = direction1 + v61; |
1297 | 6355 if ( v18 < pNumVertices ) |
6356 { | |
6357 if ( v18 < 0 ) | |
6358 v18 += pNumVertices; | |
6359 } | |
6360 else | |
6361 v18 -= pNumVertices; | |
6362 v19 = v18; | |
6363 v20 = v61; | |
1344 | 6364 if ( PortalFace._screen_space_y[v19] != PortalFace._screen_space_y[v61] ) |
6365 { | |
6366 v61 = PortalFace._screen_space_x[v20] << 16; | |
1378 | 6367 v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / |
6368 (PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20]); | |
6369 far_portal->viewport_right_side[max_y] = (short)PortalFace._screen_space_x[v20]; | |
1372 | 6370 } |
6371 //**************************************************************************************************************************************** | |
1297 | 6372 v22 = min_y; |
6373 if ( min_y <= max_y ) | |
6374 { | |
6375 for ( v70 = min_y; v70 <= max_y; ++v70 ) | |
6376 { | |
6377 v24 = v13; | |
1344 | 6378 if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y ) |
1297 | 6379 { |
1372 | 6380 v13 = direction2 + v13; |
1297 | 6381 if ( v13 < pNumVertices ) |
6382 { | |
6383 if ( v13 < 0 ) | |
6384 v13 += pNumVertices; | |
6385 } | |
6386 else | |
6387 v13 -= pNumVertices; | |
6388 v26 = v13; | |
1344 | 6389 if ( PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24] > 0 ) |
1297 | 6390 { |
1378 | 6391 v54 = ((PortalFace._screen_space_x[v26] - PortalFace._screen_space_x[v24]) << 16) / (PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]); |
1344 | 6392 v62 = PortalFace._screen_space_x[v24] << 16; |
1297 | 6393 } |
6394 } | |
6395 v29 = v18; | |
1344 | 6396 if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y ) |
1297 | 6397 { |
1372 | 6398 v18 += direction1; |
1297 | 6399 if ( v18 < pNumVertices ) |
6400 { | |
6401 if ( v18 < 0 ) | |
6402 v18 += pNumVertices; | |
6403 } | |
6404 else | |
6405 v18 -= pNumVertices; | |
6406 v31 = v18; | |
1344 | 6407 if ( PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29] > 0 ) |
1297 | 6408 { |
1378 | 6409 v53 = ((PortalFace._screen_space_x[v31] - PortalFace._screen_space_x[v29]) << 16) / (PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29]); |
1344 | 6410 v61 = PortalFace._screen_space_x[v29] << 16; |
1297 | 6411 } |
6412 } | |
1376 | 6413 far_portal->viewport_left_side[v70] = HIWORD(v62); |
6414 far_portal->viewport_right_side[v70] = HIWORD(v61); | |
6415 if ( far_portal->viewport_left_side[v70] > far_portal->viewport_right_side[v70] ) | |
1297 | 6416 { |
1376 | 6417 v36 = far_portal->viewport_left_side[v70] ^ far_portal->viewport_right_side[v70]; |
1379 | 6418 //v37 = far_portal->viewport_right_side[v70]; |
1376 | 6419 far_portal->viewport_left_side[v70] = v36; |
1379 | 6420 v38 = far_portal->viewport_right_side[v70] ^ v36; |
1376 | 6421 far_portal->viewport_left_side[v70] ^= v38; |
6422 far_portal->viewport_right_side[v70] = v38; | |
1297 | 6423 } |
6424 v62 += v54; | |
6425 v22 = v70 + 1; | |
6426 v61 += v53; | |
6427 } | |
6428 } | |
1376 | 6429 //***************************************************************************************************************************** |
6430 // check portals coordinates and determine max, min( , - ) | |
6431 if ( max_y < near_portal->_viewport_space_y ) | |
1297 | 6432 return false; |
1376 | 6433 if ( min_y > near_portal->_viewport_space_w ) |
1297 | 6434 return false; |
1376 | 6435 if ( min_y < near_portal->_viewport_space_y ) |
6436 min_y = near_portal->_viewport_space_y; | |
6437 if ( max_y > near_portal->_viewport_space_w ) | |
6438 max_y = near_portal->_viewport_space_w; | |
1297 | 6439 if ( min_y <= max_y ) |
6440 { | |
1376 | 6441 for ( min_y; min_y <= max_y; ++min_y ) |
1297 | 6442 { |
1376 | 6443 if ( far_portal->viewport_right_side[min_y] >= near_portal->viewport_left_side[min_y] |
6444 && far_portal->viewport_left_side[min_y] <= near_portal->viewport_right_side[min_y] ) | |
1297 | 6445 break; |
6446 } | |
6447 } | |
6448 if ( max_y < min_y ) | |
6449 return false; | |
1376 | 6450 for ( max_y; max_y >= min_y; --max_y ) |
6451 { | |
6452 if ( far_portal->viewport_right_side[max_y] >= near_portal->viewport_left_side[max_y] | |
6453 && far_portal->viewport_left_side[max_y] <= near_portal->viewport_right_side[max_y] ) | |
1297 | 6454 break; |
6455 } | |
6456 if ( min_y >= max_y ) | |
1390 | 6457 return false; |
1376 | 6458 //************************************************************************************************************************************* |
1297 | 6459 v59 = min_y; |
6460 for ( v46 = max_y - min_y + 1; v46; --v46 ) | |
6461 { | |
1376 | 6462 if ( far_portal->viewport_left_side[v59] < near_portal->viewport_left_side[v59] ) |
6463 far_portal->viewport_left_side[v59] = near_portal->viewport_left_side[v59]; | |
6464 if ( far_portal->viewport_right_side[v59] > near_portal->viewport_right_side[v59] ) | |
6465 far_portal->viewport_right_side[v59] = near_portal->viewport_right_side[v59]; | |
1297 | 6466 ++v59; |
1376 | 6467 } |
6468 far_portal->_viewport_space_y = min_y; | |
6469 far_portal->_viewport_space_w = max_y; | |
6470 far_portal->_viewport_space_x = far_portal->viewport_left_side[min_y]; | |
1379 | 6471 far_portal->_viewport_space_z = far_portal->viewport_right_side[min_y]; |
1376 | 6472 far_portal->_viewport_x_minID = min_y; |
6473 far_portal->_viewport_z_maxID = min_y; | |
1297 | 6474 v49 = min_y + 1; |
6475 if ( v49 <= max_y ) | |
6476 { | |
6477 for ( v49; v49 <= max_y; ++v49 ) | |
6478 { | |
1376 | 6479 if ( far_portal->viewport_left_side[v49] < far_portal->_viewport_space_x ) |
1297 | 6480 { |
1376 | 6481 far_portal->_viewport_space_x = far_portal->viewport_left_side[v49]; |
6482 far_portal->_viewport_x_minID = v49; | |
1297 | 6483 } |
1376 | 6484 if ( far_portal->viewport_right_side[v49] > far_portal->_viewport_space_z ) |
1297 | 6485 { |
1376 | 6486 far_portal->_viewport_space_z = far_portal->viewport_right_side[v49]; |
6487 far_portal->_viewport_z_maxID = v49; | |
1297 | 6488 } |
6489 } | |
6490 } | |
6491 return true; | |
6492 } | |
6493 //----- (00423B5D) -------------------------------------------------------- | |
1344 | 6494 int __fastcall GetPortalScreenCoord(unsigned int uFaceID) |
1297 | 6495 { |
6496 BLVFace *pFace; // ebx@1 | |
1344 | 6497 int pNextVertices; // edx@11 |
6498 int t; // ST28_4@12 | |
6499 int pScreenX; // eax@22 | |
6500 int pScreenY; // eax@27 | |
6501 signed int left_num_vertices; // edi@31 | |
6502 signed int right_num_vertices; // ebx@41 | |
6503 signed int top_num_vertices; // edi@51 | |
6504 int bottom_num_vertices; // ebx@61 | |
1297 | 6505 signed int v62; // edx@75 |
6506 int v63; // ecx@76 | |
6507 int v64; // esi@76 | |
6508 int v65; // ecx@83 | |
6509 signed int v71; // [sp+14h] [bp-14h]@75 | |
1301 | 6510 bool current_vertices_flag; // [sp+18h] [bp-10h]@9 |
1297 | 6511 int thisf; // [sp+18h] [bp-10h]@74 |
1301 | 6512 signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9 |
1297 | 6513 int v80; // [sp+1Ch] [bp-Ch]@76 |
1301 | 6514 bool next_vertices_flag; // [sp+20h] [bp-8h]@10 |
1297 | 6515 |
6516 pFace = &pIndoor->pFaces[uFaceID]; | |
1344 | 6517 memset(&PortalFace, 0, sizeof(stru367)); |
6518 | |
6519 //get direction the face( )********************************************************************************* | |
1297 | 6520 if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) |
6521 + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) | |
6522 + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 ) | |
6523 { | |
1344 | 6524 PortalFace.direction = true; |
1297 | 6525 } |
6526 else | |
6527 { | |
1344 | 6528 PortalFace.direction = false; |
1301 | 6529 if ( !(pFace->Portal()) ) |
1297 | 6530 return 0; |
6531 } | |
1344 | 6532 //***************************************************************************************************************************************** |
6533 //generate/cinvertetion in camera location coordinates(/ ) | |
6534 | |
6535 //for new coordinates: | |
6536 //int x = 0x AAAA BBBB; | |
6537 //AAAA - integer( ), BBBB - fractional() | |
6538 //float v = HIWORD(x) + LOWORD(x) / 65535.0f; | |
6539 //0x0351A281 849(351 ) A281 ( BBBB ) | |
6540 //if in HIWORD: FFFF = -1 | |
6541 //FFFE = -2 | |
6542 //FFFD = -3 | |
6543 //.... | |
6544 //8000 = -32767 | |
6545 //7FFF = 32767 | |
6546 //7FFE = 32766 | |
6547 // LOWORD FFFF , | |
6548 // hiword loword FFFF FFFF , | |
6549 // 7FFF /Nomad/ | |
6550 | |
1297 | 6551 if ( (signed int)pFace->uNumVertices > 0 ) |
6552 { | |
1301 | 6553 for (uint i = 0; i < pFace->uNumVertices; ++i) |
1297 | 6554 { |
1344 | 6555 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x, |
6556 pIndoor->pVertices[pFace->pVertexIDs[i]].y, | |
6557 pIndoor->pVertices[pFace->pVertexIDs[i]].z, | |
6558 &PortalFace._view_transformed_z[i + 3], &PortalFace._view_transformed_x[i + 3], &PortalFace._view_transformed_y[i + 3], 0); | |
1297 | 6559 } |
1301 | 6560 } |
1344 | 6561 //***************************************************************************************************************************************** |
6562 //check vertices for the nearest plane( ) | |
1301 | 6563 if ( pFace->uNumVertices <= 0 ) |
1297 | 6564 return 0; |
1301 | 6565 bool bFound = false; |
6566 for (uint i = 0; i < pFace->uNumVertices; ++i) | |
6567 { | |
1344 | 6568 if ( PortalFace._view_transformed_z[i + 3] >= 524288 )// 8.0(0x80000) |
1301 | 6569 { |
6570 bFound = true; | |
1297 | 6571 break; |
1301 | 6572 } |
6573 } | |
6574 if ( !bFound ) | |
1297 | 6575 return 0; |
1344 | 6576 //***************************************************************************************************************************************** |
6577 //check for near clip plane( ) | |
6578 // | |
6579 // v0 v1 | |
6580 // ._________________. | |
6581 // / \ | |
6582 // / \ | |
6583 // v5. . v2 | |
6584 // | | | |
6585 // | | | |
6586 // | | | |
6587 // ---------------------------- 8.0(near_clip) | |
6588 // | | | |
6589 // ._______________________. | |
6590 // v4 v3 | |
1301 | 6591 depth_num_vertices = 0; |
1344 | 6592 PortalFace._view_transformed_z[pFace->uNumVertices + 3] = PortalFace._view_transformed_z[3]; |
6593 PortalFace._view_transformed_x[pFace->uNumVertices + 3] = PortalFace._view_transformed_x[3]; | |
6594 PortalFace._view_transformed_y[pFace->uNumVertices + 3] = PortalFace._view_transformed_y[3]; | |
6595 current_vertices_flag = PortalFace._view_transformed_z[3] >= 524288;// 8.0(0x80000) | |
1301 | 6596 if ( pFace->uNumVertices >= 1 ) |
6597 { | |
6598 for ( uint i = 1; i <= pFace->uNumVertices; ++i) | |
1297 | 6599 { |
1344 | 6600 next_vertices_flag = PortalFace._view_transformed_z[i + 3] >= 524288;// 8.0(0x80000) |
6601 if ( current_vertices_flag ^ next_vertices_flag )// | |
1297 | 6602 { |
1344 | 6603 if ( next_vertices_flag )// |
1297 | 6604 { |
1344 | 6605 //t = near_clip - v0.z / v1.z - v0.z |
1370 | 6606 t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 2], PortalFace._view_transformed_z[i + 3] - PortalFace._view_transformed_z[i + 2]); |
1344 | 6607 //New_x = (v1.x - v0.x)*t + v0.x |
6608 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 3] | |
6609 - PortalFace._view_transformed_x[i + 2]) * t) >> 16) + PortalFace._view_transformed_x[i + 2]; | |
6610 //New_y = (v1.y - v0.y)*t + v0.y | |
6611 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 3] - PortalFace._view_transformed_y[i + 2]) | |
6612 * t) >> 16) + PortalFace._view_transformed_y[i + 2]; | |
6613 //New_z = 8.0(0x80000) | |
6614 PortalFace._view_transformed_z[depth_num_vertices] = 524288; | |
1297 | 6615 } |
1344 | 6616 else// |
1297 | 6617 { |
1344 | 6618 //t = near_clip - v1.z / v0.z - v1.z |
1370 | 6619 t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 3], PortalFace._view_transformed_z[i + 2] - PortalFace._view_transformed_z[i + 3]); |
1344 | 6620 //New_x = (v0.x - v1.x)*t + v1.x |
6621 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 2] | |
6622 - PortalFace._view_transformed_x[i + 3]) * t) >> 16) + PortalFace._view_transformed_x[i + 3]; | |
6623 //New_y = (v0.x - v1.y)*t + v1.y | |
6624 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 2] - PortalFace._view_transformed_y[i + 3]) | |
6625 * t) >> 16) + PortalFace._view_transformed_y[i + 3]; | |
6626 //New_z = 8.0(0x80000) | |
6627 PortalFace._view_transformed_z[depth_num_vertices] = 524288; | |
1297 | 6628 } |
1344 | 6629 depth_num_vertices++; |
1297 | 6630 } |
1344 | 6631 if ( next_vertices_flag )// |
1297 | 6632 { |
1344 | 6633 pNextVertices = depth_num_vertices++; |
6634 PortalFace._view_transformed_z[pNextVertices] = PortalFace._view_transformed_z[i + 3]; | |
6635 PortalFace._view_transformed_x[pNextVertices] = PortalFace._view_transformed_x[i + 3]; | |
6636 PortalFace._view_transformed_y[pNextVertices] = PortalFace._view_transformed_y[i + 3]; | |
1297 | 6637 } |
1301 | 6638 current_vertices_flag = next_vertices_flag; |
1297 | 6639 } |
1301 | 6640 } |
1344 | 6641 //: ( ) |
6642 //************************************************************************************************************************************ | |
6643 //convertion in screen coordinates( ) | |
6644 PortalFace._view_transformed_z[depth_num_vertices] = PortalFace._view_transformed_z[0]; | |
6645 PortalFace._view_transformed_x[depth_num_vertices] = PortalFace._view_transformed_x[0]; | |
6646 PortalFace._view_transformed_y[depth_num_vertices] = PortalFace._view_transformed_y[0]; | |
6647 for ( uint i = 0; i < depth_num_vertices; ++i ) | |
6648 { | |
6649 if ( (abs(PortalFace._view_transformed_x[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) | |
6650 pScreenX = fixpoint_div(PortalFace._view_transformed_x[i], PortalFace._view_transformed_z[i]); | |
1297 | 6651 else |
6652 { | |
1344 | 6653 if ( PortalFace._view_transformed_x[i] >= 0 ) |
1297 | 6654 { |
1344 | 6655 if (PortalFace._view_transformed_z[i] >= 0) |
6656 pScreenX = 0x400000; // 64.0 | |
1301 | 6657 else |
1344 | 6658 pScreenX = 0xFFC00000; // -63.0 |
1297 | 6659 } |
6660 else | |
6661 { | |
1344 | 6662 if (PortalFace._view_transformed_z[i] >= 0) |
6663 pScreenX = 0xFFC00000; // -63.0 | |
1301 | 6664 else |
1344 | 6665 pScreenX = 0x400000; // 64.0 |
1297 | 6666 } |
6667 } | |
1301 | 6668 |
1344 | 6669 if ( (abs(PortalFace._view_transformed_y[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) |
6670 pScreenY = fixpoint_div(PortalFace._view_transformed_y[i], PortalFace._view_transformed_z[i]); | |
1297 | 6671 else |
6672 { | |
1344 | 6673 if ( PortalFace._view_transformed_y[i] >= 0 ) |
1297 | 6674 { |
1344 | 6675 if (PortalFace._view_transformed_z[i] >= 0) |
6676 pScreenY = 0x400000; // 64.0 | |
1301 | 6677 else |
1344 | 6678 pScreenY = 0xFFC00000; // -63.0 |
1297 | 6679 } |
6680 else | |
6681 { | |
1344 | 6682 if (PortalFace._view_transformed_z[i] >= 0) |
6683 pScreenY = 0xFFC00000; // -63.0 | |
1301 | 6684 else |
1344 | 6685 pScreenY = 0x400000; // 64.0 |
1297 | 6686 } |
6687 } | |
1344 | 6688 PortalFace._screen_space_x[i + 12] = pBLVRenderParams->uViewportCenterX - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenX) >> 16); |
6689 PortalFace._screen_space_y[i + 12] = pBLVRenderParams->uViewportCenterY - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenY) >> 16); | |
6690 } | |
6691 // : , , () | |
6692 //****************************************************************************************************************************************** | |
1381 | 6693 // - ,.. |
6694 // . , x() = 8, = 468( ), . | |
6695 // | |
1344 | 6696 //check for left_clip plane( ) |
6697 left_num_vertices = 0; | |
6698 PortalFace._screen_space_x[depth_num_vertices + 12] = PortalFace._screen_space_x[12]; | |
6699 PortalFace._screen_space_y[depth_num_vertices + 12] = PortalFace._screen_space_y[12]; | |
1370 | 6700 current_vertices_flag = PortalFace._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;//8.0 |
1301 | 6701 if ( depth_num_vertices < 1 ) |
1297 | 6702 return 0; |
1344 | 6703 for ( uint i = 1; i <= depth_num_vertices; ++i ) |
6704 { | |
6705 next_vertices_flag = PortalFace._screen_space_x[i + 12] >= (signed int)pBLVRenderParams->uViewportX; | |
6706 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6707 { |
1344 | 6708 if ( next_vertices_flag ) |
1297 | 6709 { |
1344 | 6710 //t = left_clip - v0.x / v1.x - v0.x |
1370 | 6711 t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 11], PortalFace._screen_space_x[i + 12] - PortalFace._screen_space_x[i + 11]); |
1344 | 6712 //New_y = (v1.y - v0.y)*t + v0.y |
1370 | 6713 PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)((PortalFace._screen_space_y[i + 12]- PortalFace._screen_space_y[i + 11]) |
6714 * t) >> 16) + PortalFace._screen_space_y[i + 11]; | |
1344 | 6715 //New_x = left_clip |
6716 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; | |
1297 | 6717 } |
6718 else | |
6719 { | |
1344 | 6720 //t = left_clip - v1.x / v0.x - v1.x |
1370 | 6721 t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 12], PortalFace._screen_space_x[i + 11] - PortalFace._screen_space_x[i + 12]); |
1344 | 6722 //New_y = (v0.y - v1.y)*t + v1.y |
1370 | 6723 PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)(( PortalFace._screen_space_y[i + 11] - PortalFace._screen_space_y[i + 12]) |
6724 * t) >> 16) + PortalFace._screen_space_y[i + 12]; | |
1344 | 6725 //New_x = left_clip |
6726 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; | |
1297 | 6727 } |
1344 | 6728 left_num_vertices++; |
1297 | 6729 } |
1344 | 6730 if ( next_vertices_flag ) |
1297 | 6731 { |
1344 | 6732 pNextVertices = left_num_vertices++; |
6733 PortalFace._screen_space_x[pNextVertices + 9] = PortalFace._screen_space_x[i + 12]; | |
6734 PortalFace._screen_space_y[pNextVertices + 9] = PortalFace._screen_space_y[i + 12]; | |
1297 | 6735 } |
1344 | 6736 current_vertices_flag = next_vertices_flag; |
6737 } | |
6738 //********************************************************************************************************************************* | |
6739 //for right_clip plane( ) | |
6740 right_num_vertices = 0; | |
6741 PortalFace._screen_space_x[left_num_vertices + 9] = PortalFace._screen_space_x[9]; | |
6742 PortalFace._screen_space_y[left_num_vertices + 9] = PortalFace._screen_space_y[9]; | |
1370 | 6743 current_vertices_flag = PortalFace._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ;//468.0 |
1344 | 6744 if (left_num_vertices < 1) |
1297 | 6745 return 0; |
1344 | 6746 for ( uint i = 1; i <= left_num_vertices; ++i ) |
6747 { | |
6748 next_vertices_flag = PortalFace._screen_space_x[i + 9] <= (signed int)pBLVRenderParams->uViewportZ; | |
6749 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6750 { |
1344 | 6751 if ( next_vertices_flag ) |
1297 | 6752 { |
1344 | 6753 //t = right_clip - v1.x / v0.x - v1.x |
1370 | 6754 t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 8], PortalFace._screen_space_x[i + 9] - PortalFace._screen_space_x[i + 8]); |
1344 | 6755 //New_y = (v0.y - v1.y)*t + v1.y |
1370 | 6756 PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 9] - PortalFace._screen_space_y[i + 8]) |
6757 * t) >> 16) + PortalFace._screen_space_y[i + 8]; | |
1344 | 6758 //New_x = right_clip |
6759 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; | |
1297 | 6760 } |
6761 else | |
6762 { | |
1344 | 6763 //t = right_clip - v0.x / v1.x - v0.x |
1370 | 6764 t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 9], PortalFace._screen_space_x[i + 8] - PortalFace._screen_space_x[i + 9]); |
1344 | 6765 //New_y = (v1.y - v0.y)*t + v0.y |
1370 | 6766 PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 8] - PortalFace._screen_space_y[i + 9]) |
6767 * t) >> 16) + PortalFace._screen_space_y[i + 9]; | |
1344 | 6768 //New_x = right_clip |
6769 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; | |
1297 | 6770 } |
1344 | 6771 right_num_vertices++; |
1297 | 6772 } |
1344 | 6773 if ( next_vertices_flag ) |
1297 | 6774 { |
1344 | 6775 pNextVertices = right_num_vertices++; |
6776 PortalFace._screen_space_x[pNextVertices + 6] = PortalFace._screen_space_x[i + 9]; | |
6777 PortalFace._screen_space_y[pNextVertices + 6] = PortalFace._screen_space_y[i + 9]; | |
1297 | 6778 } |
1344 | 6779 current_vertices_flag = next_vertices_flag; |
6780 } | |
6781 //************************************************************************************************************************************ | |
6782 // for top clip plane | |
6783 top_num_vertices = 0; | |
6784 PortalFace._screen_space_x[right_num_vertices + 6] = PortalFace._screen_space_x[6]; | |
6785 PortalFace._screen_space_y[right_num_vertices + 6] = PortalFace._screen_space_y[6]; | |
6786 | |
1370 | 6787 current_vertices_flag = PortalFace._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY;//8.0 |
1344 | 6788 if ( right_num_vertices < 1 ) |
1297 | 6789 return 0; |
1344 | 6790 for ( uint i = 1; i <= right_num_vertices; ++i ) |
6791 { | |
6792 next_vertices_flag = PortalFace._screen_space_y[i + 6] >= (signed int)pBLVRenderParams->uViewportY; | |
6793 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6794 { |
1344 | 6795 if ( next_vertices_flag ) |
1297 | 6796 { |
1370 | 6797 t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 5], PortalFace._screen_space_y[i + 6] - PortalFace._screen_space_y[i + 5]); |
6798 PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 6] - PortalFace._screen_space_x[i + 5]) | |
6799 * t) >> 16) + PortalFace._screen_space_x[i + 5]; | |
1344 | 6800 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; |
1297 | 6801 } |
6802 else | |
6803 { | |
1370 | 6804 t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 6], PortalFace._screen_space_y[i + 5] - PortalFace._screen_space_y[i + 6]); |
6805 PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 5]- PortalFace._screen_space_x[i + 6]) | |
6806 * t) >> 16) + PortalFace._screen_space_x[i + 6]; | |
1344 | 6807 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; |
1297 | 6808 } |
1344 | 6809 top_num_vertices++; |
1297 | 6810 } |
1344 | 6811 current_vertices_flag = next_vertices_flag; |
6812 if ( next_vertices_flag ) | |
1297 | 6813 { |
1344 | 6814 pNextVertices = top_num_vertices++; |
6815 PortalFace._screen_space_x[pNextVertices + 3] = PortalFace._screen_space_x[i + 6]; | |
6816 PortalFace._screen_space_y[pNextVertices + 3] = PortalFace._screen_space_y[i + 6]; | |
1297 | 6817 } |
1344 | 6818 } |
6819 //********************************************************************************************************************************** | |
6820 //for bottom_clip plane( ) | |
6821 bottom_num_vertices = 0; | |
6822 PortalFace._screen_space_x[top_num_vertices + 3] = PortalFace._screen_space_x[3]; | |
6823 PortalFace._screen_space_y[top_num_vertices + 3] = PortalFace._screen_space_y[3]; | |
1370 | 6824 current_vertices_flag = PortalFace._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW;//351.0 |
1344 | 6825 if ( top_num_vertices < 1 ) |
1297 | 6826 return 0; |
1344 | 6827 for ( uint i =1; i <= top_num_vertices; ++i ) |
6828 { | |
6829 next_vertices_flag = PortalFace._screen_space_y[i + 3] <= (signed int)pBLVRenderParams->uViewportW; | |
6830 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6831 { |
1344 | 6832 if ( next_vertices_flag ) |
1297 | 6833 { |
1370 | 6834 t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 2], PortalFace._screen_space_y[i + 3] - PortalFace._screen_space_y[i + 2]); |
6835 PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 3] - PortalFace._screen_space_x[i + 2]) | |
6836 * t) >> 16) + PortalFace._screen_space_x[i + 2]; | |
1344 | 6837 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; |
1297 | 6838 } |
6839 else | |
6840 { | |
1370 | 6841 t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 3], PortalFace._screen_space_y[i + 2] - PortalFace._screen_space_y[i + 3]); |
6842 PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 2] - PortalFace._screen_space_x[i + 3]) | |
6843 * t) >> 16) + PortalFace._screen_space_x[i + 3]; | |
1344 | 6844 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; |
1297 | 6845 } |
1344 | 6846 bottom_num_vertices++; |
1297 | 6847 } |
1344 | 6848 if ( next_vertices_flag ) |
1297 | 6849 { |
1344 | 6850 pNextVertices = bottom_num_vertices++; |
6851 PortalFace._screen_space_x[pNextVertices] = PortalFace._screen_space_x[i + 3]; | |
6852 PortalFace._screen_space_y[pNextVertices] = PortalFace._screen_space_y[i + 3]; | |
1297 | 6853 } |
1344 | 6854 current_vertices_flag = next_vertices_flag; |
6855 } | |
6856 //*************************************************************************************************************************************** | |
6857 | |
6858 if ( !bottom_num_vertices ) | |
1297 | 6859 return 0; |
1344 | 6860 PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; |
6861 PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; | |
6862 //check for software( ) | |
6863 if ( !pRenderer->pRenderD3D && bottom_num_vertices > 3 ) | |
6864 { | |
6865 PortalFace._screen_space_x[bottom_num_vertices + 1] = PortalFace._screen_space_x[1]; | |
6866 PortalFace._screen_space_y[bottom_num_vertices + 1] = PortalFace._screen_space_y[1]; | |
6867 thisf = PortalFace.direction == true ? 1 : - 1; | |
6868 if ( bottom_num_vertices > 0 ) | |
1297 | 6869 { |
6870 v62 = 1; | |
6871 v71 = 1; | |
6872 do | |
6873 { | |
6874 v63 = v62 - 1; | |
6875 v64 = v62 + 1; | |
6876 v80 = v62 + 1; | |
1344 | 6877 if ( v62 - 1 >= bottom_num_vertices ) |
6878 v63 -= bottom_num_vertices; | |
6879 if ( v62 >= bottom_num_vertices ) | |
6880 v62 -= bottom_num_vertices; | |
6881 if ( v64 >= bottom_num_vertices ) | |
6882 v64 -= bottom_num_vertices; | |
6883 if ( thisf * ((PortalFace._screen_space_y[v64] - PortalFace._screen_space_y[v63]) | |
6884 * (PortalFace._screen_space_x[v62] - PortalFace._screen_space_x[v63]) | |
6885 - (PortalFace._screen_space_y[v62] - PortalFace._screen_space_y[v63]) | |
6886 * (PortalFace._screen_space_x[v64] - PortalFace._screen_space_x[v63])) < 0 ) | |
1297 | 6887 { |
6888 v62 = v80; | |
6889 v71 = v80; | |
6890 } | |
6891 else | |
6892 { | |
6893 v62 = v71; | |
6894 v65 = v71; | |
1344 | 6895 if ( v71 < bottom_num_vertices || (v65 = v71 - bottom_num_vertices, v71 - bottom_num_vertices < bottom_num_vertices) ) |
1297 | 6896 { |
1344 | 6897 memcpy(&PortalFace._screen_space_y[v65], &PortalFace._screen_space_y[v65 + 1], |
6898 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); | |
6899 memcpy(&PortalFace._screen_space_x[v65], &PortalFace._screen_space_x[v65 + 1], | |
6900 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); | |
1297 | 6901 } |
1344 | 6902 --bottom_num_vertices; |
1297 | 6903 } |
6904 } | |
1344 | 6905 while ( v62 - 1 < bottom_num_vertices ); |
1297 | 6906 } |
1344 | 6907 PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; |
6908 PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; | |
6909 } | |
6910 return bottom_num_vertices; | |
0 | 6911 } |