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