Mercurial > mm7
annotate Indoor.cpp @ 1545:c4ab816fcc5e
assert, Abortf, AbortWithError -> Assert, Error
refactors here and there
author | Nomad |
---|---|
date | Sat, 07 Sep 2013 20:05:20 +0200 |
parents | 499761153844 |
children | 9a6567c6c76c |
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 |
65 stru141 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 | |
3186 int v21; // eax@46 | |
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 | |
3211 int v46; // edi@101 | |
3212 int v47; // eax@101 | |
3213 unsigned __int64 v48; // qax@101 | |
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 v21 = v0->uActorHeight; | |
3363 stru_721530.field_84 = -1; | |
3364 stru_721530.field_70 = 0; | |
3365 uSectorID = 0; | |
3366 stru_721530.field_0 = 1; | |
3367 stru_721530.field_8 = v20; | |
3368 stru_721530.prolly_normal_d = v20; | |
3369 stru_721530.field_C = v21; | |
3370 v22 = 0; | |
3371 while ( 1 ) | |
3372 { | |
3373 stru_721530.field_34.x = v0->vPosition.x; | |
3374 stru_721530.normal.x = stru_721530.field_34.x; | |
3375 stru_721530.field_34.y = v0->vPosition.y; | |
3376 stru_721530.normal.y = stru_721530.field_34.y; | |
3377 v23 = v0->vPosition.z; | |
3378 stru_721530.normal.z = v23 + v20 + 1; | |
3379 stru_721530.field_34.z = v23 - v20 + stru_721530.field_C - 1; | |
3380 if ( stru_721530.field_34.z < stru_721530.normal.z ) | |
3381 stru_721530.field_34.z = v23 + v20 + 1; | |
3382 stru_721530.field_1C = v0->vVelocity.x; | |
3383 stru_721530.field_20 = v0->vVelocity.y; | |
3384 stru_721530.field_24 = v0->vVelocity.z; | |
3385 stru_721530.uSectorID = v0->uSectorID; | |
3386 if ( !stru_721530._47050A(v22) ) | |
3387 { | |
3388 v58 = v22; | |
3389 v24 = 8 * v63; | |
862 | 3390 LOBYTE(v24) = PID(OBJECT_Actor,v63); |
0 | 3391 v61 = v22; |
3392 _this = v24; | |
3393 do | |
3394 { | |
3395 _46E44E_collide_against_faces_and_portals(1u); | |
3396 _46E0B2_collide_against_decorations(); | |
3397 _46EF01_collision_chech_player(0); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3398 _46ED8A_collide_against_sprite_objects(_this); |
0 | 3399 v25 = 0; |
3400 v56 = 0; | |
3401 if ( ai_arrays_size > v22 ) | |
3402 { | |
3403 do | |
3404 { | |
390 | 3405 v54 = ai_near_actors_ids[v25]; |
0 | 3406 if ( v54 != v63 ) |
3407 { | |
3408 v26 = v54; | |
3409 v27 = abs(pActors[v54].vPosition.z - v0->vPosition.z); | |
3410 v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y); | |
3411 v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x); | |
322 | 3412 if ( int_get_vector_length(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius |
0 | 3413 && _46DF1A_collide_against_actor(v54, 40) ) |
3414 ++v58; | |
3415 v22 = 0; | |
3416 } | |
3417 v25 = v56++ + 1; | |
3418 } | |
3419 while ( v56 < ai_arrays_size ); | |
3420 } | |
3421 if ( _46F04E_collide_against_portals() ) | |
3422 break; | |
3423 ++v61; | |
3424 } | |
3425 while ( v61 < 100 ); | |
3426 v56 = v58 > 1; | |
3427 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
3428 { | |
3429 v30 = stru_721530.normal2.x; | |
3430 v31 = stru_721530.normal2.y; | |
3431 v32 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
3432 } | |
3433 else | |
3434 { | |
3435 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
3436 v30 = v58 + v0->vPosition.x; | |
3437 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
3438 v31 = v58 + v0->vPosition.y; | |
3439 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
3440 v32 = v58 + v0->vPosition.z; | |
3441 } | |
783 | 3442 v33 = collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID); |
0 | 3443 v34 = pIndoor->pFaces[uFaceID].uAttributes; |
3444 v35 = v34 & 0x400000; | |
3445 if (v35 && v0->uAIState == Dead) | |
3446 { | |
3447 v0->uAIState = Removed; | |
3448 goto LABEL_120; | |
3449 } | |
3450 if ( v59 != v22 || v62 != v22 || v35 == v22 ) | |
3451 { | |
3452 if ( v33 == -30000 ) | |
3453 goto LABEL_120; | |
3454 if ( v0->uCurrentActionAnimation != 1 || v33 >= v0->vPosition.z - 100 || v59 != v22 || v62 != v22 ) | |
3455 { | |
3456 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
3457 { | |
3458 v0->vPosition.x = LOWORD(stru_721530.normal2.x); | |
3459 v0->vPosition.y = LOWORD(stru_721530.normal2.y); | |
3460 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; | |
3461 v0->uSectorID = LOWORD(stru_721530.uSectorID); | |
3462 goto LABEL_123; | |
3463 } | |
3464 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
3465 v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16; | |
3466 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
3467 v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16; | |
3468 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
3469 v36 = stru_721530.uFaceID; | |
3470 v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; | |
3471 v0->uSectorID = LOWORD(stru_721530.uSectorID); | |
3472 stru_721530.field_70 += stru_721530.field_7C; | |
848 | 3473 v37 = PID_ID(v36); |
3474 if ( PID_TYPE(v36) != OBJECT_Actor) | |
0 | 3475 { |
848 | 3476 if ( PID_TYPE(v36) != OBJECT_Player) |
0 | 3477 { |
848 | 3478 if ( PID_TYPE(v36) == OBJECT_Decoration) |
0 | 3479 { |
295 | 3480 _this = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); |
0 | 3481 v45 = stru_5C6E00->Atan2( |
3482 v0->vPosition.x - pLevelDecorations[v37].vPosition.x, | |
3483 v0->vPosition.y - pLevelDecorations[v37].vPosition.y); | |
323 | 3484 v54 = stru_5C6E00->Cos(v45); |
0 | 3485 v56 = (unsigned __int64)(v54 * (signed __int64)(signed int)_this) >> 16; |
3486 v46 = v45 - stru_5C6E00->uIntegerHalfPi; | |
3487 v0->vVelocity.x = v54 * _this >> 16; | |
323 | 3488 v47 = stru_5C6E00->Sin(v45); |
0 | 3489 v54 = v47; |
3490 v48 = v47 * (signed __int64)(signed int)_this; | |
3491 v56 = v48 >> 16; | |
3492 v0->vVelocity.y = WORD1(v48); | |
3493 goto LABEL_119; | |
3494 } | |
848 | 3495 if ( PID_TYPE(v36) == OBJECT_BModel) |
0 | 3496 { |
3497 stru_721530.field_84 = v36 >> 3; | |
3498 v38 = &pIndoor->pFaces[v37]; | |
3499 if ( v38->uPolygonType == 3 ) | |
3500 { | |
3501 v39 = v0->vVelocity.x; | |
3502 v40 = v0->vVelocity.y * v0->vVelocity.y; | |
3503 v0->vVelocity.z = 0; | |
3504 v0->vPosition.z = pIndoor->pVertices[*v38->pVertexIDs].z + 1; | |
3505 if ( v39 * v39 + v40 < 400 ) | |
3506 { | |
3507 v0->vVelocity.y = 0; | |
3508 v0->vVelocity.x = 0; | |
3509 goto LABEL_119; | |
3510 } | |
3511 } | |
3512 else | |
3513 { | |
3514 v61 = abs(v38->pFacePlane_old.vNormal.x * v0->vVelocity.x + v38->pFacePlane_old.vNormal.y | |
3515 * v0->vVelocity.y | |
3516 + v38->pFacePlane_old.vNormal.z | |
3517 * v0->vVelocity.z) >> 16; | |
3518 if ( stru_721530.field_64 >> 3 > v61 ) | |
3519 v61 = stru_721530.field_64 >> 3; | |
3520 v58 = v38->pFacePlane_old.vNormal.x; | |
3521 v58 = (unsigned __int64)(v61 * (signed __int64)v58) >> 16; | |
3522 _this = v38->pFacePlane_old.vNormal.y; | |
3523 _this = (unsigned __int64)(v61 * (signed __int64)(signed int)_this) >> 16; | |
3524 v56 = v38->pFacePlane_old.vNormal.z; | |
3525 v56 = (unsigned __int64)(v61 * (signed __int64)v56) >> 16; | |
3526 v0->vVelocity.x += v58; | |
3527 v0->vVelocity.y += _this; | |
3528 v0->vVelocity.z += v56; | |
3529 v41 = v38->uPolygonType; | |
3530 if ( v41 != 4 && v41 != 3 ) | |
3531 { | |
3532 v42 = v38->pFacePlane_old.vNormal.x; | |
3533 v43 = v0->vPosition.z; | |
3534 v44 = stru_721530.prolly_normal_d | |
3535 - ((v38->pFacePlane_old.dist | |
3536 + v38->pFacePlane_old.vNormal.z * v0->vPosition.z | |
3537 + v38->pFacePlane_old.vNormal.y * v0->vPosition.y | |
3538 + v42 * v0->vPosition.x) >> 16); | |
3539 if ( v44 > 0 ) | |
3540 { | |
3541 v0->vPosition.x += (unsigned int)(v44 * v42) >> 16; | |
3542 v0->vPosition.y += (unsigned int)(v44 * v38->pFacePlane_old.vNormal.y) >> 16; | |
3543 v0->vPosition.z = v43 + ((unsigned int)(v44 * v38->pFacePlane_old.vNormal.z) >> 16); | |
3544 } | |
3545 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y); | |
3546 } | |
3547 } | |
3548 if ( BYTE3(v38->uAttributes) & 8 ) | |
3549 EventProcessor(pIndoor->pFaceExtras[v38->uFaceExtraID].uEventID, 0, 1); | |
3550 } | |
3551 LABEL_119: | |
3552 v56 = v0->vVelocity.x; | |
3553 v54 = 58500; | |
3554 v56 = (unsigned __int64)(58500i64 * v56) >> 16; | |
3555 v0->vVelocity.x = v56; | |
3556 v56 = v0->vVelocity.y; | |
3557 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16; | |
3558 v54 = 58500; | |
3559 v0->vVelocity.y = v56; | |
3560 v56 = v0->vVelocity.z; | |
3561 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16; | |
3562 v22 = 0; | |
3563 v0->vVelocity.z = v56; | |
3564 goto LABEL_120; | |
3565 } | |
3566 if ( v0->GetActorsRelation(0) ) | |
3567 { | |
1167 | 3568 v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime), v22); |
3569 v49 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == v22; | |
3570 v50 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) - v22 < 0; | |
0 | 3571 v0->vVelocity.y = v22; |
3572 v0->vVelocity.x = v22; | |
3573 if ( !(v50 ^ v51) | |
1167 | 3574 && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > v22) ) |
3575 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
0 | 3576 viewparams->bRedrawGameUI = 1; |
3577 goto LABEL_119; | |
3578 } | |
3579 v36 = stru_721530.uFaceID; | |
3580 LABEL_118: | |
1060 | 3581 Actor::AI_FaceObject(v63, v36, v22, (AIDirection *)v22); |
0 | 3582 goto LABEL_119; |
3583 } | |
1340 | 3584 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) ) |
0 | 3585 goto LABEL_119; |
3586 if ( v0->pMonsterInfo.uHostilityType ) | |
3587 { | |
3588 if ( v56 == v22 ) | |
3589 goto LABEL_114; | |
3590 } | |
3591 else | |
3592 { | |
3593 if ( v56 == v22 ) | |
3594 { | |
3595 if ( !pActors[v37].pMonsterInfo.uHostilityType ) | |
3596 goto LABEL_118; | |
3597 LABEL_114: | |
1060 | 3598 Actor::AI_Flee(v63, v36, v22, (AIDirection *)v22); |
0 | 3599 goto LABEL_119; |
3600 } | |
3601 } | |
414 | 3602 Actor::AI_StandOrBored(v63, 4, v22, &v53); |
0 | 3603 goto LABEL_119; |
3604 } | |
3605 if ( v0->vPosition.x & 1 ) | |
3606 v0->uYawAngle += 100; | |
3607 else | |
3608 v0->uYawAngle -= 100; | |
3609 } | |
3610 else | |
3611 { | |
1340 | 3612 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) ) |
0 | 3613 goto LABEL_123; |
3614 if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 ) | |
3615 { | |
414 | 3616 Actor::AI_StandOrBored(v63, 4, v22, &v52); |
0 | 3617 goto LABEL_123; |
3618 } | |
3619 } | |
3620 } | |
3621 LABEL_120: | |
3622 ++uSectorID; | |
3623 if ( uSectorID >= 100 ) | |
3624 goto LABEL_123; | |
3625 v20 = stru_721530.prolly_normal_d; | |
3626 } | |
3627 } | |
3628 } | |
3629 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); | |
3630 // 4F75D8: using guessed type int ai_arrays_size; | |
3631 | |
3632 | |
3633 | |
3634 | |
3635 | |
3636 | |
3637 //----- (00460A78) -------------------------------------------------------- | |
1458 | 3638 void PrepareToLoadBLV(unsigned int bLoading) |
0 | 3639 { |
3640 unsigned int v1; // ebx@1 | |
3641 unsigned int v2; // eax@8 | |
3642 MapInfo *v3; // edi@9 | |
3643 int v4; // eax@11 | |
3644 int v5; // eax@12 | |
3645 int v6; // eax@13 | |
3646 int v7; // esi@27 | |
3647 SpawnPointMM7 *v8; // edx@28 | |
3648 //char v9; // bl@33 | |
3649 //int v10; // eax@34 | |
3650 //char *v11; // ecx@37 | |
3651 //int v12; // edi@44 | |
3652 //unsigned int v13; // edi@48 | |
3653 char *v14; // esi@49 | |
3654 __int16 v15; // ax@50 | |
3655 int v16; // ecx@52 | |
3656 DecorationDesc *v17; // eax@54 | |
3657 int v18; // ecx@55 | |
3658 //int *v19; // edi@58 | |
3659 //unsigned char v20; // dl@58 | |
3660 int v21; // eax@64 | |
3661 char v22; // cl@64 | |
3662 //signed int v23; // ebx@67 | |
3663 //char *v24; // esi@68 | |
3664 //int v25; // eax@70 | |
3665 //char *v26; // esi@78 | |
3666 //int v27; // eax@79 | |
3667 char v28; // zf@81 | |
3668 __int16 v29; // ax@85 | |
3669 signed int v30; // edi@94 | |
3670 int v31; // esi@94 | |
1545 | 3671 //char Args; // [sp+350h] [bp-C4h]@16 |
0 | 3672 int v34[4]; // [sp+3E8h] [bp-2Ch]@96 |
3673 int v35; // [sp+3F8h] [bp-1Ch]@1 | |
3674 //char b[4]; // [sp+3FCh] [bp-18h]@58 | |
3675 MapInfo *v37; // [sp+400h] [bp-14h]@1 | |
3676 int v38; // [sp+404h] [bp-10h]@1 | |
3677 unsigned int v39; // [sp+408h] [bp-Ch]@8 | |
3678 int pDest; // [sp+40Ch] [bp-8h]@1 | |
3679 //int i; // [sp+410h] [bp-4h]@27 | |
3680 | |
3681 v37 = (MapInfo *)bLoading; | |
3682 v1 = 0; | |
3683 v35 = 0; | |
3684 pGameLoadingUI_ProgressBar->Reset(0x20u); | |
3685 bUnderwater = 0; | |
3686 bNoNPCHiring = 0; | |
3687 v38 = 0; | |
3688 pDest = 1; | |
3689 uCurrentlyLoadedLevelType = LEVEL_Indoor; | |
3690 pGame->uFlags2 &= 0xFFFFFFF7u; | |
3691 if ( Is_out15odm_underwater() ) | |
3692 { | |
3693 bUnderwater = 1; | |
3694 pGame->uFlags2 |= 8u; | |
3695 } | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
3696 if ( !_stricmp(pCurrentMapName, "out15.odm") || !_stricmp(pCurrentMapName, "d23.blv") ) |
0 | 3697 bNoNPCHiring = 1; |
3698 pPaletteManager->pPalette_tintColor[0] = 0; | |
3699 pPaletteManager->pPalette_tintColor[1] = 0; | |
3700 pPaletteManager->pPalette_tintColor[2] = 0; | |
3701 pPaletteManager->RecalculateAll(); | |
3702 if ( qword_A750D8 ) | |
3703 qword_A750D8 = 0i64; | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
3704 v2 = pMapStats->GetMapInfo(pCurrentMapName); |
0 | 3705 v39 = v2; |
3706 if ( v2 ) | |
3707 { | |
3708 v3 = &pMapStats->pInfos[v2]; | |
3709 v1 = v3->uRespawnIntervalDays; | |
3710 v38 = GetAlertStatus(); | |
3711 } | |
3712 else | |
3713 { | |
3714 v3 = v37; | |
3715 } | |
3716 dword_6BE13C_uCurrentlyLoadedLocationID = v39; | |
3717 pAllocator->FreeChunk(ptr_6A0D08); | |
3718 ptr_6A0D08 = 0; | |
3719 _6A0D0C_txt_lod_loading = 0; | |
3720 TryLoadLevelFromLOD(); | |
3721 pStationaryLightsStack->uNumLightsActive = 0; | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
3722 v4 = pIndoor->Load(pCurrentMapName, |
0 | 3723 (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1, |
3724 v1, | |
3725 (char *)&pDest) | |
3726 - 1; | |
3727 if ( !v4 ) | |
1545 | 3728 Error("Unable to open %s", pCurrentMapName); |
3729 | |
0 | 3730 v5 = v4 - 1; |
3731 if ( !v5 ) | |
1545 | 3732 Error("File %s is not a BLV File", pCurrentMapName); |
3733 | |
0 | 3734 v6 = v5 - 1; |
3735 if ( !v6 ) | |
1545 | 3736 Error("Attempt to open new level before clearing old"); |
0 | 3737 if ( v6 == 1 ) |
1545 | 3738 Error("Out of memory loading indoor level"); |
0 | 3739 if ( !(dword_6BE364_game_settings_1 & 0x2000) ) |
3740 { | |
3741 InitializeActors(); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3742 InitializeSpriteObjects(); |
0 | 3743 } |
3744 BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; | |
3745 if ( !v39 ) | |
3746 pDest = 0; | |
3747 if ( pDest == 1 ) | |
3748 { | |
3749 v7 = 0; | |
3750 for (uint i = 0; i < pIndoor->uNumSpawnPoints; ++v7 ) | |
3751 { | |
3752 v8 = &pIndoor->pSpawnPoints[v7]; | |
3753 if ( pIndoor->pSpawnPoints[v7].uKind == 3 ) | |
3754 SpawnEncounter(v3, v8, 0, 0, 0); | |
3755 else | |
3756 v3->SpawnRandomTreasure(v8); | |
3757 ++i; | |
3758 } | |
3759 RespawnGlobalDecorations(); | |
3760 } | |
3761 | |
3762 pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39], 0); | |
3763 pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39] + 1, 0); | |
3764 | |
3765 for (uint i = 0; i < pIndoor->uNumDoors; ++i) | |
3766 { | |
3767 auto pDoor = pIndoor->pDoors + i; | |
3768 | |
3769 if (pDoor->uAttributes & 0x01) | |
3770 { | |
3771 pDoor->uState = BLVDoor::Opening; | |
3772 pDoor->uTimeSinceTriggered = 15360; | |
3773 pDoor->uAttributes = 2; | |
3774 } | |
3775 | |
3776 if (pDoor->uState == BLVDoor::Closed) | |
3777 { | |
3778 pDoor->uState = BLVDoor::Closing; | |
3779 pDoor->uTimeSinceTriggered = 15360; | |
3780 pDoor->uAttributes = 2; | |
3781 } | |
3782 else if (pDoor->uState == BLVDoor::Open) | |
3783 { | |
3784 pDoor->uState = BLVDoor::Opening; | |
3785 pDoor->uTimeSinceTriggered = 15360; | |
3786 pDoor->uAttributes = 2; | |
3787 } | |
3788 } | |
3789 | |
3790 /* | |
3791 i = 0; | |
3792 v9 = 2; | |
3793 if ( pIndoor->uNumDoors > 0 ) | |
3794 { | |
3795 v10 = 0; | |
3796 while ( 1 ) | |
3797 { | |
3798 if ( pIndoor->pDoors[v10].uAttributes & 1 ) | |
3799 { | |
3800 pIndoor->pDoors[v10].uState = 1; | |
3801 pIndoor->pDoors[v10].uTimeSinceTriggered = 15360; | |
3802 pIndoor->pDoors[v10].uAttributes = 2; | |
3803 } | |
3804 v11 = (char *)&pIndoor->pDoors[v10].uState; | |
3805 if ( !*(short *)v11 ) | |
3806 break; | |
3807 if ( *(short *)v11 == 2 ) | |
3808 { | |
3809 *(short *)v11 = 1; | |
3810 goto LABEL_41; | |
3811 } | |
3812 LABEL_42: | |
3813 ++i; | |
3814 ++v10; | |
3815 if ( i >= pIndoor->uNumDoors ) | |
3816 goto LABEL_43; | |
3817 } | |
3818 *(short *)v11 = 3; | |
3819 LABEL_41: | |
3820 pIndoor->pDoors[v10].uTimeSinceTriggered = 15360; | |
3821 pIndoor->pDoors[v10].uAttributes = 2; | |
3822 goto LABEL_42; | |
3823 } | |
3824 LABEL_43: | |
3825 */ | |
3826 | |
3827 for (uint i = 0; i < pIndoor->uNumFaces; ++i) | |
3828 { | |
3829 auto pFace = pIndoor->pFaces + i; | |
3830 if (!pFace->uBitmapID != -1) | |
3831 pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id1); | |
3832 } | |
3833 | |
3834 pGameLoadingUI_ProgressBar->Progress(); | |
3835 | |
3836 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
3837 { | |
1202 | 3838 auto pDecortaion = &pLevelDecorations[i]; |
0 | 3839 |
3840 pDecorationList->InitializeDecorationSprite(pDecortaion->uDecorationDescID); | |
3841 | |
3842 v15 = pDecorationList->pDecorations[pDecortaion->uDecorationDescID].uSoundID; | |
3843 if (v15 && _6807E0_num_decorations_with_sounds_6807B8 < 9) | |
3844 { | |
3845 pSoundList->LoadSound(v15, 0); | |
3846 v16 = _6807E0_num_decorations_with_sounds_6807B8++; | |
3847 _6807B8_level_decorations_ids[v16] = i; | |
3848 } | |
3849 | |
1489 | 3850 if (!(pDecortaion->uFlags & LEVEL_DECORATION_INVISIBLE)) |
0 | 3851 { |
3852 v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID]; | |
380 | 3853 if (!v17->DontDraw()) |
0 | 3854 { |
3855 v18 = v17->uLightRadius; | |
3856 if ( v18 ) | |
3857 { | |
3858 unsigned char r = 255, | |
3859 g = 255, | |
3860 b = 255; | |
3861 if (pRenderer->pRenderD3D && pRenderer->bUseColoredLights) | |
3862 { | |
3863 r = v17->uColoredLightRed; | |
3864 g = v17->uColoredLightGreen; | |
3865 b = v17->uColoredLightBlue; | |
3866 } | |
3867 pStationaryLightsStack->AddLight(pDecortaion->vPosition.x, | |
3868 pDecortaion->vPosition.y, | |
3869 pDecortaion->vPosition.z + v17->uDecorationHeight, | |
3870 v18, | |
3871 r, | |
3872 g, | |
3873 b, | |
3874 byte_4E94D0); | |
3875 } | |
3876 } | |
3877 } | |
3878 | |
1514
965af46e8793
Rename LevelDecoration::field_16_event_id to LevelDecoration::uEventID.
yoctozepto
parents:
1493
diff
changeset
|
3879 if (!pDecortaion->uEventID) |
0 | 3880 { |
3881 if (pDecortaion->IsInteractive()) | |
3882 { | |
3883 if ( v35 < 124 ) | |
3884 { | |
3885 v21 = v35 + 1; | |
3886 pDecortaion->_idx_in_stru123 = v35 + 75; | |
3887 v22 = stru_5E4C90._decor_events[v21 + 74 - 75]; | |
3888 v35 = v21; | |
3889 if ( !v22 ) | |
1489 | 3890 pDecortaion->uFlags |= LEVEL_DECORATION_INVISIBLE; |
0 | 3891 } |
3892 } | |
3893 } | |
3894 } | |
3895 | |
3896 pGameLoadingUI_ProgressBar->Progress(); | |
3897 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3898 for (uint i = 0; i < uNumSpriteObjects; ++i) |
0 | 3899 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
3900 auto p = &pSpriteObjects[i]; |
0 | 3901 if (p->uObjectDescID) |
3902 { | |
3903 auto uItemID = p->stru_24.uItemID; | |
3904 if (uItemID) | |
3905 { | |
3906 if (uItemID != 220 && pItemsTable->pItems[uItemID].uEquipType == EQUIP_POTION && | |
570 | 3907 !p->stru_24.uEnchantmentType) |
3908 p->stru_24.uEnchantmentType = rand() % 15 + 5; | |
0 | 3909 pItemsTable->SetSpecialBonus(&p->stru_24); |
3910 } | |
3911 } | |
3912 } | |
3913 | |
3914 for (uint i = 0; i < uNumActors; ++i) | |
3915 //if ( (signed int)uNumActors > (signed int)v13 ) | |
3916 { | |
1202 | 3917 Actor *pActor = &pActors[i]; |
0 | 3918 //v26 = (char *)&pActors[0].uAttributes; |
3919 //do | |
3920 //{ | |
3921 //v27 = *(int *)v26; | |
3922 if (pActor->uAttributes & 0x100000) | |
3923 { | |
3924 if ( !v39 ) | |
3925 { | |
3926 pActor->pMonsterInfo.field_3E = 19; | |
3927 pActor->uAttributes |= 0x10000; | |
3928 continue; | |
3929 } | |
3930 v28 = v38 == 0; | |
3931 } | |
3932 else | |
3933 { | |
3934 v28 = v38 == 1; | |
3935 } | |
3936 | |
3937 if ( !v28 ) | |
3938 { | |
3939 pActor->PrepareSprites(0); | |
3940 v29 = pActor->pMonsterInfo.field_3E; | |
3941 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
3942 if ( v29 != 11 && v29 != 19 && (!pActor->sCurrentHP || !pActor->pMonsterInfo.uHP) ) | |
3943 { | |
3944 pActor->pMonsterInfo.field_3E = 5; | |
3945 pActor->UpdateAnimation(); | |
3946 } | |
3947 } | |
3948 else | |
3949 { | |
3950 pActor->pMonsterInfo.field_3E = 19; | |
3951 pActor->uAttributes |= 0x10000; | |
3952 } | |
3953 //} | |
3954 //while ( i < (signed int)uNumActors ); | |
3955 } | |
3956 | |
3957 pGameLoadingUI_ProgressBar->Progress(); | |
3958 | |
3959 Actor this_; | |
3960 this_.pMonsterInfo.uID = 45; | |
3961 this_.PrepareSprites(0); | |
3962 if ( !v37 ) | |
3963 { | |
3964 pParty->sRotationX = 0; | |
3965 pParty->sRotationY = 0; | |
3966 pParty->vPosition.z = 0; | |
3967 pParty->vPosition.y = 0; | |
3968 pParty->vPosition.x = 0; | |
3969 pParty->uFallStartY = 0; | |
3970 pParty->uFallSpeed = 0; | |
3971 TeleportToStartingPoint(uLevel_StartingPointType); | |
3972 } | |
3973 viewparams->_443365(); | |
3974 PlayLevelMusic(); | |
3975 if ( !v37 ) | |
3976 { | |
3977 v30 = 0; | |
3978 v31 = 1; | |
3979 do | |
3980 { | |
3981 if ( pPlayers[v31]->CanAct() ) | |
3982 v34[v30++] = v31; | |
3983 ++v31; | |
3984 } | |
3985 while ( v31 <= 4 ); | |
3986 if ( v30 ) | |
3987 { | |
3988 if ( pDest ) | |
3989 { | |
3990 qword_A750D8 = 256i64; | |
1406 | 3991 PlayerSpeechID = SPEECH_46; |
1407 | 3992 uSpeakingCharacter = LOWORD(v34[rand() % v30]); |
0 | 3993 } |
3994 } | |
3995 } | |
1295 | 3996 } |
3997 //----- (0046CEC3) -------------------------------------------------------- | |
3998 int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID) | |
3999 { | |
4000 int v13; // ecx@13 | |
4001 signed int v14; // ebx@14 | |
4002 int v15; // eax@16 | |
4003 //int v16; // edx@19 | |
4004 //int v17; // ST18_4@19 | |
4005 //signed int v18; // edx@19 | |
4006 //signed __int64 v19; // qtt@19 | |
4007 int v21; // eax@27 | |
4008 //int v22; // ecx@29 | |
4009 signed int v28; // eax@45 | |
4010 int v29; // ebx@47 | |
4011 int v30; // edx@49 | |
4012 //int v31; // ST10_4@49 | |
4013 //signed int v32; // edx@49 | |
4014 signed __int64 v33; // qtt@49 | |
4015 //signed int v34; // eax@54 | |
4016 //signed int v35; // esi@56 | |
4017 //int result; // eax@57 | |
4018 int v38; // edx@62 | |
4019 //int v44; // [sp+20h] [bp-20h]@10 | |
4020 bool v47; // [sp+24h] [bp-1Ch]@43 | |
4021 bool v48; // [sp+28h] [bp-18h]@10 | |
4022 bool v49; // [sp+28h] [bp-18h]@41 | |
4023 bool v50; // [sp+2Ch] [bp-14h]@12 | |
4024 signed int v53; // [sp+30h] [bp-10h]@10 | |
4025 signed int v54; // [sp+30h] [bp-10h]@41 | |
4026 signed int v55; // [sp+34h] [bp-Ch]@1 | |
4027 | |
4028 //LOG_DECOMPILATION_WARNING(); | |
4029 | |
4030 static int blv_floor_id[50]; // 00721200 | |
4031 static int blv_floor_level[50]; // 007212C8 | |
4032 | |
4033 static __int16 word_721390_ys[104]; // idb | |
4034 static __int16 word_721460_xs[104]; // idb | |
4035 | |
4036 auto pSector = &pIndoor->pSectors[uSectorID]; | |
4037 v55 = 0; | |
4038 for (uint i = 0; i < pSector->uNumFloors; ++i) | |
4039 { | |
4040 auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]]; | |
4041 if (pFloor->Clickable()) | |
4042 continue; | |
4043 | |
4044 assert(pFloor->uNumVertices); | |
4045 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && | |
4046 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) | |
4047 { | |
4048 for (uint j = 0; j < pFloor->uNumVertices; ++j) | |
4049 { | |
4050 word_721460_xs[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; | |
4051 word_721460_xs[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; | |
4052 word_721390_ys[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; | |
4053 word_721390_ys[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; | |
4054 } | |
4055 word_721460_xs[2 * pFloor->uNumVertices] = word_721460_xs[0]; | |
4056 word_721390_ys[2 * pFloor->uNumVertices] = word_721390_ys[0]; | |
4057 | |
4058 v50 = word_721390_ys[0] >= y; | |
4059 v53 = 0; | |
4060 | |
4061 for (uint j = 0; j < 2 * pFloor->uNumVertices; ++j) | |
4062 { | |
4063 if (v53 >= 2) | |
4064 break; | |
4065 | |
4066 v48 = v50; | |
4067 v50 = word_721390_ys[j + 1] >= y; | |
4068 | |
4069 v13 = i; | |
4070 if (v48 == v50) | |
4071 continue; | |
4072 | |
4073 v14 = word_721460_xs[j + 1] >= x ? 0 : 2; | |
4074 v15 = v14 | (word_721460_xs[j] < x); | |
4075 | |
4076 if (v15 == 3) | |
4077 continue; | |
4078 else if (!v15) | |
4079 ++v53; | |
4080 else | |
4081 { | |
4082 auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); | |
4083 auto res = fixpoint_sub0((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); | |
4084 | |
4085 if (res + word_721460_xs[j] >= x) | |
4086 ++v53; | |
4087 } | |
4088 } | |
4089 | |
4090 | |
4091 if ( v53 == 1 ) | |
4092 { | |
4093 if ( v55 >= 50 ) | |
4094 break; | |
4095 if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling ) | |
4096 { | |
4097 v21 = pIndoor->pVertices[pFloor->pVertexIDs[0]].z; | |
4098 } | |
4099 else | |
4100 { | |
4101 v21 = fixpoint_sub0(pFloor->zCalc1, x) + fixpoint_sub0(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16); | |
4102 } | |
4103 blv_floor_level[v55] = v21; | |
4104 blv_floor_id[v55] = pSector->pFloors[i]; | |
4105 v55++; | |
4106 } | |
4107 } | |
4108 } | |
4109 | |
4110 | |
4111 if ( pSector->field_0 & 8 ) | |
4112 { | |
4113 for (uint i = 0; i < pSector->uNumPortals; ++i) | |
4114 { | |
4115 auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; | |
4116 if (portal->uPolygonType != POLYGON_Floor) | |
4117 continue; | |
4118 | |
4119 if (!portal->uNumVertices) | |
4120 continue; | |
4121 | |
4122 if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 && | |
4123 y <= portal->pBounding.y2 && y >= portal->pBounding.y1 ) | |
4124 { | |
4125 for (uint j = 0; j < portal->uNumVertices; ++j) | |
4126 { | |
4127 word_721460_xs[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; | |
4128 word_721460_xs[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; | |
4129 word_721390_ys[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; | |
4130 word_721390_ys[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; | |
4131 } | |
4132 word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0]; | |
4133 word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0]; | |
4134 v54 = 0; | |
4135 v47 = word_721390_ys[0] >= y; | |
4136 | |
4137 for (uint j = 0; j < 2 * portal->uNumVertices; ++j) | |
4138 { | |
4139 v49 = v47; | |
4140 if ( v54 >= 2 ) | |
4141 break; | |
4142 v47 = word_721390_ys[j + 1] >= y; | |
4143 if ( v49 != v47 ) | |
4144 { | |
4145 v28 = word_721460_xs[j + 1] >= x ? 0 : 2; | |
4146 v29 = v28 | (word_721460_xs[j] < x); | |
4147 if ( v29 != 3 ) | |
4148 { | |
4149 if ( !v29 ) | |
4150 ++v54; | |
4151 else | |
4152 { | |
4153 auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); | |
4154 auto res = fixpoint_sub0(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); | |
4155 if (res + word_721460_xs[j] >= x) | |
4156 ++v54; | |
4157 } | |
4158 } | |
4159 } | |
4160 } | |
4161 if ( v54 == 1 ) | |
4162 { | |
4163 if ( v55 >= 50 ) | |
4164 break; | |
4165 blv_floor_level[v55] = -29000; | |
4166 blv_floor_id[v55] = pSector->pPortals[i]; | |
4167 v55++; | |
4168 } | |
4169 } | |
4170 } | |
4171 } | |
4172 if ( v55 == 1 ) | |
4173 { | |
4174 *pFaceID = blv_floor_id[0]; | |
4175 return blv_floor_level[0]; | |
4176 } | |
4177 if ( !v55 ) | |
4178 return -30000; | |
4179 *pFaceID = blv_floor_id[0]; | |
4180 //result = blv_floor_level[0]; | |
4181 | |
4182 /*for ( v35 = 1; v35 < v55; ++v35 ) | |
4183 { | |
4184 if ( blv_floor_level[0] <= z + 5 ) | |
4185 { | |
4186 if ( blv_floor_level[v35] >= blv_floor_level[0] || blv_floor_level[v35] > z + 5 ) | |
4187 continue; | |
4188 blv_floor_level[0] = blv_floor_level[v35]; | |
4189 *pFaceID = blv_floor_id[v35]; | |
4190 continue; | |
4191 } | |
4192 if ( blv_floor_level[v35] < blv_floor_level[0] ) | |
4193 { | |
4194 blv_floor_level[0] = blv_floor_level[v35]; | |
4195 *pFaceID = blv_floor_id[v35]; | |
4196 } | |
4197 }*/ | |
4198 | |
4199 | |
4200 int result = blv_floor_level[0]; | |
4201 for (uint i = 1; i < v55; ++i) | |
4202 { | |
4203 v38 = blv_floor_level[i]; | |
4204 if ( result <= z + 5 ) | |
4205 { | |
4206 if ( v38 > result && v38 <= z + 5 ) | |
4207 { | |
4208 result = blv_floor_level[i]; | |
4209 *pFaceID = blv_floor_id[i]; | |
4210 } | |
4211 } | |
4212 else if ( v38 < result ) | |
4213 { | |
4214 result = blv_floor_level[i]; | |
4215 *pFaceID = blv_floor_id[i]; | |
4216 } | |
4217 } | |
4218 | |
4219 return result; | |
4220 } | |
4221 //----- (004016FA) -------------------------------------------------------- | |
1458 | 4222 int MakeActorAIList_BLV() |
1295 | 4223 { |
4224 Actor *v0; // esi@2 | |
4225 int v1; // eax@4 | |
4226 int v2; // ebx@4 | |
4227 unsigned int v3; // ecx@4 | |
4228 int v4; // edx@5 | |
4229 int v5; // edx@7 | |
4230 unsigned int v6; // edx@9 | |
4231 unsigned int v7; // ST24_4@10 | |
4232 int v8; // eax@10 | |
4233 int v9; // edi@10 | |
4234 int v10; // ebx@14 | |
4235 char v11; // zf@16 | |
4236 int v12; // eax@22 | |
4237 int v13; // edx@24 | |
4238 int v14; // ecx@25 | |
4239 int v15; // ebx@26 | |
4240 unsigned int *v16; // ecx@27 | |
4241 unsigned int v17; // esi@27 | |
4242 int v18; // ecx@31 | |
4243 signed int v19; // edi@31 | |
4244 Actor *v20; // esi@32 | |
4245 bool v21; // eax@33 | |
4246 int v22; // eax@34 | |
4247 signed int v23; // ebx@36 | |
4248 Actor *v24; // esi@37 | |
4249 signed int v25; // eax@40 | |
4250 int v26; // eax@43 | |
4251 int v27; // ebx@45 | |
4252 int j; // edi@45 | |
4253 unsigned int v29; // eax@46 | |
4254 int v30; // eax@48 | |
4255 int v31; // ecx@51 | |
4256 int v32; // eax@51 | |
4257 signed int v33; // eax@53 | |
4258 __int64 v34; // qax@55 | |
4259 char *v35; // ecx@56 | |
4260 int v37; // [sp+Ch] [bp-18h]@1 | |
4261 int v38; // [sp+10h] [bp-14h]@4 | |
4262 int v39; // [sp+14h] [bp-10h]@4 | |
4263 int v40; // [sp+18h] [bp-Ch]@10 | |
4264 int v41; // [sp+18h] [bp-Ch]@29 | |
4265 int i; // [sp+18h] [bp-Ch]@31 | |
4266 signed int v43; // [sp+1Ch] [bp-8h]@1 | |
4267 signed int v44; // [sp+1Ch] [bp-8h]@25 | |
4268 int v45; // [sp+20h] [bp-4h]@1 | |
4269 | |
4270 // __debugbreak(); // refactor for blv ai | |
4271 pParty->uFlags &= 0xFFFFFFCFu; | |
4272 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
4273 v45 = 0; | |
4274 v43 = 0; | |
4275 if ( (signed int)uNumActors > 0 ) | |
4276 { | |
4277 v0 = pActors.data();//[0].uAttributes; | |
4278 do | |
4279 { | |
4280 BYTE1(v0->uAttributes) &= 0xFBu; | |
4281 if ( ! v0->CanAct() ) | |
4282 goto LABEL_60; | |
4283 v39 = abs(pParty->vPosition.z - v0->vPosition.z); | |
4284 v38 = abs(pParty->vPosition.y - v0->vPosition.y); | |
4285 v1 = abs(pParty->vPosition.x - v0->vPosition.x); | |
4286 v2 = v38; | |
4287 v3 = v39; | |
4288 if ( v1 < v38 ) | |
4289 { | |
4290 v4 = v1; | |
4291 v1 = v38; | |
4292 v2 = v4; | |
4293 } | |
4294 if ( v1 < v39 ) | |
4295 { | |
4296 v5 = v1; | |
4297 v1 = v39; | |
4298 v3 = v5; | |
4299 } | |
4300 if ( v2 < (signed int)v3 ) | |
4301 { | |
4302 v6 = v3; | |
4303 v3 = v2; | |
4304 v2 = v6; | |
4305 } | |
4306 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; | |
4307 v8 = v0->uActorRadius; | |
4308 v9 = v7 - v8; | |
4309 v40 = v7 - v8; | |
4310 if ( v40 < 0 ) | |
4311 { | |
4312 v9 = 0; | |
4313 v40 = 0; | |
4314 } | |
4315 if ( v9 < 10240 ) | |
4316 { | |
4317 v10 = v0->uAttributes & 0xFEFFFFFF; | |
4318 v0->uAttributes = v10; | |
4319 if ( v10 & 0x80000 || v0->GetActorsRelation(0) ) | |
4320 { | |
4321 v11 = (pParty->uFlags & 0x10) == 0; | |
4322 v0->uAttributes = v10 | 0x1000000; | |
4323 if ( v11 && (double)v40 < 307.2 ) | |
4324 pParty->uFlags |= 0x10u; | |
4325 if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) | |
4326 pParty->uFlags |= 0x20u; | |
4327 } | |
4328 v12 = v45++; | |
4329 ai_near_actors_distances[v12] = v9; | |
4330 ai_near_actors_ids[v12] = v43; | |
4331 } | |
4332 else | |
4333 { | |
4334 LABEL_60: | |
4335 BYTE1(v0->uAttributes) &= 0xBFu; | |
4336 } | |
4337 ++v43; | |
4338 ++v0; | |
4339 } | |
4340 while ( v43 < (signed int)uNumActors ); | |
4341 } | |
4342 v13 = 0; | |
4343 if ( v45 > 0 ) | |
4344 { | |
4345 v14 = 1; | |
4346 v44 = 1; | |
4347 do | |
4348 { | |
4349 while ( 1 ) | |
4350 { | |
4351 v41 = v14; | |
4352 if ( v14 >= v45 ) | |
4353 break; | |
4354 v15 = ai_near_actors_distances[v13]; | |
4355 if ( v15 > ai_near_actors_distances[v14] ) | |
4356 { | |
4357 v16 = &ai_near_actors_ids[v14]; | |
4358 v17 = ai_near_actors_ids[v13]; | |
4359 ai_near_actors_ids[v13] = *v16; | |
4360 *v16 = v17; | |
4361 v14 = v41; | |
4362 ai_near_actors_distances[v13] = ai_near_actors_distances[v41]; | |
4363 ai_near_actors_distances[v41] = v15; | |
4364 } | |
4365 ++v14; | |
4366 } | |
4367 ++v13; | |
4368 v14 = v44 + 1; | |
4369 v44 = v14; | |
4370 } | |
4371 while ( v14 - 1 < v45 ); | |
4372 } | |
4373 v18 = 0; | |
4374 v19 = 0; | |
4375 for ( i = 0; v18 < v45; i = v18 ) | |
4376 { | |
4377 v20 = &pActors[ai_near_actors_ids[v18]]; | |
4378 if ( v20->uAttributes & 0x8000 | |
1493 | 4379 || (v21 = sub_4070EF_prolly_detect_player(PID(OBJECT_Actor,ai_near_actors_ids[v18]), 4u), v18 = i, v21) ) |
1295 | 4380 { |
4381 v22 = ai_near_actors_ids[v18]; | |
4382 v20->uAttributes |= 0x8000u; | |
4383 ai_array_4F6638_actor_ids[v19] = v22; | |
4384 ai_array_4F5E68[v19++] = ai_near_actors_distances[v18]; | |
4385 if ( v19 >= 30 ) | |
4386 break; | |
4387 } | |
4388 ++v18; | |
4389 } | |
4390 v23 = 0; | |
4391 ai_arrays_size = v19; | |
4392 if ( (signed int)uNumActors > 0 ) | |
4393 { | |
4394 v24 = pActors.data();//[0].uAttributes; | |
4395 do | |
4396 { | |
4397 if ( v24->CanAct() && v24->uSectorID == v37 ) | |
4398 { | |
4399 v25 = 0; | |
4400 if ( v19 <= 0 ) | |
4401 { | |
4402 LABEL_43: | |
4403 v26 = ai_arrays_size; | |
4404 BYTE1(v24->uAttributes) |= 0x40u; | |
4405 ++ai_arrays_size; | |
4406 ai_array_4F6638_actor_ids[v26] = v23; | |
4407 } | |
4408 else | |
4409 { | |
4410 while ( ai_array_4F6638_actor_ids[v25] != v23 ) | |
4411 { | |
4412 ++v25; | |
4413 if ( v25 >= v19 ) | |
4414 goto LABEL_43; | |
4415 } | |
4416 } | |
4417 } | |
4418 ++v23; | |
4419 ++v24; | |
4420 } | |
4421 while ( v23 < (signed int)uNumActors ); | |
4422 } | |
4423 v27 = ai_arrays_size; | |
4424 for ( j = 0; j < v45; ++j ) | |
4425 { | |
4426 v29 = ai_near_actors_ids[j]; | |
4427 if ( pActors[v29].uAttributes & 0xC000 && pActors[v29].CanAct() ) | |
4428 { | |
4429 v30 = 0; | |
4430 if ( v27 <= 0 ) | |
4431 { | |
4432 LABEL_51: | |
4433 v31 = ai_arrays_size; | |
4434 v32 = ai_near_actors_ids[j]; | |
4435 ++ai_arrays_size; | |
4436 ai_array_4F6638_actor_ids[v31] = v32; | |
4437 } | |
4438 else | |
4439 { | |
4440 while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] ) | |
4441 { | |
4442 ++v30; | |
4443 if ( v30 >= v27 ) | |
4444 goto LABEL_51; | |
4445 } | |
4446 } | |
4447 } | |
4448 } | |
4449 v33 = ai_arrays_size; | |
4450 if ( ai_arrays_size > 30 ) | |
4451 { | |
4452 v33 = 30; | |
4453 ai_arrays_size = 30; | |
4454 } | |
4455 memcpy(ai_near_actors_ids.data(), ai_array_4F6638_actor_ids.data(), 4 * v33); | |
4456 memcpy(ai_near_actors_distances.data(), ai_array_4F5E68.data(), 4 * ai_arrays_size); | |
4457 v34 = (unsigned int)ai_arrays_size; | |
4458 if ( ai_arrays_size > 0 ) | |
4459 { | |
4460 do | |
4461 { | |
4462 v35 = (char *)&pActors[ai_near_actors_ids[HIDWORD(v34)]].uAttributes; | |
4463 v35[1] |= 4u; | |
4464 ++HIDWORD(v34); | |
4465 } | |
4466 while ( SHIDWORD(v34) < (signed int)v34 ); | |
4467 } | |
4468 return v34; | |
4469 } | |
4470 //----- (0043FDED) -------------------------------------------------------- | |
4471 void PrepareActorRenderList_BLV() | |
4472 { | |
4473 RenderBillboard *v0; // esi@0 | |
4474 unsigned __int16 v3; // ax@3 | |
4475 unsigned int v4; // eax@5 | |
4476 unsigned __int16 v5; // cx@5 | |
4477 int v6; // esi@5 | |
4478 unsigned int v7; // eax@7 | |
4479 int v8; // eax@10 | |
4480 SpriteFrame *v9; // eax@16 | |
4481 SpriteFrame *v10; // ebx@18 | |
4482 //int *v11; // eax@18 | |
4483 int v12; // ecx@28 | |
4484 //IndoorCameraD3D **v14; // eax@36 | |
4485 double v15; // st7@36 | |
4486 float v16; // eax@36 | |
4487 //double v17; // ST30_8@36 | |
4488 signed __int64 v18; // qtt@36 | |
4489 int v19; // ST5C_4@36 | |
4490 signed __int64 v20; // qtt@37 | |
4491 int v21; // ST5C_4@37 | |
4492 signed __int16 v22; // cx@39 | |
4493 int v23; // ST50_4@40 | |
4494 signed int v24; // ecx@40 | |
4495 int v25; // edx@44 | |
4496 __int16 v26; // ax@44 | |
4497 //MonsterDesc *v27; // edx@44 | |
4498 //int v28; // ecx@44 | |
4499 unsigned __int8 v29; // zf@44 | |
4500 unsigned __int8 v30; // sf@44 | |
4501 unsigned int v31; // [sp-8h] [bp-5Ch]@15 | |
4502 int v32; // [sp+1Ch] [bp-38h]@5 | |
4503 int a3; // [sp+20h] [bp-34h]@5 | |
4504 int a2; // [sp+24h] [bp-30h]@5 | |
4505 int a1a; // [sp+28h] [bp-2Ch]@5 | |
4506 __int16 a5; // [sp+2Ch] [bp-28h]@5 | |
4507 int a5a; // [sp+2Ch] [bp-28h]@36 | |
4508 int a5b; // [sp+2Ch] [bp-28h]@40 | |
4509 __int16 v41; // [sp+3Ch] [bp-18h]@18 | |
4510 int a6; // [sp+40h] [bp-14h]@34 | |
4511 int v43; // [sp+44h] [bp-10h]@34 | |
4512 int z; // [sp+48h] [bp-Ch]@32 | |
4513 signed int y; // [sp+4Ch] [bp-8h]@32 | |
4514 int x; // [sp+50h] [bp-4h]@32 | |
4515 | |
4516 for (uint i = 0; i < uNumActors; ++i) | |
4517 { | |
4518 auto p = &pActors[i]; | |
4519 | |
4520 if (p->uAIState == Removed || | |
4521 p->uAIState == Disabled) | |
4522 continue; | |
4523 | |
4524 a5 = p->uSectorID; | |
4525 a2 = p->vPosition.y; | |
4526 a1a = p->vPosition.x; | |
4527 a3 = p->vPosition.z; | |
4528 v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); | |
4529 LOWORD(v0) = p->uYawAngle; | |
4530 v5 = p->uCurrentActionAnimation; | |
4531 v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7; | |
4532 v32 = v6; | |
4533 if ( pParty->bTurnBasedModeOn ) | |
4534 { | |
4535 if ( v5 == 1 ) | |
4536 { | |
4537 v7 = pMiscTimer->uTotalGameTimeElapsed; | |
4538 goto LABEL_10; | |
4539 } | |
4540 } | |
4541 else | |
4542 { | |
4543 if ( v5 == 1 ) | |
4544 { | |
4545 v7 = pBLVRenderParams->field_0_timer_; | |
4546 LABEL_10: | |
4547 v8 = i * 32 + v7; | |
4548 goto LABEL_12; | |
4549 } | |
4550 } | |
4551 v8 = p->uCurrentActionTime; | |
4552 LABEL_12: | |
4553 if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 ) | |
4554 v8 = 0; | |
4555 v31 = p->pSpriteIDs[v5]; | |
4556 if (p->uAIState == Resurrected) | |
4557 v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8); | |
4558 else | |
4559 v9 = pSpriteFrameTable->GetFrame(v31, v8); | |
4560 v41 = 0; | |
4561 v10 = v9; | |
4562 //v11 = (int *)v9->uFlags; | |
4563 if (v9->uFlags & 2) | |
4564 v41 = 2; | |
4565 if (v9->uFlags & 0x40000) | |
4566 v41 |= 0x40u; | |
4567 if (v9->uFlags & 0x20000) | |
4568 LOBYTE(v41) = v41 | 0x80; | |
4569 v0 = (RenderBillboard *)(256 << v6); | |
4570 if ( (unsigned int)v0 & v9->uFlags) | |
4571 v41 |= 4u; | |
4572 if ( v10->uGlowRadius ) | |
4573 { | |
4574 //LOBYTE(v11) = byte_4E94D3; | |
4575 pMobileLightsStack->AddLight( | |
4576 a1a, | |
4577 a2, | |
4578 a3, | |
4579 a5, | |
4580 v10->uGlowRadius, | |
4581 0xFFu, | |
4582 0xFFu, | |
4583 0xFFu, | |
4584 byte_4E94D3); | |
4585 } | |
4586 v12 = 0; | |
4587 if ( pBspRenderer->uNumVisibleNotEmptySectors <= 0 ) | |
4588 continue; | |
4589 while (pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID) | |
4590 { | |
4591 ++v12; | |
4592 if ( v12 >= pBspRenderer->uNumVisibleNotEmptySectors ) | |
4593 goto _continue; | |
4594 } | |
4595 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1) | |
4596 || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) ) | |
4597 continue; | |
4598 pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6); | |
4599 v0 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
4600 if (uNumBillboardsToDraw >= 500) | |
4601 break; | |
4602 ++uNumBillboardsToDraw; | |
4603 ++uNumSpritesDrawnThisFrame; | |
4604 p->uAttributes |= 8u; | |
4605 v29 = pRenderer->pRenderD3D == 0; | |
4606 v0->uHwSpriteID = v10->pHwSpriteIDs[v32]; | |
4607 v0->uPalette = v10->uPaletteIndex; | |
4608 v0->uIndoorSectorID = a5; | |
4609 if ( v29 ) | |
4610 { | |
4611 LODWORD(v20) = pBLVRenderParams->field_40 << 16; | |
4612 HIDWORD(v20) = pBLVRenderParams->field_40 >> 16; | |
4613 v21 = v20 / x; | |
4614 v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v20 / x) >> 16; | |
4615 a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16; | |
4616 } | |
4617 else | |
4618 { | |
4619 //v14 = &pGame->pIndoorCameraD3D; | |
4620 v0->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
4621 v15 = pGame->pIndoorCameraD3D->fov_y; | |
4622 v16 = v0->fov_x; | |
4623 v0->fov_y = v15; | |
4624 //v17 = v16 + 6.7553994e15; | |
4625 LODWORD(v18) = 0; | |
4626 HIDWORD(v18) = floorf(v16 + 0.5f); | |
4627 v19 = v18 / x; | |
4628 v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v18 / x) >> 16; | |
4629 a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16; | |
4630 } | |
4631 v0->_screenspace_y_scaler_packedfloat = a5a; | |
4632 if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 ) | |
4633 { | |
4634 if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 ) | |
4635 { | |
4636 a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; | |
4637 goto LABEL_43; | |
4638 } | |
4639 } | |
4640 else | |
4641 { | |
4642 v22 = p->pActorBuffs[3].uPower; | |
4643 if ( v22 ) | |
4644 { | |
4645 v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->_screenspace_x_scaler_packedfloat) >> 16; | |
4646 v24 = p->pActorBuffs[3].uPower; | |
4647 v0->_screenspace_x_scaler_packedfloat = v23; | |
4648 a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; | |
4649 LABEL_43: | |
4650 v0->_screenspace_y_scaler_packedfloat = a5b; | |
4651 goto LABEL_44; | |
4652 } | |
4653 } | |
4654 LABEL_44: | |
4655 HIWORD(v25) = HIWORD(x); | |
4656 v0->world_x = a1a; | |
4657 v0->world_y = a2; | |
4658 v0->world_z = a3; | |
4659 v0->uScreenSpaceX = v43; | |
4660 v0->uScreenSpaceY = a6; | |
4661 LOWORD(v25) = 0; | |
4662 LOBYTE(v26) = v41; | |
4663 | |
4664 //v0->sZValue = v25 + (PID(OBJECT_Actor,i)); | |
4665 v0->actual_z = HIWORD(x); | |
4666 v0->object_pid = PID(OBJECT_Actor,i); | |
4667 | |
4668 v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0; | |
4669 v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0; | |
4670 v0->field_1E = v41; | |
4671 v0->pSpriteFrame = v10; | |
4672 v0->uTintColor = pMonsterList->pMonsters[p->pMonsterInfo.uID - 1].uTintColor; | |
4673 if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) ) | |
4674 { | |
4675 HIBYTE(v26) = HIBYTE(v41) | 1; | |
4676 v0->field_1E = v26; | |
4677 } | |
4678 | |
4679 _continue: | |
4680 ; | |
4681 } | |
4682 } | |
4683 //----- (0044028F) -------------------------------------------------------- | |
4684 void PrepareItemsRenderList_BLV() | |
4685 { | |
4686 ObjectDesc *v1; // ebx@4 | |
4687 __int16 v2; // ax@5 | |
4688 RenderBillboard *v3; // esi@12 | |
4689 SpriteFrame *v4; // eax@12 | |
4690 SpriteFrame *v5; // ebx@12 | |
4691 unsigned int v6; // eax@12 | |
4692 int v7; // ecx@12 | |
4693 int v8; // edx@12 | |
4694 int v9; // ecx@12 | |
4695 unsigned __int16 v10; // ax@12 | |
4696 int *v11; // eax@20 | |
4697 //char v12; // zf@26 | |
4698 __int64 v18; // ST5C_4@27 | |
4699 signed __int64 v19; // qtt@28 | |
4700 int v20; // ST5C_4@28 | |
4701 //int v21; // edx@29 | |
4702 __int16 v22; // ax@29 | |
4703 //int v23; // eax@29 | |
4704 SpriteFrame *v24; // [sp+1Ch] [bp-40h]@12 | |
4705 //__int16 a5; // [sp+28h] [bp-34h]@12 | |
4706 int a6; // [sp+2Ch] [bp-30h]@12 | |
4707 int a2; // [sp+30h] [bp-2Ch]@12 | |
4708 int a1; // [sp+34h] [bp-28h]@12 | |
4709 int v30; // [sp+38h] [bp-24h]@12 | |
4710 int v31; // [sp+38h] [bp-24h]@27 | |
4711 int a3; // [sp+40h] [bp-1Ch]@12 | |
4712 signed __int16 v34; // [sp+44h] [bp-18h]@14 | |
4713 int v35; // [sp+48h] [bp-14h]@25 | |
4714 int v36; // [sp+4Ch] [bp-10h]@25 | |
4715 signed int z; // [sp+50h] [bp-Ch]@24 | |
4716 signed int y; // [sp+54h] [bp-8h]@24 | |
4717 signed int x; // [sp+58h] [bp-4h]@24 | |
4718 | |
4719 for (uint i = 0; i < uNumSpriteObjects; ++i) | |
4720 { | |
4721 auto p = &pSpriteObjects[i]; | |
4722 if (p->uObjectDescID) | |
4723 { | |
4724 v1 = &pObjectList->pObjects[p->uObjectDescID]; | |
4725 if ( !(v1->uFlags & 1) ) | |
4726 { | |
4727 if ( ((v2 = p->uType, v2 < 1000) || v2 >= 10000) | |
4728 && (v2 < 500 || v2 >= 600) | |
4729 && (v2 < 811 || v2 >= 815) | |
4730 || pGame->pStru6Instance->_4A81CA(p)) | |
4731 { | |
4732 //a5 = p->uSectorID; | |
4733 a1 = p->vPosition.x; | |
4734 a2 = p->vPosition.y; | |
4735 a3 = p->vPosition.z; | |
4736 v3 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
4737 v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, p->uSpriteFrameID); | |
4738 v5 = v4; | |
4739 v24 = v4; | |
4740 v30 = v4->uFlags; | |
4741 a6 = v4->uGlowRadius * p->field_22_glow_radius_multiplier; | |
4742 v6 = stru_5C6E00->Atan2(p->vPosition.x - pBLVRenderParams->vPartyPos.x, | |
4743 p->vPosition.y - pBLVRenderParams->vPartyPos.y); | |
4744 LOWORD(v7) = p->uFacing; | |
4745 v8 = v30; | |
4746 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7; | |
4747 v10 = v5->pHwSpriteIDs[v9]; | |
4748 v3->uHwSpriteID = v10; | |
4749 if ( v30 & 0x20 ) | |
4750 { | |
4751 v8 = v30; | |
4752 a3 -= (signed int)((unsigned __int64)(v5->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
4753 } | |
4754 v34 = 0; | |
4755 if ( v8 & 2 ) | |
4756 v34 = 2; | |
4757 if ( v8 & 0x40000 ) | |
4758 v34 |= 0x40u; | |
4759 if ( v8 & 0x20000 ) | |
4760 LOBYTE(v34) = v34 | 0x80; | |
4761 v11 = (int *)(256 << v9); | |
4762 if ( (256 << v9) & v8 ) | |
4763 v34 |= 4u; | |
4764 if ( a6 ) | |
4765 { | |
4766 LOBYTE(v11) = byte_4E94D3; | |
4767 pMobileLightsStack->AddLight( | |
4768 a1, | |
4769 a2, | |
4770 a3, | |
4771 p->uSectorID, | |
4772 a6, | |
4773 v1->uParticleTrailColorR, | |
4774 v1->uParticleTrailColorG, | |
4775 v1->uParticleTrailColorB, | |
4776 byte_4E94D3); | |
4777 } | |
4778 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( | |
4779 a1, | |
4780 a2, | |
4781 a3, | |
4782 &x, | |
4783 &y, | |
4784 &z, | |
4785 1) ) | |
4786 { | |
4787 pGame->pIndoorCameraD3D->Project(x, y, z, &v36, &v35); | |
4788 | |
4789 assert(uNumBillboardsToDraw < 500); | |
4790 //if ( (signed int)uNumBillboardsToDraw >= 500 ) | |
4791 // return; | |
4792 ++uNumBillboardsToDraw; | |
4793 ++uNumSpritesDrawnThisFrame; | |
4794 p->uAttributes |= 1u; | |
4795 //v12 = pRenderer->pRenderD3D == 0; | |
4796 v3->uPalette = v24->uPaletteIndex; | |
4797 v3->uIndoorSectorID = p->uSectorID; | |
4798 if ( pRenderer->pRenderD3D ) | |
4799 { | |
4800 v3->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
4801 v3->fov_y = pGame->pIndoorCameraD3D->fov_y; | |
4802 LODWORD(v18) = 0; | |
4803 HIDWORD(v18) = (int)floorf(v3->fov_x + 0.5f); | |
4804 v18 = v18 / x; | |
4805 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v18) >> 16; | |
4806 v31 = (unsigned __int64)(v24->scale * v18) >> 16; | |
4807 } | |
4808 else | |
4809 { | |
1544 | 4810 __debugbreak(); // sw rendering |
4811 /*LODWORD(v19) = pBLVRenderParams->field_40 << 16; | |
1295 | 4812 HIDWORD(v19) = pBLVRenderParams->field_40 >> 16; |
4813 v20 = v19 / x; | |
4814 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v19 / x) >> 16; | |
1544 | 4815 v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16;*/ |
1295 | 4816 } |
4817 //HIWORD(v21) = HIWORD(x); | |
4818 //LOWORD(v21) = 0; | |
4819 v3->_screenspace_y_scaler_packedfloat = v31; | |
4820 v3->field_1E = v34; | |
4821 v3->world_x = a1; | |
4822 v3->world_y = a2; | |
4823 v3->world_z = a3; | |
4824 v3->uScreenSpaceX = v36; | |
4825 v22 = v35; | |
4826 v3->uTintColor = 0; | |
4827 v3->uScreenSpaceY = v22; | |
4828 //v23 = 8 * i; | |
4829 //LOBYTE(v23) = PID(OBJECT_Item,i); | |
4830 v3->pSpriteFrame = v24; | |
4831 //v12 = (p->uAttributes & 0x20) == 0; | |
4832 //v3->sZValue = v21 + v23; | |
4833 v3->actual_z = HIWORD(x); | |
4834 v3->object_pid = PID(OBJECT_Item,i); | |
4835 if (p->uAttributes & 0x20) | |
4836 { | |
4837 if ( !pRenderer->pRenderD3D ) | |
4838 v3->sZValue = 0; | |
4839 } | |
4840 } | |
4841 } | |
4842 } | |
4843 } | |
4844 } | |
4845 } | |
4846 | |
4847 //----- (00440639) -------------------------------------------------------- | |
4848 void AddBspNodeToRenderList(unsigned int node_id) | |
4849 { | |
4850 BLVSector *pSector; // esi@1 | |
4851 | |
4852 pSector = &pIndoor->pSectors[pBspRenderer->nodes[node_id].uSectorID]; | |
4853 if ( pRenderer->pRenderD3D ) | |
4854 { | |
4855 for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i) | |
4856 //Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]); | |
4857 pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[i]); | |
4858 } | |
4859 else | |
4860 { | |
4861 for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i) | |
4862 pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[i]); | |
4863 } | |
4864 if ( pSector->field_0 & 0x10 ) | |
4865 sub_4406BC(node_id, pSector->uFirstBSPNode); | |
4866 } | |
4867 | |
4868 //----- (004406BC) -------------------------------------------------------- | |
4869 void __fastcall sub_4406BC(unsigned int node_id, unsigned int uFirstNode) | |
4870 { | |
4871 BLVSector *pSector; // esi@2 | |
4872 BSPNode *pNode; // edi@2 | |
4873 BLVFace *pFace; // eax@2 | |
4874 int v5; // ecx@2 | |
4875 __int16 v6; // ax@6 | |
4876 int v7; // ebp@10 | |
4877 int v8; // ebx@10 | |
4878 __int16 v9; // di@18 | |
4879 //int v10; // [sp+10h] [bp-Ch]@1 | |
4880 //bool v11; // [sp+14h] [bp-8h]@5 | |
4881 BspRenderer_stru0 *node; // [sp+18h] [bp-4h]@1 | |
4882 | |
4883 //Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode); | |
4884 | |
4885 //v10 = a1; | |
4886 node = &pBspRenderer->nodes[node_id]; | |
4887 while ( 1 ) | |
4888 { | |
4889 pSector = &pIndoor->pSectors[node->uSectorID]; | |
4890 pNode = &pIndoor->pNodes[uFirstNode]; | |
4891 pFace = &pIndoor->pFaces[pSector->pFaceIDs[pNode->uCoplanarOffset]]; | |
4892 v5 = pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | |
4893 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z;//plane equation | |
4894 if (pFace->Portal() && pFace->uSectorID != node->uSectorID ) | |
4895 v5 = -v5; | |
4896 //v11 = v5 > 0; | |
4897 if ( v5 <= 0 ) | |
4898 v6 = pNode->uFront; | |
4899 else | |
4900 v6 = pNode->uBack; | |
4901 if ( v6 != -1 ) | |
4902 sub_4406BC(node_id, v6); | |
4903 v7 = pNode->uCoplanarOffset; | |
4904 v8 = v7 + pNode->uCoplanarSize; | |
4905 | |
4906 //Log::Warning(L"Node %u: %X to %X (%hX)", uFirstNode, v7, v8, v2->pFaceIDs[v7]); | |
4907 | |
4908 if ( pRenderer->pRenderD3D ) | |
4909 { | |
4910 while ( v7 < v8 ) | |
4911 pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[v7++]); | |
4912 } | |
4913 else | |
4914 { | |
4915 while ( v7 < v8 ) | |
4916 pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[v7++]); | |
4917 } | |
4918 v9 = v5 > 0 ? pNode->uFront : pNode->uBack; | |
4919 if ( v9 == -1 ) | |
4920 break; | |
4921 uFirstNode = v9; | |
4922 } | |
4923 } | |
4924 //----- (0043FA33) -------------------------------------------------------- | |
1544 | 4925 void PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID) |
1295 | 4926 { |
4927 LevelDecoration *v2; // esi@1 | |
4928 DecorationDesc *v3; // ebx@2 | |
4929 __int16 v4; // ax@2 | |
4930 double v5; // st7@3 | |
4931 int v6; // eax@5 | |
4932 int v7; // edx@5 | |
4933 unsigned int v8; // edi@5 | |
4934 int v9; // edi@5 | |
4935 int v10; // eax@7 | |
4936 SpriteFrame *v11; // eax@7 | |
4937 SpriteFrame *v12; // esi@7 | |
4938 int v13; // eax@7 | |
4939 int v14; // ebx@16 | |
4940 RenderBillboard *v15; // ecx@17 | |
4941 char v16; // zf@18 | |
4942 IndoorCameraD3D **v17; // eax@19 | |
4943 double v18; // st7@19 | |
4944 //float v19; // eax@19 | |
4945 signed __int64 v20; // qtt@19 | |
4946 signed __int64 v21; // qtt@20 | |
4947 //int v22; // edx@21 | |
4948 //int v23; // eax@21 | |
4949 Particle_sw local_0; // [sp+Ch] [bp-A0h]@3 | |
4950 //double v25; // [sp+74h] [bp-38h]@19 | |
4951 //unsigned int v26; // [sp+7Ch] [bp-30h]@1 | |
4952 int a2; // [sp+80h] [bp-2Ch]@5 | |
4953 int a3; // [sp+84h] [bp-28h]@5 | |
4954 int a1; // [sp+88h] [bp-24h]@5 | |
4955 int v30; // [sp+8Ch] [bp-20h]@7 | |
4956 //float v31; // [sp+90h] [bp-1Ch]@1 | |
4957 int a5; // [sp+94h] [bp-18h]@17 | |
4958 int z; // [sp+98h] [bp-14h]@15 | |
4959 int a6; // [sp+9Ch] [bp-10h]@17 | |
4960 int y; // [sp+A0h] [bp-Ch]@15 | |
4961 int x; // [sp+A4h] [bp-8h]@15 | |
4962 int v37; // [sp+A8h] [bp-4h]@5 | |
4963 | |
4964 //v26 = uDecorationID; | |
4965 //LODWORD(v31) = uSectorID; | |
4966 v2 = &pLevelDecorations[uDecorationID]; | |
1489 | 4967 if (v2->uFlags & LEVEL_DECORATION_INVISIBLE) |
1295 | 4968 return; |
4969 | |
4970 v3 = &pDecorationList->pDecorations[v2->uDecorationDescID]; | |
4971 v4 = v3->uFlags; | |
1479
59d1da1863df
Rename DECORATION_FLAGS to DECORATION_DESC_FLAGS.
yoctozepto
parents:
1477
diff
changeset
|
4972 if (v3->uFlags & DECORATION_DESC_EMITS_FIRE) |
1295 | 4973 { |
4974 memset(&local_0, 0, 0x68u); // fire, like at the Pit's tavern | |
4975 v5 = (double)v2->vPosition.x; | |
4976 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; | |
4977 local_0.uDiffuse = 0xFF3C1E; | |
4978 local_0.x = v5; | |
4979 local_0.y = (double)v2->vPosition.y; | |
4980 local_0.z = (double)v2->vPosition.z; | |
1390 | 4981 local_0.r = 0.0; |
4982 local_0.g = 0.0; | |
4983 local_0.b = 0.0; | |
1295 | 4984 local_0.flt_28 = 1.0; |
4985 local_0.timeToLive = (rand() & 0x80) + 128; | |
4986 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
4987 pGame->pParticleEngine->AddParticle(&local_0); | |
4988 return; | |
4989 } | |
4990 | |
4991 | |
1479
59d1da1863df
Rename DECORATION_FLAGS to DECORATION_DESC_FLAGS.
yoctozepto
parents:
1477
diff
changeset
|
4992 if (v4 & DECORATION_DESC_DONT_DRAW) |
1295 | 4993 return; |
4994 | |
4995 v6 = v2->vPosition.x; | |
4996 v7 = v2->vPosition.z; | |
4997 a2 = v2->vPosition.y; | |
4998 a1 = v6; | |
4999 a3 = v7; | |
5000 v8 = v2->field_10_y_rot | |
5001 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
5002 - stru_5C6E00->Atan2(v6 - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); | |
5003 v37 = pBLVRenderParams->field_0_timer_; | |
5004 v9 = ((signed int)(stru_5C6E00->uIntegerPi + v8) >> 8) & 7; | |
5005 if (pParty->bTurnBasedModeOn) | |
5006 v37 = pMiscTimer->uTotalGameTimeElapsed; | |
5007 v10 = abs(v2->vPosition.x + v2->vPosition.y); | |
5008 v11 = pSpriteFrameTable->GetFrame(v3->uSpriteID, v37 + v10); | |
5009 v30 = 0; | |
5010 v12 = v11; | |
5011 v13 = v11->uFlags; | |
5012 if ( v13 & 2 ) | |
5013 v30 = 2; | |
5014 if ( v13 & 0x40000 ) | |
5015 v30 |= 0x40u; | |
5016 if ( v13 & 0x20000 ) | |
5017 LOBYTE(v30) = v30 | 0x80; | |
5018 if ( (256 << v9) & v13 ) | |
5019 v30 |= 4u; | |
5020 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1, a2, a3, &x, &y, &z, 1) ) | |
5021 { | |
5022 v14 = abs(x); | |
5023 if ( v14 >= abs(y) ) | |
5024 { | |
5025 pGame->pIndoorCameraD3D->Project(x, y, z, &a5, &a6); | |
5026 | |
5027 v15 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
5028 assert(uNumBillboardsToDraw < 500); | |
5029 | |
5030 ++uNumBillboardsToDraw; | |
5031 ++uNumDecorationsDrawnThisFrame; | |
5032 v16 = pRenderer->pRenderD3D == 0; | |
5033 v15->uHwSpriteID = v12->pHwSpriteIDs[v9]; | |
5034 v15->uPalette = v12->uPaletteIndex; | |
5035 v15->uIndoorSectorID = uSectorID; | |
5036 if ( v16 ) | |
5037 { | |
5038 LODWORD(v21) = pBLVRenderParams->field_40 << 16; | |
5039 HIDWORD(v21) = pBLVRenderParams->field_40 >> 16; | |
5040 v37 = v21 / x; | |
5041 //LODWORD(v31) = v12->scale; | |
5042 v37 = v21 / x; | |
5043 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v21 / x) >> 16; | |
5044 v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16; | |
5045 } | |
5046 else | |
5047 { | |
5048 v17 = &pGame->pIndoorCameraD3D; | |
5049 v15->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
5050 v18 = (*v17)->fov_y; | |
5051 //v19 = v15->fov_x; | |
5052 v15->fov_y = v18; | |
5053 //v31 = v19; | |
5054 //v25 = v19 + 6.7553994e15; | |
5055 //v25 = floorf(v15->fov_x + 0.5f); | |
5056 LODWORD(v20) = 0; | |
5057 HIDWORD(v20) = floorf(v15->fov_x + 0.5f); | |
5058 v37 = v20 / x; | |
5059 //LODWORD(v31) = v12->scale; | |
5060 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5061 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5062 //v31 = v15->fov_y; | |
5063 //v25 = v31 + 6.7553994e15; | |
5064 //v25 = floorf(v15->fov_y + 0.5f); | |
5065 LODWORD(v20) = 0; | |
5066 HIDWORD(v20) = floorf(v15->fov_y + 0.5f); | |
5067 v37 = v20 / x; | |
5068 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5069 } | |
5070 //HIWORD(v22) = HIWORD(x); | |
5071 //LOWORD(v22) = 0; | |
5072 v15->_screenspace_y_scaler_packedfloat = v37; | |
5073 v15->field_1E = v30; | |
5074 v15->world_x = a1; | |
5075 v15->world_y = a2; | |
5076 v15->world_z = a3; | |
5077 v15->uScreenSpaceX = a5; | |
5078 v15->uScreenSpaceY = a6; | |
5079 //v23 = 8 * uDecorationID; | |
5080 //LOBYTE(v23) = PID(OBJECT_Decoration,uDecorationID); | |
5081 | |
5082 //v15->sZValue = v22 + v23; | |
5083 v15->actual_z = HIWORD(x); | |
5084 v15->object_pid = PID(OBJECT_Decoration,uDecorationID); | |
5085 | |
5086 v15->uTintColor = 0; | |
5087 v15->pSpriteFrame = v12; | |
5088 } | |
5089 } | |
5090 } | |
5091 //----- (0043F953) -------------------------------------------------------- | |
5092 void PrepareBspRenderList_BLV() | |
5093 { | |
5094 pBspRenderer->num_faces = 0; | |
5095 | |
5096 if (pBLVRenderParams->uPartySectorID) | |
5097 { | |
5098 pBspRenderer->nodes[0].uSectorID = pBLVRenderParams->uPartySectorID; | |
5099 pBspRenderer->nodes[0].uViewportW = pBLVRenderParams->uViewportW; | |
5100 pBspRenderer->nodes[0].uViewportZ = pBLVRenderParams->uViewportZ; | |
5101 pBspRenderer->nodes[0].uViewportY = pBLVRenderParams->uViewportY; | |
5102 pBspRenderer->nodes[0].uViewportX = pBLVRenderParams->uViewportX; | |
1376 | 5103 pBspRenderer->nodes[0].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, |
1295 | 5104 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); |
5105 pBspRenderer->nodes[0].uFaceID = -1; | |
5106 pBspRenderer->nodes[0].viewing_portal_id = -1; | |
5107 pBspRenderer->num_nodes = 1; | |
5108 AddBspNodeToRenderList(0); | |
5109 } | |
5110 | |
5111 pBspRenderer->MakeVisibleSectorList(); | |
5112 } | |
5113 | |
5114 //----- (0043F9E1) -------------------------------------------------------- | |
1376 | 5115 void BspRenderer_PortalViewportData::GetViewportData(__int16 x, int y, __int16 z, int w) |
1295 | 5116 { |
5117 _viewport_space_y = y; | |
5118 _viewport_space_w = w; | |
5119 | |
5120 for (uint i = 0; i < 480; ++i) | |
5121 { | |
5122 if ( i < y || i > w ) | |
5123 { | |
5124 viewport_left_side[i] = 640; | |
5125 viewport_right_side[i] = -1; | |
5126 } | |
5127 else | |
5128 { | |
5129 viewport_left_side[i] = x; | |
5130 viewport_right_side[i] = z; | |
5131 } | |
5132 } | |
5133 } | |
5134 //----- (0048653D) -------------------------------------------------------- | |
1544 | 5135 void stru149::_48653D_frustum_blv(int a2, int a3, int a4, int a5, int a6, int a7)//portal frustum culling |
1295 | 5136 { |
1544 | 5137 //stru149 *v7; // esi@1 |
1295 | 5138 int v8; // edi@1 |
5139 int v9; // eax@1 | |
5140 //int v10; // edx@1 | |
5141 //int v11; // ecx@1 | |
1544 | 5142 //int v12; // eax@1 |
5143 //int v13; // ebx@2 | |
5144 //int v14; // ecx@2 | |
5145 //int v15; // eax@2 | |
1295 | 5146 int v16; // ST14_4@3 |
5147 int v17; // ST10_4@3 | |
1544 | 5148 //int v18; // eax@5 |
1295 | 5149 int v19; // ST10_4@6 |
1544 | 5150 //int v20; // eax@8 |
1295 | 5151 int v21; // ST10_4@9 |
1544 | 5152 //int v22; // eax@10 |
5153 //int v23; // ecx@10 | |
5154 //int v24; // eax@10 | |
5155 //int result; // eax@10 | |
1295 | 5156 //int v26; // [sp+14h] [bp-14h]@1 |
1544 | 5157 //int v27; // [sp+18h] [bp-10h]@1 |
1295 | 5158 int v28; // [sp+1Ch] [bp-Ch]@1 |
5159 int v29; // [sp+24h] [bp-4h]@1 | |
1544 | 5160 //int v30; // [sp+30h] [bp+8h]@10 |
5161 //int v31; // [sp+3Ch] [bp+14h]@10 | |
5162 | |
1295 | 5163 v8 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotY); |
5164 v29 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotY); | |
5165 v28 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotX); | |
5166 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX); | |
5167 //v11 = -pBLVRenderParams->vPartyPos.y; | |
5168 //v26 = -pBLVRenderParams->vPartyPos.x; | |
1544 | 5169 //v27 = v9; |
5170 //v12 = -pBLVRenderParams->vPartyPos.z; | |
1295 | 5171 if ( pBLVRenderParams->sPartyRotX ) |
5172 { | |
5173 v16 = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y; | |
5174 v17 = -65536 * pBLVRenderParams->vPartyPos.z; | |
1544 | 5175 this->field_0_party_dir_x = fixpoint_sub0(v16, v28) + fixpoint_sub0((-pBLVRenderParams->vPartyPos.z) << 16, v9); |
5176 this->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x; | |
5177 this->field_8_party_dir_z = fixpoint_sub0(v17, v28) - fixpoint_sub0(v16, v9); | |
1295 | 5178 } |
5179 else | |
5180 { | |
1544 | 5181 this->field_0_party_dir_x = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y; |
5182 this->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x; | |
5183 this->field_8_party_dir_z = (-pBLVRenderParams->vPartyPos.z) << 16; | |
1295 | 5184 } |
1544 | 5185 |
5186 if (pBLVRenderParams->sPartyRotX) | |
1295 | 5187 { |
1544 | 5188 v19 = fixpoint_sub0(a2, v8) + fixpoint_sub0(a3, v29); |
5189 | |
5190 this->field_C = fixpoint_sub0(v19, v28) + fixpoint_sub0(a4, v9); | |
5191 this->field_10 = fixpoint_sub0(a3, v8) - fixpoint_sub0(a2, v29); | |
5192 this->field_14 = fixpoint_sub0(a4, v28) - fixpoint_sub0(v19, v9); | |
1295 | 5193 } |
5194 else | |
5195 { | |
1544 | 5196 this->field_C = fixpoint_sub0(a2, v8) + fixpoint_sub0(a3, v29); |
5197 this->field_10 = fixpoint_sub0(a3, v8) - fixpoint_sub0(a2, v29); | |
5198 this->field_14 = a4; | |
1295 | 5199 } |
1544 | 5200 |
5201 if (pBLVRenderParams->sPartyRotX) | |
1295 | 5202 { |
1544 | 5203 v21 = fixpoint_sub0(a5, v8) + fixpoint_sub0(a6, v29); |
5204 | |
5205 this->field_18 = fixpoint_sub0(v21, v28) + fixpoint_sub0(a7, v9); | |
5206 this->field_1C = fixpoint_sub0(a6, v8) - fixpoint_sub0(a5, v29); | |
5207 this->field_20 = fixpoint_sub0(a7, v28) - fixpoint_sub0(v21, v9); | |
1295 | 5208 } |
5209 else | |
5210 { | |
1544 | 5211 this->field_18 = fixpoint_sub0(a5, v8) + fixpoint_sub0(a6, v29); |
5212 this->field_1C = fixpoint_sub0(a6, v8) - fixpoint_sub0(a5, v29); | |
5213 this->field_20 = a7; | |
1295 | 5214 } |
1544 | 5215 |
5216 this->field_18 = -this->field_18; | |
5217 this->field_1C = -this->field_1C; | |
5218 this->field_20 = -this->field_20; | |
5219 | |
5220 this->field_24 = fixpoint_dot(this->field_C, this->field_0_party_dir_x, | |
5221 this->field_10, this->field_4_party_dir_y, | |
5222 this->field_14, this->field_8_party_dir_z); | |
5223 this->field_28 = fixpoint_dot(this->field_18, this->field_0_party_dir_x, | |
5224 this->field_1C, this->field_4_party_dir_y, | |
5225 this->field_20, this->field_8_party_dir_z); | |
1297 | 5226 } |
5227 //----- (00407A1C) -------------------------------------------------------- | |
5228 bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v) | |
5229 { | |
5230 unsigned int v4; // esi@1 | |
5231 Vec3_int_ v5; // ST08_12@2 | |
5232 int v6; // edi@2 | |
5233 int v7; // ebx@2 | |
5234 int v8; // esi@2 | |
5235 signed int v9; // ecx@2 | |
5236 int v10; // eax@2 | |
5237 int v11; // ecx@4 | |
5238 int v12; // eax@4 | |
5239 int v13; // ebx@4 | |
5240 int v14; // edx@6 | |
5241 char *v15; // edi@16 | |
5242 ODMFace *v16; // esi@19 | |
5243 int v17; // ST34_4@25 | |
5244 int v18; // ST38_4@25 | |
5245 int v19; // eax@25 | |
5246 char v20; // zf@25 | |
5247 int v21; // ebx@25 | |
5248 int v22; // eax@26 | |
5249 signed int v23; // edi@26 | |
5250 int v24; // ST34_4@30 | |
5251 signed __int64 v25; // qtt@31 | |
5252 int v26; // eax@31 | |
5253 Vec3_int_ v27; // ST08_12@37 | |
5254 Vec3_int_ v28; // ST08_12@37 | |
5255 int v29; // edi@37 | |
5256 int v30; // ebx@37 | |
5257 int v31; // esi@37 | |
5258 signed int v32; // ecx@37 | |
5259 int v33; // eax@37 | |
5260 int v34; // ecx@39 | |
5261 int v35; // eax@39 | |
5262 int v36; // ebx@39 | |
5263 int v37; // edx@41 | |
5264 char *v38; // edi@51 | |
5265 ODMFace *v39; // esi@54 | |
5266 int v40; // ebx@60 | |
5267 int v41; // eax@61 | |
5268 signed int v42; // edi@61 | |
5269 signed __int64 v43; // qtt@66 | |
5270 int v44; // eax@66 | |
5271 Vec3_int_ v45; // ST08_12@73 | |
5272 int v46; // edi@73 | |
5273 int v47; // ebx@73 | |
5274 int v48; // esi@73 | |
5275 signed int v49; // ecx@73 | |
5276 int v50; // eax@73 | |
5277 int v51; // edx@75 | |
5278 int v52; // ecx@75 | |
5279 int v53; // eax@75 | |
5280 int v54; // ebx@75 | |
5281 int v55; // edi@77 | |
5282 int v56; // ecx@77 | |
5283 int v57; // eax@81 | |
5284 int v58; // esi@81 | |
5285 int v59; // eax@90 | |
5286 BLVSector *v60; // edx@90 | |
5287 int v61; // ecx@90 | |
5288 BLVFace *v62; // esi@91 | |
5289 int v63; // ST34_4@98 | |
5290 int v64; // ST30_4@98 | |
5291 int v65; // eax@98 | |
5292 int v66; // ebx@98 | |
5293 int v67; // eax@99 | |
5294 signed int v68; // edi@99 | |
5295 int v69; // ST2C_4@103 | |
5296 signed __int64 v70; // qtt@104 | |
5297 int v71; // eax@104 | |
5298 Vec3_int_ v72; // ST08_12@111 | |
5299 Vec3_int_ v73; // ST08_12@111 | |
5300 int v74; // edi@111 | |
5301 int v75; // ebx@111 | |
5302 int v76; // esi@111 | |
5303 signed int v77; // ecx@111 | |
5304 int v78; // eax@111 | |
5305 int v79; // edx@113 | |
5306 int v80; // ecx@113 | |
5307 int v81; // eax@113 | |
5308 int v82; // ebx@113 | |
5309 int v83; // edi@115 | |
5310 int v84; // ecx@115 | |
5311 int v85; // eax@119 | |
5312 int v86; // esi@119 | |
5313 int v87; // ecx@128 | |
5314 BLVSector *v88; // eax@128 | |
5315 int v89; // ecx@128 | |
5316 BLVFace *v90; // esi@129 | |
5317 int v91; // ebx@136 | |
5318 int v92; // eax@137 | |
5319 signed int v93; // edi@137 | |
5320 signed __int64 v94; // qtt@142 | |
5321 int v95; // eax@142 | |
5322 Vec3_int_ v97; // [sp-18h] [bp-94h]@1 | |
5323 int v98; // [sp-Ch] [bp-88h]@88 | |
5324 int v99; // [sp-Ch] [bp-88h]@126 | |
5325 int v100; // [sp-8h] [bp-84h]@88 | |
5326 int v101; // [sp-8h] [bp-84h]@126 | |
5327 int v102; // [sp-4h] [bp-80h]@88 | |
5328 int v103; // [sp-4h] [bp-80h]@126 | |
5329 int v104; // [sp+Ch] [bp-70h]@13 | |
5330 int v105; // [sp+Ch] [bp-70h]@48 | |
5331 int v106; // [sp+10h] [bp-6Ch]@18 | |
5332 int v107; // [sp+10h] [bp-6Ch]@98 | |
5333 int v108; // [sp+10h] [bp-6Ch]@104 | |
5334 int v109; // [sp+18h] [bp-64h]@25 | |
5335 int v110; // [sp+18h] [bp-64h]@31 | |
5336 int i; // [sp+18h] [bp-64h]@90 | |
5337 int v112; // [sp+18h] [bp-64h]@128 | |
5338 signed int v113; // [sp+20h] [bp-5Ch]@1 | |
5339 signed int v114; // [sp+24h] [bp-58h]@1 | |
1544 | 5340 //unsigned __int64 a4; // [sp+28h] [bp-54h]@1 |
1297 | 5341 unsigned int a4_8; // [sp+30h] [bp-4Ch]@1 |
5342 int v117; // [sp+34h] [bp-48h]@4 | |
5343 int v118; // [sp+34h] [bp-48h]@39 | |
5344 int v119; // [sp+34h] [bp-48h]@75 | |
5345 int v120; // [sp+34h] [bp-48h]@113 | |
5346 int v121; // [sp+38h] [bp-44h]@4 | |
5347 int v122; // [sp+38h] [bp-44h]@39 | |
5348 int v123; // [sp+38h] [bp-44h]@76 | |
5349 int v124; // [sp+38h] [bp-44h]@114 | |
5350 int v125; // [sp+3Ch] [bp-40h]@4 | |
5351 int v126; // [sp+3Ch] [bp-40h]@39 | |
5352 int v127; // [sp+3Ch] [bp-40h]@77 | |
5353 int v128; // [sp+3Ch] [bp-40h]@115 | |
5354 int v129; // [sp+40h] [bp-3Ch]@11 | |
5355 int v130; // [sp+40h] [bp-3Ch]@46 | |
5356 int v131; // [sp+40h] [bp-3Ch]@78 | |
5357 int v132; // [sp+40h] [bp-3Ch]@116 | |
5358 int v133; // [sp+44h] [bp-38h]@10 | |
5359 int v134; // [sp+44h] [bp-38h]@45 | |
5360 int v135; // [sp+44h] [bp-38h]@81 | |
5361 int v136; // [sp+44h] [bp-38h]@119 | |
5362 int v137; // [sp+48h] [bp-34h]@7 | |
5363 int v138; // [sp+48h] [bp-34h]@42 | |
5364 int v139; // [sp+48h] [bp-34h]@82 | |
5365 int v140; // [sp+48h] [bp-34h]@120 | |
5366 int v141; // [sp+4Ch] [bp-30h]@6 | |
5367 int v142; // [sp+4Ch] [bp-30h]@41 | |
5368 int v143; // [sp+4Ch] [bp-30h]@75 | |
5369 int v144; // [sp+4Ch] [bp-30h]@113 | |
5370 int v145; // [sp+50h] [bp-2Ch]@5 | |
5371 int v146; // [sp+50h] [bp-2Ch]@40 | |
5372 int v147; // [sp+50h] [bp-2Ch]@75 | |
5373 int v148; // [sp+50h] [bp-2Ch]@113 | |
5374 int v149; // [sp+54h] [bp-28h]@4 | |
5375 int v150; // [sp+54h] [bp-28h]@39 | |
5376 int v151; // [sp+54h] [bp-28h]@75 | |
5377 int v152; // [sp+54h] [bp-28h]@113 | |
5378 int sDepth; // [sp+58h] [bp-24h]@17 | |
5379 int sDeptha; // [sp+58h] [bp-24h]@52 | |
5380 int sDepthb; // [sp+58h] [bp-24h]@90 | |
5381 char *a5; // [sp+5Ch] [bp-20h]@16 | |
5382 char *a5a; // [sp+5Ch] [bp-20h]@51 | |
5383 signed int a5b; // [sp+5Ch] [bp-20h]@83 | |
5384 signed int a5c; // [sp+5Ch] [bp-20h]@121 | |
5385 signed int v160; // [sp+60h] [bp-1Ch]@12 | |
5386 signed int v161; // [sp+60h] [bp-1Ch]@47 | |
5387 int v162; // [sp+60h] [bp-1Ch]@128 | |
5388 int v163; // [sp+64h] [bp-18h]@2 | |
5389 int outx; // [sp+68h] [bp-14h]@2 | |
5390 int outy; // [sp+6Ch] [bp-10h]@2 | |
5391 int outz; // [sp+70h] [bp-Ch]@2 | |
5392 Vec3_int_ pOut; // [sp+74h] [bp-8h]@2 | |
5393 int ya; // [sp+84h] [bp+8h]@60 | |
5394 int yb; // [sp+84h] [bp+8h]@136 | |
5395 int ve; // [sp+88h] [bp+Ch]@60 | |
5396 int va; // [sp+88h] [bp+Ch]@60 | |
5397 int vb; // [sp+88h] [bp+Ch]@66 | |
5398 int vf; // [sp+88h] [bp+Ch]@136 | |
5399 int vc; // [sp+88h] [bp+Ch]@136 | |
5400 int vd; // [sp+88h] [bp+Ch]@142 | |
5401 int v_4; // [sp+8Ch] [bp+10h]@60 | |
5402 int v_4a; // [sp+8Ch] [bp+10h]@65 | |
5403 int v_4b; // [sp+8Ch] [bp+10h]@136 | |
5404 int v_4c; // [sp+8Ch] [bp+10h]@141 | |
5405 int v_8; // [sp+90h] [bp+14h]@53 | |
5406 | |
1458 | 5407 __debugbreak(); |
5408 | |
1297 | 5409 v4 = stru_5C6E00->Atan2(v.x - x, v.y - z); |
5410 v114 = 0; | |
5411 v97.z = y; | |
1544 | 5412 v97.x = x; |
5413 v97.y = z; | |
1297 | 5414 v113 = 0; |
5415 a4_8 = v4; | |
5416 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) | |
5417 { | |
5418 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); | |
5419 v45.z = v.z; | |
5420 *(_QWORD *)&v45.x = *(_QWORD *)&v; | |
5421 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163); | |
5422 v46 = outy - pOut.y; | |
5423 v47 = v163 - outz; | |
5424 v48 = outx - pOut.x; | |
5425 v49 = integer_sqrt(v48 * v48 + v46 * v46 + v47 * v47); | |
5426 v50 = 65536; | |
5427 if ( v49 ) | |
5428 v50 = 65536 / v49; | |
5429 v51 = outx; | |
5430 v143 = v48 * v50; | |
5431 v52 = v46 * v50; | |
5432 v53 = v47 * v50; | |
5433 v54 = pOut.x; | |
5434 v147 = v52; | |
5435 v151 = v53; | |
5436 v119 = pOut.x; | |
5437 if ( pOut.x < outx ) | |
5438 { | |
5439 v123 = outx; | |
5440 } | |
5441 else | |
5442 { | |
5443 v119 = outx; | |
5444 v123 = pOut.x; | |
5445 } | |
5446 v55 = pOut.y; | |
5447 v56 = outy; | |
5448 v127 = pOut.y; | |
5449 if ( pOut.y < outy ) | |
5450 { | |
5451 v131 = outy; | |
5452 } | |
5453 else | |
5454 { | |
5455 v127 = outy; | |
5456 v131 = pOut.y; | |
5457 } | |
5458 v57 = v163; | |
5459 v58 = outz; | |
5460 v135 = outz; | |
5461 if ( outz < v163 ) | |
5462 { | |
5463 v139 = v163; | |
5464 } | |
5465 else | |
5466 { | |
5467 v135 = v163; | |
5468 v139 = outz; | |
5469 } | |
5470 a5b = 0; | |
5471 while ( !v114 ) | |
5472 { | |
5473 if ( a5b ) | |
5474 { | |
5475 v102 = v58; | |
5476 v100 = v55; | |
5477 v98 = v54; | |
5478 } | |
5479 else | |
5480 { | |
5481 v102 = v57; | |
5482 v100 = v56; | |
5483 v98 = v51; | |
5484 } | |
5485 v59 = pIndoor->GetSector(v98, v100, v102); | |
5486 v60 = pIndoor->pSectors; | |
5487 v61 = 116 * v59; | |
5488 sDepthb = 0; | |
5489 for ( i = 116 * v59; | |
5490 sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61) | |
5491 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61); | |
5492 ++sDepthb ) | |
5493 { | |
5494 v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]]; | |
5495 if ( v62->Portal() | |
5496 || v119 > v62->pBounding.x2 | |
5497 || v123 < v62->pBounding.x1 | |
5498 || v127 > v62->pBounding.y2 | |
5499 || v131 < v62->pBounding.y1 | |
5500 || v135 > v62->pBounding.z2 | |
5501 || v139 < v62->pBounding.z1 | |
5502 || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16, | |
5503 v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16, | |
5504 v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16, | |
5505 v20 = v63 + v64 + v65 == 0, | |
5506 v66 = v63 + v64 + v65, | |
5507 v107 = v63 + v64 + v65, | |
5508 v20) ) | |
5509 goto LABEL_107; | |
5510 v67 = outz * v62->pFacePlane_old.vNormal.z; | |
5511 v68 = -(v62->pFacePlane_old.dist | |
5512 + v67 | |
5513 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5514 + pOut.x * v62->pFacePlane_old.vNormal.x); | |
5515 if ( v66 <= 0 ) | |
5516 { | |
5517 if ( v62->pFacePlane_old.dist | |
5518 + v67 | |
5519 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5520 + pOut.x * v62->pFacePlane_old.vNormal.x < 0 ) | |
5521 goto LABEL_107; | |
5522 } | |
5523 else | |
5524 { | |
5525 if ( v62->pFacePlane_old.dist | |
5526 + v67 | |
5527 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5528 + pOut.x * v62->pFacePlane_old.vNormal.x > 0 ) | |
5529 goto LABEL_107; | |
5530 } | |
5531 v69 = abs(-(v62->pFacePlane_old.dist | |
5532 + v67 | |
5533 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5534 + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14; | |
5535 if ( v69 <= abs(v66) ) | |
5536 { | |
5537 LODWORD(v70) = v68 << 16; | |
5538 HIDWORD(v70) = v68 >> 16; | |
5539 v71 = v70 / v107; | |
5540 v108 = v70 / v107; | |
5541 if ( v71 >= 0 ) | |
5542 { | |
5543 if ( sub_4075DB( | |
5544 pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16), | |
5545 pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16), | |
5546 outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16), | |
5547 v62) ) | |
5548 { | |
5549 v114 = 1; | |
5550 break; | |
5551 } | |
5552 } | |
5553 } | |
5554 v61 = i; | |
5555 LABEL_107: | |
5556 v60 = pIndoor->pSectors; | |
5557 } | |
5558 ++a5b; | |
5559 if ( a5b >= 2 ) | |
5560 break; | |
5561 v57 = v163; | |
5562 v56 = outy; | |
5563 v51 = outx; | |
5564 v58 = outz; | |
5565 v55 = pOut.y; | |
5566 v54 = pOut.x; | |
5567 } | |
5568 v72.z = y; | |
1544 | 5569 v72.x = x; |
5570 v72.y = z; | |
1297 | 5571 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz); |
5572 v73.z = v.z; | |
1544 | 5573 v73.x = v.x; |
5574 v73.y = v.y; | |
1297 | 5575 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163); |
5576 v74 = outy - pOut.y; | |
5577 v75 = v163 - outz; | |
5578 v76 = outx - pOut.x; | |
5579 v77 = integer_sqrt(v76 * v76 + v74 * v74 + v75 * v75); | |
5580 v78 = 65536; | |
5581 if ( v77 ) | |
5582 v78 = 65536 / v77; | |
5583 v79 = outx; | |
5584 v144 = v76 * v78; | |
5585 v80 = v74 * v78; | |
5586 v81 = v75 * v78; | |
5587 v82 = pOut.x; | |
5588 v148 = v80; | |
5589 v152 = v81; | |
5590 v120 = pOut.x; | |
5591 if ( pOut.x < outx ) | |
5592 { | |
5593 v124 = outx; | |
5594 } | |
5595 else | |
5596 { | |
5597 v120 = outx; | |
5598 v124 = pOut.x; | |
5599 } | |
5600 v83 = pOut.y; | |
5601 v84 = outy; | |
5602 v128 = pOut.y; | |
5603 if ( pOut.y < outy ) | |
5604 { | |
5605 v132 = outy; | |
5606 } | |
5607 else | |
5608 { | |
5609 v128 = outy; | |
5610 v132 = pOut.y; | |
5611 } | |
5612 v85 = v163; | |
5613 v86 = outz; | |
5614 v136 = outz; | |
5615 if ( outz < v163 ) | |
5616 { | |
5617 v140 = v163; | |
5618 } | |
5619 else | |
5620 { | |
5621 v136 = v163; | |
5622 v140 = outz; | |
5623 } | |
5624 a5c = 0; | |
5625 while ( 1 ) | |
5626 { | |
5627 if ( v113 ) | |
5628 return !v114 || !v113; | |
5629 if ( a5c ) | |
5630 { | |
5631 v103 = v86; | |
5632 v101 = v83; | |
5633 v99 = v82; | |
5634 } | |
5635 else | |
5636 { | |
5637 v103 = v85; | |
5638 v101 = v84; | |
5639 v99 = v79; | |
5640 } | |
5641 v87 = pIndoor->GetSector(v99, v101, v103); | |
5642 v88 = pIndoor->pSectors; | |
5643 v89 = 116 * v87; | |
5644 v162 = 0; | |
5645 v112 = v89; | |
5646 if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) | |
5647 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 ) | |
5648 break; | |
5649 LABEL_148: | |
5650 ++a5c; | |
5651 if ( a5c >= 2 ) | |
5652 return !v114 || !v113; | |
5653 v85 = v163; | |
5654 v84 = outy; | |
5655 v79 = outx; | |
5656 v86 = outz; | |
5657 v83 = pOut.y; | |
5658 v82 = pOut.x; | |
5659 } | |
5660 while ( 1 ) | |
5661 { | |
5662 v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]]; | |
5663 if ( v90->Portal() | |
5664 || v120 > v90->pBounding.x2 | |
5665 || v124 < v90->pBounding.x1 | |
5666 || v128 > v90->pBounding.y2 | |
5667 || v132 < v90->pBounding.y1 | |
5668 || v136 > v90->pBounding.z2 | |
5669 || v140 < v90->pBounding.z1 | |
5670 || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16, | |
5671 v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16, | |
5672 vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16, | |
5673 v20 = yb + vf + v_4b == 0, | |
5674 v91 = yb + vf + v_4b, | |
5675 vc = yb + vf + v_4b, | |
5676 v20) ) | |
5677 goto LABEL_145; | |
5678 v92 = outz * v90->pFacePlane_old.vNormal.z; | |
5679 v93 = -(v90->pFacePlane_old.dist | |
5680 + v92 | |
5681 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5682 + pOut.x * v90->pFacePlane_old.vNormal.x); | |
5683 if ( v91 <= 0 ) | |
5684 { | |
5685 if ( v90->pFacePlane_old.dist | |
5686 + v92 | |
5687 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5688 + pOut.x * v90->pFacePlane_old.vNormal.x < 0 ) | |
5689 goto LABEL_145; | |
5690 } | |
5691 else | |
5692 { | |
5693 if ( v90->pFacePlane_old.dist | |
5694 + v92 | |
5695 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5696 + pOut.x * v90->pFacePlane_old.vNormal.x > 0 ) | |
5697 goto LABEL_145; | |
5698 } | |
5699 v_4c = abs(-(v90->pFacePlane_old.dist | |
5700 + v92 | |
5701 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5702 + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14; | |
5703 if ( v_4c <= abs(v91) ) | |
5704 { | |
5705 LODWORD(v94) = v93 << 16; | |
5706 HIDWORD(v94) = v93 >> 16; | |
5707 v95 = v94 / vc; | |
5708 vd = v94 / vc; | |
5709 if ( v95 >= 0 ) | |
5710 { | |
5711 if ( sub_4075DB( | |
5712 pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16), | |
5713 pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16), | |
5714 outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16), | |
5715 v90) ) | |
5716 { | |
5717 v113 = 1; | |
5718 goto LABEL_148; | |
5719 } | |
5720 } | |
5721 } | |
5722 v89 = v112; | |
5723 LABEL_145: | |
5724 v88 = pIndoor->pSectors; | |
5725 ++v162; | |
5726 if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) | |
5727 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) ) | |
5728 goto LABEL_148; | |
5729 } | |
5730 } | |
5731 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); | |
5732 v5.z = v.z; | |
5733 *(_QWORD *)&v5.x = *(_QWORD *)&v; | |
5734 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163); | |
5735 v6 = outy - pOut.y; | |
5736 v7 = v163 - outz; | |
5737 v8 = outx - pOut.x; | |
5738 v9 = integer_sqrt(v8 * v8 + v6 * v6 + v7 * v7); | |
5739 v10 = 65536; | |
5740 if ( v9 ) | |
5741 v10 = 65536 / v9; | |
5742 v125 = v8 * v10; | |
5743 v11 = v10; | |
5744 v12 = v7 * v10; | |
5745 v13 = pOut.x; | |
5746 v117 = v12; | |
5747 v121 = v6 * v11; | |
5748 v149 = pOut.x; | |
5749 if ( pOut.x < outx ) | |
5750 { | |
5751 v145 = outx; | |
5752 } | |
5753 else | |
5754 { | |
5755 v149 = outx; | |
5756 v145 = pOut.x; | |
5757 } | |
5758 v14 = outy; | |
5759 v141 = pOut.y; | |
5760 if ( pOut.y < outy ) | |
5761 { | |
5762 v137 = outy; | |
5763 } | |
5764 else | |
5765 { | |
5766 v141 = outy; | |
5767 v137 = pOut.y; | |
5768 } | |
5769 v133 = outz; | |
5770 if ( outz < v163 ) | |
5771 { | |
5772 v129 = v163; | |
5773 } | |
5774 else | |
5775 { | |
5776 v133 = v163; | |
5777 v129 = outz; | |
5778 } | |
5779 v160 = 0; | |
5780 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
5781 { | |
5782 v104 = 0; | |
5783 while ( 1 ) | |
5784 { | |
5785 v15 = (char *)&pOutdoor->pBModels[v104].pVertices; | |
5786 a5 = (char *)&pOutdoor->pBModels[v104].pVertices; | |
5787 if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 ) | |
5788 { | |
5789 sDepth = 0; | |
5790 if ( *((int *)v15 + 2) > 0 ) | |
5791 break; | |
5792 } | |
5793 LABEL_36: | |
5794 ++v160; | |
5795 ++v104; | |
5796 if ( v160 >= (signed int)pOutdoor->uNumBModels ) | |
5797 goto LABEL_37; | |
5798 v14 = outy; | |
5799 v13 = pOut.x; | |
5800 } | |
5801 v106 = 0; | |
5802 while ( 1 ) | |
5803 { | |
5804 v16 = (ODMFace *)(v106 + *((int *)a5 + 4)); | |
5805 if ( v149 > v16->pBoundingBox.x2 | |
5806 || v145 < v16->pBoundingBox.x1 | |
5807 || v141 > v16->pBoundingBox.y2 | |
5808 || v137 < v16->pBoundingBox.y1 | |
5809 || v133 > v16->pBoundingBox.z2 | |
5810 || v129 < v16->pBoundingBox.z1 | |
5811 || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16, | |
5812 v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16, | |
5813 v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16, | |
5814 v20 = v17 + v18 + v19 == 0, | |
5815 v21 = v17 + v18 + v19, | |
5816 v109 = v17 + v18 + v19, | |
5817 v20) ) | |
5818 goto LABEL_33; | |
5819 v22 = pOut.y * v16->pFacePlane.vNormal.y; | |
5820 v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x); | |
5821 if ( v21 <= 0 ) | |
5822 { | |
5823 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 ) | |
5824 goto LABEL_33; | |
5825 } | |
5826 else | |
5827 { | |
5828 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 ) | |
5829 goto LABEL_33; | |
5830 } | |
5831 v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14; | |
5832 if ( v24 <= abs(v21) ) | |
5833 { | |
5834 LODWORD(v25) = v23 << 16; | |
5835 HIDWORD(v25) = v23 >> 16; | |
5836 v26 = v25 / v109; | |
5837 v110 = v25 / v109; | |
5838 if ( v26 >= 0 ) | |
5839 { | |
5840 if ( sub_4077F1( | |
5841 pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16), | |
5842 pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16), | |
5843 outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16), | |
5844 v16, | |
5845 (BSPVertexBuffer *)a5) ) | |
5846 { | |
5847 v114 = 1; | |
5848 goto LABEL_36; | |
5849 } | |
5850 } | |
5851 } | |
5852 LABEL_33: | |
5853 ++sDepth; | |
5854 v106 += 308; | |
5855 if ( sDepth >= *((int *)a5 + 2) ) | |
5856 goto LABEL_36; | |
5857 } | |
5858 } | |
5859 LABEL_37: | |
5860 v27.z = y; | |
1544 | 5861 v27.x = x; |
5862 v27.y = z; | |
1297 | 5863 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz); |
5864 v28.z = v.z; | |
1544 | 5865 v28.x = v.x; |
5866 v28.y = v.y; | |
1297 | 5867 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163); |
5868 v29 = outy - pOut.y; | |
5869 v30 = v163 - outz; | |
5870 v31 = outx - pOut.x; | |
5871 v32 = integer_sqrt(v31 * v31 + v29 * v29 + v30 * v30); | |
5872 v33 = 65536; | |
5873 if ( v32 ) | |
5874 v33 = 65536 / v32; | |
5875 v126 = v31 * v33; | |
5876 v34 = v33; | |
5877 v35 = v30 * v33; | |
5878 v36 = pOut.x; | |
5879 v118 = v35; | |
5880 v122 = v29 * v34; | |
5881 v150 = pOut.x; | |
5882 if ( pOut.x < outx ) | |
5883 { | |
5884 v146 = outx; | |
5885 } | |
5886 else | |
5887 { | |
5888 v150 = outx; | |
5889 v146 = pOut.x; | |
5890 } | |
5891 v37 = outy; | |
5892 v142 = pOut.y; | |
5893 if ( pOut.y < outy ) | |
5894 { | |
5895 v138 = outy; | |
5896 } | |
5897 else | |
5898 { | |
5899 v142 = outy; | |
5900 v138 = pOut.y; | |
5901 } | |
5902 v134 = outz; | |
5903 if ( outz < v163 ) | |
5904 { | |
5905 v130 = v163; | |
5906 } | |
5907 else | |
5908 { | |
5909 v134 = v163; | |
5910 v130 = outz; | |
5911 } | |
5912 v161 = 0; | |
5913 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
5914 { | |
5915 v105 = 0; | |
5916 while ( 1 ) | |
5917 { | |
5918 v38 = (char *)&pOutdoor->pBModels[v105].pVertices; | |
5919 a5a = (char *)&pOutdoor->pBModels[v105].pVertices; | |
5920 if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 ) | |
5921 { | |
5922 sDeptha = 0; | |
5923 if ( *((int *)v38 + 2) > 0 ) | |
5924 break; | |
5925 } | |
5926 LABEL_71: | |
5927 ++v161; | |
5928 ++v105; | |
5929 if ( v161 >= (signed int)pOutdoor->uNumBModels ) | |
5930 return !v114 || !v113; | |
5931 v37 = outy; | |
5932 v36 = pOut.x; | |
5933 } | |
5934 v_8 = 0; | |
5935 while ( 1 ) | |
5936 { | |
5937 v39 = (ODMFace *)(v_8 + *((int *)a5a + 4)); | |
5938 if ( v150 > v39->pBoundingBox.x2 | |
5939 || v146 < v39->pBoundingBox.x1 | |
5940 || v142 > v39->pBoundingBox.y2 | |
5941 || v138 < v39->pBoundingBox.y1 | |
5942 || v134 > v39->pBoundingBox.z2 | |
5943 || v130 < v39->pBoundingBox.z1 | |
5944 || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16, | |
5945 ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16, | |
5946 v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16, | |
5947 v20 = ya + ve + v_4 == 0, | |
5948 v40 = ya + ve + v_4, | |
5949 va = ya + ve + v_4, | |
5950 v20) ) | |
5951 goto LABEL_68; | |
5952 v41 = pOut.y * v39->pFacePlane.vNormal.y; | |
5953 v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x); | |
5954 if ( v40 <= 0 ) | |
5955 { | |
5956 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 ) | |
5957 goto LABEL_68; | |
5958 } | |
5959 else | |
5960 { | |
5961 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 ) | |
5962 goto LABEL_68; | |
5963 } | |
5964 v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14; | |
5965 if ( v_4a <= abs(v40) ) | |
5966 { | |
5967 LODWORD(v43) = v42 << 16; | |
5968 HIDWORD(v43) = v42 >> 16; | |
5969 v44 = v43 / va; | |
5970 vb = v43 / va; | |
5971 if ( v44 >= 0 ) | |
5972 { | |
5973 if ( sub_4077F1( | |
5974 pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16), | |
5975 pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16), | |
5976 outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16), | |
5977 v39, | |
5978 (BSPVertexBuffer *)a5a) ) | |
5979 { | |
5980 v113 = 1; | |
5981 goto LABEL_71; | |
5982 } | |
5983 } | |
5984 } | |
5985 LABEL_68: | |
5986 ++sDeptha; | |
5987 v_8 += 308; | |
5988 if ( sDeptha >= *((int *)a5a + 2) ) | |
5989 goto LABEL_71; | |
5990 } | |
5991 } | |
5992 return !v114 || !v113; | |
5993 } | |
5994 //----- (0043F333) -------------------------------------------------------- | |
5995 void BspRenderer::MakeVisibleSectorList() | |
5996 { | |
5997 int v6; // ebx@3 | |
5998 | |
5999 uNumVisibleNotEmptySectors = 0; | |
6000 for (uint i = 0; i < num_nodes; ++i) | |
6001 { | |
6002 if (!uNumVisibleNotEmptySectors) | |
6003 { | |
6004 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; | |
6005 continue; | |
6006 } | |
6007 | |
6008 v6 = 0; | |
6009 while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != nodes[i].uSectorID ) | |
6010 { | |
6011 ++v6; | |
6012 if ( v6 >= uNumVisibleNotEmptySectors) | |
6013 { | |
6014 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; | |
6015 } | |
6016 } | |
6017 | |
6018 } | |
6019 } | |
6020 //----- (0046A334) -------------------------------------------------------- | |
6021 char __fastcall DoInteractionWithTopmostZObject(int a1, int a2) | |
6022 { | |
6023 int v2; // edx@1 | |
6024 BLVFace *v4; // eax@9 | |
6025 unsigned int v5; // ecx@9 | |
6026 unsigned __int16 v6; // ax@11 | |
6027 //ODMFace *v7; // eax@16 | |
6028 LevelDecoration *v8; // esi@19 | |
6029 __int16 v9; // ax@19 | |
6030 int v10; // eax@22 | |
6031 int v11; // ecx@22 | |
6032 int v12; // edi@23 | |
6033 Actor *v13; // esi@23 | |
6034 unsigned __int16 v14; // ax@23 | |
6035 unsigned __int16 v15; // ax@33 | |
6036 const char *v16; // eax@34 | |
6037 int v17; // edi@36 | |
6038 int v18; // eax@36 | |
6039 ItemGen *v19; // esi@39 | |
6040 unsigned int v20; // eax@39 | |
6041 int v21; // ecx@40 | |
6042 std::string v22; // [sp-18h] [bp-2Ch]@5 | |
6043 const char *v23; // [sp-8h] [bp-1Ch]@5 | |
6044 int v24; // [sp-4h] [bp-18h]@5 | |
6045 char v25; // [sp+8h] [bp-Ch]@5 | |
6046 int v26; // [sp+Ch] [bp-8h]@1 | |
6047 int a3; // [sp+13h] [bp-1h]@5 | |
6048 | |
6049 v26 = a2; | |
6050 v2 = a1; | |
6051 switch ( PID_TYPE(a1) ) | |
6052 { | |
6053 case OBJECT_Item: // take the item | |
6054 v17 = PID_ID(a1); | |
6055 v26 = PID_ID(a1); | |
6056 v18 = PID_ID(a1); | |
6057 if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 | |
6058 || v17 >= 1000 | |
6059 || !pSpriteObjects[v18].uObjectDescID ) | |
6060 return 1; | |
6061 v19 = &pSpriteObjects[v18].stru_24; | |
6062 v20 = pSpriteObjects[v18].stru_24.uItemID; | |
6063 if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) | |
6064 { | |
6065 party_finds_gold(v19->uSpecEnchantmentType, 0); | |
6066 viewparams->bRedrawGameUI = 1; | |
6067 v21 = v17; | |
6068 } | |
6069 else | |
6070 { | |
6071 if ( pParty->pPickedItem.uItemID ) | |
6072 return 1; | |
6073 v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName; | |
6074 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v24); | |
6075 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
6076 if ( v19->uItemID == 506 ) | |
6077 _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); | |
6078 if ( v19->uItemID == 455 ) | |
6079 _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); | |
6080 if ( !pParty->AddItem(v19) ) | |
6081 pParty->SetHoldingItem(v19); | |
6082 v21 = v26; | |
6083 } | |
6084 SpriteObject::OnInteraction(v21); | |
6085 break; | |
6086 | |
6087 case OBJECT_Actor: | |
6088 v12 = PID_ID(a1); | |
6089 v13 = &pActors[PID_ID(a1)]; | |
6090 v14 = v13->uAIState; | |
6091 if ( v14 == 4 || v14 == 17 ) | |
6092 return 1; | |
6093 if ( v14 == 5 ) | |
6094 { | |
6095 stru_50C198.LootActor(&pActors[PID_ID(a1)]); | |
6096 } | |
6097 else | |
6098 { | |
6099 if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() ) | |
6100 { | |
6101 Actor::AI_FaceObject(v12, 4u, 0, 0); | |
6102 if ( v13->sNPC_ID ) | |
6103 { | |
6104 pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); | |
6105 } | |
6106 else | |
6107 { | |
6108 v15 = pNPCStats->pGroups_copy[v13->uGroup]; | |
6109 if ( v15 ) | |
6110 { | |
6111 v16 = pNPCStats->pCatchPhrases[v15]; | |
6112 if ( v16 ) | |
6113 { | |
6114 pParty->uFlags |= 2u; | |
6115 strcpy(byte_5B0938.data(), v16); | |
6116 sub_4451A8_press_any_key(0, 0, 0); | |
6117 } | |
6118 } | |
6119 } | |
6120 } | |
6121 } | |
6122 break; | |
6123 | |
6124 case OBJECT_Decoration: | |
6125 v8 = &pLevelDecorations[PID_ID(a1)]; | |
1514
965af46e8793
Rename LevelDecoration::field_16_event_id to LevelDecoration::uEventID.
yoctozepto
parents:
1493
diff
changeset
|
6126 v9 = v8->uEventID; |
1297 | 6127 if ( v9 ) |
6128 { | |
6129 EventProcessor(v9, a1, 1); | |
1489 | 6130 v8->uFlags |= LEVEL_DECORATION_VISIBLE_ON_MAP; |
1297 | 6131 } |
6132 else | |
6133 { | |
6134 if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() ) | |
6135 return 1; | |
6136 v10 = v8->_idx_in_stru123; | |
6137 v24 = 1; | |
6138 v11 = stru_5E4C90._decor_events[v10 - 75] + 380; | |
6139 activeLevelDecoration = v8; | |
6140 EventProcessor(v11, 0, 1); | |
6141 activeLevelDecoration = NULL; | |
6142 } | |
6143 break; | |
6144 | |
6145 default: | |
6146 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); | |
6147 return 1; | |
6148 | |
6149 case OBJECT_BModel: | |
6150 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6151 { | |
6152 int bmodel_id = a1 >> 9, | |
6153 face_id = PID_ID(a1) & 0x3F; | |
6154 if (bmodel_id >= pOutdoor->uNumBModels) | |
6155 return 1; | |
6156 auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id]; | |
6157 if (face->uAttributes & 0x100000 || face->sCogTriggeredID == 0 ) | |
6158 return 1; | |
6159 EventProcessor((signed __int16)face->sCogTriggeredID, v2, 1); | |
6160 } | |
6161 else | |
6162 { | |
6163 v4 = &pIndoor->pFaces[PID_ID(a1)]; | |
6164 v5 = v4->uAttributes; | |
6165 if ( !(v5 & 0x2000000) ) | |
6166 { | |
6167 ShowNothingHereStatus(); | |
6168 return 1; | |
6169 } | |
6170 if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 ) | |
6171 return 1; | |
6172 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) | |
6173 EventProcessor((signed __int16)v6, v2, 1); | |
6174 } | |
6175 return 0; | |
6176 break; | |
6177 } | |
6178 return 0; | |
6179 } | |
6180 //----- (0046BDF1) -------------------------------------------------------- | |
1458 | 6181 void BLV_UpdateUserInputAndOther() |
1297 | 6182 { |
6183 UpdateObjects(); | |
6184 BLV_ProcessPartyActions(); | |
6185 UpdateActors_BLV(); | |
6186 BLV_UpdateDoors(); | |
6187 check_event_triggers(); | |
6188 } | |
6189 //----- (00424829) -------------------------------------------------------- | |
1378 | 6190 // Finds out if current portal can be seen through the previous portal |
1376 | 6191 bool PortalFrustrum(int pNumVertices, BspRenderer_PortalViewportData *far_portal, BspRenderer_PortalViewportData *near_portal, int uFaceID) |
1297 | 6192 { |
6193 int min_y; // esi@5 | |
6194 int max_y; // edx@5 | |
1372 | 6195 int current_ID; // eax@12 |
1297 | 6196 int v13; // eax@22 |
6197 int v15; // ecx@29 | |
6198 int v18; // eax@39 | |
6199 int v19; // eax@44 | |
6200 int v20; // ecx@44 | |
6201 int v22; // edi@46 | |
6202 int v24; // edx@48 | |
6203 int v26; // eax@55 | |
6204 signed int v27; // edi@55 | |
6205 int v29; // edx@57 | |
6206 int v31; // eax@64 | |
6207 signed int v32; // edi@64 | |
6208 int v34; // eax@66 | |
6209 int v35; // dx@66 | |
6210 __int16 v36; // dx@67 | |
1379 | 6211 //__int16 v37; // di@67 |
1297 | 6212 __int16 v38; // dx@67 |
6213 int v46; // edx@87 | |
6214 int v49; // esi@93 | |
6215 int v53; // [sp+Ch] [bp-34h]@44 | |
6216 int v54; // [sp+10h] [bp-30h]@0 | |
1372 | 6217 int min_y_ID2; // [sp+14h] [bp-2Ch]@12 |
1297 | 6218 int v59; // [sp+14h] [bp-2Ch]@87 |
6219 int v61; // [sp+1Ch] [bp-24h]@29 | |
6220 int v62; // [sp+20h] [bp-20h]@0 | |
1372 | 6221 signed int direction1; // [sp+24h] [bp-1Ch]@3 |
6222 signed int direction2; // [sp+28h] [bp-18h]@3 | |
6223 int min_y_ID; // [sp+2Ch] [bp-14h]@5 | |
1297 | 6224 int v69; // [sp+34h] [bp-Ch]@29 |
6225 int v70; // [sp+34h] [bp-Ch]@46 | |
1370 | 6226 |
1297 | 6227 if ( pNumVertices <= 1 ) |
6228 return false; | |
1344 | 6229 min_y = PortalFace._screen_space_y[0]; |
1372 | 6230 min_y_ID = 0; |
1344 | 6231 max_y = PortalFace._screen_space_y[0]; |
1372 | 6232 //face direction(направление фейса) |
1344 | 6233 if ( !PortalFace.direction ) |
1297 | 6234 { |
1372 | 6235 direction1 = 1; |
6236 direction2 = -1; | |
1297 | 6237 } |
6238 else | |
6239 { | |
1372 | 6240 direction1 = -1; |
6241 direction2 = 1; | |
6242 } | |
6243 | |
6244 //get min and max y for portal(дать минимальное и максимальное значение y для портала) | |
6245 for ( uint i = 1; i < pNumVertices; ++i ) | |
6246 { | |
1378 | 6247 if (PortalFace._screen_space_y[i] < min_y) |
1297 | 6248 { |
1372 | 6249 min_y_ID = i; |
6250 min_y = PortalFace._screen_space_y[i]; | |
1297 | 6251 } |
1378 | 6252 else if (PortalFace._screen_space_y[i] > max_y) |
6253 { | |
6254 max_y = PortalFace._screen_space_y[i]; | |
6255 } | |
1297 | 6256 } |
6257 if ( max_y == min_y ) | |
6258 return false; | |
6259 | |
1372 | 6260 //***************************************************************************************************************************** |
1376 | 6261 far_portal->_viewport_space_y = min_y; |
6262 far_portal->_viewport_space_w = max_y; | |
1372 | 6263 current_ID = min_y_ID; |
6264 min_y_ID2 = min_y_ID; | |
6265 | |
6266 for ( uint i = 0; i < pNumVertices; ++i ) | |
6267 { | |
6268 current_ID += direction2; | |
6269 if ( current_ID < pNumVertices ) | |
1297 | 6270 { |
1372 | 6271 if ( current_ID < 0 ) |
6272 current_ID += pNumVertices; | |
1297 | 6273 } |
6274 else | |
1372 | 6275 current_ID -= pNumVertices; |
6276 if ( PortalFace._screen_space_y[current_ID] <= PortalFace._screen_space_y[min_y_ID] )//определение минимальной у | |
1297 | 6277 { |
1372 | 6278 min_y_ID2 = current_ID; |
6279 min_y_ID = current_ID; | |
1297 | 6280 } |
1372 | 6281 if ( PortalFace._screen_space_y[current_ID] == max_y ) |
1297 | 6282 break; |
6283 } | |
1372 | 6284 |
6285 v13 = min_y_ID2 + direction2; | |
1297 | 6286 if ( v13 < pNumVertices ) |
6287 { | |
6288 if ( v13 < 0 ) | |
6289 v13 += pNumVertices; | |
6290 } | |
6291 else | |
6292 v13 -= pNumVertices; | |
1372 | 6293 if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[min_y_ID2] ) |
6294 { | |
6295 v62 = PortalFace._screen_space_x[min_y_ID2] << 16; | |
1378 | 6296 v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[min_y_ID2]) << 16) / |
6297 (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[min_y_ID2]); | |
6298 far_portal->viewport_left_side[min_y] = (short)PortalFace._screen_space_x[min_y_ID2]; | |
1372 | 6299 } |
6300 //**************************************************************************************************************************************** | |
6301 // | |
6302 v15 = min_y_ID; | |
6303 v61 = min_y_ID; | |
1297 | 6304 for ( v69 = 0; v69 < pNumVertices; ++v69 ) |
6305 { | |
1372 | 6306 v15 += direction1; |
1297 | 6307 if ( v15 < pNumVertices ) |
6308 { | |
6309 if ( v15 < 0 ) | |
6310 v15 += pNumVertices; | |
6311 } | |
6312 else | |
6313 v15 -= pNumVertices; | |
1372 | 6314 if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[min_y_ID] ) |
1297 | 6315 { |
6316 v61 = v15; | |
1372 | 6317 min_y_ID = v15; |
1297 | 6318 } |
1344 | 6319 if ( PortalFace._screen_space_y[v15] == max_y ) |
1297 | 6320 break; |
6321 } | |
1372 | 6322 v18 = direction1 + v61; |
1297 | 6323 if ( v18 < pNumVertices ) |
6324 { | |
6325 if ( v18 < 0 ) | |
6326 v18 += pNumVertices; | |
6327 } | |
6328 else | |
6329 v18 -= pNumVertices; | |
6330 v19 = v18; | |
6331 v20 = v61; | |
1344 | 6332 if ( PortalFace._screen_space_y[v19] != PortalFace._screen_space_y[v61] ) |
6333 { | |
6334 v61 = PortalFace._screen_space_x[v20] << 16; | |
1378 | 6335 v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / |
6336 (PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20]); | |
6337 far_portal->viewport_right_side[max_y] = (short)PortalFace._screen_space_x[v20]; | |
1372 | 6338 } |
6339 //**************************************************************************************************************************************** | |
1297 | 6340 v22 = min_y; |
6341 if ( min_y <= max_y ) | |
6342 { | |
6343 for ( v70 = min_y; v70 <= max_y; ++v70 ) | |
6344 { | |
6345 v24 = v13; | |
1344 | 6346 if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y ) |
1297 | 6347 { |
1372 | 6348 v13 = direction2 + v13; |
1297 | 6349 if ( v13 < pNumVertices ) |
6350 { | |
6351 if ( v13 < 0 ) | |
6352 v13 += pNumVertices; | |
6353 } | |
6354 else | |
6355 v13 -= pNumVertices; | |
6356 v26 = v13; | |
1344 | 6357 if ( PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24] > 0 ) |
1297 | 6358 { |
1378 | 6359 v54 = ((PortalFace._screen_space_x[v26] - PortalFace._screen_space_x[v24]) << 16) / (PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]); |
1344 | 6360 v62 = PortalFace._screen_space_x[v24] << 16; |
1297 | 6361 } |
6362 } | |
6363 v29 = v18; | |
1344 | 6364 if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y ) |
1297 | 6365 { |
1372 | 6366 v18 += direction1; |
1297 | 6367 if ( v18 < pNumVertices ) |
6368 { | |
6369 if ( v18 < 0 ) | |
6370 v18 += pNumVertices; | |
6371 } | |
6372 else | |
6373 v18 -= pNumVertices; | |
6374 v31 = v18; | |
1344 | 6375 if ( PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29] > 0 ) |
1297 | 6376 { |
1378 | 6377 v53 = ((PortalFace._screen_space_x[v31] - PortalFace._screen_space_x[v29]) << 16) / (PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29]); |
1344 | 6378 v61 = PortalFace._screen_space_x[v29] << 16; |
1297 | 6379 } |
6380 } | |
1376 | 6381 far_portal->viewport_left_side[v70] = HIWORD(v62); |
6382 far_portal->viewport_right_side[v70] = HIWORD(v61); | |
6383 if ( far_portal->viewport_left_side[v70] > far_portal->viewport_right_side[v70] ) | |
1297 | 6384 { |
1376 | 6385 v36 = far_portal->viewport_left_side[v70] ^ far_portal->viewport_right_side[v70]; |
1379 | 6386 //v37 = far_portal->viewport_right_side[v70]; |
1376 | 6387 far_portal->viewport_left_side[v70] = v36; |
1379 | 6388 v38 = far_portal->viewport_right_side[v70] ^ v36; |
1376 | 6389 far_portal->viewport_left_side[v70] ^= v38; |
6390 far_portal->viewport_right_side[v70] = v38; | |
1297 | 6391 } |
6392 v62 += v54; | |
6393 v22 = v70 + 1; | |
6394 v61 += v53; | |
6395 } | |
6396 } | |
1376 | 6397 //***************************************************************************************************************************** |
6398 // check portals coordinates and determine max, min(проверка координат порталов и определение макс, мин-ой у) | |
6399 if ( max_y < near_portal->_viewport_space_y ) | |
1297 | 6400 return false; |
1376 | 6401 if ( min_y > near_portal->_viewport_space_w ) |
1297 | 6402 return false; |
1376 | 6403 if ( min_y < near_portal->_viewport_space_y ) |
6404 min_y = near_portal->_viewport_space_y; | |
6405 if ( max_y > near_portal->_viewport_space_w ) | |
6406 max_y = near_portal->_viewport_space_w; | |
1297 | 6407 if ( min_y <= max_y ) |
6408 { | |
1376 | 6409 for ( min_y; min_y <= max_y; ++min_y ) |
1297 | 6410 { |
1376 | 6411 if ( far_portal->viewport_right_side[min_y] >= near_portal->viewport_left_side[min_y] |
6412 && far_portal->viewport_left_side[min_y] <= near_portal->viewport_right_side[min_y] ) | |
1297 | 6413 break; |
6414 } | |
6415 } | |
6416 if ( max_y < min_y ) | |
6417 return false; | |
1376 | 6418 for ( max_y; max_y >= min_y; --max_y ) |
6419 { | |
6420 if ( far_portal->viewport_right_side[max_y] >= near_portal->viewport_left_side[max_y] | |
6421 && far_portal->viewport_left_side[max_y] <= near_portal->viewport_right_side[max_y] ) | |
1297 | 6422 break; |
6423 } | |
6424 if ( min_y >= max_y ) | |
1390 | 6425 return false; |
1376 | 6426 //************************************************************************************************************************************* |
1297 | 6427 v59 = min_y; |
6428 for ( v46 = max_y - min_y + 1; v46; --v46 ) | |
6429 { | |
1376 | 6430 if ( far_portal->viewport_left_side[v59] < near_portal->viewport_left_side[v59] ) |
6431 far_portal->viewport_left_side[v59] = near_portal->viewport_left_side[v59]; | |
6432 if ( far_portal->viewport_right_side[v59] > near_portal->viewport_right_side[v59] ) | |
6433 far_portal->viewport_right_side[v59] = near_portal->viewport_right_side[v59]; | |
1297 | 6434 ++v59; |
1376 | 6435 } |
6436 far_portal->_viewport_space_y = min_y; | |
6437 far_portal->_viewport_space_w = max_y; | |
6438 far_portal->_viewport_space_x = far_portal->viewport_left_side[min_y]; | |
1379 | 6439 far_portal->_viewport_space_z = far_portal->viewport_right_side[min_y]; |
1376 | 6440 far_portal->_viewport_x_minID = min_y; |
6441 far_portal->_viewport_z_maxID = min_y; | |
1297 | 6442 v49 = min_y + 1; |
6443 if ( v49 <= max_y ) | |
6444 { | |
6445 for ( v49; v49 <= max_y; ++v49 ) | |
6446 { | |
1376 | 6447 if ( far_portal->viewport_left_side[v49] < far_portal->_viewport_space_x ) |
1297 | 6448 { |
1376 | 6449 far_portal->_viewport_space_x = far_portal->viewport_left_side[v49]; |
6450 far_portal->_viewport_x_minID = v49; | |
1297 | 6451 } |
1376 | 6452 if ( far_portal->viewport_right_side[v49] > far_portal->_viewport_space_z ) |
1297 | 6453 { |
1376 | 6454 far_portal->_viewport_space_z = far_portal->viewport_right_side[v49]; |
6455 far_portal->_viewport_z_maxID = v49; | |
1297 | 6456 } |
6457 } | |
6458 } | |
6459 return true; | |
6460 } | |
6461 //----- (00423B5D) -------------------------------------------------------- | |
1344 | 6462 int __fastcall GetPortalScreenCoord(unsigned int uFaceID) |
1297 | 6463 { |
6464 BLVFace *pFace; // ebx@1 | |
1344 | 6465 int pNextVertices; // edx@11 |
6466 int t; // ST28_4@12 | |
6467 int pScreenX; // eax@22 | |
6468 int pScreenY; // eax@27 | |
6469 signed int left_num_vertices; // edi@31 | |
6470 signed int right_num_vertices; // ebx@41 | |
6471 signed int top_num_vertices; // edi@51 | |
6472 int bottom_num_vertices; // ebx@61 | |
1297 | 6473 signed int v62; // edx@75 |
6474 int v63; // ecx@76 | |
6475 int v64; // esi@76 | |
6476 int v65; // ecx@83 | |
6477 signed int v71; // [sp+14h] [bp-14h]@75 | |
1301 | 6478 bool current_vertices_flag; // [sp+18h] [bp-10h]@9 |
1297 | 6479 int thisf; // [sp+18h] [bp-10h]@74 |
1301 | 6480 signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9 |
1297 | 6481 int v80; // [sp+1Ch] [bp-Ch]@76 |
1301 | 6482 bool next_vertices_flag; // [sp+20h] [bp-8h]@10 |
1297 | 6483 |
6484 pFace = &pIndoor->pFaces[uFaceID]; | |
1344 | 6485 memset(&PortalFace, 0, sizeof(stru367)); |
6486 | |
6487 //get direction the face(определение направленности фейса)********************************************************************************* | |
1297 | 6488 if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) |
6489 + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) | |
6490 + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 ) | |
6491 { | |
1344 | 6492 PortalFace.direction = true; |
1297 | 6493 } |
6494 else | |
6495 { | |
1344 | 6496 PortalFace.direction = false; |
1301 | 6497 if ( !(pFace->Portal()) ) |
1297 | 6498 return 0; |
6499 } | |
1344 | 6500 //***************************************************************************************************************************************** |
6501 //generate/cinvertetion in camera location coordinates(генерация/конвертирование в координаты пространства камеры) | |
6502 | |
6503 //for new coordinates: | |
6504 //int x = 0x AAAA BBBB; | |
6505 //AAAA - integer(целая часть), BBBB - fractional(дробная) | |
6506 //float v = HIWORD(x) + LOWORD(x) / 65535.0f; | |
6507 //0x0351A281 это 849(351 в шестнадцатиричной) в целой части и A281 в дробной(хотя как точно BBBB считалась не помню) | |
6508 //if in HIWORD: FFFF = -1 | |
6509 //FFFE = -2 | |
6510 //FFFD = -3 | |
6511 //.... | |
6512 //8000 = -32767 | |
6513 //7FFF = 32767 | |
6514 //7FFE = 32766 | |
6515 //если в LOWORD например лежит FFFF то не совсем понятно, что это | |
6516 //потому что если и hiword и loword равны FFFF FFFF то двойное отрицание как бы, нужно тестировать что конкретно получается чтобы понять что это значит | |
6517 //всё что больше 7FFF для верхнего слова это идёт уже с минусом/Nomad/ | |
6518 | |
1297 | 6519 if ( (signed int)pFace->uNumVertices > 0 ) |
6520 { | |
1301 | 6521 for (uint i = 0; i < pFace->uNumVertices; ++i) |
1297 | 6522 { |
1344 | 6523 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x, |
6524 pIndoor->pVertices[pFace->pVertexIDs[i]].y, | |
6525 pIndoor->pVertices[pFace->pVertexIDs[i]].z, | |
6526 &PortalFace._view_transformed_z[i + 3], &PortalFace._view_transformed_x[i + 3], &PortalFace._view_transformed_y[i + 3], 0); | |
1297 | 6527 } |
1301 | 6528 } |
1344 | 6529 //***************************************************************************************************************************************** |
6530 //check vertices for the nearest plane(проверка вершин есть ли в области за ближайшей плоскостью) | |
1301 | 6531 if ( pFace->uNumVertices <= 0 ) |
1297 | 6532 return 0; |
1301 | 6533 bool bFound = false; |
6534 for (uint i = 0; i < pFace->uNumVertices; ++i) | |
6535 { | |
1344 | 6536 if ( PortalFace._view_transformed_z[i + 3] >= 524288 )// 8.0(0x80000) |
1301 | 6537 { |
6538 bFound = true; | |
1297 | 6539 break; |
1301 | 6540 } |
6541 } | |
6542 if ( !bFound ) | |
1297 | 6543 return 0; |
1344 | 6544 //***************************************************************************************************************************************** |
6545 //check for near clip plane(проверка по ближней границе) | |
6546 // | |
6547 // v0 v1 | |
6548 // ._________________. | |
6549 // / \ | |
6550 // / \ | |
6551 // v5. . v2 | |
6552 // | | | |
6553 // | | | |
6554 // | | | |
6555 // ---------------------------- 8.0(near_clip) | |
6556 // | | | |
6557 // ._______________________. | |
6558 // v4 v3 | |
1301 | 6559 depth_num_vertices = 0; |
1344 | 6560 PortalFace._view_transformed_z[pFace->uNumVertices + 3] = PortalFace._view_transformed_z[3]; |
6561 PortalFace._view_transformed_x[pFace->uNumVertices + 3] = PortalFace._view_transformed_x[3]; | |
6562 PortalFace._view_transformed_y[pFace->uNumVertices + 3] = PortalFace._view_transformed_y[3]; | |
6563 current_vertices_flag = PortalFace._view_transformed_z[3] >= 524288;// 8.0(0x80000) | |
1301 | 6564 if ( pFace->uNumVertices >= 1 ) |
6565 { | |
6566 for ( uint i = 1; i <= pFace->uNumVertices; ++i) | |
1297 | 6567 { |
1344 | 6568 next_vertices_flag = PortalFace._view_transformed_z[i + 3] >= 524288;// 8.0(0x80000) |
6569 if ( current_vertices_flag ^ next_vertices_flag )//или текущая или следующая вершина за ближней границей | |
1297 | 6570 { |
1344 | 6571 if ( next_vertices_flag )//следующая вершина за ближней границей |
1297 | 6572 { |
1344 | 6573 //t = near_clip - v0.z / v1.z - v0.z |
1370 | 6574 t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 2], PortalFace._view_transformed_z[i + 3] - PortalFace._view_transformed_z[i + 2]); |
1344 | 6575 //New_x = (v1.x - v0.x)*t + v0.x |
6576 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 3] | |
6577 - PortalFace._view_transformed_x[i + 2]) * t) >> 16) + PortalFace._view_transformed_x[i + 2]; | |
6578 //New_y = (v1.y - v0.y)*t + v0.y | |
6579 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 3] - PortalFace._view_transformed_y[i + 2]) | |
6580 * t) >> 16) + PortalFace._view_transformed_y[i + 2]; | |
6581 //New_z = 8.0(0x80000) | |
6582 PortalFace._view_transformed_z[depth_num_vertices] = 524288; | |
1297 | 6583 } |
1344 | 6584 else// текущая вершина за ближней границей |
1297 | 6585 { |
1344 | 6586 //t = near_clip - v1.z / v0.z - v1.z |
1370 | 6587 t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 3], PortalFace._view_transformed_z[i + 2] - PortalFace._view_transformed_z[i + 3]); |
1344 | 6588 //New_x = (v0.x - v1.x)*t + v1.x |
6589 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 2] | |
6590 - PortalFace._view_transformed_x[i + 3]) * t) >> 16) + PortalFace._view_transformed_x[i + 3]; | |
6591 //New_y = (v0.x - v1.y)*t + v1.y | |
6592 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 2] - PortalFace._view_transformed_y[i + 3]) | |
6593 * t) >> 16) + PortalFace._view_transformed_y[i + 3]; | |
6594 //New_z = 8.0(0x80000) | |
6595 PortalFace._view_transformed_z[depth_num_vertices] = 524288; | |
1297 | 6596 } |
1344 | 6597 depth_num_vertices++; |
1297 | 6598 } |
1344 | 6599 if ( next_vertices_flag )//если следующая вершина за ближней границей |
1297 | 6600 { |
1344 | 6601 pNextVertices = depth_num_vertices++; |
6602 PortalFace._view_transformed_z[pNextVertices] = PortalFace._view_transformed_z[i + 3]; | |
6603 PortalFace._view_transformed_x[pNextVertices] = PortalFace._view_transformed_x[i + 3]; | |
6604 PortalFace._view_transformed_y[pNextVertices] = PortalFace._view_transformed_y[i + 3]; | |
1297 | 6605 } |
1301 | 6606 current_vertices_flag = next_vertices_flag; |
1297 | 6607 } |
1301 | 6608 } |
1344 | 6609 //результат: нет моргания на границе портала(когда проходим сквозь портал) |
6610 //************************************************************************************************************************************ | |
6611 //convertion in screen coordinates(конвертирование в координаты экрана) | |
6612 PortalFace._view_transformed_z[depth_num_vertices] = PortalFace._view_transformed_z[0]; | |
6613 PortalFace._view_transformed_x[depth_num_vertices] = PortalFace._view_transformed_x[0]; | |
6614 PortalFace._view_transformed_y[depth_num_vertices] = PortalFace._view_transformed_y[0]; | |
6615 for ( uint i = 0; i < depth_num_vertices; ++i ) | |
6616 { | |
6617 if ( (abs(PortalFace._view_transformed_x[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) | |
6618 pScreenX = fixpoint_div(PortalFace._view_transformed_x[i], PortalFace._view_transformed_z[i]); | |
1297 | 6619 else |
6620 { | |
1344 | 6621 if ( PortalFace._view_transformed_x[i] >= 0 ) |
1297 | 6622 { |
1344 | 6623 if (PortalFace._view_transformed_z[i] >= 0) |
6624 pScreenX = 0x400000; // 64.0 | |
1301 | 6625 else |
1344 | 6626 pScreenX = 0xFFC00000; // -63.0 |
1297 | 6627 } |
6628 else | |
6629 { | |
1344 | 6630 if (PortalFace._view_transformed_z[i] >= 0) |
6631 pScreenX = 0xFFC00000; // -63.0 | |
1301 | 6632 else |
1344 | 6633 pScreenX = 0x400000; // 64.0 |
1297 | 6634 } |
6635 } | |
1301 | 6636 |
1344 | 6637 if ( (abs(PortalFace._view_transformed_y[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) |
6638 pScreenY = fixpoint_div(PortalFace._view_transformed_y[i], PortalFace._view_transformed_z[i]); | |
1297 | 6639 else |
6640 { | |
1344 | 6641 if ( PortalFace._view_transformed_y[i] >= 0 ) |
1297 | 6642 { |
1344 | 6643 if (PortalFace._view_transformed_z[i] >= 0) |
6644 pScreenY = 0x400000; // 64.0 | |
1301 | 6645 else |
1344 | 6646 pScreenY = 0xFFC00000; // -63.0 |
1297 | 6647 } |
6648 else | |
6649 { | |
1344 | 6650 if (PortalFace._view_transformed_z[i] >= 0) |
6651 pScreenY = 0xFFC00000; // -63.0 | |
1301 | 6652 else |
1344 | 6653 pScreenY = 0x400000; // 64.0 |
1297 | 6654 } |
6655 } | |
1344 | 6656 PortalFace._screen_space_x[i + 12] = pBLVRenderParams->uViewportCenterX - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenX) >> 16); |
6657 PortalFace._screen_space_y[i + 12] = pBLVRenderParams->uViewportCenterY - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenY) >> 16); | |
6658 } | |
6659 // результат: при повороте камеры, когда граница портала сдвигается к краю экрана, портал остается прозрачным(видимым) | |
6660 //****************************************************************************************************************************************** | |
1381 | 6661 //координаты как в Ида-базе игры так и в данном проекте перевёрнутые,т.е. портал который в правой части экрана имеет экранные координаты |
6662 //которые для левой части экрана. Например, x(оригинал) = 8, у нас х = 468(противоположный край экрана), точно также и с у. | |
6663 // | |
1344 | 6664 //check for left_clip plane(порверка по левой границе) |
6665 left_num_vertices = 0; | |
6666 PortalFace._screen_space_x[depth_num_vertices + 12] = PortalFace._screen_space_x[12]; | |
6667 PortalFace._screen_space_y[depth_num_vertices + 12] = PortalFace._screen_space_y[12]; | |
1370 | 6668 current_vertices_flag = PortalFace._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;//8.0 |
1301 | 6669 if ( depth_num_vertices < 1 ) |
1297 | 6670 return 0; |
1344 | 6671 for ( uint i = 1; i <= depth_num_vertices; ++i ) |
6672 { | |
6673 next_vertices_flag = PortalFace._screen_space_x[i + 12] >= (signed int)pBLVRenderParams->uViewportX; | |
6674 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6675 { |
1344 | 6676 if ( next_vertices_flag ) |
1297 | 6677 { |
1344 | 6678 //t = left_clip - v0.x / v1.x - v0.x |
1370 | 6679 t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 11], PortalFace._screen_space_x[i + 12] - PortalFace._screen_space_x[i + 11]); |
1344 | 6680 //New_y = (v1.y - v0.y)*t + v0.y |
1370 | 6681 PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)((PortalFace._screen_space_y[i + 12]- PortalFace._screen_space_y[i + 11]) |
6682 * t) >> 16) + PortalFace._screen_space_y[i + 11]; | |
1344 | 6683 //New_x = left_clip |
6684 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; | |
1297 | 6685 } |
6686 else | |
6687 { | |
1344 | 6688 //t = left_clip - v1.x / v0.x - v1.x |
1370 | 6689 t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 12], PortalFace._screen_space_x[i + 11] - PortalFace._screen_space_x[i + 12]); |
1344 | 6690 //New_y = (v0.y - v1.y)*t + v1.y |
1370 | 6691 PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)(( PortalFace._screen_space_y[i + 11] - PortalFace._screen_space_y[i + 12]) |
6692 * t) >> 16) + PortalFace._screen_space_y[i + 12]; | |
1344 | 6693 //New_x = left_clip |
6694 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; | |
1297 | 6695 } |
1344 | 6696 left_num_vertices++; |
1297 | 6697 } |
1344 | 6698 if ( next_vertices_flag ) |
1297 | 6699 { |
1344 | 6700 pNextVertices = left_num_vertices++; |
6701 PortalFace._screen_space_x[pNextVertices + 9] = PortalFace._screen_space_x[i + 12]; | |
6702 PortalFace._screen_space_y[pNextVertices + 9] = PortalFace._screen_space_y[i + 12]; | |
1297 | 6703 } |
1344 | 6704 current_vertices_flag = next_vertices_flag; |
6705 } | |
6706 //********************************************************************************************************************************* | |
6707 //for right_clip plane(проверка по правой плоскости) | |
6708 right_num_vertices = 0; | |
6709 PortalFace._screen_space_x[left_num_vertices + 9] = PortalFace._screen_space_x[9]; | |
6710 PortalFace._screen_space_y[left_num_vertices + 9] = PortalFace._screen_space_y[9]; | |
1370 | 6711 current_vertices_flag = PortalFace._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ;//468.0 |
1344 | 6712 if (left_num_vertices < 1) |
1297 | 6713 return 0; |
1344 | 6714 for ( uint i = 1; i <= left_num_vertices; ++i ) |
6715 { | |
6716 next_vertices_flag = PortalFace._screen_space_x[i + 9] <= (signed int)pBLVRenderParams->uViewportZ; | |
6717 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6718 { |
1344 | 6719 if ( next_vertices_flag ) |
1297 | 6720 { |
1344 | 6721 //t = right_clip - v1.x / v0.x - v1.x |
1370 | 6722 t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 8], PortalFace._screen_space_x[i + 9] - PortalFace._screen_space_x[i + 8]); |
1344 | 6723 //New_y = (v0.y - v1.y)*t + v1.y |
1370 | 6724 PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 9] - PortalFace._screen_space_y[i + 8]) |
6725 * t) >> 16) + PortalFace._screen_space_y[i + 8]; | |
1344 | 6726 //New_x = right_clip |
6727 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; | |
1297 | 6728 } |
6729 else | |
6730 { | |
1344 | 6731 //t = right_clip - v0.x / v1.x - v0.x |
1370 | 6732 t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 9], PortalFace._screen_space_x[i + 8] - PortalFace._screen_space_x[i + 9]); |
1344 | 6733 //New_y = (v1.y - v0.y)*t + v0.y |
1370 | 6734 PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 8] - PortalFace._screen_space_y[i + 9]) |
6735 * t) >> 16) + PortalFace._screen_space_y[i + 9]; | |
1344 | 6736 //New_x = right_clip |
6737 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; | |
1297 | 6738 } |
1344 | 6739 right_num_vertices++; |
1297 | 6740 } |
1344 | 6741 if ( next_vertices_flag ) |
1297 | 6742 { |
1344 | 6743 pNextVertices = right_num_vertices++; |
6744 PortalFace._screen_space_x[pNextVertices + 6] = PortalFace._screen_space_x[i + 9]; | |
6745 PortalFace._screen_space_y[pNextVertices + 6] = PortalFace._screen_space_y[i + 9]; | |
1297 | 6746 } |
1344 | 6747 current_vertices_flag = next_vertices_flag; |
6748 } | |
6749 //************************************************************************************************************************************ | |
6750 // for top clip plane | |
6751 top_num_vertices = 0; | |
6752 PortalFace._screen_space_x[right_num_vertices + 6] = PortalFace._screen_space_x[6]; | |
6753 PortalFace._screen_space_y[right_num_vertices + 6] = PortalFace._screen_space_y[6]; | |
6754 | |
1370 | 6755 current_vertices_flag = PortalFace._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY;//8.0 |
1344 | 6756 if ( right_num_vertices < 1 ) |
1297 | 6757 return 0; |
1344 | 6758 for ( uint i = 1; i <= right_num_vertices; ++i ) |
6759 { | |
6760 next_vertices_flag = PortalFace._screen_space_y[i + 6] >= (signed int)pBLVRenderParams->uViewportY; | |
6761 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6762 { |
1344 | 6763 if ( next_vertices_flag ) |
1297 | 6764 { |
1370 | 6765 t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 5], PortalFace._screen_space_y[i + 6] - PortalFace._screen_space_y[i + 5]); |
6766 PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 6] - PortalFace._screen_space_x[i + 5]) | |
6767 * t) >> 16) + PortalFace._screen_space_x[i + 5]; | |
1344 | 6768 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; |
1297 | 6769 } |
6770 else | |
6771 { | |
1370 | 6772 t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 6], PortalFace._screen_space_y[i + 5] - PortalFace._screen_space_y[i + 6]); |
6773 PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 5]- PortalFace._screen_space_x[i + 6]) | |
6774 * t) >> 16) + PortalFace._screen_space_x[i + 6]; | |
1344 | 6775 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; |
1297 | 6776 } |
1344 | 6777 top_num_vertices++; |
1297 | 6778 } |
1344 | 6779 current_vertices_flag = next_vertices_flag; |
6780 if ( next_vertices_flag ) | |
1297 | 6781 { |
1344 | 6782 pNextVertices = top_num_vertices++; |
6783 PortalFace._screen_space_x[pNextVertices + 3] = PortalFace._screen_space_x[i + 6]; | |
6784 PortalFace._screen_space_y[pNextVertices + 3] = PortalFace._screen_space_y[i + 6]; | |
1297 | 6785 } |
1344 | 6786 } |
6787 //********************************************************************************************************************************** | |
6788 //for bottom_clip plane(проверка по нижней плоскости) | |
6789 bottom_num_vertices = 0; | |
6790 PortalFace._screen_space_x[top_num_vertices + 3] = PortalFace._screen_space_x[3]; | |
6791 PortalFace._screen_space_y[top_num_vertices + 3] = PortalFace._screen_space_y[3]; | |
1370 | 6792 current_vertices_flag = PortalFace._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW;//351.0 |
1344 | 6793 if ( top_num_vertices < 1 ) |
1297 | 6794 return 0; |
1344 | 6795 for ( uint i =1; i <= top_num_vertices; ++i ) |
6796 { | |
6797 next_vertices_flag = PortalFace._screen_space_y[i + 3] <= (signed int)pBLVRenderParams->uViewportW; | |
6798 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6799 { |
1344 | 6800 if ( next_vertices_flag ) |
1297 | 6801 { |
1370 | 6802 t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 2], PortalFace._screen_space_y[i + 3] - PortalFace._screen_space_y[i + 2]); |
6803 PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 3] - PortalFace._screen_space_x[i + 2]) | |
6804 * t) >> 16) + PortalFace._screen_space_x[i + 2]; | |
1344 | 6805 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; |
1297 | 6806 } |
6807 else | |
6808 { | |
1370 | 6809 t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 3], PortalFace._screen_space_y[i + 2] - PortalFace._screen_space_y[i + 3]); |
6810 PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 2] - PortalFace._screen_space_x[i + 3]) | |
6811 * t) >> 16) + PortalFace._screen_space_x[i + 3]; | |
1344 | 6812 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; |
1297 | 6813 } |
1344 | 6814 bottom_num_vertices++; |
1297 | 6815 } |
1344 | 6816 if ( next_vertices_flag ) |
1297 | 6817 { |
1344 | 6818 pNextVertices = bottom_num_vertices++; |
6819 PortalFace._screen_space_x[pNextVertices] = PortalFace._screen_space_x[i + 3]; | |
6820 PortalFace._screen_space_y[pNextVertices] = PortalFace._screen_space_y[i + 3]; | |
1297 | 6821 } |
1344 | 6822 current_vertices_flag = next_vertices_flag; |
6823 } | |
6824 //*************************************************************************************************************************************** | |
6825 | |
6826 if ( !bottom_num_vertices ) | |
1297 | 6827 return 0; |
1344 | 6828 PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; |
6829 PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; | |
6830 //check for software(проверка для софтвар) | |
6831 if ( !pRenderer->pRenderD3D && bottom_num_vertices > 3 ) | |
6832 { | |
6833 PortalFace._screen_space_x[bottom_num_vertices + 1] = PortalFace._screen_space_x[1]; | |
6834 PortalFace._screen_space_y[bottom_num_vertices + 1] = PortalFace._screen_space_y[1]; | |
6835 thisf = PortalFace.direction == true ? 1 : - 1; | |
6836 if ( bottom_num_vertices > 0 ) | |
1297 | 6837 { |
6838 v62 = 1; | |
6839 v71 = 1; | |
6840 do | |
6841 { | |
6842 v63 = v62 - 1; | |
6843 v64 = v62 + 1; | |
6844 v80 = v62 + 1; | |
1344 | 6845 if ( v62 - 1 >= bottom_num_vertices ) |
6846 v63 -= bottom_num_vertices; | |
6847 if ( v62 >= bottom_num_vertices ) | |
6848 v62 -= bottom_num_vertices; | |
6849 if ( v64 >= bottom_num_vertices ) | |
6850 v64 -= bottom_num_vertices; | |
6851 if ( thisf * ((PortalFace._screen_space_y[v64] - PortalFace._screen_space_y[v63]) | |
6852 * (PortalFace._screen_space_x[v62] - PortalFace._screen_space_x[v63]) | |
6853 - (PortalFace._screen_space_y[v62] - PortalFace._screen_space_y[v63]) | |
6854 * (PortalFace._screen_space_x[v64] - PortalFace._screen_space_x[v63])) < 0 ) | |
1297 | 6855 { |
6856 v62 = v80; | |
6857 v71 = v80; | |
6858 } | |
6859 else | |
6860 { | |
6861 v62 = v71; | |
6862 v65 = v71; | |
1344 | 6863 if ( v71 < bottom_num_vertices || (v65 = v71 - bottom_num_vertices, v71 - bottom_num_vertices < bottom_num_vertices) ) |
1297 | 6864 { |
1344 | 6865 memcpy(&PortalFace._screen_space_y[v65], &PortalFace._screen_space_y[v65 + 1], |
6866 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); | |
6867 memcpy(&PortalFace._screen_space_x[v65], &PortalFace._screen_space_x[v65 + 1], | |
6868 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); | |
1297 | 6869 } |
1344 | 6870 --bottom_num_vertices; |
1297 | 6871 } |
6872 } | |
1344 | 6873 while ( v62 - 1 < bottom_num_vertices ); |
1297 | 6874 } |
1344 | 6875 PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; |
6876 PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; | |
6877 } | |
6878 return bottom_num_vertices; | |
1408 | 6879 } |
6880 | |
6881 //----- (004AAEA6) -------------------------------------------------------- | |
6882 int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1) | |
6883 { | |
6884 double v4; // st5@2 | |
6885 double v5; // st4@3 | |
6886 float v11; // [sp+8h] [bp-8h]@2 | |
6887 float v12; // [sp+8h] [bp-8h]@6 | |
6888 float v13; // [sp+Ch] [bp-4h]@2 | |
6889 float v14; // [sp+Ch] [bp-4h]@6 | |
6890 | |
6891 if ( pBLVRenderParams->sPartyRotX ) | |
6892 { | |
6893 v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x; | |
6894 v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y; | |
6895 v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z; | |
6896 if ( pRenderer->pRenderD3D ) | |
6897 { | |
6898 v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY; | |
6899 a1->vWorldViewPosition.y = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY; | |
6900 } | |
6901 else | |
6902 { | |
6903 v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY; | |
6904 a1->vWorldViewPosition.y = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY; | |
6905 } | |
6906 a1->vWorldViewPosition.x = v5 * pBLVRenderParams->fCosineNegX - v4 * pBLVRenderParams->fSineNegX; | |
6907 a1->vWorldViewPosition.z = v5 * pBLVRenderParams->fSineNegX + v4 * pBLVRenderParams->fCosineNegX; | |
6908 } | |
6909 else | |
6910 { | |
6911 v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x; | |
6912 v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y; | |
6913 a1->vWorldViewPosition.z = a1->vWorldPosition.z - (double)pParty->vPosition.z; | |
6914 if ( pRenderer->pRenderD3D ) | |
6915 { | |
6916 a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY; | |
6917 a1->vWorldViewPosition.y = v14 * pBLVRenderParams->fSineY - v12 * pBLVRenderParams->fCosineY; | |
6918 } | |
6919 else | |
6920 { | |
6921 a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY; | |
6922 a1->vWorldViewPosition.y = v14 * pBLVRenderParams->fSineY + v12 * pBLVRenderParams->fCosineY; | |
6923 } | |
6924 } | |
6925 return 0; | |
0 | 6926 } |