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