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